using PaintingPC.Model; using PaintingPC.WebReference; using System; using System.Linq; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Net.NetworkInformation; using System.Reflection; using System.Threading; using System.Windows.Forms; namespace PaintingPC { public partial class FrmQuality : Form { int count = 0; //缺陷图选择个数 public static string ColorName = ""; //修改颜色 public static string paintId = ""; private static string position = "", reason = ""; private bool _isWmsQuality = false ; private string _carType = string.Empty; private Dictionary _lastJustDict = new Dictionary(); public FrmQuality(bool isWmsQuality) { InitializeComponent(); //WindowState = FormWindowState.Normal; this.Size = new Size(1280, 1024); this._isWmsQuality = isWmsQuality; if(isWmsQuality == true) { groupBox1.Visible = false; btnNok.Visible = false; btnOk.Visible = false; btnAbt.Visible = false; } } private void FrmSecondCheck_Load(object sender, EventArgs e) { try { Control.CheckForIllegalCrossThreadCalls = false; UpdateSoftware(); InitPage(); } catch (Exception ex) { MessageBox.Show("网络故障,请联系网络管理员"); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); } } public void InitPage() { try { string title = ConfigurationManager.AppSettings["Position"].ToString(); string workClass = Function.GetWorkClass2(); 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(); //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) { } } public void InitColor(string stockNo) { try { DataTable dt = Function.GetColorByStockNo(stockNo); if(dt.Rows.Count == 0) { lbForeig.Text = $"基础数据-产品颜色菜单未配置[{stockNo}]的颜色信息"; } DataRow dr = dt.NewRow(); dr["Color"] = ""; dt.Rows.InsertAt(dr, 0); cboxAddColor.DataSource = dt; cboxAddColor.DisplayMember = "Color"; cboxAddColor.ValueMember = "Color"; //if (dt != null && dt.Rows.Count > 0) //{ // RadioButton[] rb = new RadioButton[dt.Rows.Count]; // for(int i=0; i 6) // { // rb[i].Location = new Point(rb[i - 1].Location.X + rb[i - 1].Width + 50, rb[i - 1].Location.Y); // } // else // { // rb[i].Location = new Point(rb[i - 1].Location.X + rb[i - 1].Width + 50, rb[i - 1].Location.Y); // } // } // rb[i].Click += new System.EventHandler(this.rb_Click); // } // groupBox1.Controls.AddRange(rb); //} } catch (Exception ex) { LogHelper.WriteLogManager(ex); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); throw ex; } } private void cboxAddColor_SelectedValueChanged(object sender, EventArgs e) { string[] ss = labProductInfo.Text.Split(','); if (ss.Length > 1) { string attchColor = cboxAddColor.Text.Trim(); if (!string.IsNullOrEmpty(attchColor)) { labProductInfo.Text = cboxAddColor.Text.Trim() + "," + ss[1]; } } } private void rb_CheckedChanged(object sender, EventArgs e) { RadioButton rb = sender as RadioButton; if (rb.Checked) { rb.BackColor = Color.LightSalmon; } else { rb.BackColor = Color.Silver; } } 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) { try { labTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Thread.Sleep(500); } catch { } } /// /// 缺陷图点击 /// /// /// void lblRoom_Click(object sender, EventArgs e) { Label a = (Label)sender; string aa = a.Text; if (a.BackColor == Color.Transparent) { a.BackColor = Color.FromArgb(150, System.Drawing.Color.Chartreuse); position += aa; 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 += a.Text + ";"; } else { a.BackColor = Color.Transparent; reason = reason.Replace(a.Text + ";", ""); } } private Control[] SetControlGroup() { //Control[] controls = { btnPass, btnAbt, btnRepair }; Control[] controls = { btnAbt, btnRepair }; return controls; } /// /// 清除控件选中 /// /// public void ClearControlColor(Control[] controls) { foreach (Control c in controls) { c.BackColor = Color.LightGray; } } /// /// 合格 /// /// /// private void btnOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtBarCode.Text.Trim())) { MessageBox.Show("请先扫描数据,然后操作."); return; } ShowHint(""); #region 判断产品是否有颜色 string colorName = string.Empty; string partName = string.Empty; if (CheckColor(ref colorName,ref partName) == false) return; #endregion ClearControlColor(SetControlGroup()); btnAbt.BackColor = Color.Red; string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); if (lastRst.Contains("合格")) { MessageBox.Show("条码已判定为合格,无需重复判定"); Clear(); return; } //保存 SaveInspect("合格", colorName, partName); try { SendToWms(txtBarCode.Text.Trim(), 1); } catch (Exception ex) { ShowHint("合格WMS报工异常,原因:" + ex.Message); MessageBox.Show("合格WMS报工异常,原因:" + ex.Message); LogHelper.WriteErrLogBase("合格WMS报工调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } Clear(); } void Clear() { ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; } /// /// 不合格 /// /// /// private void btnNok_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtBarCode.Text.Trim())) { MessageBox.Show("请先扫描数据,然后操作."); return; } if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行不良判定?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ShowHint(""); #region 必须选择缺陷位置与缺陷原因,否则无法保存 if (CheckDefect() == false) return; #endregion #region 判断产品是否有颜色 string colorName = string.Empty; string partName = string.Empty; if (CheckColor(ref colorName, ref partName) == false) return; #endregion string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); if (lastRst.Contains("不良")) { MessageBox.Show("条码已判定为不合格,无需重复判定"); Clear(); return; } //保存 SaveInspect("不良", colorName, partName); ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; } /// /// 返喷按钮 /// /// /// private void btnRepair_Click(object sender, EventArgs e) { #region 可回喷次数 =1,不能打磨, =2 可以, 不能有两次质检结果为打磨 if (string.IsNullOrEmpty(txtBarCode.Text.Trim())) { MessageBox.Show("请先扫描数据,然后操作."); return; } if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行返喷操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ShowHint(""); string barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim()); int cs = Function.YiDaMoCiShu(barcode); int keHuiPen = Function.keHuiPen(barcode); if (keHuiPen > 0 && cs < keHuiPen) { #region 必须选择缺陷位置与缺陷原因,否则无法保存 if (CheckDefect() == false) return; #endregion #region 判断产品是否有颜色 string colorName = string.Empty; string partName = string.Empty; if (CheckColor(ref colorName, ref partName) == false) return; #endregion ClearControlColor(SetControlGroup()); btnRepair.BackColor = Color.Yellow; string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); if (lastRst.Contains("打磨")) { MessageBox.Show("条码已判定为返喷,无需重复判定"); Clear(); return; } string s = _isWmsQuality == false ? "打磨" : "WMS打磨"; //保存 SaveInspect(s, colorName, partName); try { SendToWms(txtBarCode.Text.Trim(), 9); } catch (Exception ex) { ShowHint("返喷WMS报工异常,原因:" + ex.Message); MessageBox.Show("返喷WMS报工异常,原因:" + ex.Message); LogHelper.WriteErrLogBase("返喷WMS报工调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } Clear(); } else { MessageBox.Show("根据该零件可回喷次数设置,不能判定为打磨或已超过打磨次数!"); Clear(); return; } #endregion } /// /// 报废按钮 /// /// /// private void btnAbt_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtBarCode.Text.Trim())) { MessageBox.Show("请先扫描数据,然后操作."); return; } if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行报废操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; ShowHint(""); #region 必须选择缺陷位置与缺陷原因,否则无法保存 if (CheckDefect() == false) return; #endregion #region 判断产品是否有颜色 string colorName = string.Empty; string partName = string.Empty; if (CheckColor(ref colorName, ref partName) == false) return; #endregion string lastRst = GetLastInspectRst(txtBarCode.Text.Trim()); if (lastRst.Contains("合格")) { MessageBox.Show("条码已判定为合格,无法重新判定为报废"); Clear(); return; } if (lastRst.Contains("报废")) { MessageBox.Show("条码已判定为报废,无需重复报废"); Clear(); return; } ClearControlColor(SetControlGroup()); btnAbt.BackColor = Color.Red; string id = SaveInspect("报废", colorName, partName); #region 报废则调WMS WebService,入库 try { SendToWms(txtBarCode.Text.Trim(), 0); // WMSWebService webService = new WMSWebService(); // webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); // //webService.Timeout = 1200000; // string errorReason = ""; //bool rst = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 0, out errorReason); //if(rst == false) // { // if (!string.IsNullOrEmpty(id)) // { // LogHelper.WriteErrLogBase($"质检调用WMS接口失败,删除条码为[{txtBarCode.Text}]的质检记录", MethodBase.GetCurrentMethod().Name); // Function.DelInspectRst(id); // } // MessageBox.Show("报废操作失败,原因:"+ errorReason); // return; // } } catch (Exception ex) { MessageBox.Show("报废操作发生异常,原因:" + ex.Message); LogHelper.WriteErrLogBase("质检调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion ClearPage(); ClearTxtBarcode(); txtBarCode.TabIndex = 0; //ClearInspect(); //ClearControlColor(SetControlGroup()); } /// /// /// /// /// string GetLastInspectRst(string barCode) { DataTable inspectTable = Function.GetInspectInfoByBarCode2(txtBarCode.Text.Trim()); if (inspectTable.Rows.Count > 0) { return inspectTable.Rows[0]["inspectResult"].ToString(); } return ""; } /// /// 发送wms罢工 /// /// /// 0:报废 1:合格 9:返喷 void SendToWms(string scanBarCode, int isOk) { WMSWebService webService = new WMSWebService(); webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString(); //webService.Timeout = 1200000; string errorReason = ""; //上次异常提交 if (_lastJustDict.Count > 0) { bool rst2 = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(_lastJustDict.First().Key), int.Parse( _lastJustDict.First().Value), out errorReason); } bool rst = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(scanBarCode), isOk, out errorReason); if (rst == false) { ShowHint("WMS报工接口调用失败: " + errorReason); _lastJustDict.Clear(); _lastJustDict.Add(scanBarCode, isOk.ToString()); return; } _lastJustDict.Clear(); } /// /// 判断产品是否有颜色 /// /// bool CheckColor(ref string colorName,ref string partName) { string[] ss = labProductInfo.Text.Split(','); if (ss.Length >= 1) { if (string.IsNullOrWhiteSpace(ss[0])) { MessageBox.Show("无颜色信息,请重新扫描"); return false; } } else { MessageBox.Show("条码有误,请重新扫描"); return false; } colorName = ss[0]; if (ss.Length > 1) { if (!string.IsNullOrEmpty(ss[1])) { partName = ss[1]; } } return true; } /// /// 必须选择缺陷位置与缺陷原因,否则无法保存 /// /// bool CheckDefect() { string damnPositionTemp = ""; string reasonTemp = ""; //缺陷位置 foreach (Control c in pictureBox2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { damnPositionTemp += lab.Text + ";"; position = damnPositionTemp; } } //缺陷原因 foreach (Control c in panel2.Controls) { Label lab = c as Label; if (lab.BackColor != Color.Transparent) { reasonTemp += lab.Text + ";"; reason = reasonTemp; } } if (string.IsNullOrWhiteSpace(damnPositionTemp) || string.IsNullOrWhiteSpace(reasonTemp)) { MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!"); return false; } return true; } /// /// 保存质检记录 tb_InspectResult /// /// /// /// /// 返回插入记录的ID public string SaveInspect(string inspectResult,string colorName, string partName) { try { if (!string.IsNullOrWhiteSpace(txtBarCode.Text.Trim())) { InspectModel model1 = new InspectModel(); model1.barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim()); model1.position = labProPosition.Text; model1.stationNo = labStation.Text; model1.workClass = labWorkClass.Text; model1.inspectResult = "[" + inspectResult + "]"; model1.damnPosition = position; model1.reason = reason; model1.remark3 = paintId; if (!string.IsNullOrEmpty(_carType)) { model1.CarType = _carType; } else { string paintID = labProPosition.Tag?.ToString(); string carType = Function.carTypeName(model1.barcode.Substring(0, 10), paintID); model1.CarType = carType; } if (inspectResult != "合格") { 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.side = labProPosition.Text.Contains("A侧") ? "A侧" : "B侧"; model1.InspectTimes = (Function.GetInspectTimes(txtBarCode.Text.Trim())+1).ToString(); model1.remark1 = colorName; //颜色名称 model1.remark2 = partName; //零件描述 if(_isWmsQuality == false) { model1.remark3 = "喷涂质检"; // 喷涂质检 或 油漆件库 } else { model1.remark3 = "油漆件库"; // 喷涂质检 或 油漆件库 } return Function.InsertInspect2(model1); } return ""; } catch (Exception ex) { ShowHint("质检提交异常,原因:" + ex.Message); LogHelper.WriteErrLogBase("质检提交:" + ex.ToString(), MethodBase.GetCurrentMethod().Name); MessageBox.Show("质检提交异常,原因:" + ex.Message); return null; } } void ShowHint(string txt) { lbForeig.Text = txt; } 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) { try { lbForeig.Text = ""; ClearPage(); LoadPage(); } catch (Exception ex) { MessageBox.Show("请查看网络是否与服务器连通,无法连通请联系网络管理员。"+ ex); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); } } } 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 if (_isWmsQuality) { DataTable dt = Function.GetLastResult(barcode); if (dt.Rows.Count == 0) { MessageBox.Show($"条码[{barcode}]没有质检记录, 请核对数据!"); return; } else if (dt.Rows[0]["inspectResult"].ToString().Contains("合格") == false) { MessageBox.Show($"条码[{barcode}]最后质检结果为{dt.Rows[0]["inspectResult"].ToString()}, 非[合格]状态无法返喷!"); return; } } #region 查询该系列产品都有什么颜色 string canChanageColor = ConfigurationManager.AppSettings["CanChangeColor"].Trim(); if (canChanageColor.ToLower() == "true" && _isWmsQuality==false) //_isWmsQuality =true 表示库房返喷判断,不能附加颜色 { string stockNo = barcode.Substring(0, 10); InitColor(stockNo); } #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.GetReprintInfo2(barcode); if (string.IsNullOrWhiteSpace(labProductInfo.Text.Trim())) { ButtonDisable(SetControlGroup()); labProductInfo.Text = "没有查询到补打条码信息"; return; } } } #endregion //根据条码查询,加载图片及原因 int row = 0, col = 0; string picture = ""; #region 缺陷原因 try { 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 = ContentAlignment.MiddleCenter; panel2.Controls.Add(dLb[i]); dLb[i].Click += new EventHandler(dLbRoom_Click); } } } } } catch (Exception ex) { LogHelper.WriteLogManager(ex); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); throw ex; } #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 (!string.IsNullOrEmpty(picture)) { 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(Directory.GetCurrentDirectory() + "\\" + picture, FileMode.Open, FileAccess.Read);//获取图片文件流 Image img = Image.FromStream(fs); // 文件流转换成Image格式 pictureBox2.Image = img; //给 图片框设置要显示的图片 fs.Close(); // 关闭流,释放图片资源 } } catch (Exception ex) { LogHelper.WriteLogManager(ex); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); } #endregion #region 缺陷图划分区域 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 = ContentAlignment.MiddleCenter; pictureBox2.Controls.Add(lb[i]); lb[i].Click += new EventHandler(lblRoom_Click); } } #endregion //不是补打的条码,根据条码查询产品信息、检验信息,选中缺陷位置及原因 DataTable dtInspect = Function.GetInspectInfoByBarCode2(barcode); if (dtInspect != null && dtInspect.Rows.Count > 0) { List list = dtInspect.AsEnumerable().Where(p => p.Field("inspectResult").Contains("打磨")).ToList(); if (list.Count > 0) { lableFP.Text = "存在返喷"; } _carType = dtInspect.Rows[0]["CarType"].ToString().Trim(); labProductInfo.Text = dtInspect.Rows[0]["productInfo"].ToString().Trim(); //产品信息 //string position1 = dtInspect.Rows[0]["damnPosition"].ToString(); //缺陷位置 //string reason1 = dtInspect.Rows[0]["reason"].ToString(); //原因 position= dtInspect.Rows[0]["damnPosition"].ToString(); //缺陷位置 reason= dtInspect.Rows[0]["reason"].ToString(); //原因 paintId = dtInspect.Rows[0]["remark3"].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.GetFirstInsPosition2(dtInspect); #endregion } else { #region 没有一检结果,查询老外数据库,取产品信息 if(_isWmsQuality == false) { string paintError = string.Empty; //喷涂线边质检,没有质检结果,查询老外数据库,取产品信息 string[] info = Function.GetProductInfo2(barcode,ref paintError).Split(','); if (!string.IsNullOrEmpty(paintError)) { ShowHint(paintError); } labProductInfo.Text = info[0] + "," + info[1]; paintId = info[2]; labProPosition.Tag = paintId; labProductInfo.Tag = Function.GetSide(barcode, paintId); labProPosition.Text = labTitle.Text.Trim() + " " + labProductInfo.Tag.ToString().Replace(';', ' '); } else { //库房返喷,没有质检结果,不能查老外库,就是条码不正确 MessageBox.Show("没有喷涂线边质检记录,无法返喷操作!"); txtBarCode.Text = ""; txtBarCode.TabIndex = 0; txtBarCode.Select(); return ; } #endregion } txtBarCode.SelectAll(); } catch (Exception ex) { MessageBox.Show("请查看网络是否与服务器连通,无法连通请联系网络管理员。" + ex.ToString()); LogHelper.WriteLogManager(ex); LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); } } /// /// 设置按钮不可用 /// /// 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 = ""; btnAbt.BackColor = Color.LightGray; btnRepair.BackColor = Color.LightGray; //ClearRadioButton(); ClearInspect(); ClearControlColor(SetControlGroup()); pictureBox2.Controls.Clear(); panel2.Controls.Clear(); pictureBox2.Image = null; txtBarCode.TabIndex = 0; txtBarCode.Select(); position = ""; reason = ""; lableFP.Text = ""; cboxAddColor.DataSource = null; _carType = string.Empty; } public void ClearRadioButton() { groupBox1.Controls.Clear(); } public void ClearTxtBarcode() { txtBarCode.Text = ""; labProPosition.Text = ""; } #region 更改颜色按钮 /// /// 更改颜色 /// /// /// private void labChangeColor_Click(object sender, EventArgs e) { ColorName = ""; FrmChangeColor frm = new FrmChangeColor(); 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 /// /// 其他按钮 /// /// /// //private void button1_Click(object sender, EventArgs e) //{ // ClearControlColor(SetControlGroup()); // //btnPass.BackColor = Color.GreenYellow; // //保存 // SaveInspect("其他"); // ClearPage(); // ClearTxtBarcode(); // txtBarCode.TabIndex = 0; //} private void UpdateSoftware() { return; var serverUrl = "http://10.60.101.59:8013/"; var updateXmlFileName = "PaintingUpdatePC.xml"; var updater = new AutoUpdater(); if (updater.CheckUpdateLoad(serverUrl, updateXmlFileName)) { Environment.Exit(0); } } private void rb_Click(object sender, EventArgs e) { RadioButton rb = sender as RadioButton; if (!string.IsNullOrWhiteSpace(labProductInfo.Text)) { string[] ss = labProductInfo.Text.Split(','); labProductInfo.Text = rb.Text.Trim() + "," + ss[1]; } } private void txtBarCode_DoubleClick(object sender, EventArgs e) { txtBarCode.SelectAll(); } } }