using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using QM.Account; using DCS.Common; using Model; using QM.Assist; using DCS.Place; using QMAPP.FJC.Entity.Operation; using QMAPP.Entity; using QMAPP.MD.Entity; using QMAPP.FJC.Entity.Basic; namespace QMAPP.WinForm.Forms.DisPatch { /// /// 工位终端FIS发货效验功能 /// 创建时间:2012-11-12 /// 创 建 人:pxbibm /// H1:modified by sun g.q. on 20130330 /// 1)隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置; /// 2)增加 CreatePastecardNo(String lineNo)代替CreatePastecardNo(),贴车单流水号,根据生产线代码生成; /// 3)校准功能进行了bug修改; /// 4)20190325移植了成都DCS发运功能,同时保留原有发运,校验信息通过零件规则表判断//gzf。 /// 5)20190325成都存在东西厂情况,且未来要货可能都混线生产,现场操作者要讲求快速切换发货,将单选按钮恢复,且用此过滤发货计划。--gzf /// public partial class FrmPlace : Form { #region 常量 private const string DISPLAY_NAME = "工位终端"; private DataTable dt = null; private DataTable dtmat = null; private DataTable dtpro = null; private BindingSource bs; private bool setRedBackgroudFlag = false;//设置第一次设置背景颜色校验标识 //获取服务代理 QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent(); List _barcodeRules = null; public delegate void myMethodDelegate(); #endregion #region 变量 public string a = "1"; DateTime _dt = DateTime.Now; //2016-01-07 增加车架的1号位置的扫描校验 private string placeFirstPosition = ""; //1号码标识 private DateTime placeFirstPositionTime = DateTime.MinValue;//获取1号码的时间 int BarcodeTime = 10000; /// /// 指令二次确认 /// string _CMDConfirm = ""; public string WORKCENTER_CODE = "";//工作重心参数 public string ProMaterial = "";//扫描产品物料信息 #endregion #region 界面初始化 public FrmPlace() { InitializeComponent(); _barcodeRules = _agent.InvokeServiceFunction>("BarcodeRulesBLL_GetListForSend"); } #endregion #region 绑定DataGridView /// /// 绑定DataGridView /// private DataTable BindDataGridView() { #region return null; #endregion } #endregion #region 字段 //主键 private string strFiskey; //大众顺序号 private string strvwseq; //车身号 private string strkin; //底盘号 private string strvin; //零件号 private string strprodno; //总成描述 private string strcarsetdesc_cn; //上线时间 private string strcp5a; //车型 private string strlineno; //扫描状态 private string strscanstat; int nfindex = 0; //int ncsindex = 0; //int rowindex = 0; /// /// NF贴车单明细列表 /// List nflist = null; /// /// NCS贴车单明细列表 /// List ncslist = null; /// /// NF贴车单主键 /// string nfpastcardkey = ""; /// /// 当前guidview行号 /// int dgvrowindex = 0; /// /// 正确的声音文件路径 /// private string okSoundPath = null; public string pFisType = ""; /// /// 错误的声音文件路径 /// private string errorSoundPath = null; #endregion #region FIS数据列Post /// /// FIS数据列Post /// /// /// private void dgvMATChange_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { #region try { if (dgvMATChange.Rows.Count > 0) { e.Graphics.DrawString((e.RowIndex + 1).ToString(), dgvMATChange.RowHeadersDefaultCellStyle.Font, new SolidBrush(dgvMATChange.RowHeadersDefaultCellStyle.ForeColor), e.RowBounds.Location.X + 15, e.RowBounds.Y + 5); } } catch (Exception ex) { //MessageBox.Show(ex.Message); lberror.Text = ex.Message; } #endregion } #endregion #region 获取混线,单线FIS数据 /// /// 获取混线,单线FIS数据 /// /// public void GetInitData() { #region try { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetList.ToString(), pFisType, WORKCENTER_CODE); //tbl.Columns["PRODNO"].SetOrdinal(5); tbl.Columns["VIN"].SetOrdinal(3); tbl.AcceptChanges(); if (tbl.Rows.Count <= 0) { DataTable dt = (DataTable)dgvMATChange.DataSource; if (dt != null) { dt.Rows.Clear(); } } else { dgvMATChange.DataSource = tbl; } setRedBackgroudFlag = false; SetRowColor(); computenfncs(); } catch (Exception ex) { //MessageBox.Show(ex.Message); lberror.Text = ex.Message; } finally { } #endregion } #endregion #region 获取EPasteDetailsCard数据 /// /// /// public void GetInitData2() { try { dgvNF.DataSource = new List(); nfpastecard = null; nflist = null; nfindex = 0; dgvrowindex = 0; setRedBackgroudFlag = false; } catch (Exception ex) { //MessageBox.Show(ex.Message); lberror.Text = ex.Message; } finally { } } #endregion #region 设置FIS数据颜色 /// /// 设置FIS数据颜色 /// private void SetRowColor() { if (setRedBackgroudFlag == true) { //return; } //底盘号 int vinNumber = 0; int lastVinNumber = 0; int num = 0; int defaultNum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", "4"]); for (int i = 0; i < this.dgvMATChange.Rows.Count; i++) { // vinNumber = Convert.ToInt32(dgvMATChange.Rows[i].Cells["VIN"].Value.ToString().Substring(10, 7)); vinNumber = Convert.ToInt32(dgvMATChange.Rows[i].Cells["REQUESTID"].Value.ToString()); //2016-01-21 wangqingnan 如果行变色则不重新刷颜色 var fispid=dgvMATChange.Rows[i].Cells[PID.Name].Value.ToString(); if (nflist != null && nflist.Exists(p => p.FIS_KEY == fispid)) { this.dgvMATChange.Rows[i].Cells[clscanstate.Name].Value = "1"; } if (this.dgvMATChange.Rows[i].Cells[clscanstate.Name].Value.ToString() == "1") { this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.White; continue; } //2016-01-21 wangqingnan 如果行变色则不重新刷颜色 //int defaultNum = Convert.ToInt32(QM.Config.CustomConfig.GetItem("ShowDataCount")); if (num == 0) { this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.Yellow; if ((i + 1) % defaultNum == 0) { num = 1; } } else { this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.YellowGreen; if ((i + 1) % defaultNum == 0) { num = 0; } } //2016-10-31 闫永刚 如果出现该底盘号与上一条底盘号间断的情况, //设置当前底盘号的颜色为红色 if (lastVinNumber > 0) { //if ((vinNumber - lastVinNumber) > 1) //DQZhang 优化FIS断号颜色显示9999-0001 if (Math.Abs(vinNumber - lastVinNumber) > 1 && Math.Abs(vinNumber - lastVinNumber) != 9998) { this.dgvMATChange.Rows[i - 1].DefaultCellStyle.BackColor = Color.Red; this.dgvMATChange.Rows[i].DefaultCellStyle.BackColor = Color.Red; setRedBackgroudFlag = true; } } lastVinNumber = vinNumber; } if (dgvMATChange.RowCount > 0) { dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4; } dgvMATChange.Refresh(); dgvMATChange.ClearSelection(); txtCode.Focus(); } #endregion #region 设置版面的显示与隐藏(无用) /// /// 设置版面的显示与隐藏 /// private void SetShowData() { //"隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置" //02为单线 if (pFisType == "02") { //gbGeneralData.Visible = false; } else { //gbGeneralData.Visible = true; //gbGeneralData.Dock = DockStyle.Bottom; } } #endregion #region 处理扫描条码框设置焦点 /// /// 处理扫描条码框设置焦点 /// private void ArragetxtCode() { txtCode.Text = string.Empty; //Activates the control. txtCode.Select(); //Sets input focus to the control. txtCode.Focus(); } #endregion #region 加载画面 /// /// 加载画面 /// /// /// private void FrmElevateRequest_Load(object sender, EventArgs e) { try { timeRefew.Enabled = true; //UserBuffer.Interval = CtlApp.GetInterval(QM.Config.CustomConfig.GetItem("RefreshTime")); UserBuffer.Interval = CtlApp.GetInterval(QMAPP.WinForm.Common.LocalSetting.Settings["RefreshTime","20"]); timeRefew.Interval = UserBuffer.Interval; //BarcodeTime = int.Parse(QM.Config.CustomConfig.GetItem("BarcodeTime")); //BarcodeTime = int.Parse(QMAPP.WinForm.Common.LocalSetting.Settings["BarcodeTime","1"]); okSoundPath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "Sound\\" + PlaySoundConst.strSoundOk; errorSoundPath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "Sound\\" + PlaySoundConst.strSoundNg; //隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置; //pFisType = "01"; //pFisType = QM.Config.CustomConfig.GetItem("FlashProCode"); //pFisType = QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode","01"]; pFisType = QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode", ""]; if (!string.IsNullOrEmpty(pFisType)) { if (pFisType.Equals("01")) { rb_dx.Checked = true; } else { rb_dx.Checked = true; } } //发运信息直接用单选按钮过滤,工作中心字段用作打印功能格式使用 //WORKCENTER_CODE = QMAPP.WinForm.Common.LocalSetting.Settings["PlantNameConfig", ""]; WORKCENTER_CODE = "IPFY" + pFisType; //发运框设置 InitContainer(); GetInitData(); SetShowData(); //computenfncs();//lable1原有copy代码 这个功能注释掉了 崔法宝-20170905调整 dgvMATChange.ClearSelection(); dgvNF.AutoGenerateColumns = false; SetPastNOConfirm(0); GetLastPastCard(); //lblLastPastNO.Text = ""; } catch (Exception ex) { //MessageBox.Show(ex.Message); lberror.Text = ex.Message; } finally { ArragetxtCode(); dgvMATChange.ClearSelection(); } } #endregion #region 获取上一条发运单信息 /// /// 获取上一条发运单信息 /// private void GetLastPastCard() { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); var lastpastcard= agent.InvokeServiceFunction("FrmPlaceBLL_GetLastPastCard", WORKCENTER_CODE); if (lastpastcard != null) { lblLastPastNO.Text = lastpastcard.PASTECARDNO; } } #endregion #region 设置贴车单确认状态 /// /// 设置贴车单确认状态 /// /// 0:未确认 1:确认OK 2:确认失败 private void SetPastNOConfirm(int state) { switch (state) { case 0: { pbPastNoConfirmed.Enabled = false; pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.help; break; } case 1: { pbPastNoConfirmed.Enabled = true; pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.ok; break; } case 2: { pbPastNoConfirmed.Enabled = false; pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.cancel; break; } default: { pbPastNoConfirmed.Enabled = false; pbPastNoConfirmed.Image = global::QMAPP.WinForm.Resource1.stop; break; } } } #endregion #region 贴车单查询功能 /// /// 贴车单查询功能 /// /// /// private void btnSearch_Click(object sender, EventArgs e) { FrmItemList frm = new FrmItemList(); frm.ShowDialog(); txtCode.Focus(); } #endregion #region 实现效验功能 /// /// 实现效验功能 /// /// /// private void btnJZ_Click(object sender, EventArgs e) { try { if (MessageBox.Show("您确实要做FIS校准跳过功能吗?", "校准提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (nfindex > 0) { MessageBox.Show("发运已开始扫描无法进行FIS校准!", "校准提示"); return; } if (dgvMATChange.Rows.Count > 0) { int i = dgvMATChange.CurrentRow.Index; string strvwseq = dgvMATChange.Rows[i].Cells["REQUESTID"].Value.ToString(); //上线时间 string strCP5A = dgvMATChange.Rows[i].Cells["CP5A"].Value.ToString(); //BllFisOrder bllFisOrder = new BllFisOrder(); //bllFisOrder.UpdateFisOrder(strvwseq, strCP5A); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_UpdateFisOrder.ToString(), strvwseq, strCP5A, WORKCENTER_CODE); GetInitData(); } } } catch (Exception ex) { } finally { txtCode.Focus(); } } #endregion #region 获取FIS数据 /// /// 获取FIS数据 /// /// /// private void btnGetFisData_Click(object sender, EventArgs e) { if (dgvNF.Rows.Count == 0) { GetInitData(); //computenfncs(); } } #endregion #region 手动刷新 /// /// 手动刷新 /// /// /// private void btnRef_Click(object sender, EventArgs e) { GetInitData(); } #endregion #region 创建贴车单号 //EPasteCard nfpastecard = null; /// /// 创建贴车单号 /// 贴车单号的规则生成贴车单号,格式为“FB”(2位)+日期(8位,20121008)+流水号(4位); /// /// private string CreatePastecardNo() { #region //BllFisOrder bllFisOrder = new BllFisOrder(); string strdate = DateTime.Now.ToString("yyyyMMdd"); // DataTable tbl = bllFisOrder.GetPastecardNo(DateTime.Now.ToShortDateString()); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardNo.ToString(), DateTime.Now.ToShortDateString()); string strindex = tbl.Rows[0][0].ToString().PadLeft(4, '0'); string pastecardno = string.Format("FB{0}{1}", strdate, strindex); return pastecardno; #endregion } #endregion #region 创建贴车单号(外来) /// /// 创建贴车单号 /// 贴车单号的规则生成贴车单号,格式为“生产线代码”(2位)+日期(8位,20121008)+流水号(4位); /// 20190329--贴车单号的规则生成贴车单号,格式为“生产线代码”(工作中心)+日期(8位,20121008)+流水号(4位) /// /// private string CreatePastecardNo(String lineNo) { #region String prefix = lineNo; //BllFisOrder bllFisOrder = new BllFisOrder(); //2016-10-30闫永刚获取贴车单号修改 // DataTable dt = bllFisOrder.GetPastecardIndex(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); //DataTable dt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardIndex.ToString()); DataTable dt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), prefix); string PASTECARDNO = ""; string OLD_PASTECARDNO = ""; string NEW_PASTECARDNO = ""; if (dt.Rows.Count == 0) { PASTECARDNO =lineNo+ DateTime.Now.ToString("yyyyMMdd") + "0001"; nfpastecard.PASTECARDNO = PASTECARDNO; int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard); } else { foreach (DataRow dr in dt.Rows) { //OLD_PASTECARDNO = dr["PASTECARDNO"].ToString(); //int Addvalue = Convert.ToInt32(OLD_PASTECARDNO.Substring(OLD_PASTECARDNO.Length - 1, 1)) + 1; //NEW_PASTECARDNO = OLD_PASTECARDNO.Substring(lineNo.Length, OLD_PASTECARDNO.Length - lineNo.Length - 1) + Addvalue.ToString(); //20190314 PASTECARDNO = dr["PASTECARDNO"].ToString(); if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4) { int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length; string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); string sumValue = ""; for (var i = 0; i < num; i++) { sumValue = sumValue + "0"; } if (PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 4) + sumValue + value; } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } else { if (PASTECARDNO.Substring(lineNo.Length, 8).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(lineNo.Length, PASTECARDNO.Length - lineNo.Length - 2) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } //nfpastecard.PASTECARDNO = PASTECARDNO; //nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString(); } PASTECARDNO = lineNo + PASTECARDNO; } return PASTECARDNO; #region XXX //string pasteCardIndex = ""; //DateTime updateTime; //foreach (DataRow dr in dt.Rows) //{ // string lineNoRow = dr["PASTECARDNO"].ToString().Substring(0, 2); // if (lineNo == lineNoRow) // { // pasteCardIndex = dr["PASTECARDNO"].ToString(); // updateTime = Convert.ToDateTime(dr["PASTECARDDATE"]); // } //} //string strdate = DateTime.Now.ToString("yyyyMMdd"); //string strindex = ""; //if (pasteCardIndex.Substring(2, 8) == strdate) //{ // strindex = (Convert.ToInt32(pasteCardIndex.Substring(10, 4)) + 1).ToString().PadLeft(4, '0'); //} //else //{ // strindex = "0001"; //} //原来获取贴车单方式 //string strdate = DateTime.Now.ToString("yyyyMMdd"); //DataTable tbl = bllFisOrder.GetPastecardNo(DateTime.Now.ToShortDateString(), prefix); //string strindex = tbl.Rows[0][0].ToString().PadLeft(4, '0'); //string pastecardno = string.Format("{0}{1}{2}", prefix, strdate, strindex); //return pastecardno; #endregion #endregion } #endregion #region 删除已经打印过的贴车单FIS列表 /// /// 删除已经打印过的贴车单FIS列表 /// /// /// private void DGVRemoveRow(List pnflist, ref List pnflist2) { #region if (pnflist2 != null) { for (int rowindex = 0; rowindex < pnflist2.Count; rowindex++) { string tempfiskey2 = pnflist2[rowindex].FIS_KEY; for (int rowindex1 = 0; rowindex1 < dgvMATChange.Rows.Count; rowindex1++) { string tempFiskey1 = dgvMATChange.Rows[rowindex1].Cells["clFiskey"].Value.ToString(); if (tempFiskey1 == tempfiskey2) { DataGridViewCellStyle ds = new DataGridViewCellStyle(); ds.BackColor = Color.Green; this.dgvMATChange.Rows[rowindex1].DefaultCellStyle = ds; //当删除了满6个的记录后,另一个数据集的行号需要重新排列。 dgvMATChange.Rows[rowindex1].Cells[clscanstate.Name].Value = "1"; pnflist2[rowindex].DGVROWINDEX = rowindex1; break; } } } } #endregion } #endregion #region NF贴车单手动打印功能 /// /// NF贴车单手动打印功能 /// /// /// private void btnPrint_NF_Click(object sender, EventArgs e) { #region bool isprint = false; try { if (nflist != null) { if (MessageBox.Show("您确定要提交并且打印数据吗?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { //当点击了确定,则会执行删除操作 QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), nfpastecard.PLANTNAME.ToString()); if (tbl.Rows.Count > 0) { nfpastecard.PASTECARDNO = tbl.Rows[0][0].ToString(); } else { MessageBox.Show("无法打印!"); } EFailLog log = new EFailLog(); log.TID = Guid.NewGuid().ToString(); log.FCT_DATE = DateTime.Now; log.FCT_NO = nfpastecard.PASTE_CARD_KEY; log.FCT_OPER = UserBuffer.UserCode; log.FCT_OPERTYPE = 1; log.FCT_REASON = "NF手动打印贴车单操作"; nfpastecard.FailLog = log; string strprodtype = ""; //#region "隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置" if (pFisType == "01") { strprodtype = "( 混 )"; } else if (pFisType == "02") { strprodtype = "( 单 )"; } //提交数据处理 foreach (DataRow dr in tbl.Rows) { string PASTECARDNO = dr["PASTECARDNO"].ToString(); if (PASTECARDNO.Substring(2, 8).ToString() == DateTime.Now.ToString("yyyyMMdd")) { if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4) { int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length; string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); string sumValue = ""; for (var i = 0; i < num; i++) { sumValue = sumValue + "0"; } if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + sumValue + value; } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } else { if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } nfpastecard.PASTECARDNO = PASTECARDNO; nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString(); // nfpastecard. } int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard); // 打印处理 FrmCarCardPrintShow frm = new FrmCarCardPrintShow(nfpastecard, strprodtype, "手动"); frm.Owner = this; frm.ShowDialog(); isprint = frm.isprint; } //if (isprint) //{ // nfpastecard.DetailsCardlist = nflist; // nfindex = 0; // // BllFisOrder bllFisOrder = new BllFisOrder(); // //int strindex = bllFisOrder.AddPasteCard(nfpastecard); // //QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); // int strindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard); // PrintPasteCard prin = new PrintPasteCard(); // prin.Print(strindex, nfpastecard, strprodtype); // GetInitData(); // DGVRemoveRow(nflist, ref ncslist); // nflist = new List(); // dgvNF.DataMember = null; // dgvNF.DataSource = nflist; // //computenfncs(); //} } else { MessageBox.Show("无打印数据!"); } } catch (Exception ex) { } finally { if (isprint) { nflist = null; txtCode.Focus(); //2016-01-07 增加1号位校验 - 清空1号位 this.placeFirstPosition = ""; this.placeFirstPositionTime = DateTime.MinValue; //2016-01-07 增加1号位校验 } } #endregion } #endregion #region 打印1号位的条码 /// /// 打印1号位的条码 /// /// /// private void btnFirstPlace_Click(object sender, EventArgs e) { this.dgvMATChange.Rows[0].DefaultCellStyle.BackColor = Color.White; #region 打印 DCS.Common.PrintCode printFun = new DCS.Common.PrintCode(); //执行打印 printFun.PinrtFirstPlaceHU(); #endregion } #endregion #region 判断当前扫描过的数据集合中是否有相同条码 EPasteCard ncspastecard = null; /// /// 判断当前扫描过的数据集合中是否有相同条码 /// 与右侧列表中校验,条码是否扫描过 /// /// 扫描的条码 private bool CheckDataSet(string strbarcode) { String teshucode = getTeShuBarcode(barcodeidentification); if (nfpastecard != null) { foreach (EPasteDetailsCard pe in nfpastecard.DetailsCardlist) { if (teshucode == strbarcode) { continue; } if (strbarcode == pe.SANBARCODE) { Alert("条码重复:已扫描过的条码,不可以重复扫描。"); ArragetxtCode(); return false; } } } if (ncspastecard != null) { foreach (EPasteDetailsCard pe2 in ncspastecard.DetailsCardlist) { if (teshucode == strbarcode) { continue; } if (strbarcode == pe2.SANBARCODE) { Alert("条码重复:已扫描过的条码,不可以重复扫描。"); ArragetxtCode(); return false; } } } return true; } #endregion #region 创建NF的贴车单以及明细(外来件) /// /// 创建NF的贴车单以及明细(NF开头) /// private void CreateNFPaste__() { #region if (nfindex == 0) { nflist = new List(); nfpastcardkey = Guid.NewGuid().ToString(); nfpastecard = new EPasteCard(); nfpastecard.DetailsCardlist = new List(); nfpastecard.PASTE_CARD_KEY = nfpastcardkey; nfpastecard.PLANTNAME = WORKCENTER_CODE.ToString(); nfpastecard.PASTECARDNO = ""; nfpastecard.PRODUCTIONNAME = pFisType; nfpastecard.PASTECARDDATE = DateTime.Now.ToString(); nfpastecard.OPERATOR = UserBuffer.UserCode; nfpastecard.CREATETIME = DateTime.Now.ToString(); } EPasteDetailsCard pastdetail = new EPasteDetailsCard(); pastdetail.PASTEDETAILED_CARD_KEY = Guid.NewGuid().ToString(); pastdetail.FIS_KEY = strFiskey; pastdetail.PASTE_CARD_KEY = nfpastcardkey; pastdetail.SANBARCODE = txtCode.Text.ToString(); pastdetail.SCANDATE = DateTime.Now.ToString(); pastdetail.PRODNO = strprodno; pastdetail.CARSETDESC_CN = strcarsetdesc_cn; pastdetail.VIN = strvin; pastdetail.VWSEQ = strvwseq; pastdetail.CP5A = strcp5a; pastdetail.DGVROWINDEX = dgvrowindex; pastdetail.LINENO = strlineno; nfpastecard.DetailsCardlist.Add(pastdetail); nflist.Add(pastdetail); dgvNF.DataMember = null; dgvNF.DataSource = nflist; strprodno = ""; nfindex++; int setdefaultSum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", ""]); if (nfindex == setdefaultSum) { EFailLog log = new EFailLog(); log.TID = Guid.NewGuid().ToString(); log.FCT_DATE = DateTime.Now; log.FCT_NO = nfpastecard.PASTE_CARD_KEY; log.FCT_OPER = UserBuffer.UserCode; log.FCT_OPERTYPE = 1; log.FCT_REASON = "NF贴车单自动打印操作"; //nfpastecard.PLANTNAME = WORKCENTER_CODE.ToString(); nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString(); nfpastecard.PASTECARDNO = CreatePastecardNo(WORKCENTER_CODE.ToString()); nfpastecard.DetailsCardlist = nflist; nfpastecard.FailLog = log; nfindex = 0; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_AddPasteCard.ToString(), nfpastecard); //BllFisOrder bllFisOrder = new BllFisOrder(); //int rowindex = bllFisOrder.AddPasteCard(nfpastecard); PrintPasteCard prin = new PrintPasteCard(); string strprodtype = ""; //#region "隐藏了rb_hx 和rb_dx,全部根据pFisType判断,生产线的设置使用按钮进行设置" if (pFisType == "01") { strprodtype = "( 混 )"; } else if (pFisType == "02") { strprodtype = "( 单 )"; } prin.Print(rowindex, nfpastecard, strprodtype); ClearContainer(); GetInitData(); DGVRemoveRow(nflist, ref ncslist); dgvNF.DataSource = new List(); nfpastecard = null; nflist = null; nfindex = 0; dgvrowindex = 0; computenfncs(); GetLastPastCard(); SetPastNOConfirm(0); //2016-01-07 增加1号位校验 - 清空1号位 this.placeFirstPosition = ""; this.placeFirstPositionTime = DateTime.MinValue; //2016-01-07 增加1号位校验 } #endregion } #endregion #region 计算NF,NCS数量 /// /// 计算NF,NCS数量 /// private void computenfncs() { //BindingSource bin = (BindingSource)dgvMATChange.DataSource; //DataTable tbl = (DataTable)dgvMATChange.DataSource; //DataRow[] nfrows = tbl.Select("LINENO='NF'"); //DataRow[] ncsrows = tbl.Select("LINENO='NCS'"); //DataRow[] ncsnfrows = tbl.Select("LINENO='NCSNF'"); //DataRow[] ncsgprows = tbl.Select("LINENO='NCSGP'"); //lblCount.Text = "NCS: " + ncsrows.Length + " NF: " + nfrows.Length + " NCSNF: " + ncsnfrows.Length + " NCSGP: " + ncsgprows.Length; DataTable tbl = (DataTable)dgvMATChange.DataSource; DataRow[] nfrows = tbl.Select("LINENO='NCSNFPA'"); DataRow[] ncsrows = tbl.Select("LINENO='PA311'"); DataRow[] ncsnfrows = tbl.Select("LINENO='A SUV'"); //DataRow[] ncsgprows = tbl.Select("LINENO='NCSGP'"); lblCount.Text = "NCSNFPA: " + nfrows.Length + " " + " PA311: " + ncsrows.Length + " " + " A SUV: " + ncsnfrows.Length; } #endregion #region NF仪表板校验 /// /// NF仪表板校验 /// /// /// private bool CheckRule(string scanbarcode) { try { int temprowindex = 0; int nflistCount = 0; if (nflist != null && nflist.Count > 0) { nflistCount = nflist.Count; } int ncslistCount = 0; if (ncslist != null && ncslist.Count > 0) { ncslistCount = ncslist.Count; } temprowindex = nflistCount + ncslistCount; strprodno = dgvMATChange.Rows[temprowindex].Cells["PRODNO"].Value.ToString(); DataTable tbl = GetSparepartsinfo(scanbarcode); if (tbl.Rows.Count > 0) { barcodeidentification = tbl.Rows[0]["BARCODEIDENTIFICATION"].ToString(); } else { Alert("条码错误:无法根据条码识别零件号"); } if (tbl.Rows.Count > 0) { //零件号 string strkhprodno = tbl.Rows[0]["CUSTOMERSPAREPARTS"].ToString(); string templineno = tbl.Rows[0]["CODENAME"].ToString(); if (strkhprodno.ToUpper().Replace(" ", "").Contains(strprodno.ToUpper().Replace(" ", ""))) { DGVCurrontRow(strprodno, "NF", temprowindex); return true; } else { Alert("条码错误:扫描的条码与FIS中的零件不符。"); return false; } } else { Alert("条码错误:无法根据条码识别零件号。"); return false; } QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable dtother = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetOhterCode.ToString(), scanbarcode); DataTable dtrule = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetRule.ToString(), strprodno, scanbarcode.Substring(0, 3)); if (dtother.Rows.Count <= 0) { Alert("条码匹配错误:该下护板在上工位未进行绑定扫描!"); ArragetxtCode(); return false; } int sended = Convert.ToInt32(dtother.Rows[0]["SENDED"]); if (sended == 1) { Alert("该下护板已经发货!"); ArragetxtCode(); return false; } if (dtrule.Rows.Count <= 0) { Alert("条码匹配错误:车型校验规则不存在。"); ArragetxtCode(); return false; } List barCodeList = new List(); string[] listother = dtother.Rows[0][0].ToString().Split(' '); for (int i = 0; i < listother.Length; i++) { if (string.IsNullOrEmpty(listother[i]) == false) { barCodeList.Add(listother[i]); } } barCodeList.Add(scanbarcode.Substring(0, 3)); //获取所有的规则条码 List ruleList = new List(); foreach (DataRow dr in dtrule.Rows) { ruleList.Add(dr["OTHERCODE"].ToString()); } bool checkResult = true; string errorBarcode = ""; foreach (string str in barCodeList) { if (ruleList.Contains(str) == false) { checkResult = false; errorBarcode = str; break; } } if (checkResult == false) { Alert(errorBarcode + "与零件号" + strprodno + "的类型不匹配!"); ArragetxtCode(); return false; } DGVCurrontRow(strprodno, "NF", temprowindex); return true; } catch (Exception ex) { throw ex; } } private void Alert(string message, bool openConfirmDialog = true) { PlaySound.PlaySounds.Play(@errorSoundPath); lberror.Text = message; if (openConfirmDialog && string.Equals(QMAPP.WinForm.Common.LocalSetting.Settings["AlertConfirmEnable", "0"], "1")) { Common.frmAlertConfirm alertconfirm = new Common.frmAlertConfirm(message, "CD85010800"); alertconfirm.StartPosition = FormStartPosition.CenterScreen; alertconfirm.ShowDialog(); } } #endregion #region 与FIS数据匹配 /// /// 与FIS数据匹配 /// private void FISDataCompare(string Code,Product product) { int temprowindex = 0; int nflistCount = 0; if (nflist != null && nflist.Count > 0) { nflistCount = nflist.Count; } int ncslistCount = 0; if (ncslist != null && ncslist.Count > 0) { ncslistCount = ncslist.Count; } temprowindex = nflistCount + ncslistCount; strprodno = dgvMATChange.Rows[temprowindex].Cells["PRODNO"].Value.ToString(); string pstrprodcno = strprodno; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); //2.判断成品 //Product statusRuslt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetProductByAssembleCode.ToString(), Code); if (product.MATERIAL_CODE != pstrprodcno) { SetContainerItem(nfindex, false); Alert("扫描的成品零件号与FIS零件号不符!"); txtCode.Text = ""; txtCode.Focus(); return; } DataTable tblbarcode = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_ExistBarcode.ToString(), BarcodeTime, Code); if (tblbarcode.Rows.Count == 0) { for (; temprowindex < dgvMATChange.Rows.Count; temprowindex++) { //主键 strFiskey = dgvMATChange.Rows[temprowindex].Cells["PID"].Value.ToString(); //大众顺序号 strvwseq = dgvMATChange.Rows[temprowindex].Cells["REQUESTID"].Value.ToString(); //零件号 strprodno = dgvMATChange.Rows[temprowindex].Cells["PRODNO"].Value.ToString(); //总成描述 strcarsetdesc_cn = dgvMATChange.Rows[temprowindex].Cells["CARSETDESC_CN"].Value.ToString(); //上线时间 strcp5a = dgvMATChange.Rows[temprowindex].Cells["CP5A"].Value.ToString(); //车型 strlineno = dgvMATChange.Rows[temprowindex].Cells["LINENO"].Value.ToString(); //车身号 strkin = dgvMATChange.Rows[temprowindex].Cells["KIN"].Value.ToString(); //底盘号 strvin = dgvMATChange.Rows[temprowindex].Cells["VIN"].Value.ToString(); //工作中心 WORKCENTER_CODE = dgvMATChange.Rows[temprowindex].Cells[dgvWorkcenter.Name].Value.ToString(); //扫描状态 strscanstat = dgvMATChange.Rows[temprowindex].Cells[clscanstate.Name].Value.ToString(); dgvrowindex = temprowindex; if (strscanstat == "0") { strprodno = strprodno.ToString().Trim(); pstrprodcno = pstrprodcno.ToString().Trim(); //if (strprodno == pstrprodcno) if (pstrprodcno.ToUpper().Replace(".", "").Contains(strprodno.ToUpper().Replace(".", ""))) { this.dgvMATChange.Rows[temprowindex].DefaultCellStyle.BackColor = Color.White; dgvMATChange.Rows[temprowindex].Cells[clscanstate.Name].Value = "1"; break; } else { SetContainerItem(nfindex, false); Alert("条码错误:条码的零件号与FIS队列零件号不符合。"); break; } } else { SetContainerItem(nfindex, false); Alert("条码错误:条码已扫描或车型不符合。"); break; } } } else { Alert("扫描条码重复,请重新扫描。"); } SetContainerItem(nfindex, true); CreateNFPaste(Code,product); if (dgvMATChange.RowCount > 0) { dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4; } lberror.Text = ""; } #endregion #region 扫描条码时触发事件 ///// ///// 扫描条码时触发事件 ///// ///// ///// 崔法宝20170906 private void txtCode_KeyDown(object sender, KeyEventArgs e) { QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); string inputstring = ""; try { if (e.KeyCode != Keys.Enter) { return; } inputstring = txtCode.Text.ToUpper(); this.lberror.Text = null; #region 使用登录码快速切换用户 //使用登录码快速切换用户 if (System.Text.RegularExpressions.Regex.IsMatch(txtCode.Text, "^<\\w+::\\w+>$")) { var ret = ClientContext.CodeLogin(txtCode.Text); if (string.Equals(ret, "登录成功!")) { ClientContext.SetUserAuth(this); } lberror.Text = ret; ArragetxtCode(); return; } if (System.Text.RegularExpressions.Regex.IsMatch(txtCode.Text.ToUpper(), "^>CMD:\\w+$"))//扫描输入为指令码 { ExcuteCMDCode(); txtCode.Text = ""; txtCode.Focus(); return; } _CMDConfirm = ""; #endregion #region 原校验 string PastNOConfirmEnable = QMAPP.WinForm.Common.LocalSetting.Settings["PastNOConfirmEnable", "0"]; if (System.Text.RegularExpressions.Regex.IsMatch(txtCode.Text.ToUpper(), "^" + WORKCENTER_CODE + "\\w+$"))//扫描输入为贴车单号 { if (string.Equals("1", PastNOConfirmEnable)) //贴车单确认功能开启 { GetLastPastCard(); if (string.Equals(txtCode.Text.ToUpper(), lblLastPastNO.Text.ToUpper())) { lberror.Text = "前车贴车单号确认完成!"; SetPastNOConfirm(1); ArragetxtCode(); return; } else { lberror.Text = "前车贴车单号确认失败!"; SetPastNOConfirm(2); ArragetxtCode(); return; } } else { lberror.Text = "贴车单号确认功能未开启,无需扫描贴车单号!"; SetPastNOConfirm(0); ArragetxtCode(); return; } } if (string.Equals("1", PastNOConfirmEnable)) //贴车单确认功能开启 { if (!pbPastNoConfirmed.Enabled) { Alert("请先扫描前车贴车单号进行贴车单确认!"); ArragetxtCode(); return; } } #endregion #region fis区是否有记录 if (dgvMATChange.Rows.Count == 0) { Alert("FIS区域没有数据,请获取数据后再扫描!"); ArragetxtCode(); return; } #endregion #region 一号位校验是否扫描校验 //2016-01-07 增加1号位校验 if (this.dgvNF.Rows.Count == 0) //第一个码必须先扫描1号位 { string placeCode = txtCode.Text.Trim(); if (placeCode.Equals(System.Configuration.ConfigurationManager.AppSettings["PlaceFirstPositionCode"].ToString())) { this.placeFirstPosition = placeCode; this.placeFirstPositionTime = DateTime.Now; this.txtCode.Text = ""; //处理条码扫描文本框 ArragetxtCode(); return; } } #endregion #region 一号位时间校验 if (this.dgvNF.Rows.Count == 0 && !string.IsNullOrEmpty(this.placeFirstPosition))//超时判断 { double timeOutSecond = 0; //获取超时时间设定值 //DataTable dtTimeOut = new BllTimeOutSet().GetList(); DataTable dtTimeOut = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetTimeOutSet.ToString()); if (dtTimeOut.Rows.Count > 0) { timeOutSecond = Convert.ToDouble(dtTimeOut.Rows[0]["TIMEOUT_VALUE"].ToString()); } //获取超时时间设定值 if (timeOutSecond > 0) { TimeSpan ts = DateTime.Now - this.placeFirstPositionTime; if (ts.TotalSeconds > timeOutSecond) { this.placeFirstPosition = ""; this.txtCode.Text = ""; this.placeFirstPositionTime = DateTime.MinValue; lberror.Text = "扫描本体件超时,请重新扫描1号位!"; //处理条码扫描文本框 ArragetxtCode(); return; } } } #endregion #region 请先扫描1号位 if (string.IsNullOrEmpty(this.placeFirstPosition)) { this.placeFirstPosition = ""; this.txtCode.Text = ""; lberror.Text = "请先扫描1号位!"; return; } #endregion #region FIS区域数据全部扫描完成,请获取数据后再扫描 if (dgvNF.Rows.Count >= dgvMATChange.Rows.Count) { Alert("FIS区域数据全部扫描完成,请获取数据后再扫描!"); ArragetxtCode(); return; } #endregion #region 长度校验 //string pp = System.Configuration.ConfigurationManager.AppSettings["UpperBarcodeLen"].ToString(); Int32 ul = int.Parse(System.Configuration.ConfigurationManager.AppSettings["UpperBarcodeLen"].ToString()); Int32 ll = int.Parse(System.Configuration.ConfigurationManager.AppSettings["LowerBarcodeLen"].ToString()); if (txtCode.Text.Length <= ll || txtCode.Text.Length >= ul) { Alert("条码错误:条码长度不符合要求(" + ll.ToString() + "-" + ul.ToString() + ")。"); ArragetxtCode(); return; } #endregion #region 校验位计算 if (txtCode.Text.StartsWith("052")) { string codepart = txtCode.Text.Substring(0, txtCode.Text.Length - 1).ToUpper(); string checksum = txtCode.Text.Substring(txtCode.Text.Length-1,1).ToUpper(); if (!string.Equals(checksum, CalculateChecksum(codepart))) { Alert("条码错误:总成条码校验位错误!"); ArragetxtCode(); return; } } #endregion #region 判断扫描条形码是否存在 获取扫描条码 string Code = txtCode.Text.Trim().ToUpper(); #region 校验是否有重复的扫过的条码 if (dgvNF.Rows.Count > 0) { for (var i = 0; i < dgvNF.Rows.Count; i++) { if (dgvNF.Rows[i].Cells[CODE_NF.Name].Value.ToString().ToUpper() == Code) { SetContainerItem(nfindex, false); Alert("该条码已扫描!"); txtCode.Text = ""; txtCode.Focus(); return; } } } #endregion //规则 bool signal = false; string outSourceProduct = ""; foreach (var rule in _barcodeRules) { if (System.Text.RegularExpressions.Regex.IsMatch(Code, rule.REGEX)) { signal = true; ProMaterial = rule.MATERIAL_CODE; outSourceProduct = rule.DATA_TYPE; if (rule.REMARK == "NFPD") { Alert("该产品为NF产品,请扫描下护板条码。"); ArragetxtCode(); return; } } } if (signal == false) { //规则表里没有则去数据库里查找是否存在(VW371 bc316产品) if (System.Text.RegularExpressions.Regex.IsMatch(Code, "^DP\\w+(-\\w+)?-DF[LR][FR]\\w+$"))//扫描输入为门板计划标签 { //从计划标签中截取产品码 Code = Code.Substring(Code.LastIndexOf('-') + 1); } #region 去数据库查询相关产品信息,外来零件忽略此步骤 Product product = null; if (System.Text.RegularExpressions.Regex.IsMatch(Code, "^BCP")) { //BCP开头的是BC316-MP4的包覆件 } else { product = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetProductByAssembleCode.ToString(), Code); } if (product != null) { Code = string.IsNullOrEmpty(product.MAINCODE) ? product.PRODUCTCODE : product.MAINCODE; } else { product = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetProductByAssembleCodeMP4.ToString(), Code); if (product != null) { Code = string.IsNullOrEmpty(product.MAINCODE) ? product.PRODUCTCODE : product.MAINCODE; } else { Alert("未查询到该产品零件信息:" + Code + "。"); //清理文本框 ArragetxtCode(); return; } } #region 校验是否有重复的扫过的条码 //------------------校验是否有重复的扫过的条码------ if (dgvNF.Rows.Count > 0 && product != null) { for (var i = 0; i < dgvNF.Rows.Count; i++) { if (dgvNF.Rows[i].Cells[CODE_NF.Name].Value.ToString() == Code) { SetContainerItem(nfindex, false); Alert("该条码已扫描!"); txtCode.Text = ""; txtCode.Focus(); return; } } } //-------------------------End----------- #endregion //int ExitResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetExitsCode.ToString(), Code); if ((product == null || string.IsNullOrEmpty(product.PID))) { SetContainerItem(nfindex, false); Alert("扫描的产品条码不存在,请重新扫描!"); txtCode.Text = ""; txtCode.Focus(); return; } //Object statusRuslt = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetExitsStatus.ToString(), Code); #region 2.判断成品 if (product.STATUS != "0") { SetContainerItem(nfindex, false); Alert("扫描的不是合格成品,不能进行发运!"); txtCode.Text = ""; txtCode.Focus(); return; } if (product.OUTFLAG != "0") { SetContainerItem(nfindex, false); Alert("扫描产品已出库,不能进行发运操作!"); txtCode.Text = ""; txtCode.Focus(); return; } var StorageTimeLimit=0d; double.TryParse(QMAPP.WinForm.Common.LocalSetting.Settings["StorageTimeLimit", "24"],out StorageTimeLimit); if ((DateTime.Now - product.CREATEDATE).TotalHours < StorageTimeLimit) { SetContainerItem(nfindex, false); Alert("扫描产品下线时间不足"+StorageTimeLimit+"小时!,不能进行发运操作!"); txtCode.Text = ""; txtCode.Focus(); return; } var mcresult = agent.InvokeServiceFunction>("MaterialClassBLL_Get", new MaterialClass { MATERIAL_TYPE_CODE = product.MATERIAL_TYPE }); if (System.Text.RegularExpressions.Regex.IsMatch(product.PRODUCTCODE, "^BCP")) { mcresult = agent.InvokeServiceFunction>("MaterialClassBLL_GetMP4", new MaterialClass { MATERIAL_TYPE_CODE = product.MATERIAL_TYPE }); } var mc = mcresult.IsSuccess ? mcresult.Result : new MaterialClass { }; if (!string.Equals(mc.MATERIAL_ATTRIBUTE, "2")) { SetContainerItem(nfindex, false); Alert("扫描产品不是总成件!,不能进行发运操作!"); txtCode.Text = ""; txtCode.Focus(); return; } FJC.Entity.ProductIn.ProductIn inrecord = agent.InvokeServiceFunction("ProductInBLL_GetInRecord", Code); if (System.Text.RegularExpressions.Regex.IsMatch(product.PRODUCTCODE, "^BCP")) { inrecord = agent.InvokeServiceFunction("ProductInBLL_GetInRecordmp4", Code); } if (inrecord != null) { SetContainerItem(nfindex, false); Alert("此产品为退返件,请更换总成标签后再发运!"); txtCode.Text = ""; txtCode.Focus(); return; } #endregion #region 4.与FIS数据匹配 //4.与FIS数据匹配 FISDataCompare(Code, product); #endregion #endregion } #endregion #region 底盘号间隔校验 //2016-10-31 闫永刚 int scanSum = dgvNF.Rows.Count; int lastvinNumber = 0; int vinNumber = 0; if (scanSum > 0) { //lastvinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum - 1].Cells["VIN"].Value.ToString().Substring(10, 7)); //vinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum].Cells["VIN"].Value.ToString().Substring(10, 7)); lastvinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum - 1].Cells["REQUESTID"].Value.ToString()); vinNumber = Convert.ToInt32(dgvMATChange.Rows[scanSum].Cells["REQUESTID"].Value.ToString()); } if ((vinNumber - lastvinNumber) > 1) { var dresult = MessageBox.Show("出现顺序号间隔,是否继续发货?", "提示", MessageBoxButtons.YesNo); if (dresult == DialogResult.No) { ArragetxtCode(); return; } } #endregion #region 判断当前扫描过的数据集合中是否有相同条码 //判断当前扫描过的数据集合中是否有相同条码 if (outSourceProduct == "OP") { //CheckDataSet(Code) && ////判断数据库中是否有相同的条码 //if (Code.Substring(0, 2) != "NF") //{ // CheckDataBase(Code); //} //else //2016-07-29 董阳 新增其他校验规则校验 //{ // if (CheckRule(Code)) // { // CreateNFPaste(); // } //} CheckDataBase(Code); } #endregion #region 处理条码扫描文本框 ArragetxtCode(); #endregion txtCode.Text = ""; txtCode.Focus(); } catch (Exception ex) { //MessageBox.Show(ex.Message); lberror.Text = ex.Message; } finally { if (!string.IsNullOrWhiteSpace(inputstring)) WriteLog.WriteShipmentLog(string.Format("{0}\t{1}\t{2}", DateTime.Now, inputstring, lberror.Text)); dgvMATChange.ClearSelection(); } } #endregion #region 执行CMD码 /// /// 执行CMD码 /// private void ExcuteCMDCode() { string cmd = txtCode.Text.Trim().Split(':')[1]; switch (cmd) { case "CLOSECART"://强制提交 { CloseCart(cmd); break; } case "RESETCART"://重扫器具 { ResetCart(); break; } case "FORCESCAN"://强制扫描 { ForceScan(cmd); break; } default: { Alert("未知指令!",false); _CMDConfirm = ""; break; } } } #endregion #region 强制扫描 将下一次扫描的物料验证 /// /// 强制扫描 将下一次扫描的物料验证 /// /// private void ForceScan(string cmd) { if (_CMDConfirm == cmd)//指令二次确认 { //CreatePaste(); lberror.Text = ""; _CMDConfirm = ""; } else { Alert("确定要提交此贴车单?请再次扫描指令码确认。"); _CMDConfirm = cmd; } } #endregion #region 手动提交贴车单-在器具未满情况下使用 /// /// 手动提交贴车单-在器具未满情况下使用 /// /// private void CloseCart(string cmd) { if (!btnCloseCart.Enabled) { Alert("您没有进行此操作的权限!", false); _CMDConfirm = ""; return; } if (nflist == null) { Alert("需要至少扫描一件产品才能提交贴车单!",false); _CMDConfirm = ""; return; } if (_CMDConfirm == cmd)//指令二次确认 { lberror.Text = ""; _CMDConfirm = ""; CreatePaste(); } else { Alert("确定要提交此贴车单?请再次扫描指令码确认。",false); _CMDConfirm = cmd; } } #endregion #region 根据条码标识查询零件信息(无用) /// /// 根据条码标识查询零件信息 /// /// private DataTable GetSparepartsinfo(string strbarcode) { //根据条码前3位去零件表查询条码标识查找零件号。包括的数据有052、NF1、NF2、NF3、NF4。车型,指NF或NCS。 // BllFisOrder bllFisOrder = new BllFisOrder(); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); //----------2015-02-10 王丹丹 修改(条码规则变更,所以查询零件号的条件也变更)---------------- if (strbarcode.Substring(0, 3) != "052") { //如果前3位不是"052",截取条码前3位进行查询 //return bllFisOrder.GetSparepartsinfo(strbarcode.Substring(0, 3)); return agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetSparepartsinfo.ToString(), strbarcode.Substring(0, 3)); } else { //如果前3位是"052",截取条码前8位进行查询 //return bllFisOrder.GetSparepartsinfo(strbarcode.Substring(0, 8)); return agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetSparepartsinfo.ToString(), strbarcode.Substring(0, 8)); } //-------------------------------------------------------------------------------------------- } #endregion #region 判断数据库中是否有相同的条码 //条码标识 string barcodeidentification = ""; /// /// 判断数据库中是否有相同的条码 /// /// 扫描条码 private void CheckDataBase(string strbarcode) { barcodeidentification = ""; //特殊条码,当丢失条码或者条码损坏时,扫描一个特殊条码 string specialbarcode = ""; // BllFisOrder bllFisOrder = new BllFisOrder(); //根据条码标识获取零件信息 //DataTable tbl = GetSparepartsinfo(strbarcode); //if (tbl.Rows.Count > 0) //{ // barcodeidentification = tbl.Rows[0]["BARCODEIDENTIFICATION"].ToString(); //} //else //{ // PlaySound.PlaySounds.Play(@errorSoundPath); // lberror.Text = "条码错误:无法根据条码识别零件号"; //} //if (getTeShuBarcode(barcodeidentification) == strbarcode) //{ // specialbarcode = "SPECIALBARCODE"; //} //DataTable tblbarcode = bllFisOrder.ExistBarcode(BarcodeTime, strbarcode); QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tblbarcode = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_ExistBarcode.ToString(), BarcodeTime, strbarcode); if (tblbarcode.Rows.Count == 0 || specialbarcode == "SPECIALBARCODE") { //d.AddDays(-40)+"00:00:00"; #region "校验:根据条码获取零件号" //if (tbl.Rows.Count > 0) //{ //零件号 //string strkhprodno = tbl.Rows[0]["CUSTOMERSPAREPARTS"].ToString(); string strkhprodno = ProMaterial; //01,02 //string templineno = tbl.Rows[0]["CODENAME"].ToString(); string templineno = "02"; //车型 //string vehicletype = tbl.Rows[0][1].ToString(); GetCruentFisData(strbarcode, strkhprodno, templineno, nfpastecard, ncspastecard); //判断当前FIS队列中的零件号,是否等于条码标识获取的零件号。 //if (strkhprodno == strprodno) if (strkhprodno.ToUpper().Replace(".", "").Contains(strprodno.ToUpper().Replace(".", ""))) { SetContainerItem(nfindex, true); CreateNFPaste(strbarcode, new Product()); } else { Alert("条码错误:扫描的条码与FIS中的零件不符。"); } //} //else //{ // PlaySound.PlaySounds.Play(@errorSoundPath); // lberror.Text = "条码错误:无法根据条码识别零件号。"; //} #endregion } else { Alert("扫描条码重复,请重新扫描。"); } } #endregion #region 光标聚焦 /// /// 光标聚焦 /// /// /// private void txtCode_Leave(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCode.Text)) { txtCode.Focus(); } } #endregion #region 获取FIS发货数据的当前行 /// /// 获取FIS发货数据的当前行 /// private void GetCruentFisData(string pstrbarcode, string pstrprodcno, string ptemplineno, EPasteCard pnfpascard, EPasteCard pncspascard) { #region if (dgvMATChange.Rows.Count != 0) { //if (ptemplineno == "NCS") //{ // if (ncslist == null) // { // DGVCurrontRow(pstrprodcno, ptemplineno, 0); // } // else // { // int rowcount = ncslist.Count; // int temprowindex = ncslist[rowcount - 1].DGVROWINDEX + 1; // DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex); // } //} //if (ptemplineno == "NF") //{ // if (nflist == null) // { // DGVCurrontRow(pstrprodcno, ptemplineno, 0); // } // else // { // int rowcount = nflist.Count; // int temprowindex = nflist[rowcount - 1].DGVROWINDEX + 1; // DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex); // } //} if (nflist == null) { DGVCurrontRow(pstrprodcno, ptemplineno, 0); } else { int rowcount = nflist.Count; int temprowindex = nflist[rowcount - 1].DGVROWINDEX + 1; DGVCurrontRow(pstrprodcno, ptemplineno, temprowindex); } } #endregion } #endregion #region 根据零件号,车型获取当前要发货的FIS信息(外来件) /// /// 根据零件号,车型获取当前要发货的FIS信息 /// /// /// /// private void DGVCurrontRow(string pstrprodcno, string ptemplineno, int rowindex) { #region for (; rowindex < dgvMATChange.Rows.Count; rowindex++) { //主键 //strFiskey = dgvMATChange.Rows[rowindex].Cells["clFiskey"].Value.ToString(); strFiskey = dgvMATChange.Rows[rowindex].Cells["PID"].Value.ToString(); //大众顺序号 strvwseq = dgvMATChange.Rows[rowindex].Cells["REQUESTID"].Value.ToString(); //零件号 strprodno = dgvMATChange.Rows[rowindex].Cells["PRODNO"].Value.ToString(); //总成描述 strcarsetdesc_cn = dgvMATChange.Rows[rowindex].Cells["CARSETDESC_CN"].Value.ToString(); //上线时间 strcp5a = dgvMATChange.Rows[rowindex].Cells["CP5A"].Value.ToString(); //车型 strlineno = dgvMATChange.Rows[rowindex].Cells["LINENO"].Value.ToString(); //车身号 strkin = dgvMATChange.Rows[rowindex].Cells["KIN"].Value.ToString(); //底盘号 strvin = dgvMATChange.Rows[rowindex].Cells["VIN"].Value.ToString(); //扫描状态 strscanstat = dgvMATChange.Rows[rowindex].Cells[clscanstate.Name].Value.ToString(); dgvrowindex = rowindex; if (strscanstat == "0" )//&& strlineno == ptemplineno { strprodno = strprodno.ToString().Trim(); pstrprodcno = pstrprodcno.ToString().Trim(); //if (strprodno == pstrprodcno) if (pstrprodcno.ToUpper().Replace(".", "").Contains(strprodno.ToUpper().Replace(".", ""))) { //2016-01-21 wangqingnan 如果行变色则不重新刷颜色 //DataGridViewCellStyle ds = new DataGridViewCellStyle(); //ds.BackColor = Color.White; //this.dgvMATChange.Rows[rowindex].DefaultCellStyle = ds; this.dgvMATChange.Rows[rowindex].DefaultCellStyle.BackColor = Color.White; //2016-01-21 wangqingnan 如果行变色则不重新刷颜色 dgvMATChange.Rows[rowindex].Cells[clscanstate.Name].Value = "1"; break; } else { Alert("条码错误:条码的零件号与FIS队列零件号不符合。"); break; } } else { Alert("条码错误:条码已扫描或车型不符合。"); break; } } #endregion } #endregion #region 创建NF的贴车单以及明细(vw371) EPasteCard nfpastecard = null; /// /// 创建NF的贴车单以及明细 /// private void CreateNFPaste(string barcode,Product product) { #region if (nfindex == 0) { nflist = new List(); nfpastcardkey = Guid.NewGuid().ToString(); nfpastecard = new EPasteCard(); nfpastecard.DetailsCardlist = new List(); nfpastecard.PASTE_CARD_KEY = nfpastcardkey; nfpastecard.PASTECARDNO = ""; nfpastecard.PRODUCTIONNAME = pFisType; nfpastecard.PASTECARDDATE = DateTime.Now.ToString(); nfpastecard.OPERATOR = UserBuffer.UserCode; nfpastecard.CREATETIME = DateTime.Now.ToString(); nfpastecard.PLANTNAME = WORKCENTER_CODE.ToString(); } EPasteDetailsCard pastdetail = new EPasteDetailsCard(); pastdetail.PASTEDETAILED_CARD_KEY = Guid.NewGuid().ToString(); pastdetail.FIS_KEY = strFiskey; pastdetail.PASTE_CARD_KEY = nfpastcardkey; //为扫描记录关联产品主键 张鹏 2018-3-8 pastdetail.SANBARCODE = barcode;// txtCode.Text.ToString(); pastdetail.PRODUCT_PID = product.PID; pastdetail.SCANDATE = DateTime.Now.ToString(); pastdetail.PRODNO = strprodno; pastdetail.CARSETDESC_CN = strcarsetdesc_cn; pastdetail.VIN = strvin; pastdetail.VWSEQ = strvwseq; pastdetail.CP5A = strcp5a; pastdetail.KIN = strkin; pastdetail.DGVROWINDEX = dgvrowindex; pastdetail.LINENO = strlineno; nfpastecard.DetailsCardlist.Add(pastdetail); nflist.Add(pastdetail); dgvNF.DataMember = null; dgvNF.DataSource = nflist; strprodno = ""; nfindex++; //int setdefaultSum = Convert.ToInt32(QM.Config.CustomConfig.GetItem("ShowDataCount")); int setdefaultSum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount",""]); if (nfindex == setdefaultSum) { EFailLog log = new EFailLog(); log.TID = Guid.NewGuid().ToString(); log.FCT_DATE = DateTime.Now; log.FCT_NO = nfpastecard.PASTE_CARD_KEY; log.FCT_OPER = UserBuffer.UserCode; log.FCT_OPERTYPE = 1; log.FCT_REASON = "NF贴车单自动打印操作"; nfpastecard.DetailsCardlist = nflist; nfpastecard.FailLog = log; nfindex = 0; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), nfpastecard.PLANTNAME.ToString()); if (tbl.Rows.Count == 0) { nfpastecard.PASTECARDNO = WORKCENTER_CODE + DateTime.Now.ToString("yyyyMMdd") + "0001"; int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard); } else { foreach (DataRow dr in tbl.Rows) { string PASTECARDNO = dr["PASTECARDNO"].ToString(); string PLANTNAME = dr["PLANTNAME"].ToString(); if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4) { int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length; string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); string sumValue = ""; for (var i = 0; i < num; i++) { sumValue = sumValue + "0"; } if (PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4) + sumValue + value; } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } else { if (PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(PLANTNAME.Length, PASTECARDNO.Length - PLANTNAME.Length - 4) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } nfpastecard.PASTECARDNO = PLANTNAME + PASTECARDNO; nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString(); } } int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard); Print();//手动提交打印功能 ClearContainer(); GetInitData(); DGVRemoveRow(nflist, ref ncslist); dgvNF.DataSource = new List(); nfpastecard = null; nflist = null; nfindex = 0; dgvrowindex = 0; //computenfncs(); //2016-01-07 增加1号位校验 - 清空1号位 //this.placeFirstPosition = ""; //this.placeFirstPositionTime = DateTime.MinValue; //2016-01-07 增加1号位校验 GetLastPastCard(); SetPastNOConfirm(0); } #endregion } #endregion #region 创建贴车单(不满车提交) /// /// 创建贴车单(不满车提交) /// private void CreatePaste() { if (nflist == null) { Alert("无数据,请先按FIS顺序扫描产品!",false); return; } EFailLog log = new EFailLog(); log.TID = Guid.NewGuid().ToString(); log.FCT_DATE = DateTime.Now; log.FCT_NO = nfpastecard.PASTE_CARD_KEY; log.FCT_OPER = UserBuffer.UserCode; log.FCT_OPERTYPE = 1; log.FCT_REASON = "NF贴车单自动打印操作"; nfpastecard.DetailsCardlist = nflist; nfpastecard.FailLog = log; nfindex = 0; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetDaspssteCarIndexByPlanName.ToString(), nfpastecard.PLANTNAME.ToString()); if (tbl.Rows.Count == 0) { nfpastecard.PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; int delResult = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_InsertDaspssteCarIndexByPlanName.ToString(), nfpastecard); } else { foreach (DataRow dr in tbl.Rows) { string PASTECARDNO = dr["PASTECARDNO"].ToString(); string PLANTNAME = dr["PLANTNAME"].ToString(); if ((Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length < 4) { int num = 4 - (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString().Length; string value = (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); string sumValue = ""; for (var i = 0; i < num; i++) { sumValue = sumValue + "0"; } string ii = PASTECARDNO.Substring(PLANTNAME.Length, 8).ToString(); if (PASTECARDNO.Substring(PLANTNAME.Length, 8).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PLANTNAME + PASTECARDNO.Substring(PLANTNAME.Length - PLANTNAME.Length, 6) + sumValue + value; } else { PASTECARDNO = PLANTNAME + DateTime.Now.ToString("yyyyMMdd") + "0001"; } } else { if (PASTECARDNO.Substring(2, PASTECARDNO.Length - 6).ToString() == DateTime.Now.ToString("yyyyMMdd")) { PASTECARDNO = PASTECARDNO.Substring(2, PASTECARDNO.Length - 6) + (Convert.ToInt32(PASTECARDNO.Substring(PASTECARDNO.Length - 4, 4)) + 1).ToString(); } else { PASTECARDNO = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } nfpastecard.PASTECARDNO = PASTECARDNO; nfpastecard.OPERATOR = ClientContext.LoginInfo.UserName.ToString(); } } int rowindex = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_AddNewPasteCard.ToString(), nfpastecard); Print();//手动提交打印功能 ClearContainer(); GetInitData(); DGVRemoveRow(nflist, ref ncslist); dgvNF.DataSource = new List(); nfpastecard = null; nflist = null; nfindex = 0; dgvrowindex = 0; GetLastPastCard(); SetPastNOConfirm(0); } #endregion #region 打印功能 /// /// 打印功能 /// private void Print() { int PrintDisable = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["PrintDisable", "1"]); if (PrintDisable == 1) { lberror.Text = "贴车单打印已禁用!"; return; } PrintPasteCard prin = new PrintPasteCard(); string strprodtype = ""; if (pFisType == "01") { strprodtype = "( 混 )"; } else if (pFisType == "02") { strprodtype = "( 单 )"; } DataTable dt = new DataTable(); dt.Columns.Add("ROWINDEX"); dt.Columns.Add("VWSEQ"); dt.Columns.Add("VIN"); dt.Columns.Add("PRODNO"); dt.Columns.Add("CARSETDESCCN"); dt.Columns.Add("CP5A"); dt.Columns.Add("PASTECARDNO"); dt.Columns.Add("SCANDATE"); dt.Columns.Add("PRODUCTIONNAME"); dt.Columns.Add("LINENO"); int index = 1; QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent(); //DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPastecardDeatis.ToString()); DataTable tbl = agent.InvokeServiceFunction(QMAPP.ServicesAgent.FrmPlaceManage.FrmPlaceBLL_GetPascardDetailsByPid.ToString(), nfpastecard.PASTE_CARD_KEY); //index = Convert.ToInt32(tbl.Rows[0][0].ToString()); for (var i = 0; i < tbl.Rows.Count; i++) { DataRow ncsdr = dt.NewRow(); ncsdr["ROWINDEX"] = index.ToString(); ; ncsdr["VWSEQ"] = tbl.Rows[i]["VWSEQ"].ToString(); ncsdr["VIN"] = tbl.Rows[i]["VIN"].ToString(); ncsdr["PRODNO"] = tbl.Rows[i]["PRODNO"].ToString(); ncsdr["CARSETDESCCN"] = tbl.Rows[i]["CARSETDESC_CN"].ToString(); ncsdr["CP5A"] = tbl.Rows[i]["CP5A"].ToString(); ncsdr["PASTECARDNO"] = tbl.Rows[i]["PASTECARDNO"].ToString();; ncsdr["SCANDATE"] = DateTime.Now.ToString(); ncsdr["PRODUCTIONNAME"] = strprodtype; ncsdr["LINENO"] = tbl.Rows[i]["LINENO"].ToString(); dt.Rows.Add(ncsdr); index++; } prin.Print(dt); //MessageBox.Show("打印成功!"); lberror.Text = "贴车单已打印"; } #endregion #region 定时刷新数据 /// /// 定时刷新数据 /// /// /// private void timeRefew_Tick(object sender, EventArgs e) { //if (dgvNF.Rows.Count == 0) //{ GetInitData(); //} } #endregion #region 扫描件状态框动作 /// /// /// public void InitContainer() { tpContainer.Controls.Clear(); tpContainer.RowStyles.Clear(); tpContainer.ColumnStyles.Clear(); int defaultNum = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["ShowDataCount", "6"]); int rowcount = Convert.ToInt32(QMAPP.WinForm.Common.LocalSetting.Settings["RowCount", "2"]); tpContainer.RowCount = rowcount; tpContainer.ColumnCount = defaultNum / rowcount + (defaultNum % rowcount > 0 ? 1 : 0); for (int i = 0; i < tpContainer.RowCount; i++) { if (i == 0) { tpContainer.RowStyles.Add(new RowStyle(SizeType.Percent, 50)); } else { tpContainer.RowStyles.Add(new RowStyle(SizeType.Percent, 50)); } } for (int i = 0; i < tpContainer.ColumnCount; i++) { //tpContainer.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, tpContainer.ColumnCount > 8 ? 60 : 90)); tpContainer.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50)); //Label lblno = new Label(); //lblno.Text = (i + 1).ToString(); //lblno.Font = new Font("微软雅黑", 20, FontStyle.Bold); //lblno.Dock = DockStyle.Fill; //lblno.TextAlign = ContentAlignment.MiddleCenter; //tpContainer.Controls.Add(lblno, i, 0); for (int j = 0; j < tpContainer.RowCount; j++) { Label lblItem = new Label(); lblItem.Text = (i*rowcount+j+ 1).ToString(); lblItem.Font = new Font("微软雅黑", 24, FontStyle.Bold); lblItem.Dock = DockStyle.Fill; lblItem.TextAlign = ContentAlignment.MiddleCenter; tpContainer.Controls.Add(lblItem, i, j); } } //tpContainer.Height = tpContainer.RowCount * (3 + (tpContainer.ColumnCount > 8 ? 60 : 90)); for (int i = 0; i < nfindex; i++) { SetContainerItem(i, true); } } /// /// /// /// /// public void SetContainerItem(int itemindex, bool result) { var columnindex = itemindex / (tpContainer.RowCount); var rowindex = itemindex % (tpContainer.RowCount) ; var label = tpContainer.GetControlFromPosition(columnindex, rowindex) as Label; if (label != null) { label.BackColor = result ? Color.Lime : Color.Red; } } /// /// /// public void ClearContainer() { foreach (var ctrl in tpContainer.Controls) { var label = ctrl as Label; if (label != null) { label.BackColor = tpContainer.BackColor; } } } #endregion #region 重新扫描 /// /// 重新扫描 /// /// /// private void btnResetCart_Click(object sender, EventArgs e) { ResetCart(); } private void ResetCart() { if (!btnResetCart.Enabled) { lberror.Text = "您无权执行此操作!"; } nflist = null; nfindex = 0; ClearContainer(); GetInitData(); //DGVRemoveRow(nflist, ref ncslist); dgvNF.DataSource = new List(); nfpastecard = null; dgvrowindex = 0; if (dgvMATChange.RowCount > 0) { dgvMATChange.FirstDisplayedScrollingRowIndex = nfindex - nfindex % 4; } } #endregion #region 混线单选按钮 /// /// 混线单选按钮 /// /// /// int signal = 0; private void rb_hx_CheckedChanged(object sender, EventArgs e) { if (dgvNF.Rows.Count > 0) { if (rb_hx.Checked == true && signal == 0) { signal++; rb_dx.Checked = true; } else if (rb_dx.Checked == true && signal == 0) { signal++; rb_hx.Checked = true; } lberror.Text = "已扫描数据区不为空,重置或者扫描整车后才能切换生产线!"; signal = 0; return; } lberror.Text = ""; QMAPP.WinForm.Common.LocalSetting.Settings["FlashProCode"] = rb_hx.Checked ? "01" : "02"; if (this.rb_hx.Checked == true) { //混 pFisType = "01"; WORKCENTER_CODE = "IPFY01"; } else { //单 pFisType = "02"; WORKCENTER_CODE = "IPFY02"; } GetInitData(); } #endregion #region 工作中心设置按钮 /// /// 工作中心设置按钮 /// /// /// private void btnLineSetting_Click(object sender, EventArgs e) { frmLineSetting frm = new frmLineSetting(); frm.Owner = this; frm.ShowDialog(); txtCode.Focus(); } #endregion #region 贴车单顺序校正按钮 /// /// 贴车单顺序校正按钮 /// /// /// private void btnResetIndex_Click(object sender, EventArgs e) { ResetSendIndexForm form = new ResetSendIndexForm(); form.ShowDialog(); txtCode.Focus(); } #endregion #region 设置容器容量 /// /// 设置容器容量 /// /// /// private void btnSetDatagroupType_Click(object sender, EventArgs e) { DefaultDataSetNum window = new DefaultDataSetNum(); window.Owner = this; window.Show(); } #endregion /// /// /// /// /// private void FrmPlace_Activated(object sender, EventArgs e) { SetRowColor(); } /// /// /// /// /// private string getTeShuBarcode(String str) { return str + " 4XR#" + DateTime.Now.ToString("MMddHH") + "#"; } #region 不满车打印贴车单 /// /// 不满车打印贴车单 /// /// /// private void btnCloseCart_Click(object sender, EventArgs e) { lberror.Text = ""; _CMDConfirm = ""; CreatePaste(); } #endregion public static string CalculateChecksum(string barcode) { string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; int sum = 0; foreach (var c in barcode) { sum += chars.IndexOf(c); } int rem = sum % chars.Length; return chars[rem].ToString(); } } }