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 QMAPP.FJC.Entity.Basic; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.MD.Entity; using QMAPP.Entity; using QMFrameWork.Data; using System.Configuration; using System.Threading; namespace QMAPP.WinForm.Forms.TianJin { public partial class TJPrintPlanLabel : Form { QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent(); List cbsource = null; private string planMATERIAL_CODE = string.Empty; private string FR = string.Empty; /// /// /// public TJPrintPlanLabel() { InitializeComponent(); } /// /// 加载工艺路线 /// private void LoadProcessRoute() { var routes = _agent.InvokeServiceFunction>> ("ProcessRouteBLL_GetProcessRouteList", new QMAPP.FJC.Entity.Basic.ProcessRoute { }).Result; routes = routes.OrderBy(p => p.ROUTE_CODE).ToList(); cbsource = routes; //cbsource.Insert(0, new QMAPP.FJC.Entity.Basic.ProcessRoute { ROUTE_NAME = "", ROUTE_CODE = "" }); cbRoutes.DisplayMember = "ROUTE_NAME"; cbRoutes.ValueMember = "ROUTE_CODE"; cbRoutes.DataSource = cbsource; var listDir = new List(); listDir.Add(new Direction { Code = "左", Name = "左侧" }); listDir.Add(new Direction { Code = "右", Name = "右侧" }); comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Code"; comboBox1.DataSource = listDir; var listSHIFT = new List(); listSHIFT.Add(new Direction { Code = "A", Name = "A班" }); listSHIFT.Add(new Direction { Code = "B", Name = "B班" }); listSHIFT.Add(new Direction { Code = "C", Name = "C班" }); comboBox2.DisplayMember = "Name"; comboBox2.ValueMember = "Code"; comboBox2.DataSource = listSHIFT; // tsbPrint.Enabled = false; } #region 加载列表显示设置 /// /// 加载列表显示设置 /// private void LoadViewSetting() { #region 加载列表显示设置 string filepath = ConfigurationManager.AppSettings["SaveFilePath"]; filepath = string.Format("{0}ViewSetting.cfg", filepath); var setting = new { ListRowcount = 20, RefreshRate = 5 }; if (System.IO.File.Exists(filepath)) { string settingstring = System.IO.File.ReadAllText(filepath); setting = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(settingstring, setting); } cbListRowcount.Text = setting.ListRowcount.ToString(); //cbRefreshRate.Text = string.Format("{0}s", setting.RefreshRate); cbPlanFilter.SelectedIndex = 1; cbListRowcount.SelectedIndexChanged += new EventHandler(cbListRowcount_SelectedIndexChanged); //cbRefreshRate.SelectedIndexChanged += new EventHandler(cbRefreshRate_SelectedIndexChanged); cbPlanFilter.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged); comboBox1.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged); comboBox2.TextChanged += new EventHandler(cbPlanFilter_SelectedIndexChanged); #endregion } #endregion #region 列表定时刷新 private void cbListRowcount_SelectedIndexChanged(object sender, EventArgs e) { SaveSetting(); BindPlanView(); } /// /// 发送指令或者接受完成指令刷新列表 /// public void BindPlanView() { #region 刷新生产计划 dgvPlan.AutoGenerateColumns = false; this.dgvPlan.DataSource = new List(); try { DataPage dataPage = new DataPage(); dataPage.PageSize = int.Parse(cbListRowcount.Text); dataPage.PageIndex = 1; dataPage.SortExpression = " ROWVALUE ASC"; if (cbRoutes.Text.Contains("018D") || cbRoutes.Text.Contains("278D") || cbRoutes.Text.Contains("493D")) { var count = Convert.ToInt32(cbListRowcount.Text) / 2; var orderlist = new List(); var orderlistF = _agent.InvokeServiceFunction>("TJWorkOrderBLL_GetOrderUnPrinted018DF", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString()); var orderlistR = _agent.InvokeServiceFunction>("TJWorkOrderBLL_GetOrderUnPrinted018DR", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString()); for (var i = 0; i < count; i++) { if (string.IsNullOrEmpty(FR) || FR == "前") { if (i < orderlistF.Count) orderlist.Add(orderlistF[i]); if (i < orderlistR.Count) orderlist.Add(orderlistR[i]); } else if (FR == "后") { if (i < orderlistR.Count) orderlist.Add(orderlistR[i]); if (i < orderlistF.Count) orderlist.Add(orderlistF[i]); } } this.dgvPlan.DataSource = orderlist; } else { //770B var count = Convert.ToInt32(cbListRowcount.Text) / 2; var orderlist = new List(); var orderlistF = _agent.InvokeServiceFunction>("TJWorkOrderBLL_GetOrderUnPrintedF", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString()); var orderlistR = _agent.InvokeServiceFunction>("TJWorkOrderBLL_GetOrderUnPrintedR", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString()); for (var i = 0; i < count; i++) { if (string.IsNullOrEmpty(FR) || FR == "前") { if (i < orderlistF.Count) orderlist.Add(orderlistF[i]); if (i < orderlistR.Count) orderlist.Add(orderlistR[i]); } else if (FR == "后") { if (i < orderlistR.Count) orderlist.Add(orderlistR[i]); if (i < orderlistF.Count) orderlist.Add(orderlistF[i]); } } this.dgvPlan.DataSource = orderlist; #region 服务查询 //var orderlist = _agent.InvokeServiceFunction>("TJWorkOrderBLL_GetOrderUnPrintedF", cbRoutes.SelectedValue.ToString(), cbPlanFilter.SelectedIndex, dataPage, comboBox1.SelectedValue.ToString(), comboBox2.SelectedValue.ToString(), this.dtpCREATEDATESTART.Value.ToString(), this.dtpCREATEDATEEND.Value.ToString()); #endregion this.dgvPlan.DataSource = orderlist; } } catch (Exception ex) { WriteLog.WriteError(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + ex.Message); } finally { timecounter = 0; } #endregion } private void cbRefreshRate_SelectedIndexChanged(object sender, EventArgs e) { SaveSetting(); } private void cbPlanFilter_SelectedIndexChanged(object sender, EventArgs e) { BindPlanView(); SaveSetting(); } private void SaveSetting() { string filepath = ConfigurationManager.AppSettings["SaveFilePath"]; filepath = string.Format("{0}ViewSetting.cfg", filepath); if (string.IsNullOrEmpty(cbListRowcount.Text)) cbListRowcount.Text = "1"; var setting = new { ListRowcount = int.Parse("100"), RefreshRate = int.Parse("20"), //PlanFilter = cbPlanFilter.SelectedIndex }; string settingstring = Newtonsoft.Json.JsonConvert.SerializeObject(setting); System.IO.File.WriteAllText(filepath, settingstring); } int timecounter = 0; private void timer1_Tick(object sender, EventArgs e) { if (!tsbOrderOperation.DropDown.Visible) { timecounter = 1; if (timecounter > int.Parse("20"))//计时达到刷新时间 { BindPlanView(); } } } #endregion private void PrintLabel(List labeldata) { #region 计划标签打印 //string xmlPath = System.Configuration.ConfigurationSettings.AppSettings["XmlName"].ToString(); ; //BarcodeLib.BarCodeGenerate g = new BarcodeLib.BarCodeGenerate( xmlPath); //bool b = g.PrintBarCode(_operationServiceParam.main.MAINCODE); QM.Assist.LabelInfo ll = new QM.Assist.LabelInfo(); StringBuilder dataline = new StringBuilder(); var TMPPath = string.Empty; var DATPath = string.Empty; foreach (var label in labeldata) { string[] texts = new string[8]; var sourcetext = label.Description.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < texts.Length && i < sourcetext.Length; i++) { texts[i] = sourcetext[i]; } //OrderNo,OrderType,PlanDate,Name,Class,CarModel,Text1,Text2,Text3,Text4,Text5,Text6 dataline.AppendFormat("\"{0}\",\"{1}\",\"{2:yyyy-MM-dd HH:mm:ss}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\",\"{15}\"\r\n", label.OrderNo,//计划号 label.OrderType,//计划类型(0:FIS,1:STOCK,2:INSERT) label.PlanDate,//计划日期 label.MaterialName,//总成物料名称 label.Class,// label.CarModel,//车型 texts[0],//装配详细信息 texts[1],//装配详细信息 texts[2],//装配详细信息 texts[3],//装配详细信息 texts[4],//装配详细信息 texts[5],//装配详细信息 texts[6],//装配详细信息 texts[7],//装配详细信息 label.MATERIALCODE,// label.Remark ); if (label.OrderNo.Contains("018D") || label.OrderNo.Contains("278D") || label.OrderNo.Contains("493D")) { TMPPath = "PlanLabelTMPPath8D"; DATPath = "PlanLabelDATPath8D"; } else { TMPPath = "PlanLabelTMPPath"; DATPath = "PlanLabelDATPath"; } } ll.BarCode = dataline.ToString().TrimEnd('\r', '\n'); ll.PrinterName = ""; QM.Assist.PrintUtil.LabelList2.Add(ll); QM.Assist.PrintUtil pu = new QM.Assist.PrintUtil(); pu.PrintLabel2(System.Configuration.ConfigurationManager.AppSettings["proPath"].ToString (), System.Configuration.ConfigurationManager.AppSettings[TMPPath].ToString (), System.Configuration.ConfigurationManager.AppSettings[DATPath].ToString ()); #endregion } private void PrintPlanLabel_Load(object sender, EventArgs e) { LoadViewSetting(); LoadProcessRoute(); //如果工位已设定 if (ClientContext.MachineInfo != null && !string.IsNullOrEmpty(ClientContext.MachineInfo.PID)) { //this.comMachine.SelectedValue = ClientContext.MachineInfo.MACHINECODDE; var route = _agent.InvokeServiceFunction ("ProcessRouteBLL_GetRouteByMachine", ClientContext.MachineInfo.MACHINECODDE); if (route != null) { this.cbRoutes.SelectedValue = route.ROUTE_CODE; } } BindPlanView(); cbRoutes.SelectedIndexChanged += new EventHandler(cbRoutes_SelectedIndexChanged); } void cbRoutes_SelectedIndexChanged(object sender, EventArgs e) { BindPlanView(); } #region 工单操作 #region 取消挂起 /// /// 取消挂起 /// /// /// private void tsmiCancelSuspend_Click(object sender, EventArgs e) { if (dgvPlan.SelectedRows.Count <= 0) { MessageBox.Show("请选择一条工单进行取消挂起操作!"); return; } List ids = new List(); foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows) { var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (!int.Equals(order.STATE, 4)) { MessageBox.Show("只可取消状态为挂起的工单!"); return; } ids.Add(order.PID); } _agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_CancelSuspend.ToString(), ids); BindPlanView(); } #endregion #region 删除工单 /// /// 删除工单 /// /// /// private void tsmiDeleteOrder_Click(object sender, EventArgs e) { if (dgvPlan.SelectedRows.Count <= 0) { MessageBox.Show("请选择一条工单进行删除操作!"); return; } List ids = new List(); foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows) { var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (!int.Equals(order.STATE, 4)) { MessageBox.Show("只可删除状态为挂起的工单!"); return; } ids.Add(order.PID); } _agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_DeleteOrder.ToString(), ids); BindPlanView(); } #endregion #region 重置工单 /// /// 重置工单 /// /// /// private void tsmiResetOrder_Click(object sender, EventArgs e) { if (dgvPlan.SelectedRows.Count <= 0) { MessageBox.Show("请选择一条工单进行重置操作!"); return; } List ids = new List(); foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows) { var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (!int.Equals(order.STATE, 4)) { MessageBox.Show("只可重置状态为挂起的工单!"); return; } ids.Add(order.PID); } _agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_ResetOrder.ToString(), ids); BindPlanView(); } #endregion #region 挂起工单 /// /// 挂起工单 /// /// /// private void tsmiSuspendOrder_Click(object sender, EventArgs e) { if (dgvPlan.SelectedRows.Count <= 0) { MessageBox.Show("请选择一条工单进行挂起操作!"); return; } List ids = new List(); foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows) { var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (int.Equals(order.STATE, 2)) { MessageBox.Show("不能挂起正在执行的工单!"); return; } ids.Add(order.PID); } _agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_SuspendOrder.ToString(), ids); BindPlanView(); } #endregion #region 回收工单 /// /// 回收工单 /// /// /// private void tsmiTakebackOrder_Click(object sender, EventArgs e) { if (dgvPlan.SelectedRows.Count <= 0) { MessageBox.Show("请选择一条工单进行回收操作!"); return; } List ids = new List(); foreach (System.Windows.Forms.DataGridViewRow row in dgvPlan.SelectedRows) { var order = (QMAPP.FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (!int.Equals(order.STATE, 4)) { MessageBox.Show("只可回收状态为挂起的工单!"); return; } ids.Add(order.PID); } _agent.InvokeServiceFunction(B9IPCService.WorkOrderBLL_TakeBack.ToString(), ids); BindPlanView(); } #endregion #endregion #region 工单列表选择发送变化时延时自动刷新 /// /// 工单列表选择发送变化时延时自动刷新 /// /// /// private void dgvPlan_SelectionChanged(object sender, EventArgs e) { timecounter = -10; } #endregion #region 设置计划工单列状态、颜色 /// /// 设置计划工单列状态、颜色 /// /// /// private void dgvPlan_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { var WORKORDER_STATE_TEXT = new string[] { "初始", "确认", "执行中", "完成", "挂起" }; var row = dgvPlan.Rows[e.RowIndex]; var order = (FJC.Entity.ProductionPlan.WorkOrder)row.DataBoundItem; if (order.STATE >= 0 && order.STATE < WORKORDER_STATE_TEXT.Length) { row.Cells[dgcState.Name].Value = WORKORDER_STATE_TEXT[order.STATE]; } if (order.STATE == FJC.Entity.EnumGeter.WorkOrderState.Suspended.GetHashCode()) { row.DefaultCellStyle.BackColor = Color.LightGray; row.DefaultCellStyle.ForeColor = Color.Gray; } if (order.STATE == FJC.Entity.EnumGeter.WorkOrderState.Executing.GetHashCode()) { row.DefaultCellStyle.BackColor = Color.YellowGreen; dgvPlan.ClearSelection(); } } #endregion private void tsbPrint_Click(object sender, EventArgs e) { try { if (dgvPlan.Rows.Count == 0) { MessageBox.Show("当前生产线没有未打印标签的计划工单!"); // return; } tsbPrint.Enabled = false; var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[0].DataBoundItem; var orders = new List(); orders.Add(order1); if (dgvPlan.Rows.Count > 1) { var orders2 = new List(); var order2 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[1].DataBoundItem; orders2.Add(order2); if ((orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7)) && !orders[0].MATERIAL_CODE.Contains("018D") && !orders[0].MATERIAL_CODE.Contains("278D")) { MessageBox.Show("计划工单即将变换配置,请注意!"); } } List labels = new List(); var data = DateTime.Now.ToString("yyyyMMddHHmmssfff"); data = data.Substring(2, data.Length - 2); //var codematch = System.Text.RegularExpressions.Regex.Match(order.PBOM_CODE, "_[LR][FR]_"); string positioncode = GetNameCode(orders[0].MATERIAL_NAME); var book = _agent.InvokeServiceFunction("FISPhraseBLL_GetFisPhraseBook", orders[0].MATERIAL_CODE + "", positioncode); LabelData labeldata = new LabelData(); labeldata.MATERIALCODE = orders[0].MATERIAL_CODE; labeldata.PlanDate = orders[0].PLAN_DATE; if (book != null) { labeldata.Class = " " + book.CarModel.Substring(book.CarModel.Length - 3, 3); labeldata.Description = book.Text; labeldata.OrderNo = book.CarModel + positioncode + data; if (orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) { var bookS = _agent.InvokeServiceFunction("FISPhraseBLL_GetPHRASEBOOK", labeldata.Class.Trim(),""); labeldata.Remark = bookS.Text; } else if (orders[0].MATERIAL_CODE.Contains("493D")) { var bookS = _agent.InvokeServiceFunction("FISPhraseBLL_GetPHRASEBOOK", labeldata.Class.Trim(), "493D"); labeldata.Remark = bookS.Text; } } var mcresult = _agent.InvokeServiceFunction>("MaterialBLL_Get", new Material { MATERIAL_CODE = orders[0].MATERIAL_CODE }); var material = mcresult.IsSuccess ? mcresult.Result : null; if (material != null) { labeldata.MaterialName = material.MATERIAL_SHORT; labeldata.CarModel = material.PROJECTCODE; } labels.Add(labeldata); //WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo); PrintLabel(labels); //WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo); //变更打印状态 0=>1 _agent.InvokeServiceFunction("WorkOrderBLL_SetOrderPrinted", orders[0].PID); //WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo); InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString()); //WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo); if (orders[0].MATERIAL_NAME.Contains("前")) FR = "后"; else if (orders[0].MATERIAL_NAME.Contains("后")) FR = "前"; BindPlanView(); tsbPrint.Enabled = true; } catch (Exception ee) { MessageBox.Show("打印出现异常!" + ee.Message); } } public string GetNameCode(string Name) { var Code = ""; if (!string.IsNullOrEmpty(Name)) { if (Name.Contains("左前")) Code = "FL"; else if (Name.Contains("左后")) Code = "RL"; else if (Name.Contains("右前")) Code = "FR"; else if (Name.Contains("右后")) Code = "RR"; return Code; } else return null; } /// /// /// /// /// public void InsertProduct(string ProductCode, string Material_Code, string prepare) { #region 组成新增产品实例 Product newProduct = new Product(); newProduct.PID = Guid.NewGuid().ToString(); newProduct.PRODUCTTYPE = string.Empty; newProduct.PRODUCTCODE = ProductCode; newProduct.PRODUCTSOURCE = "0"; newProduct.MACHINENAME = "门板打印"; newProduct.MACHINECODDE = "门板打印"; newProduct.MATERIAL_CODE = Material_Code; newProduct.STATUS = "0"; newProduct.OUTFLAG = "0"; newProduct.CAPACITY = 1; newProduct.USINGCOUNT = 0; if (prepare.Contains("左")) { newProduct.WORKCELL_CODE = "DP_L_PREPARE1"; newProduct.WORKLOC_CODE = "DP_L_PREPARELOC1"; } else if (prepare.Contains("右")) { newProduct.WORKCELL_CODE = "DP_R_PREPARE1"; newProduct.WORKLOC_CODE = "DP_R_PREPARELOC1"; } else { newProduct.WORKCELL_CODE = "PREPARE1"; newProduct.WORKLOC_CODE = "DP_PREPARELOC1"; } newProduct.WORKCENTER_CODE = "WORK770B"; newProduct.MATERIAL_TYPE = "DP_FINASSY"; newProduct.USINGSTATE = "0"; #endregion //新增 //ProductHelper.Insert(newProduct); _agent.InvokeServiceFunction>("ProductBLL_Insert", newProduct); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { SaveSetting(); BindPlanView(); } /// /// 批量打印 /// /// /// private void toolStripButton1_Click(object sender, EventArgs e) { var count = 0; if (dgvPlan.Rows.Count == 0) { MessageBox.Show("当前生产线没有未打印标签的计划工单!"); } if (int.Parse(cbListRowcount.Text) <= dgvPlan.Rows.Count) count = int.Parse(cbListRowcount.Text); else count = dgvPlan.Rows.Count; for (var i = 0; i < count; i++) { System.Threading.Thread.Sleep(1000); var orders = new List(); var order1 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i].DataBoundItem; orders.Add(order1); if ((i + 1) < count) { var orders2 = new List(); var order2 = (FJC.Entity.ProductionPlan.WorkOrder)dgvPlan.Rows[i + 1].DataBoundItem; orders2.Add(order2); if ((orders[0].MATERIAL_NAME.Substring(0, 7) != orders2[0].MATERIAL_NAME.Substring(0, 7)) && !orders[0].MATERIAL_CODE.Contains("018D") && !orders[0].MATERIAL_CODE.Contains("278D") && !orders[0].MATERIAL_CODE.Contains("493D")) { MessageBox.Show("计划工单即将变换配置,请注意!"); } } toolStripButton1.Enabled = false; List labels = new List(); var data = DateTime.Now.ToString("yyyyMMddHHmmssfff"); data = data.Substring(2, data.Length - 2); string positioncode = GetNameCode(orders[0].MATERIAL_NAME); var book = _agent.InvokeServiceFunction("FISPhraseBLL_GetFisPhraseBook", orders[0].MATERIAL_CODE + "", positioncode); LabelData labeldata = new LabelData(); labeldata.MATERIALCODE = orders[0].MATERIAL_CODE; labeldata.PlanDate = orders[0].PLAN_DATE; if (book != null) { labeldata.Class = " " + book.Class.Substring(0, 2); labeldata.Description = book.Text; labeldata.OrderNo = book.CarModel + positioncode + data; if (orders[0].MATERIAL_CODE.Contains("018D") || orders[0].MATERIAL_CODE.Contains("278D")) { var bookS = _agent.InvokeServiceFunction("FISPhraseBLL_GetPHRASEBOOK", orders[0].MATERIAL_CODE.Substring(5, 3).Trim(),""); labeldata.Remark = bookS.Text; } else if (orders[0].MATERIAL_CODE.Contains("493D")) { var bookS = _agent.InvokeServiceFunction("FISPhraseBLL_GetPHRASEBOOK", orders[0].MATERIAL_CODE.Substring(5, 3).Trim(),"493D"); labeldata.Remark = bookS.Text; } } var mcresult = _agent.InvokeServiceFunction>("MaterialBLL_Get", new Material { MATERIAL_CODE = orders[0].MATERIAL_CODE }); var material = mcresult.IsSuccess ? mcresult.Result : null; if (material != null) { labeldata.MaterialName = material.MATERIAL_SHORT; labeldata.CarModel = material.PROJECTCODE; } labels.Add(labeldata); WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始打印" + labeldata.OrderNo); PrintLabel(labels); WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始变成打印状态" + labeldata.OrderNo); //变更打印状态 0=>1 _agent.InvokeServiceFunction("WorkOrderBLL_SetOrderPrinted", orders[0].PID); WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 开始插入记录" + labeldata.OrderNo); InsertProduct(labeldata.OrderNo, orders[0].MATERIAL_CODE, comboBox1.SelectedValue.ToString()); if (orders[0].MATERIAL_NAME.Contains("前")) FR = "后"; else if (orders[0].MATERIAL_NAME.Contains("后")) FR = "前"; WriteLog.Write(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 插入结束" + labeldata.OrderNo); } BindPlanView(); toolStripButton1.Enabled = true; } private void toolStripButton2_Click(object sender, EventArgs e) { PlanRePrintForm frm = new PlanRePrintForm(this); frm.ShowDialog(); } private void dtpCREATEDATESTART_ValueChanged(object sender, EventArgs e) { BindPlanView(); } private void dtpCREATEDATEEND_ValueChanged(object sender, EventArgs e) { BindPlanView(); } /// /// 刷新 /// /// /// private void SelectStripButton_Click(object sender, EventArgs e) { BindPlanView(); } } class Direction { public string Code { get; set; } public string Name { get; set; } } class LabelData { public string OrderNo { get; set; } public string MATERIALCODE { get; set; } public DateTime PlanDate { get; set; } public string Class { get; set; } public string Description { get; set; } public string MaterialName { get; set; } public string CarModel { get; set; } public object[] OrderType { get; set; } public string Remark { get; set; } } }