一厂MES,含注塑,喷涂,冲孔
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1172 lines
42 KiB


using PaintingPC.Model;
using PaintingPC.WebReference;
using System;
1 month ago
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;
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();
1 month ago
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<dt.Rows.Count; i++)
// {
// rb[i] = new RadioButton();
// rb[i].Font = new System.Drawing.Font("微软雅黑", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
// rb[i].TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// rb[i].AutoSize = true;
// rb[i].Text = dt.Rows[i]["Color"].ToString();
// //rb[i].Text = dt.Rows[i]["ColorName"].ToString();
// rb[i].CheckedChanged += rb_CheckedChanged;
// rb[i].BackColor = Color.Silver;
// rb[i].AutoSize = false;
// rb[i].Size = new Size(150,40);
// if(i == 0)
// {
// rb[i].Location = new Point(15,20);
// }
// else
// {
// if (i == 5)
// {
// rb[i].Location = new Point(rb[0].Location.X, rb[0].Location.Y + 50);
// }
// else if (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
{
}
}
/// <summary>
/// 缺陷图点击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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--;
}
}
/// <summary>
/// 缺陷原因点击
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
/// <summary>
/// 清除控件选中
/// </summary>
/// <param name="controls"></param>
public void ClearControlColor(Control[] controls)
{
foreach (Control c in controls)
{
c.BackColor = Color.LightGray;
}
}
/// <summary>
/// 抛光按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
1 month ago
//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
// ClearControlColor(SetControlGroup());
// btnRepair.BackColor = Color.Yellow;
// //保存
// SaveInspect("抛光");
// ClearPage();
// ClearTxtBarcode();
// txtBarCode.TabIndex = 0;
// //LoadPage();
// //ClearInspect();
// //ClearControlColor(SetControlGroup());
//}
1 month ago
/// <summary>
/// 合格
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOk_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
1 month ago
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
1 month ago
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName,ref partName) == false) return;
1 month ago
#endregion
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
//保存
SaveInspect("合格", colorName, partName);
ClearPage();
ClearTxtBarcode();
txtBarCode.TabIndex = 0;
}
/// <summary>
/// 不合格
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnNok_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
1 month ago
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
1 month ago
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行不良判定?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
1 month ago
#region 必须选择缺陷位置与缺陷原因,否则无法保存
if (CheckDefect() == false) return;
#endregion
1 month ago
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
//保存
SaveInspect("不良", colorName, partName);
ClearPage();
ClearTxtBarcode();
txtBarCode.TabIndex = 0;
}
/// <summary>
1 month ago
/// 返喷按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRepair_Click(object sender, EventArgs e)
{
#region 可回喷次数 =1,不能打磨, =2 可以, 不能有两次质检结果为打磨
1 month ago
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
1 month ago
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行返喷操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
string barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim());
int cs = Function.YiDaMoCiShu(barcode);
//if (cs >= 1)
//{
// MessageBox.Show("该条码已有判定为打磨的质检结果!");
// return;
//}
int keHuiPen = Function.keHuiPen(barcode);
if (keHuiPen > 0 && cs < keHuiPen)
{
#region 必须选择缺陷位置与缺陷原因,否则无法保存
1 month ago
if (CheckDefect() == false) return;
1 month ago
#endregion
1 month ago
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
1 month ago
ClearControlColor(SetControlGroup());
btnRepair.BackColor = Color.Yellow;
string s = _isWmsQuality == false ? "打磨" : "WMS打磨";
//保存
SaveInspect(s, colorName, partName);
ClearPage();
ClearTxtBarcode();
txtBarCode.TabIndex = 0;
}
else
{
MessageBox.Show("根据该零件可回喷次数设置,不能判定为打磨或已超过打磨次数!");
ClearPage();
ClearTxtBarcode();
txtBarCode.TabIndex = 0;
return;
}
#endregion
}
/// <summary>
/// 报废按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAbt_Click(object sender, EventArgs e)
{
1 month ago
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
1 month ago
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行报废操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
#region 必须选择缺陷位置与缺陷原因,否则无法保存
1 month ago
if (CheckDefect() == false) return;
#endregion
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
DataTable inspectTable = Function. GetInspectInfoByBarCode2(txtBarCode.Text.Trim());
if(inspectTable.Rows.Count>0)
{
if (inspectTable.Rows[0]["inspectResult"].ToString().Contains("合格"))
{
MessageBox.Show("条码已判定为合格,无法重新判定为报废");
return ;
}
}
1 month ago
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
string id = SaveInspect("报废", colorName, partName);
1 month ago
#region 报废则调WMS WebService,入库
try
{
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;
}
1 month ago
}
catch (Exception ex)
{
MessageBox.Show("报废操作发生异常,原因:" + ex.Message);
LogHelper.WriteErrLogBase("质检调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
1 month ago
}
1 month ago
#endregion
ClearPage();
ClearTxtBarcode();
txtBarCode.TabIndex = 0;
//ClearInspect();
//ClearControlColor(SetControlGroup());
}
/// <summary>
/// 判断产品是否有颜色
/// </summary>
/// <returns></returns>
bool CheckColor(ref string colorName,ref string partName)
{
string[] ss = labProductInfo.Text.Split(',');
if (ss.Length >= 1)
{
1 month ago
if (string.IsNullOrWhiteSpace(ss[0]))
1 month ago
{
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;
}
/// <summary>
/// 必须选择缺陷位置与缺陷原因,否则无法保存
/// </summary>
/// <returns></returns>
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("必须选择缺陷位置与缺陷原因,否则无法保存!");
1 month ago
return false;
}
1 month ago
return true;
}
/// <summary>
/// 保存质检记录 tb_InspectResult
/// </summary>
/// <param name="inspectResult"></param>
/// <param name="colorName"></param>
/// <param name="partName"></param>
/// <returns> 返回插入记录的ID</returns>
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 != "合格")
{
1 month ago
if (string.IsNullOrWhiteSpace(model1.damnPosition) || string.IsNullOrWhiteSpace(model1.reason))
{
MessageBox.Show("必须选择缺陷位置与缺陷原因,否则无法保存!");
return "";
1 month ago
}
}
1 month ago
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();
1 month ago
model1.remark1 = colorName; //颜色名称
model1.remark2 = partName; //零件描述
if(_isWmsQuality == false)
{
model1.remark3 = "喷涂质检"; // 喷涂质检 或 油漆件库
}
else
{
model1.remark3 = "油漆件库"; // 喷涂质检 或 油漆件库
}
return Function.InsertInspect2(model1);
}
return "";
}
catch (Exception ex)
{
LogHelper.WriteErrLogBase("质检提交:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
MessageBox.Show("质检提交异常,原因:" + ex.Message);
return null;
}
}
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;
}
}
/// <summary>
/// 扫码-根据条码查询信息(产品信息、加载图片及缺陷原因、三次检验信息)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
1 month ago
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)
{
1 month ago
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();
1 month ago
if (!string.IsNullOrEmpty(picture))
{
1 month ago
if (!File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\" + picture))
{
1 month ago
string strImageURL = Function.GetImgPath() + picture;
1 month ago
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(); // 关闭流,释放图片资源
1 month ago
}
}
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
//不是补打的条码,根据条码查询产品信息、检验信息,选中缺陷位置及原因
1 month ago
DataTable dtInspect = Function.GetInspectInfoByBarCode2(barcode);
if (dtInspect != null && dtInspect.Rows.Count > 0)
{
1 month ago
List<DataRow> list = dtInspect.AsEnumerable().Where(p => p.Field<string>("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 根据一检结果显示一检时的位置--暂时不要
1 month ago
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))
{
lbForeig.Text = 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);
}
}
/// <summary>
/// 设置按钮不可用
/// </summary>
/// <param name="controls"></param>
private void ButtonDisable(Control[] controls)
{
foreach (Control c in controls)
{
Button btn = c as Button;
btn.Enabled = false;
}
}
/// <summary>
/// 设置按钮可用
/// </summary>
/// <param name="controls"></param>
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);
}
/// <summary>
/// 点击退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labTime_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
/// <summary>
/// 清空页面
/// </summary>
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;
//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 更改颜色按钮
/// <summary>
/// 更改颜色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 其他按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
1 month ago
//private void button1_Click(object sender, EventArgs e)
//{
// ClearControlColor(SetControlGroup());
// //btnPass.BackColor = Color.GreenYellow;
// //保存
// SaveInspect("其他");
// ClearPage();
// ClearTxtBarcode();
// txtBarCode.TabIndex = 0;
//}
private void UpdateSoftware()
{
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();
}
}
}