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.
1544 lines
56 KiB
1544 lines
56 KiB
|
|
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;
|
|
using MESClassLibrary.BLL.BasicInfo;
|
|
using static System.Windows.Forms.AxHost;
|
|
using PaintingPC;
|
|
|
|
namespace PunchingMistake
|
|
{
|
|
public partial class FrmQualityNew : Form
|
|
{
|
|
int count = 0; //缺陷图选择个数
|
|
public static string ColorName = ""; //修改颜色
|
|
public static string paintId = "";
|
|
|
|
private static string position = "", reason = "";
|
|
|
|
private string _carType = string.Empty;
|
|
private Dictionary<string, string> _lastJustDict = new Dictionary<string, string>();
|
|
private string _foreighColor = string.Empty;
|
|
private string _lineCode = string.Empty;
|
|
private List<string> _stations = new List<string>();
|
|
|
|
private StationBLL _stationBLL = new StationBLL();
|
|
/// <summary>
|
|
/// 从tb_ForeignColorMap表得到的零件号
|
|
/// </summary>
|
|
private string _foreignPartCode = string.Empty;
|
|
private bool _isSingleStation = false;
|
|
private string _isTest = "false";
|
|
private string _stationNo = "";
|
|
private string IsHigh = "1";
|
|
public FrmQualityNew()
|
|
{
|
|
InitializeComponent();
|
|
//WindowState = FormWindowState.Normal;
|
|
this.Size = new Size(1280, 1020);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmSecondCheck_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Control.CheckForIllegalCrossThreadCalls = false;
|
|
InitPage();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("网络故障,请联系网络管理员");
|
|
LogHelper.WriteLog(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
|
|
public void InitPage()
|
|
{
|
|
try
|
|
{
|
|
string title = ConfigurationManager.AppSettings["Display"].ToString();
|
|
string workClass = Function.GetWorkClass2();
|
|
_stationNo = ConfigurationManager.AppSettings["Station"].ToString();
|
|
|
|
labTitle.Text = title;
|
|
|
|
labWorkClass.Text = workClass;
|
|
labStation.Text = _stationNo;
|
|
labelVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
|
|
LoadScreen();
|
|
|
|
|
|
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)
|
|
{
|
|
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 = { };
|
|
return controls;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清除控件选中
|
|
/// </summary>
|
|
/// <param name="controls"></param>
|
|
public void ClearControlColor(Control[] controls)
|
|
{
|
|
foreach (Control c in controls)
|
|
{
|
|
c.BackColor = Color.LightGray;
|
|
}
|
|
}
|
|
|
|
bool SaveBeforeVerify( string currentRst)
|
|
{
|
|
string lastRst = GetLastInspectRst(txtBarCode.Text.Trim());
|
|
if (lastRst.Contains("报废"))
|
|
{
|
|
MessageBox.Show($"条码已判定为报废,不能再判定为{currentRst}.");
|
|
Clear();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 合格
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
|
|
{
|
|
MessageBox.Show("请先扫描数据,然后操作.");
|
|
return;
|
|
}
|
|
#region 返喷下线数据验证
|
|
if (lableFP.Text.Contains("[返喷]"))
|
|
{
|
|
string barcode = txtBarCode.Text.Trim();
|
|
DataTable dtInspect = Function.GetInspectInfoByBarCode2(barcode);
|
|
if (dtInspect != null && dtInspect.Rows.Count > 0)
|
|
{
|
|
string inspectResult = dtInspect.Rows[0]["inspectResult"].ToString(); //检测结果
|
|
string inspectColorInfo = dtInspect.Rows[0]["remark1"].ToString(); //颜色
|
|
if (inspectResult.Contains("打磨"))
|
|
{
|
|
string createTime = dtInspect.Rows[0]["createTime"].ToString(); //创建时间
|
|
int count = 0;
|
|
string colorInfo = "";
|
|
if (_lineCode == "2")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA", createTime ,ref colorInfo);
|
|
}
|
|
else if (_lineCode == "1")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA_OLD", createTime , ref colorInfo);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
{
|
|
MessageBox.Show("未发现返喷下线数据!,无法进行质量判定");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if(inspectColorInfo != colorInfo)
|
|
{
|
|
btnOk.Enabled = false;
|
|
btnRepair.Enabled = false;
|
|
btnNok.Enabled = false;
|
|
|
|
MessageBox.Show("当前产品返喷颜色与原颜色不符,需报废!");
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
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;
|
|
|
|
bool rr = SaveBeforeVerify("合格");
|
|
if (rr == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//if (lastRst.Contains("合格"))
|
|
//{
|
|
// MessageBox.Show("条码已判定为合格,无需重复判定");
|
|
// Clear();
|
|
// return;
|
|
//}
|
|
SaveRst("合格", colorName, partName, 1);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
ShowHint("执行合格判定发生异常,异常原因:" + ex.Message);
|
|
MessageBox.Show("执行合格判定发生异常,异常原因:" + ex.Message);
|
|
Clear();
|
|
}
|
|
|
|
}
|
|
void Clear()
|
|
{
|
|
ClearPage();
|
|
ClearTxtBarcode();
|
|
txtBarCode.TabIndex = 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 其它
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnNok_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
|
|
{
|
|
MessageBox.Show("请先扫描数据,然后操作.");
|
|
return;
|
|
}
|
|
|
|
#region 返喷下线数据验证
|
|
if (lableFP.Text.Contains("[返喷]"))
|
|
{
|
|
string barcode = txtBarCode.Text.Trim();
|
|
DataTable dtInspect = Function.GetInspectInfoByBarCode2(barcode);
|
|
if (dtInspect != null && dtInspect.Rows.Count > 0)
|
|
{
|
|
string inspectResult = dtInspect.Rows[0]["inspectResult"].ToString(); //检测结果
|
|
string inspectColorInfo = dtInspect.Rows[0]["remark1"].ToString(); //颜色
|
|
if (inspectResult.Contains("打磨"))
|
|
{
|
|
string createTime = dtInspect.Rows[0]["createTime"].ToString(); //创建时间
|
|
int count = 0;
|
|
string colorInfo = "";
|
|
if (_lineCode == "2")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA", createTime, ref colorInfo);
|
|
}
|
|
else if (_lineCode == "1")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA_OLD", createTime, ref colorInfo);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
{
|
|
MessageBox.Show("未发现返喷下线数据!,无法进行质量判定");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (inspectColorInfo != colorInfo)
|
|
{
|
|
btnOk.Enabled = false;
|
|
btnRepair.Enabled = false;
|
|
btnNok.Enabled = false;
|
|
|
|
MessageBox.Show("当前产品返喷颜色与原颜色不符,需报废!");
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
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
|
|
|
|
int cs = Function.OtherTimes(txtBarCode.Text.Trim());
|
|
if (cs > 0)
|
|
{
|
|
MessageBox.Show("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
|
|
ShowHint("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
|
|
Clear();
|
|
return;
|
|
}
|
|
|
|
bool rr = SaveBeforeVerify("其它");
|
|
if (rr == false)
|
|
{
|
|
return;
|
|
}
|
|
SaveRst("其它", colorName, partName, 4);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
ShowHint("执行其它判定发生异常,异常原因:" + ex.Message);
|
|
MessageBox.Show("执行其它判定发生异常,异常原因:" + ex.Message);
|
|
Clear();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返喷按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnRepair_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
#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 > 1)
|
|
keHuiPen = 1;
|
|
|
|
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("打磨"))
|
|
//{
|
|
// ShowHint("条码已判定为返喷,无需重复判定");
|
|
// MessageBox.Show("条码已判定为返喷,无需重复判定");
|
|
// Clear();
|
|
// return;
|
|
//}
|
|
|
|
|
|
bool rr = SaveBeforeVerify("返喷");
|
|
if (rr == false)
|
|
{
|
|
return;
|
|
}
|
|
SaveRst("", colorName, partName, 9);
|
|
|
|
}
|
|
else
|
|
{
|
|
ShowHint("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
|
|
MessageBox.Show("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
|
|
Clear();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
ShowHint("执行返喷操作发生异常,异常原因:"+ex.Message);
|
|
MessageBox.Show("执行返喷操作发生异常,异常原因:" + ex.Message);
|
|
Clear();
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 报废按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnAbt_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
|
|
{
|
|
MessageBox.Show("请先扫描数据,然后操作.");
|
|
return;
|
|
}
|
|
|
|
#region 返喷下线数据验证
|
|
if (lableFP.Text.Contains("[返喷]"))
|
|
{
|
|
string barcode = txtBarCode.Text.Trim();
|
|
DataTable dtInspect = Function.GetInspectInfoByBarCode2(barcode);
|
|
if (dtInspect != null && dtInspect.Rows.Count > 0)
|
|
{
|
|
string inspectResult = dtInspect.Rows[0]["inspectResult"].ToString(); //检测结果
|
|
string inspectColorInfo = dtInspect.Rows[0]["remark1"].ToString(); //颜色
|
|
if (inspectResult.Contains("打磨"))
|
|
{
|
|
string createTime = dtInspect.Rows[0]["createTime"].ToString(); //创建时间
|
|
int count = 0;
|
|
string colorInfo = "";
|
|
if (_lineCode == "2")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA", createTime, ref colorInfo);
|
|
}
|
|
else if (_lineCode == "1")
|
|
{
|
|
count = Function.GetProducColorFromWms(barcode, "TM_BJBMPT_MES_DATA_OLD", createTime, ref colorInfo);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
if (count == 0)
|
|
{
|
|
MessageBox.Show("未发现返喷下线数据!,无法进行质量判定");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
// if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行报废操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
|
|
|
|
//UserInput(userName => {
|
|
|
|
//string userName = Program.UserName;
|
|
// if (string.IsNullOrEmpty(userName))
|
|
// {
|
|
// MessageBox.Show("报废必须录入用户名.");
|
|
// return;
|
|
// }
|
|
// else
|
|
// {
|
|
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;
|
|
|
|
bool rr = SaveBeforeVerify("报废");
|
|
if (rr == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
SaveRst("报废", colorName, partName, 2);
|
|
|
|
// }
|
|
// });
|
|
}
|
|
|
|
catch(Exception ex)
|
|
{
|
|
ShowHint("执行报废操作发生异常,异常原因:" + ex.Message);
|
|
MessageBox.Show("执行报废操作发生异常,异常原因:" + ex.Message);
|
|
Clear();
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
/// <param name="colorName"></param>
|
|
/// <param name="partName"></param>
|
|
/// <param name="isOK">0-不合格;1-合格;9-返喷 8-其他 </param>
|
|
void SaveRst(string state, string colorName, string partName,int isOK,string userName="")
|
|
{
|
|
if (string.IsNullOrEmpty(userName))
|
|
{
|
|
userName = Program.UserName;
|
|
}
|
|
if (string.IsNullOrEmpty(userName))
|
|
{
|
|
|
|
}
|
|
|
|
if(reason.Contains("点修补") && state!="其它")
|
|
{
|
|
MessageBox.Show("选择[点修补],只能判定为[其它]状态,不能判定为"+ state);
|
|
return;
|
|
}
|
|
string bcode = txtBarCode.Text.Trim();
|
|
|
|
bool ispass = ScanCodeValidVerify(bcode);
|
|
if (ispass == false)
|
|
{
|
|
txtBarCode.SelectAll();
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//保存
|
|
string id = SaveInspect(state, colorName, partName, userName);
|
|
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
string interfaceMsg = string.Empty;
|
|
bool rst = SendToWms(txtBarCode.Text.Trim(), isOK,ref interfaceMsg);
|
|
if (rst == false)
|
|
{
|
|
DeleteRepectRst(id, "Web接口调用返回false,原因:" + interfaceMsg, bcode);
|
|
}
|
|
else
|
|
{
|
|
ShowHint(txtBarCode.Text.Trim()+"操作成功",true);
|
|
Clear();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("质检记录保存失败,请重新操作.");
|
|
return;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.Message.Contains("WMS"))
|
|
{
|
|
DeleteRepectRst(id,"Web接口调用抛出异常,异常原因:" + ex.Message , bcode);
|
|
}
|
|
ShowHint(state+"-WMS报工异常,原因:" + ex.Message);
|
|
MessageBox.Show(state+"-WMS报工异常,原因:" + ex.Message);
|
|
LogHelper.WriteLog(state+"-WMS报工调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
private void DeleteRepectRst(string id,string msg,string oneBarCode)
|
|
{
|
|
Function.DelInspectRst(id);
|
|
LogHelper.WriteLog($"接口异常,删除塑件[{oneBarCode}]喷涂质检记录,异常内容:" + msg, MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="barCode"></param>
|
|
/// <returns></returns>
|
|
string GetLastInspectRst(string barCode)
|
|
{
|
|
DataTable inspectTable = Function.GetInspectInfoByBarCode2(txtBarCode.Text.Trim());
|
|
if (inspectTable.Rows.Count > 0)
|
|
{
|
|
return inspectTable.Rows[0]["inspectResult"].ToString();
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 发送wms罢工
|
|
/// </summary>
|
|
/// <param name="scanBarCode"></param>
|
|
/// <param name="isOk">0:报废 1:合格 9:返喷 </param>
|
|
bool SendToWms(string scanBarCode, int isOk,ref string errorMsg)
|
|
{
|
|
try
|
|
{
|
|
if (_isTest == "true")
|
|
return true;
|
|
|
|
//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)
|
|
//{
|
|
|
|
// MessageBox.Show("调用远程接口失败");
|
|
// ShowHint("调用远程接口失败: " + errorReason);
|
|
|
|
// _lastJustDict.Clear();
|
|
// _lastJustDict.Add(scanBarCode, isOk.ToString());
|
|
|
|
// return false;
|
|
//}
|
|
//_lastJustDict.Clear();
|
|
return true;
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
throw new Exception("WMS接口调用异常,异常原因:" + ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 判断产品是否有颜色
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
bool CheckColor(ref string colorName,ref string partName)
|
|
{
|
|
string[] ss = null;
|
|
if (string.IsNullOrEmpty(labProductInfo.Text))
|
|
{
|
|
MessageBox.Show("颜色信息有误,请重新扫描");
|
|
return false;
|
|
}
|
|
if (labProductInfo.Text.Contains(","))
|
|
{
|
|
ss = labProductInfo.Text.Split(',');
|
|
}
|
|
else
|
|
{
|
|
ss = labProductInfo.Text.Split(',');
|
|
}
|
|
if (ss.Length >= 1)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ss[0]))
|
|
{
|
|
MessageBox.Show("无颜色信息,请重新扫描");
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("颜色信息有误1,请重新扫描");
|
|
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("必须选择缺陷位置与缺陷原因,否则无法保存!");
|
|
return false;
|
|
}
|
|
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,string userName)
|
|
{
|
|
try
|
|
{
|
|
|
|
return "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ShowHint("质检提交异常,原因:" + ex.Message);
|
|
LogHelper.WriteLog("质检提交:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
MessageBox.Show("质检提交异常,原因:" + ex.Message);
|
|
return null;
|
|
}
|
|
}
|
|
void ShowHint(string txt,bool isOk =false)
|
|
{
|
|
lbForeig.ForeColor = Color.Red;
|
|
lbForeig.Text = txt;
|
|
if(isOk == true)
|
|
{
|
|
lbForeig.ForeColor = Color.Green;
|
|
}
|
|
}
|
|
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
|
|
{
|
|
btnOk.Enabled = true;
|
|
btnRepair.Enabled = true;
|
|
btnNok.Enabled = true;
|
|
|
|
lbForeig.Text = "";
|
|
ClearPage();
|
|
if (string.IsNullOrEmpty(lbPlanCode.Text))
|
|
{
|
|
throw new Exception("当前没有生产计划.");
|
|
}
|
|
ScanBarCode();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("请查看网络是否与服务器连通,无法连通请联系网络管理员。"+ ex);
|
|
LogHelper.WriteLog(ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ScanBarCode()
|
|
{
|
|
try
|
|
{
|
|
ButtonEnable(SetControlGroup());
|
|
//ClearPage();
|
|
|
|
string barcode = txtBarCode.Text.Trim();
|
|
if (barcode.Contains("."))
|
|
{
|
|
barcode = Function.TransToBarCodeOne(barcode);
|
|
}
|
|
|
|
#region 判断条码有效性
|
|
|
|
if (! Function.BarCodeValid(barcode))
|
|
{
|
|
MessageBox.Show("扫描的条码号:"+barcode+"无效,请重新扫描!");
|
|
txtBarCode.Text = "";
|
|
return;
|
|
}
|
|
//bool ispass = ScanCodeValidVerify(barcode);
|
|
//if (ispass == false)
|
|
//{
|
|
// txtBarCode.SelectAll();
|
|
// return;
|
|
//}
|
|
|
|
DataTable stockInTable = Function2.SearchStockIn(barcode);
|
|
if(stockInTable.Rows.Count == 0)
|
|
{
|
|
ShowHint("扫描半成品码没有喷涂完工记录,无法使用.",false);
|
|
return;
|
|
}
|
|
|
|
DataTable punchTable = Function2.SearchPunchCodeRecord(barcode);
|
|
if(punchTable.Rows.Count > 0)
|
|
{
|
|
if(punchTable.Rows[0]["Flag"].ToString() == "0" || punchTable.Rows[0]["Flag"].ToString() == "1")
|
|
{
|
|
ShowHint("扫描半成品码已存在装配记录,无法使用.", false);
|
|
return;
|
|
}
|
|
}
|
|
DataTable productTable = Function2.GetProductInfo(barcode.Substring(0, 10));
|
|
if(productTable.Rows.Count == 0)
|
|
{
|
|
ShowHint($"扫描半成品码的存货代码[{barcode.Substring(0, 10)}]在零件表找不对对应零件号,请检查系统维护.", false);
|
|
return;
|
|
}
|
|
string asselblePartCode = Function2.GetAssemblePartCode(productTable.Rows[0]["PartNo"].ToString(), _stationNo);
|
|
|
|
if(lbProductCode.Text?.ToLower() != asselblePartCode?.ToLower())
|
|
{
|
|
ShowHint($"扫描半成品码在BOM中对应的总成零件号[{asselblePartCode}]与当前计划的零件号[{lbProductCode.Text}]不匹配.", false);
|
|
return;
|
|
}
|
|
|
|
DataTable bomTable = Function2.GetBomTable(asselblePartCode, _stationNo);
|
|
List<DataRow> list = bomTable.AsEnumerable().Where(p => p.Field<int>("IsChecked") == 1).ToList();
|
|
|
|
|
|
#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;
|
|
|
|
if (dLb[i].Text.Contains("点修补"))
|
|
{
|
|
dLb[i].Font = new Font(dLb[i].Font.FontFamily, 36, FontStyle.Bold);
|
|
dLb[i].Size = new Size(170, 60);
|
|
dLb[i].ForeColor = Color.Red;
|
|
//dLb[i].BackColor = Color.Red;
|
|
}
|
|
panel2.Controls.Add(dLb[i]);
|
|
dLb[i].Click += new EventHandler(dLbRoom_Click);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLog("缺陷项-"+ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
throw ex;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 加载图片
|
|
|
|
try
|
|
{
|
|
DataTable dt2 = Function.SearchInfoByBarCode(barcode);
|
|
|
|
if (dt2 != null && dt2.Rows.Count > 0)
|
|
{
|
|
row = Convert.ToInt32(dt2.Rows[0]["Rows"].ToString());
|
|
col = Convert.ToInt32(dt2.Rows[0]["Cols"].ToString());
|
|
picture = dt2.Rows[0]["PicturePath"].ToString();
|
|
}
|
|
dt2.Dispose();
|
|
|
|
if (!string.IsNullOrEmpty(picture))
|
|
{
|
|
if (!File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\" + picture))
|
|
{
|
|
|
|
string strImageURL = Function.GetImgPath() + picture;
|
|
|
|
if(_isTest != "true")
|
|
{
|
|
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.WriteLog("图片项-" + 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<DataRow> list = dtInspect.AsEnumerable().Where(p => p.Field<string>("inspectResult").Contains("打磨")).ToList();
|
|
//string state = string.Empty;
|
|
//if (list.Count > 0)
|
|
//{
|
|
// state = "返喷";
|
|
//}
|
|
//List<DataRow> list2 = dtInspect.AsEnumerable().Where(p => p.Field<string>("inspectResult").Contains("其它")).ToList();
|
|
//if (list2.Count > 0)
|
|
//{
|
|
// if(list2.Where(p=> p.Field<string>("inspectResult")=="其它WMS").Count() > 0)
|
|
// {
|
|
// state = state + ",其它WMS";
|
|
// }
|
|
// if (list2.Where(p => p.Field<string>("inspectResult") == "其它").Count() > 0)
|
|
// {
|
|
// state = state + ",其它";
|
|
// }
|
|
|
|
//}
|
|
|
|
//if (!string.IsNullOrEmpty(state))
|
|
//{
|
|
// lableFP.Text = "存在[" + state + "]状态";
|
|
//}
|
|
|
|
//_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(); //原因
|
|
|
|
//string stationNo = dtInspect.Rows[0]["stationNo"].ToString(); //质检工位
|
|
//if(!_stations.Contains(stationNo))
|
|
//{
|
|
|
|
// //ShowHint(em, false);
|
|
// txtBarCode.Text = "";
|
|
// txtBarCode.TabIndex = 0;
|
|
// txtBarCode.Select();
|
|
// return;
|
|
//}
|
|
|
|
//#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 ((_isSingleStation==true ))
|
|
{
|
|
string paintError = string.Empty;
|
|
//喷涂线边质检,没有质检结果,查询老外数据库,取产品信息
|
|
string foreignVal = string.Empty;
|
|
if(_lineCode == "2")
|
|
{
|
|
foreignVal = Function.GetProductInfoFrWms(barcode, "TM_BJBMPT_MES_DATA", ref paintError);
|
|
}
|
|
else if (_lineCode == "1")
|
|
{
|
|
foreignVal = Function.GetProductInfoFrWms(barcode, "TM_BJBMPT_MES_DATA_OLD", ref paintError);
|
|
|
|
}
|
|
else
|
|
{
|
|
foreignVal = Function.GetProductInfo2(barcode, ref paintError);
|
|
}
|
|
if (!string.IsNullOrEmpty(paintError))
|
|
{
|
|
lbForeig.Text = paintError;
|
|
}
|
|
if (string.IsNullOrEmpty(foreignVal))
|
|
{
|
|
return;
|
|
}
|
|
string[] info = foreignVal.Split(',');
|
|
if (!string.IsNullOrEmpty(paintError))
|
|
{
|
|
ShowHint(paintError);
|
|
}
|
|
_foreighColor = info[0];
|
|
labProductInfo.Text = info[0] + "," + info[1];
|
|
paintId = info[2];
|
|
labProPosition.Tag = paintId;
|
|
labProductInfo.Tag = Function.GetSide(barcode, paintId);
|
|
labProPosition.Text = labProductInfo.Tag.ToString().Replace(';', ' ');
|
|
if (info.Length == 4)
|
|
{
|
|
_foreignPartCode = info[3];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//库房返喷,没有质检结果,不能查老外库,就是条码不正确
|
|
MessageBox.Show("没有喷涂线边质检记录,无法返喷操作!");
|
|
txtBarCode.Text = "";
|
|
txtBarCode.TabIndex = 0;
|
|
txtBarCode.Select();
|
|
return ;
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
txtBarCode.SelectAll();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("请查看网络是否与服务器连通,无法连通请联系网络管理员。" + ex.ToString());
|
|
LogHelper.WriteLog("整体项-" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 一检 二检 点修补扫码是否允许验证
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
private bool ScanCodeValidVerify(string barcode)
|
|
{
|
|
//string position = _stationType;
|
|
// switch (position)
|
|
// {
|
|
// case "下线一检": return First(barcode);
|
|
// case "下线二检": return Second(barcode);;
|
|
// case "下线点修补": return Third(barcode);
|
|
// default:return true;
|
|
|
|
// }
|
|
return true;
|
|
|
|
}
|
|
|
|
private bool First(string barcode)
|
|
{
|
|
if(_isSingleStation == true)
|
|
{
|
|
ShowHint("当前系统配置为[单工位生产],无法在此工位扫码,请去终检工位进行操作.", false);
|
|
return false;
|
|
}
|
|
|
|
DataTable dt = Function.GetLastResult(barcode);
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
ShowHint("扫描条码["+ barcode + "]已存在质检记录,无法在[下线一检]工位进行重新扫码." , false);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private bool Second(string barcode)
|
|
{
|
|
DataTable dt = Function.GetLastResult(barcode);
|
|
if (_isSingleStation == false)
|
|
{
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
ShowHint("扫描条码[" + barcode + "]不存在[下线一检]记录,无法在[下线二检]工位进行扫码.", false);
|
|
return false;
|
|
}
|
|
|
|
DataRow dr = dt.Rows[0];
|
|
if (dr["reason"].ToString().Contains("点修补") && dr["inspectResult"].ToString().Contains("其它"))
|
|
{
|
|
ShowHint("扫描条码[" + barcode + "]上次质量判定为[点修补],无法进行二检扫码.", false);
|
|
return false;
|
|
}
|
|
if (dr["inspectResult"].ToString().Contains("报废"))
|
|
{
|
|
ShowHint("上次质量判定为[报废],无法进行二检扫码.", false);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点修补扫码校验
|
|
/// </summary>
|
|
/// <param name="barcode"></param>
|
|
/// <returns></returns>
|
|
private bool Third(string barcode)
|
|
{
|
|
string errorMsg = string.Empty;
|
|
bool isExsit = Function. GetPointRepairFrWms(barcode, ref errorMsg);
|
|
if(isExsit == false)
|
|
{
|
|
if (!string.IsNullOrEmpty(errorMsg))
|
|
{
|
|
ShowHint("在wms系统的查询返修入库记录时发生错误,错误原因:"+errorMsg, false);
|
|
return false;
|
|
|
|
}
|
|
else{
|
|
ShowHint("没有在wms系统的返修入库记录,无法进行点修补.", false);
|
|
return false;
|
|
}
|
|
|
|
}
|
|
DataTable dt = Function.GetLastResult(barcode);
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
if(dt.Rows[0]["reason"].ToString().Contains("点修补") && dt.Rows[0]["inspectResult"].ToString().Contains("其它"))
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
ShowHint("必须上次质量判定记录为点修补,类型为其它,才能在当前[点修补]工位扫码.", false);
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ShowHint("没有初始质量判定记录,无法在[点修补]工位扫码.", false);
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <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 = "";
|
|
//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 = "";
|
|
_foreighColor = "";
|
|
_foreignPartCode = "";
|
|
_carType = string.Empty;
|
|
}
|
|
|
|
public void ClearRadioButton()
|
|
{
|
|
groupBox1.Controls.Clear();
|
|
}
|
|
|
|
public void ClearTxtBarcode()
|
|
{
|
|
txtBarCode.Text = "";
|
|
labProPosition.Text = "";
|
|
}
|
|
|
|
public void LoadScreen()
|
|
{
|
|
DataTable dt = Function2.GetProScreen(_stationNo);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
SetPage(dt);
|
|
}
|
|
|
|
}
|
|
private void SetPage(DataTable dt)
|
|
{
|
|
IsHigh = "1";
|
|
lbPlanCode.Text = "";
|
|
lbProductCode.Text = "";
|
|
lbProductName.Text = "";
|
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
lbPlanCode.Text = dt.Rows[0]["OrderNo"].ToString();
|
|
lbPlanCode.Tag = dt.Rows[0]["ID"].ToString();
|
|
lbProductName.Text = dt.Rows[0]["ProductName"].ToString();
|
|
lbProductCode.Text = dt.Rows[0]["PartNo"].ToString();
|
|
|
|
SetProduceCount(dt.Rows[0]);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 设置生产数量
|
|
/// </summary>
|
|
/// <param name="planRow"></param>
|
|
void SetProduceCount(DataRow planRow)
|
|
{
|
|
int planQty = 0;
|
|
int okQty = 0;
|
|
int badQty = 0;
|
|
int repairQty = 0;
|
|
|
|
int.TryParse(planRow["OrderCount"].ToString(), out planQty);
|
|
int.TryParse(planRow["OKCount"].ToString(), out okQty);
|
|
int.TryParse(planRow["BadCount"].ToString(), out badQty);
|
|
int.TryParse(planRow["RepairCount"].ToString(), out repairQty);
|
|
lbPlanQty.Text = planQty.ToString();
|
|
lbPlanCompleteQty.Text = (okQty+ badQty).ToString();
|
|
lbOkCount.Text = okQty.ToString();
|
|
lbRepairCount.Text = repairQty.ToString();
|
|
lbBadCount.Text = badQty.ToString();
|
|
}
|
|
|
|
private void btnPlanUp_Click(object sender, EventArgs e)
|
|
{
|
|
LoadPlanScreen(lbPlanCode.Tag?.ToString(), "上一计划");
|
|
txtBarCode.Select();
|
|
txtBarCode.Focus();
|
|
}
|
|
|
|
private void btnPlanDown_Click(object sender, EventArgs e)
|
|
{
|
|
LoadPlanScreen(lbPlanCode.Tag?.ToString(), "下一计划");
|
|
txtBarCode.Select();
|
|
txtBarCode.Focus();
|
|
}
|
|
public void LoadPlanScreen(string id, string plan)
|
|
{
|
|
|
|
DataTable dt = Function2.GetProScreenPlan(id, _stationNo, plan);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
SetPage(dt);
|
|
}
|
|
else
|
|
{
|
|
if (plan == "下一计划")
|
|
{
|
|
MessageBox.Show("无下一计划");
|
|
txtBarCode.SelectAll();
|
|
txtBarCode.Focus();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("无上一计划");
|
|
txtBarCode.SelectAll();
|
|
txtBarCode.Focus();
|
|
}
|
|
}
|
|
txtBarCode.SelectAll();
|
|
txtBarCode.Focus();
|
|
}
|
|
|
|
private void txtBarCode_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
txtBarCode.SelectAll();
|
|
}
|
|
|
|
}
|
|
}
|
|
|