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.
799 lines
28 KiB
799 lines
28 KiB
2 months ago
|
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.Threading;
|
||
|
using System.Windows.Forms;
|
||
|
|
||
|
namespace PaintingPC
|
||
|
{
|
||
|
public partial class FrmSecondCheckSpec : Form
|
||
|
{
|
||
|
int count = 0; //缺陷图选择个数
|
||
|
public static string ColorName = ""; //修改颜色
|
||
|
|
||
|
public FrmSecondCheckSpec()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void FrmSecondCheck_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
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();
|
||
|
|
||
|
//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);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 缺陷图点击
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
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--;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <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;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
a.BackColor = Color.Transparent;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private Control[] SetControlGroup()
|
||
|
{
|
||
|
Control[] controls = { btnPass, btnAbt };
|
||
|
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>
|
||
|
private void btnPass_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
ClearControlColor(SetControlGroup());
|
||
|
btnPass.BackColor = Color.GreenYellow;
|
||
|
//保存
|
||
|
SaveInspect();
|
||
|
ClearPage();
|
||
|
ClearTxtBarcode();
|
||
|
txtBarCode.TabIndex = 0;
|
||
|
//LoadPage();
|
||
|
//ClearInspect();
|
||
|
//ClearControlColor(SetControlGroup());
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 抛光按钮
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnRepair_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 报废按钮
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
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
|
||
|
|
||
|
ClearControlColor(SetControlGroup());
|
||
|
btnAbt.BackColor = Color.Red;
|
||
|
//保存
|
||
|
SaveInspect();
|
||
|
|
||
|
#region 报废则调WMS WebService,入库
|
||
|
|
||
|
try
|
||
|
{
|
||
|
LogHelper.WriteSysLogBase("工位:S10,条码:" + Function.UniteBarCodeToOne(txtBarCode.Text.Trim()) + "报废调用WMS接口", MethodBase.GetCurrentMethod().Name);
|
||
|
|
||
|
WMSWebService webService = new WMSWebService();
|
||
|
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
|
||
|
//webService.Timeout = 1200000;
|
||
|
|
||
|
string errorReason = "";
|
||
|
bool result = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(txtBarCode.Text.Trim()), 0, out errorReason);
|
||
|
|
||
|
LogHelper.WriteSysLogBase("工位:S10,条码:" + Function.UniteBarCodeToOne(txtBarCode.Text.Trim()) + "报废调用WMS接口,地址:" + webService.Url + ",结果:" + result.ToString(), MethodBase.GetCurrentMethod().Name);
|
||
|
}
|
||
|
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()
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
if (btnPass.BackColor != Color.LightGray && btnAbt.BackColor == Color.LightGray)
|
||
|
{
|
||
|
model1.inspectResult = "[合格]";
|
||
|
}
|
||
|
if (btnPass.BackColor == Color.LightGray && btnAbt.BackColor != Color.LightGray)
|
||
|
{
|
||
|
model1.inspectResult = "[报废]";
|
||
|
}
|
||
|
if (btnPass.BackColor == Color.LightGray && btnAbt.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 + ";";
|
||
|
}
|
||
|
}
|
||
|
//缺陷原因
|
||
|
foreach (Control c in panel2.Controls)
|
||
|
{
|
||
|
Label lab = c as Label;
|
||
|
if (lab.BackColor != Color.Transparent)
|
||
|
{
|
||
|
model1.reason += lab.Text + ";";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (model1.inspectResult == "[报废]" || model1.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.InspectTimes = ConfigurationManager.AppSettings["InspectTimes"].ToString();
|
||
|
|
||
|
if (!string.IsNullOrWhiteSpace(labSecondCheck.Text))
|
||
|
{
|
||
|
model1.InspectTimes = "3";
|
||
|
}
|
||
|
|
||
|
Function.InsertInspect(model1);
|
||
|
}
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 扫码-根据条码查询信息(产品信息、加载图片及缺陷原因、三次检验信息)
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
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;
|
||
|
|
||
|
#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, 40);
|
||
|
dLb[i].Location = new Point(20 + i * (dLb[i].Size.Width + 5), 5 + j * (dLb[i].Size.Height + 5));
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 加载图片
|
||
|
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(Program.PicturePath + @"\" + "picture"))
|
||
|
if (!File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\" + picture))
|
||
|
{
|
||
|
Ping p1 = new Ping();
|
||
|
bool status = false;
|
||
|
|
||
|
PingReply reply = p1.Send(Program.IP); //发送主机名或Ip地址
|
||
|
if (reply.Status == IPStatus.Success)
|
||
|
{
|
||
|
string PictureFolder = ConfigurationManager.AppSettings["PictureFolder"].ToString();
|
||
|
string User = ConfigurationManager.AppSettings["User"].ToString();
|
||
|
string UserPwd = ConfigurationManager.AppSettings["UserPwd"].ToString();
|
||
|
status = Upload.DoConnComputer(Program.IP, PictureFolder, User, UserPwd);
|
||
|
if (status == true)
|
||
|
{
|
||
|
//共享文件夹的目录
|
||
|
string path = ConfigurationManager.AppSettings["RemotePictureFolder"].ToString() + picture;
|
||
|
DirectoryInfo theFolder = new DirectoryInfo(path);
|
||
|
string filename = theFolder.ToString();
|
||
|
|
||
|
//执行方法
|
||
|
Function.TransportRemoteToLocal(filename, System.Environment.CurrentDirectory + "\\", picture); //实现将远程服务器文件写入到本地
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
FileStream fs = new FileStream(System.Environment.CurrentDirectory + "\\" + picture, FileMode.Open,
|
||
|
FileAccess.Read);//获取图片文件流
|
||
|
Image img = Image.FromStream(fs); // 文件流转换成Image格式
|
||
|
pictureBox2.Image = img; //给 图片框设置要显示的图片
|
||
|
fs.Close(); // 关闭流,释放图片资源
|
||
|
#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.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;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 根据一检结果显示一检时的位置
|
||
|
|
||
|
labProPosition.Text = Function.GetFirstInsPosition(dtInspect);
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
|
||
|
#region 没有一检结果,查询老外数据库,取产品信息
|
||
|
|
||
|
if (string.IsNullOrWhiteSpace(labProductInfo.Text.Trim()))
|
||
|
{
|
||
|
//没有一检结果,查询产品信息
|
||
|
labProductInfo.Text = Function.GetProductInfo(barcode);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 没有一检结果,提示
|
||
|
if (string.IsNullOrWhiteSpace(labFirstCheck.Text.Trim()))
|
||
|
{
|
||
|
MessageBox.Show("没有一检结果!", "警告", MessageBoxButtons.OK);
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogHelper.WriteLogManager(ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <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;
|
||
|
|
||
|
ClearInspect();
|
||
|
ClearControlColor(SetControlGroup());
|
||
|
pictureBox2.Controls.Clear();
|
||
|
panel2.Controls.Clear();
|
||
|
pictureBox2.Image = null;
|
||
|
txtBarCode.TabIndex = 0;
|
||
|
txtBarCode.Select();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 一次合格
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnFirstPass_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
ClearControlColor(SetControlGroup());
|
||
|
btnPass.BackColor = Color.SeaGreen;
|
||
|
//保存
|
||
|
SaveInspect_First();
|
||
|
ClearPage();
|
||
|
txtBarCode.TabIndex = 0;
|
||
|
//LoadPage();
|
||
|
//ClearInspect();
|
||
|
//ClearControlColor(SetControlGroup());
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 一次质检合格按钮
|
||
|
/// </summary>
|
||
|
private void SaveInspect_First()
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
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 更改颜色按钮
|
||
|
/// <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
|
||
|
|
||
|
public void ClearTxtBarcode()
|
||
|
{
|
||
|
txtBarCode.Text = "";
|
||
|
labProPosition.Text = "";
|
||
|
}
|
||
|
}
|
||
|
}
|