// //保存 // private void btn_Save_Inspect_Standard_Click(object sender, System.Windows.RoutedEventArgs e) { if (_ISD.Count > 0) { _M_InspectStandard.Delete(_ISD[0].OrderID); } int TemAddCount = 0; //记录操作所影响的记录数 for (int t = 0; t < _ISD.Count; t++) //循环添加数据 { if (_M_InspectStandard.Add(_ISD[t])) //如果添加成功 { TemAddCount++; //记录添加次数 与 添加信息 _TemMessage += "工单单号:" + _ISD[t].OrderID + "接头类型:" + _ISD[t].Type + "\r\n"; } } if (TemAddCount >= 1) //判断是否添加成功 { My_MessageBox.My_MessageBox_Message("数据添加成功!\r\n " + _TemMessage + "\r\n共添加记录 " + TemAddCount + ""); _ISD.Clear(); //清空检测标准列表 _TemMessage = ""; } else { My_MessageBox.My_MessageBox_Erry("数据添加失败!"); } }
/****************************************** Controls ******************************************/ // //保存工单基本信息 // private void btn_Save_OrderInfo_Click(object sender, System.Windows.RoutedEventArgs e) { //检查填写的信息是否完整 if (txb_OrderID.Text == "" || txb_ProductName.Text == "" || txb_Model.Text == "" || txb_Order_Count.Text == "" || cmb_InspectMethod.Text == "" || cmb_InspectType.Text == "" || date_DeliveryDate.Text == "" || txb_Model.Text == "" || cmb_WorkShop.Text == "") { My_MessageBox.My_MessageBox_Erry("请检查工单信息是否设置完整!\r\n请补充后重试!"); } else { //如果数据库中已经有记录 if (_M_WorkOrder.GetCount(txb_OrderID.Text.ToString()) > 0) { if (MessageBox.Show("工单" + txb_OrderID.Text.ToString() + "已经存在,继续将替换原有工单!\r\n是否继续添加", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { // _M_WorkOrder.Delete(txb_OrderID.Text.ToString()); //删除原有数据 Maticsoft.Model.WorkOrder _temWorkdOrder = new Maticsoft.Model.WorkOrder(); _temWorkdOrder = _M_WorkOrder.GetModel(txb_OrderID.Text.Trim()); Add_orderInfo(_temWorkdOrder); //添加新数据数据 } } else { Add_orderInfo(); } //添加数据 } }
// //移除 // private void txb_InspectStandard_Move_Click(object sender, System.Windows.RoutedEventArgs e) { try { _ISD.Remove((Maticsoft.Model.InspectStandard)dgv_Inspect_Standard_Info.SelectedItem); } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry(ex.Message + "\r\n提示此消息是因为您选择的列为空列!\r\n请重试 或联系管理员"); } }
//图纸——编辑 private void btn_Drw_Edit_Click(object sender, System.Windows.RoutedEventArgs e) { try { DrawProcess.EditProcess(eFlowList); } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry(ex.Message); } }
// //生产预览 // private void btn_YL_Click(object sender, RoutedEventArgs e) { try { string Patch = "\\\\QQQQQQ-MS2\\Templates\\PrintTemplates\\HP_Templates\\" + cmb_LabTemplate.Text.Trim(); btEngine.Start(); LabelFormatDocument btFormat2 = btEngine.Documents.Open(Patch); //填充打印数据源 foreach (Maticsoft.Model.LabInfo _lin in _WTT_LabInfo) { string drName = _lin.Name; btFormat2.SubStrings[drName].Value = _lin.Value; } string path = @"D:\Thumbnail.jpeg"; File.Delete(path); Resolution t = new Resolution(ImageResolution.Screen); btFormat2.ExportImageToFile(path, ImageType.JPEG, Seagull.BarTender.Print.ColorDepth.ColorDepth256, new Resolution(3840, 2160), OverwriteOptions.Overwrite); btFormat2.Close(SaveOptions.DoNotSaveChanges); btEngine.Stop(); lab_State.Content = "显示图片"; try { //读成二进制 imBytes = File.ReadAllBytes(path); //直接把这个存储到数据就行了cmd.Parameters.Add("@image", SqlDbType.Image).Value = bytes; //在控件中显示图片 BitmapImage BI = new BitmapImage(); BI.BeginInit(); BI.StreamSource = new MemoryStream(imBytes); //bufPic是图片二进制,byte类型 BI.EndInit(); // image1.Width = BI.Width; // image1.Height = BI.Height; image1.UseLayoutRounding = true; image1.Source = BI;//image是XAML页面上定义的Image控件 } catch { } lab_State.Content = "生成完成!"; // System.Diagnostics.Process.Start("explorer.exe", FilePath); //打开指定文件夹 } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry("错误\r\n" + ex.Message); } }
// //选择物料 // private void dgv_Source_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { txb_AliasName.Text = ""; txb_AliasName.IsEnabled = false; btn_Save_AliasName.Visibility = System.Windows.Visibility.Hidden; lab_Emphasis.Visibility = System.Windows.Visibility.Hidden; // // int selectIndex = dgv_Source.SelectedIndex; DataRowView dr = (DataRowView)dgv_Source.SelectedItem; _WTT_Orm_ID = dr["Orm_ID"].ToString(); // txb_AliasName.Text = dr["别名"].ToString(); txb_MaterialNum.Text = dr["料号"].ToString(); txb_ProductName.Text = dr["品名"].ToString(); txb_Model.Text = dr["规格"].ToString(); lab_Unit.Content = dr["单位"].ToString(); double.TryParse(dr["需领数量"].ToString(), out _wantCount); //需领用量 txb_WantCount.Text = _wantCount.ToString("0.00"); _yetCount = _M_MaterReceive.Get_Count(_WTT_Orm_ID); //已领用量 txb_YetCount.Text = _yetCount.ToString("0.00"); // DataSet temds = _M_MaterReceive.GetList("Orm_ID = '" + _WTT_Orm_ID + "'"); dgv_Receive_Record.ItemsSource = temds.Tables[0].DefaultView; // 判断是否是重点管控料件 string product = dr["品名"].ToString(); if (product.Contains("FERRULE")) { lab_Emphasis.Visibility = System.Windows.Visibility.Visible; if (txb_AliasName.Text == "") { txb_AliasName.IsEnabled = true; btn_Save_AliasName.Visibility = System.Windows.Visibility.Visible; My_MessageBox.My_MessageBox_Message("重点管控料件,出现此提示的原因是此料件未设置别名;\r\n请在别名设置窗口中设置别名后点击保存!"); } } // Set_IsEn(false, true); } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry(ex.Message + "\r\n弹出此错题的原因是您选择的列为空列!"); } }
// //窗体载入事件 // private void DocumentContent_Loaded(object sender, RoutedEventArgs e) { try { dgv_TemplateInfo.ItemsSource = _WTT_LabInfo; //加载模板名称 string[] browsingFormats; // 存放文件名 // browsingFormats = System.IO.Directory.GetFiles("D:\\模板\\PrintTemplates\\BT_Templates\\", "*.btw"); // FolderPath 文件夹路径 *.btw 文家后缀 browsingFormats = System.IO.Directory.GetFiles("\\\\QQQQQQ-MS2\\Templates\\PrintTemplates\\HP_Templates\\", "*.btw"); // FolderPath 文件夹路径 *.btw 文家后缀 int i = 0; foreach (string temName in browsingFormats) { browsingFormats[i] = temName.Substring(51); i++; } cmb_LabTemplate.ItemsSource = browsingFormats; } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry("未启动BT线程!此模式下只可进行标签核对功能!\r\n" + ex.Message); } }
// //选择列显示所选择的值 // private void dgv_Inspect_Standard_Info_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { try { Maticsoft.Model.InspectStandard _Tem = (Maticsoft.Model.InspectStandard)dgv_Inspect_Standard_Info.SelectedItem; txb_InspectStandard_OrderID.Text = _Tem.OrderID; cmb_InspectStandardType.Text = _Tem.Type; txb_IL_Max.Text = _Tem.IL_Max; txb_IL_Min.Text = _Tem.IL_Min; txb_RL_Max.Text = _Tem.RL_Max; txb_RL_Min.Text = _Tem.RL_Min; txb_RCO_Max.Text = _Tem.RCO_Max; txb_RCO_Min.Text = _Tem.RCO_Min; txb_AE_Max.Text = _Tem.AE_Max; txb_AE_Min.Text = _Tem.AE_Min; txb_FH_Max.Text = _Tem.FH_Max; txb_FH_Min.Text = _Tem.FH_Min; txb_AO_Max.Text = _Tem.AO_Max; txb_AO_Min.Text = _Tem.AO_Min; } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry(ex.Message + "\r\n弹出此错题的原因是您选择的列为空列!"); } }
// //SN赋值 // private void txb_BarCode_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && txb_BarCode.IsFocused) { try { if (txb_BarCode.Text != "") { DataSet SN_data = _M_Pack_Exfo.GetList(" (ClientSN = '" + txb_BarCode.Text.Trim() + "') AND (Wave = '1550nm') "); if (SN_data != null) { string PigtailSN = txb_BarCode.Text.Trim(); //如果检测类型是12芯x2 则将条码设置为 10位 if (_WTT_OrderInfo.InspectMethod == Maticsoft.Model.E_InspectMethod.TFK十二芯检测x2 && PigtailSN.Length > 10) { _WTT_My_Print.SN = PigtailSN.Substring(0, 10); } _WTT_My_Print.Add_PrintData(SN_data); lst_BarCodeRecord.Items.Add(txb_BarCode.Text.Trim()); } else { My_MessageBox.My_MessageBox_Message("未找到条码数据!"); } } else { My_MessageBox.My_MessageBox_Message("条码不能为空"); } } catch (Exception ex) { My_MessageBox.My_MessageBox_Erry(ex.Message); } } }
/****************************************** Controls ******************************************/ // //添加 // private void btn_Add_Inspect_Standard_Click(object sender, System.Windows.RoutedEventArgs e) { if (InspectSatanard_InputTxb_Verification()) { //验证此批号在已经添加的批号中是否存在 bool _TemVerification = false; for (int t = 0; t < _ISD.Count; t++) { if (_ISD.Count > 0 && txb_InspectStandard_OrderID.Text == _ISD[t].OrderID && cmb_InspectStandardType.Text == _ISD[t].Type) { _TemVerification = true; break; } } if (_TemVerification || _M_InspectStandard.Exists(txb_InspectStandard_OrderID.Text, cmb_InspectStandardType.Text)) { //弹出提示!如果选择继续则删除数据库中对应的批号信息 if (MessageBox.Show("工单" + txb_InspectStandard_OrderID.Text + "类型:" + cmb_InspectStandardType.Text + "已存在,\r\n继续将立即删除原有3D&Exfo检测标准!\r\n备注:如果是已添加到待保存列表中的请手动移除!\r\n是否继续添加", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { //从数据库中删除记录 _M_InspectStandard.Delete(txb_InspectStandard_OrderID.Text, cmb_InspectStandardType.Text); InspectAdd(); //添加 InspectStandard_InputTxb_Clear(); } } else { InspectAdd(); //添加 InspectStandard_InputTxb_Clear(); } } else { My_MessageBox.My_MessageBox_Erry("检测标准信息不完整,请检测并补充完整后。重试!"); } }
// //保存 // private void btn_Save_Click(object sender, RoutedEventArgs e) { if (txb_UserName_Receive.Text != "") { Maticsoft.BLL.Material_Receive _M_Material_Receive = new Maticsoft.BLL.Material_Receive(); string dt = DateTime.Now.ToString(); if (txb_Count.Text != "" && _WTT_User_Receive != null) { Maticsoft.Model.Material_Receive _Material_receive = new Maticsoft.Model.Material_Receive() { Client = txb_Client.Text.Trim(), ClientNum = txb_MaterialPath.Text.Trim(), Count = txb_Count.Text.Trim(), Orm_ID = _WTT_Orm_ID, UserID = txb_JobNumber_Receive.Text.Trim(), WorkStationID = _WTT_WK.Wo_ID.ToString(), DataTime = DateTime.Now, Re_ID = _WTT_Rece_ID }; _M_Material_Receive.Update(_Material_receive); // txb_MaterialPath.Text = ""; DataSet temds = _M_MaterReceive.GetList("Orm_ID = '" + _WTT_Orm_ID + "'"); dgv_Receive_Record.ItemsSource = temds.Tables[0].DefaultView; _yetCount = _M_MaterReceive.Get_Count(_WTT_Orm_ID); //已领用量 txb_YetCount.Text = _yetCount.ToString("0.00"); } else { My_MessageBox.My_MessageBox_Message("数量未设置,或领用人未验证,完成后重试! "); } } else { My_MessageBox.My_MessageBox_Erry("请先输入修改人的工号!"); } }
/// <summary> /// 添加工单基本信息 /// </summary> /// <returns></returns> private void Add_orderInfo(Maticsoft.Model.WorkOrder _workOrder) { _workOrder = new Maticsoft.Model.WorkOrder() { OrderID = txb_OrderID.Text.ToString(), //工单单号 Client = "Ezconn", ProductName = txb_ProductName.Text.ToString(), Model = txb_Model.Text.ToString(), Count = txb_Order_Count.Text.ToString(), //枚举类型的检测方法 InspectMethod = (Maticsoft.Model.E_InspectMethod)Enum.Parse(typeof(Maticsoft.Model.E_InspectMethod), cmb_InspectMethod.SelectedItem.ToString(), false), //枚举类型检测选项 InspectType = (Maticsoft.Model.E_InspectType)Enum.Parse(typeof(Maticsoft.Model.E_InspectType), cmb_InspectType.Text.ToString(), false), DeliveryDate = date_DeliveryDate.Text.ToString(), // LabelType = cmb_LabType.Text.ToString(), ModelNo = txb_Model.Text.ToString(), Workshop = cmb_WorkShop.Text.ToString(), State = "待生产" , ID_Key = _workOrder.ID_Key }; //判断是否添加成功 if (_M_WorkOrder.Update(_workOrder)) { _dt_OrderMaterial = _M_WorkOrder.GetOrderMaterial(txb_OrderID.Text); //工单物料需领用量 Add_orderMaterial(_dt_OrderMaterial); //添加工单中的物料清单 Add_MaterialInfo(_dt_OrderMaterial); //添加物料信息 暂时使用 用于收集物料信息 //弹出提示信息 My_MessageBox.My_MessageBox_Message("工单" + txb_OrderID.Text.ToString() + "添加成功!"); //保存条码 if (txb_Stat_SN.Text != "") { Maticsoft.BLL.SerialNumber _M_SerialNumber = new SerialNumber(); if (_M_SerialNumber.GetList("OrderID = '" + txb_OrderID.Text.Trim() + "'").Tables[0].Rows.Count < 1) { addSerialNumber(long.Parse(txb_Stat_SN.Text.ToString()), int.Parse(txb_Order_Count.Text)); } else { if (MessageBox.Show("工单" + txb_OrderID.Text.ToString() + "已经存在条码,继续将替换原有条码!\r\n是否继续添加", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { // _M_SerialNumber.DeleteList("OrderID = '" + txb_OrderID.Text.Trim() + "'"); addSerialNumber(long.Parse(txb_Stat_SN.Text.ToString()), int.Parse(txb_Order_Count.Text)); } } } else { My_MessageBox.My_MessageBox_Message("开始条码 为空 将不进行条码添加!"); } #region 清空文本框 txb_OrderID.Text = ""; txb_ProductName.Text = ""; txb_Model.Text = ""; txb_Order_Count.Text = ""; cmb_InspectMethod.Text = ""; cmb_InspectType.Text = ""; date_DeliveryDate.Text = ""; txb_Model.Text = ""; cmb_WorkShop.Text = ""; txb_Stat_SN.Text = ""; _GLL_Lst_SerialNumber.Clear(); #endregion } else { //弹出提示信息 My_MessageBox.My_MessageBox_Erry("工单" + txb_OrderID.Text.ToString() + "添加失败!"); } }