using PaintingPC.Model; using PaintingPC.WebReference; using System; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Net.NetworkInformation; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using System.Windows.Forms.VisualStyles; namespace PaintingPC { public partial class FrmSecondCheck : Form { int count = 0; //缺陷图选择个数 public static string ColorName = ""; //修改颜色 public static string Reason = ""; public static string floor = ""; public FrmSecondCheck() { InitializeComponent(); } private void FrmSecondCheck_Load(object sender, EventArgs e) { var serverUrl = "http://10.60.101.10:8013/"; var updateXmlFileName = "PaintUpdate.xml"; var updater = new AutoUpdater(); if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName)) { Environment.Exit(0); } Control.CheckForIllegalCrossThreadCalls = false; InitPage(); } public void InitPage() { try { string title = ConfigurationManager.AppSettings["Position"].ToString(); string workClass = Function.GetWorkClass(); string station = ConfigurationManager.AppSettings["Station"].ToString(); labTitle.Text = title; labWorkClass.Text = workClass; labStation.Text = station; labelVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Program.IP = ConfigurationManager.AppSettings["IP"].ToString(); labChangeColor.Visible = ConfigurationManager.AppSettings["IsShowChangeColor"].ToString() == "1" ? true : false; //System.Threading.Timer timer = new System.Threading.Timer(delegate //{ // labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //}, //null, //2000, //1000 //); Thread t = new Thread(new ThreadStart(TimeGo)); t.Start(); } catch (Exception ex) { } } private void TimeGo() { System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 10; timer.Enabled = true; timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Tick); } private void timer_Tick(object sender, EventArgs e) { labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Thread.Sleep(500); } /// /// 缺陷图点击 /// /// /// void lblRoom_Click(object sender, EventArgs e) { //Label a = (Label)sender; //foreach (Control c in pictureBox2.Controls) //{ // c.BackColor = Color.Transparent; //} //string aa = a.Text; ////a.BackColor = System.Drawing.Color.Chartreuse; //a.BackColor = Color.FromArgb(150,System.Drawing.Color.Chartreuse); Label a = (Label)sender; string aa = a.Text; if (a.BackColor == Color.Transparent) { a.BackColor = Color.FromArgb(150, System.Drawing.Color.Chartreuse); count++; } else { a.BackColor = Color.Transparent; count--; } } /// /// 缺陷原因点击 /// /// /// void dLbRoom_Click(object sender, EventArgs e) { if (count == 0) { MessageBox.Show("请选择缺陷区域!"); return; } Label a = (Label)sender; string aa = a.Text; if (a.BackColor == Color.Transparent) { a.BackColor = Color.Chartreuse; Reason = Reason + a.Text + ";"; } else { a.BackColor = Color.Transparent; Reason = Reason.Replace(a.Text.Trim()+";",""); } } private Control[] SetControlGroup() { //Control[] controls = { btnPass, btnAbt, btnRepair, btnFirstPass }; //return controls; Control[] controls = { btnPass, btnAbt, btnRepair }; return controls; } /// /// 清除控件选中 /// /// public void ClearControlColor(Control[] controls) { foreach (Control c in controls) { c.BackColor = Color.LightGray; } } /// /// 通过按钮 /// /// /// private void btnPass_Click(object sender, EventArgs e) { #region 必须选择缺陷位置与缺陷原因,否则无法保存 string damnPositionTemp = ""; string reasonTemp = ""; //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { damnPositionTemp += lab.Text + ";"; } } //缺陷原因 foreach (Control c in panel2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { reasonTemp += lab.Text + ";"; } } if (string.IsNullOrWhiteSpace(damnPositionTemp) || string.IsNullOrWhiteSpace(reasonTemp)) { MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!"); return; } #endregion #region 必须有颜色信息才能提交 if (Regex.Matches(labProductInfo.Text.Trim(), ",").Count < 3) { MessageBox.Show("条码:" + txtBarCode.Text.Trim() + "没有录入颜色信息,不能提交,请补全!"); return; } #endregion //ClearControlColor(SetControlGroup()); //btnPass.BackColor = Color.GreenYellow; //保存 SaveInspect(1); ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; //LoadPage(); //ClearInspect(); //ClearControlColor(SetControlGroup()); } /// /// 二次返修按钮 /// /// /// private void btnRepair_Click(object sender, EventArgs e) { #region 必须选择缺陷位置与缺陷原因,否则无法保存 string damnPositionTemp = ""; string reasonTemp = ""; //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { damnPositionTemp += lab.Text + ";"; } } //缺陷原因 foreach (Control c in panel2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { reasonTemp += lab.Text + ";"; } } if (string.IsNullOrWhiteSpace(damnPositionTemp) || string.IsNullOrWhiteSpace(reasonTemp)) { MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!"); return; } #endregion #region 必须有颜色信息才能提交 if (Regex.Matches(labProductInfo.Text.Trim(), ",").Count < 3) { MessageBox.Show("条码:" + txtBarCode.Text.Trim() + "没有录入颜色信息,不能提交,请补全!"); return; } #endregion //ClearControlColor(SetControlGroup()); //btnRepair.BackColor = Color.Yellow; #region 点修补则调WMS WebService try { WMSWebService webService = new WMSWebService(); webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); //webService.Timeout = 1200000; string errorReason = ""; //webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 0, out errorReason); //2022-04-19wff,点修补为0 webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 0, out errorReason); } catch (Exception ex) { LogHelper.WriteErrLogBase("工位:" + labStation.Text.Trim() + ",二次质检点修补调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion //保存 SaveInspect(3); ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; //LoadPage(); //ClearInspect(); //ClearControlColor(SetControlGroup()); } /// /// 报废按钮 /// /// /// private void btnAbt_Click(object sender, EventArgs e) { #region 必须选择缺陷位置与缺陷原因,否则无法保存 string damnPositionTemp = ""; string reasonTemp = ""; //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { damnPositionTemp += lab.Text + ";"; } } //缺陷原因 foreach (Control c in panel2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { reasonTemp += lab.Text + ";"; } } if (string.IsNullOrWhiteSpace(damnPositionTemp) || string.IsNullOrWhiteSpace(reasonTemp)) { MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!"); return; } #endregion #region 必须有颜色信息才能提交 if (Regex.Matches(labProductInfo.Text.Trim(), ",").Count < 3) { MessageBox.Show("条码:" + txtBarCode.Text.Trim() + "没有录入颜色信息,不能提交,请补全!"); return; } #endregion //ClearControlColor(SetControlGroup()); //btnAbt.BackColor = Color.Red; //保存 SaveInspect(2); #region 报废则调WMS WebService,入库,大线报废由0改成2 try { WMSWebService webService = new WMSWebService(); webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); //webService.Timeout = 1200000; string errorReason = ""; //webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 0, out errorReason); //2022-04-19wff,报废由0变成2 webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 2, out errorReason); } catch (Exception ex) { LogHelper.WriteErrLogBase("工位:" + labStation.Text.Trim() + ",二次质检调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; //ClearInspect(); //ClearControlColor(SetControlGroup()); } public void SaveInspect(int i) { try { if (!string.IsNullOrWhiteSpace(txtBarCode.Text.Trim())) { InspectModel model1 = new InspectModel(); model1.ID = Guid.NewGuid().ToString(); model1.barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim()); if (labProductInfo.Tag != null) { model1.side = labProductInfo.Tag.ToString(); } else { model1.side = ""; } model1.position = labTitle.Text.Trim(); model1.stationNo = labStation.Text; model1.workClass = labWorkClass.Text; //TODO:1抛光合格;2:抛光报废;3:二次返修 switch (i) { case 1: model1.inspectResult = "[合格]"; break; case 2: model1.inspectResult = "[报废]"; break; case 3: model1.inspectResult = "[抛光]"; break; } //if (btnPass.BackColor != Color.LightGray && btnAbt.BackColor == Color.LightGray && btnRepair.BackColor == Color.LightGray) //抛光合格 //{ // model1.inspectResult = "[合格]"; //} //if (btnPass.BackColor == Color.LightGray && btnAbt.BackColor != Color.LightGray && btnRepair.BackColor == Color.LightGray) //抛光报废 //{ // model1.inspectResult = "[报废]"; //} //if (btnPass.BackColor == Color.LightGray && btnAbt.BackColor == Color.LightGray && btnRepair.BackColor != Color.LightGray) //二次返修 //{ // model1.inspectResult = "[抛光]"; //} //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { model1.damnPosition += lab.Text + ";"; } } //缺陷原因 model1.reason = Reason; if (string.IsNullOrWhiteSpace(model1.damnPosition) || string.IsNullOrWhiteSpace(model1.reason)) { MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!"); return; } if (rdo1.Checked) { model1.productOption = "1"; } else if (rdo2.Checked) { model1.productOption = "2"; } else if (rdo3.Checked) { model1.productOption = "3"; } model1.productInfo = labProductInfo.Text.Trim(); model1.InspectTimes = ConfigurationManager.AppSettings["InspectTimes"]; #region 判断是否有一次质检结果,如果没有补齐一次质检结果 if (string.IsNullOrWhiteSpace(labFirstCheck.Text)) { InspectModel md = new InspectModel(); md.ID = Guid.NewGuid().ToString(); md.side = model1.side; md.barcode = model1.barcode; if (md.side.Contains("B") && floor.Contains("下")) { md.position = "下线一检 B侧 下支架"; } else { md.position = "下线一检 " + model1.side + " " + floor; } md.stationNo = labStation.Text; md.workClass = labWorkClass.Text; md.inspectResult = "[抛光]"; if (rdo1.Checked) { md.productOption = "1"; } else if (rdo2.Checked) { md.productOption = "2"; } else if (rdo3.Checked) { md.productOption = "3"; } md.damnPosition = model1.damnPosition; md.reason = Reason; md.productInfo = labProductInfo.Text.Trim(); md.InspectTimes = "1"; Function.InsertInspect(md); } #endregion Thread.Sleep(Convert.ToInt32( ConfigurationManager.AppSettings["SleepTime"])); #region 判断是否有二次质检结果 if (!string.IsNullOrWhiteSpace(labSecondCheck.Text)) { model1.InspectTimes = "3"; Function.InsertInspect(model1); } else { InspectModel md2 = new InspectModel(); md2.ID = Guid.NewGuid().ToString(); md2.side = model1.side; md2.position = model1.position; md2.barcode = model1.barcode ; md2.stationNo = labStation.Text; ; md2.workClass = labWorkClass.Text; if (model1.inspectResult == "[抛光]") { md2.inspectResult = "[二次抛光]"; } else { md2.inspectResult = model1.inspectResult; } if (rdo1.Checked) { md2.productOption = "1"; } else if (rdo2.Checked) { md2.productOption = "2"; } else if (rdo3.Checked) { md2.productOption = "3"; } md2.damnPosition = model1.damnPosition; md2.reason = Reason; md2.productInfo = labProductInfo.Text.Trim(); md2.InspectTimes = "2"; Function.InsertInspect(md2); } #endregion } } catch (Exception ex) { LogHelper.WriteErrLogBase("二次质检提交:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } } public void ClearInspect() { //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; lab.BackColor = Color.Transparent; } //缺陷原因 foreach (Control c in panel2.Controls) { Label lab = c as Label; lab.BackColor = Color.Transparent; } } /// /// 扫码-根据条码查询信息(产品信息、加载图片及缺陷原因、三次检验信息) /// /// /// private void txtBarCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ClearPage(); LoadPage(); } } private void LoadPage() { try { ButtonEnable(SetControlGroup()); //ClearPage(); //测试条码:11111111112222222222 string barcode = txtBarCode.Text.Trim(); if (barcode.Contains(".")) { barcode = Function.TransToBarCodeOne(barcode); } #region 判断条码有效性 if (! Function.BarCodeValid(barcode)) { MessageBox.Show("扫描的条码号:"+barcode+"无效,请重新扫描!"); txtBarCode.Text = ""; return; } #endregion #region 根据条码查询AB侧,支架位置 string side = Function.GetSide(barcode); labProductInfo.Tag = side; floor = Function.GetPosition(barcode); #endregion #region 如果是补打的条码,查询产品信息 if (!barcode.Contains(".") && barcode.Length > 4) { string strCode = barcode.Substring(barcode.Length - 4, 4); int num = 0; Int32.TryParse(strCode, out num); if (num > 7000) { labProductInfo.Text = Function.GetReprintInfo(barcode); if (string.IsNullOrWhiteSpace(labProductInfo.Text.Trim())) { ButtonDisable(SetControlGroup()); labProductInfo.Text = "没有查询到补打条码信息"; return; } } } #endregion //根据条码查询,加载图片及原因 int row = 0, col = 0; string picture = ""; #region 缺陷原因 int drow = 0, dcol = 5; //行,列 DataTable dt3 = Function.SearchDefectInfo(ConfigurationManager.AppSettings["Station"].Trim()); if (dt3 != null && dt3.Rows.Count > 0) { drow = Convert.ToInt32(Math.Ceiling((double)dt3.Rows.Count / dcol)); Label[] dLb = new Label[7]; string[] dstr = new string[dt3.Rows.Count]; for (int i = 0; i < dt3.Rows.Count; i++) { dstr[i] = dt3.Rows[i]["DefectName"].ToString(); } for (int i = 0; i < dcol; i++) //列 { for (int j = 0; j < drow; j++) //行 { dLb[i] = new Label(); if ((i + dcol * j) < dstr.Length) { dLb[i].Text = dstr[i + dcol * j].ToString(); dLb[i].Font = new Font(dLb[i].Font.FontFamily, 24, FontStyle.Bold); dLb[i].Size = new Size(150, 50); dLb[i].Location = new Point(20 + i * (dLb[i].Size.Width + 25), 5 + j * (dLb[i].Size.Height + 20)); dLb[i].BorderStyle = BorderStyle.FixedSingle; dLb[i].BackColor = Color.Transparent; dLb[i].TextAlign = System.Drawing.ContentAlignment.MiddleCenter; panel2.Controls.Add(dLb[i]); dLb[i].Click += new EventHandler(dLbRoom_Click); } } } } #endregion #region 加载图片 //try //{ // DataTable dt = Function.SearchInfoByBarCode(barcode); // if (dt != null && dt.Rows.Count > 0) // { // row = Convert.ToInt32(dt.Rows[0]["Rows"].ToString()); // col = Convert.ToInt32(dt.Rows[0]["Cols"].ToString()); // picture = dt.Rows[0]["PicturePath"].ToString(); // } // dt.Dispose(); // if (!File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\" + picture)) // { // string strImageURL = Function.GetImgPath() + picture; // System.Net.WebClient webClient = new System.Net.WebClient(); // webClient.DownloadFile(strImageURL, Directory.GetCurrentDirectory() + @"\" + picture); // } // FileStream fs = new FileStream(System.Environment.CurrentDirectory + "\\" + picture, FileMode.Open, // FileAccess.Read);//获取图片文件流 // Image img = Image.FromStream(fs); // 文件流转换成Image格式 // pictureBox2.Image = img; //给 图片框设置要显示的图片 // fs.Close(); // 关闭流,释放图片资源 //} //catch (Exception ex) //{ // LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); //} #endregion #region 缺陷图划分区域 try { Label[] lb = new Label[5]; string[] str = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; for (int i = 0; i < col; i++) { for (int j = 0; j < row; j++) { lb[i] = new Label(); lb[i].Text = str[i + col * j].ToString(); lb[i].Font = new Font(lb[i].Font.FontFamily, 32, FontStyle.Bold); lb[i].Size = new Size(pictureBox2.Width / col, pictureBox2.Height / row); lb[i].Location = new Point(0 + i * lb[i].Size.Width, 0 + j * lb[i].Size.Height); lb[i].BorderStyle = BorderStyle.FixedSingle; lb[i].BackColor = Color.Transparent; lb[i].TextAlign = System.Drawing.ContentAlignment.MiddleCenter; pictureBox2.Controls.Add(lb[i]); lb[i].Click += new EventHandler(lblRoom_Click); } } } catch (Exception ex) { LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion //不是补打的条码,根据条码查询产品信息、检验信息,选中缺陷位置及原因 DataTable dtInspect = Function.GetInspectInfoByBarCode(barcode); if (dtInspect != null && dtInspect.Rows.Count > 0) { labProductInfo.Text = dtInspect.Rows[0]["productInfo"].ToString().Trim(); //产品信息 string position = dtInspect.Rows[0]["damnPosition"].ToString(); //缺陷位置 string reason = dtInspect.Rows[0]["reason"].ToString(); //原因 #region 三检结果 for (int i = 0; i < dtInspect.Rows.Count; i++) { string time = dtInspect.Rows[i]["InspectTimes"].ToString(); string result = dtInspect.Rows[i]["inspectResult"].ToString() + dtInspect.Rows[i]["damnPosition"].ToString() + ":" + dtInspect.Rows[i]["reason"].ToString(); switch (time) { case "1": labFirstCheck.Text = result; break; case "2": labSecondCheck.Text = result; break; case "3": labThirdCheck.Text = result; break; } } #endregion #region 选中缺陷位置及原因 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (position.Contains(lab.Text)) { lab.BackColor = Color.FromArgb(150, System.Drawing.Color.Chartreuse); count++; } } foreach (Control c in panel2.Controls) { Label lab = c as Label; if (reason.Contains(lab.Text)) { lab.BackColor = Color.Chartreuse; Reason += lab.Text + ";"; } } #endregion #region 根据一检结果显示一检时的位置 labProPosition.Text = Function.GetFirstInsPosition(dtInspect); #endregion } #region 没有一检结果,查询老外数据库,取产品信息 if (string.IsNullOrWhiteSpace(labProductInfo.Text.Trim())) { //没有一检结果,查询产品信息 labProductInfo.Text = Function.GetProductInfo(barcode); labProPosition.Text = side + " " + floor; } #endregion #region 没有一检结果,提示,取消一次质检所以注释掉 //if (string.IsNullOrWhiteSpace(labFirstCheck.Text.Trim())) //{ // MessageBox.Show("没有一检结果!", "警告", MessageBoxButtons.OK); //} #endregion } catch (Exception ex) { LogHelper.WriteLogManager(ex); } } /// /// 设置按钮不可用 /// /// private void ButtonDisable(Control[] controls) { foreach (Control c in controls) { Button btn = c as Button; btn.Enabled = false; } } /// /// 设置按钮可用 /// /// private void ButtonEnable(Control[] controls) { foreach (Control c in controls) { Button btn = c as Button; btn.Enabled = true; } } private void labWorkClass_Click(object sender, EventArgs e) { Function.ChangeWorkClass(labWorkClass); } /// /// 点击退出 /// /// /// private void labTime_Click(object sender, EventArgs e) { Environment.Exit(0); } /// /// 清空页面 /// private void ClearPage() { labProductInfo.Tag = null; labProductInfo.Text = ""; labFirstCheck.Text = ""; labSecondCheck.Text = ""; labThirdCheck.Text = ""; //btnPass.BackColor = Color.LightGray; //btnAbt.BackColor = Color.LightGray; //btnRepair.BackColor = Color.LightGray; btnFirstPass.BackColor = Color.Green; btnPass.BackColor = Color.Yellow; btnAbt.BackColor = Color.Red; btnRepair.BackColor = Color.LimeGreen; Reason = ""; ClearInspect(); //ClearControlColor(SetControlGroup()); pictureBox2.Controls.Clear(); panel2.Controls.Clear(); pictureBox2.Image = null; txtBarCode.TabIndex = 0; txtBarCode.Select(); } public void ClearTxtBarcode() { txtBarCode.Text = ""; labProPosition.Text = ""; } /// /// 一次合格 /// /// /// private void btnFirstPass_Click(object sender, EventArgs e) { //ClearControlColor(SetControlGroup()); //btnPass.BackColor = Color.SeaGreen; //保存 SaveInspect_First(); ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; //LoadPage(); //ClearInspect(); //ClearControlColor(SetControlGroup()); } /// /// 一次质检合格按钮 /// private void SaveInspect_First() { try { if (!string.IsNullOrWhiteSpace(txtBarCode.Text.Trim()) && string.IsNullOrWhiteSpace(labFirstCheck.Text)) { if (Regex.Matches(labProductInfo.Text.Trim(), ",").Count < 3) { MessageBox.Show("条码:" + txtBarCode.Text.Trim() + "没有录入颜色信息,不能提交,请补全!"); return; } InspectModel model1 = new InspectModel(); model1.ID = Guid.NewGuid().ToString(); model1.barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim()); if (labProductInfo.Tag != null) { model1.side = labProductInfo.Tag.ToString(); } else { model1.side = ""; } if (model1.side.Contains("B") && floor.Contains("下")) { model1.position = "下线一检 B侧 下支架"; } else { model1.position = "下线一检 " + model1.side + " "+floor; } model1.stationNo = labStation.Text; //model1.position = labTitle.Text.Trim(); //model1.stationNo = labStation.Text; model1.workClass = labWorkClass.Text; model1.inspectResult = "[合格]"; if (rdo1.Checked) { model1.productOption = "1"; } else if (rdo2.Checked) { model1.productOption = "2"; } else if (rdo3.Checked) { model1.productOption = "3"; } model1.productInfo = labProductInfo.Text.Trim(); model1.InspectTimes = "1"; Function.InsertInspect(model1); txtBarCode.Text = ""; } } catch (Exception ex) { LogHelper.WriteErrLogBase("二次质检补录一检结果:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } } #region 更改颜色按钮 /// /// 更改颜色 /// /// /// private void labChangeColor_Click(object sender, EventArgs e) { ColorName = ""; bool isShow = true; if (string.IsNullOrWhiteSpace(txtBarCode.Text.Trim())) { MessageBox.Show("条码不能位空!", "提示", MessageBoxButtons.OK); txtBarCode.SelectAll(); txtBarCode.Focus(); return; } DialogResult result = MessageBox.Show("确定要修改颜色?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { FrmPassWord pass = new FrmPassWord(); pass.OkBtnClick += (arg1) => { if (!string.IsNullOrEmpty(arg1) && arg1.ToLower() == ConfigurationManager.AppSettings["PassWord"].ToLower()) { pass.Close(); } else { MessageBox.Show("密码错误,请重新输入!", "提示", MessageBoxButtons.OK); isShow = false; } }; pass.ShowDialog(); } else { return; } if (!isShow) { return; } FrmChangeColor frm = new FrmChangeColor(txtBarCode.Text.Trim(), labStation.Text); frm.ShowDialog(); if (!string.IsNullOrWhiteSpace(labProductInfo.Text.Trim())) { string[] str = labProductInfo.Text.Trim().Split(','); if (str.Length > 1) { labProductInfo.Text = ColorName + "," + str[str.Length - 1]; } } else { labProductInfo.Text = ColorName; } } private void labChangeColor_MouseLeave(object sender, EventArgs e) { Label lab = sender as Label; lab.BackColor = Color.FromArgb(192, 255, 255); } private void labChangeColor_MouseMove(object sender, MouseEventArgs e) { Label lab = sender as Label; lab.BackColor = Color.Turquoise; } #endregion } }