You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
414 lines
12 KiB
C#
414 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Estsh.Client.Base;
|
|
using System.Configuration;
|
|
using MainProgram;
|
|
using MainProgram.BLL;
|
|
using System.IO;
|
|
|
|
|
|
namespace Estsh.Client.StepLibrary
|
|
{
|
|
public partial class OutPdlineInspection : StepBase
|
|
{
|
|
private StepLibraryAPP _app = null;
|
|
private List<dynamic> _CheckData = null; //绑定数据
|
|
private delegate void DeleGrdBind(List<dynamic> dt);
|
|
private int _terminalID = 0;
|
|
private string _sn = "";
|
|
|
|
private int Inum = 1;
|
|
|
|
//PASS间隔限制工位集合
|
|
private string _passIntervalLimit = string.Empty;
|
|
|
|
public OutPdlineInspection()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// 有用户界面的工步在初始化时需要设置为不可见
|
|
// 开始执行此工步后再置为可见
|
|
this.Visible = false;
|
|
|
|
|
|
}
|
|
|
|
public override bool Do()
|
|
{
|
|
try
|
|
{
|
|
// 置为可见并加载到最前端
|
|
this.Visible = true;
|
|
this.BringToFront();
|
|
|
|
// 从配置文件中加载工位编号
|
|
_terminalID = Convert.ToInt32(Context["terminal_id"].ToString());
|
|
_sn = Context["serial_number"].ToString();
|
|
|
|
_app = new StepLibraryAPP(httpClient);
|
|
string _PartNo = _app.GetPartNo(_sn);
|
|
string rule = _app.GetRuleNo(_PartNo);
|
|
string partLocation = _app.GetPartLoc(_PartNo);
|
|
|
|
|
|
// 执行父类的 Do 方法并返回
|
|
return base.Do();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// 记录日志
|
|
using (StreamWriter sw = new StreamWriter("Error_Log_" + DateTime.Now.ToString("yyyyMM") + ".txt", true))
|
|
{
|
|
sw.WriteLine(string.Format("{0} {1}", "["
|
|
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
+ "] ", ex.ToString()));
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ForeachPanelControls()
|
|
{
|
|
string ctrlName = "btnNGType";
|
|
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
ctrlName = "btnNGType" + i.ToString();
|
|
foreach (Control ctrl in tableLayoutPanel1.Controls)
|
|
{
|
|
if (ctrl is Button)
|
|
{
|
|
if (ctrl.Name.Equals(ctrlName))
|
|
ctrl.Text = "";
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OutPdlineInspection_Load(object sender, EventArgs e)
|
|
{
|
|
_sn = Context["serial_number"].ToString();
|
|
|
|
_app = new StepLibraryAPP(httpClient);
|
|
_terminalID = Convert.ToInt32(Context["terminal_id"].ToString());
|
|
|
|
ForeachPanelControls();
|
|
|
|
|
|
LoadDefect();
|
|
|
|
// 工步执行完成后调用此方法
|
|
//Complate(this, e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下一页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnNextPage_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
Inum++;
|
|
LoadDefect();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上一页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnLastPage_Click(object sender, EventArgs e)
|
|
{
|
|
Inum--;
|
|
LoadDefect();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载不良
|
|
/// </summary>
|
|
private void LoadDefect()
|
|
{
|
|
List<dynamic> DefectList = _app.getDefectList();
|
|
|
|
int CountQty = DefectList.Count; //一页有多少行
|
|
int PageRows = 16;
|
|
int PageCount = (int)Math.Ceiling((double)CountQty / (double)PageRows);//一共有多少页
|
|
int RowsEnd = 0;//终止行数
|
|
//Inum:当前页数
|
|
|
|
if (Inum < 1)
|
|
{
|
|
Inum++;
|
|
return;
|
|
}
|
|
else if (Inum > PageCount)
|
|
{
|
|
Inum--;
|
|
return;
|
|
}
|
|
|
|
//颜色初始化
|
|
btnNGType1.BackColor = Color.Gainsboro;
|
|
btnNGType2.BackColor = Color.Gainsboro;
|
|
btnNGType3.BackColor = Color.Gainsboro;
|
|
btnNGType4.BackColor = Color.Gainsboro;
|
|
btnNGType5.BackColor = Color.Gainsboro;
|
|
btnNGType6.BackColor = Color.Gainsboro;
|
|
btnNGType7.BackColor = Color.Gainsboro;
|
|
btnNGType8.BackColor = Color.Gainsboro;
|
|
btnNGType9.BackColor = Color.Gainsboro;
|
|
btnNGType10.BackColor = Color.Gainsboro;
|
|
btnNGType11.BackColor = Color.Gainsboro;
|
|
btnNGType12.BackColor = Color.Gainsboro;
|
|
btnNGType13.BackColor = Color.Gainsboro;
|
|
btnNGType14.BackColor = Color.Gainsboro;
|
|
btnNGType15.BackColor = Color.Gainsboro;
|
|
btnNGType16.BackColor = Color.Gainsboro;
|
|
|
|
string strInum = Inum.ToString() + "/" + PageCount.ToString();
|
|
btnInum.Text = strInum;
|
|
|
|
ForeachPanelControls();
|
|
|
|
List<dynamic> SNDefectLDt = _app.getSNDefect(_sn, _terminalID);
|
|
|
|
for (int i = 1; i <= Inum * PageRows; i++)
|
|
{
|
|
int j = 0;
|
|
if (Inum > 1)
|
|
{
|
|
j = i + 16;
|
|
}
|
|
else
|
|
{
|
|
j = i;
|
|
}
|
|
|
|
if (CountQty < j)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string strDefect = DefectList[j - 1]["defect_desc"].ToString();
|
|
string button = "btnNGType" + i.ToString();
|
|
Button btn = (Button)this.GetType().GetField(button, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
|
|
btn.Text = strDefect;
|
|
|
|
|
|
if (SNDefectLDt.Select("defect_desc" + "='" + strDefect + "'").Length > 0)
|
|
{
|
|
btn.BackColor = Color.Red;
|
|
}
|
|
else
|
|
{
|
|
btn.BackColor = Color.Gainsboro;
|
|
}
|
|
//ForeachPanelControls(button);
|
|
}
|
|
if (_app.getSNifunc(_sn))
|
|
{
|
|
if (btnNGType14.BackColor == Color.Red)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
defectOperation(btnNGType14.Name);
|
|
}
|
|
|
|
}
|
|
ShowMessage(this, "Green|请检测座椅,并选择不良项!");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增不良明细
|
|
/// </summary>
|
|
private void operationDefect(string sn, int terminalID, string defectName, string operationType)
|
|
{
|
|
if (operationType.ToUpper() == "ADD")
|
|
{
|
|
_app.addSndefect(sn, terminalID, defectName);
|
|
}
|
|
else if ((operationType.ToUpper() == "DEL"))
|
|
{
|
|
_app.delSndefect(sn, terminalID, defectName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入或修改不良项
|
|
/// </summary>
|
|
/// <param name="btnName"></param>
|
|
private void defectOperation(string btnName)
|
|
{
|
|
string button = btnName;
|
|
|
|
foreach (Control ctrl in tableLayoutPanel1.Controls)
|
|
{
|
|
if (ctrl is Button)
|
|
{
|
|
if (ctrl.Name.Equals(button))
|
|
{
|
|
//ctrl.Text = strDefect;
|
|
|
|
if (ctrl.BackColor == Color.Gainsboro)
|
|
{
|
|
if (string.IsNullOrEmpty(ctrl.Text.ToString()))
|
|
{
|
|
return;
|
|
}
|
|
operationDefect(_sn, _terminalID, ctrl.Text.ToString(), "ADD");
|
|
ctrl.BackColor = Color.Red;
|
|
ShowMessage(this, "Green|【" + ctrl.Text.ToString() + "】不良,新增成功!");
|
|
}
|
|
else if (ctrl.BackColor == Color.Red)
|
|
{
|
|
operationDefect(_sn, _terminalID, ctrl.Text.ToString(), "DEL");
|
|
ctrl.BackColor = Color.Gainsboro;
|
|
ShowMessage(this, "Green|【" + ctrl.Text.ToString() + "】不良,删除成功!");
|
|
}
|
|
else
|
|
{
|
|
ctrl.BackColor = Color.Yellow;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btnNGType1_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType1.Name);
|
|
|
|
//if (btnNGType1.BackColor == Color.Gainsboro)
|
|
//{
|
|
// operationDefect(_sn, _terminalID, btnNGType1.Text.ToString(), "ADD");
|
|
// btnNGType1.BackColor = Color.Red;
|
|
//}
|
|
//else if (btnNGType1.BackColor == Color.Red)
|
|
//{
|
|
// operationDefect(_sn, _terminalID, btnNGType1.Text.ToString(), "DEL");
|
|
// btnNGType1.BackColor = Color.Gainsboro;
|
|
//}
|
|
}
|
|
|
|
private void btnNGType2_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType2.Name);
|
|
}
|
|
|
|
private void btnNGType3_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType3.Name);
|
|
}
|
|
|
|
private void btnNGType4_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType4.Name);
|
|
}
|
|
|
|
private void btnNGType5_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType5.Name);
|
|
}
|
|
|
|
private void btnNGType6_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType6.Name);
|
|
}
|
|
|
|
private void btnNGType7_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType7.Name);
|
|
}
|
|
|
|
private void btnNGType8_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType8.Name);
|
|
}
|
|
|
|
private void btnNGType9_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType9.Name);
|
|
}
|
|
|
|
private void btnNGType10_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType10.Name);
|
|
}
|
|
|
|
private void btnNGType11_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType11.Name);
|
|
}
|
|
|
|
private void btnNGType12_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType12.Name);
|
|
}
|
|
|
|
private void btnNGType13_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType13.Name);
|
|
}
|
|
|
|
private void btnNGType14_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType14.Name);
|
|
}
|
|
|
|
private void btnNGType15_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType15.Name);
|
|
}
|
|
|
|
private void btnNGType16_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType16.Name);
|
|
}
|
|
|
|
private void btnRework_Click(object sender, EventArgs e)
|
|
{
|
|
List<dynamic> SNDefectLDt = new DataTable();
|
|
SNDefectLDt = _app.getSNDefect(_sn, _terminalID);
|
|
|
|
if (SNDefectLDt.Count <= 0)
|
|
{
|
|
ShowMessage(this, "red|【" + _sn + "】没有添加不良项,请选择不良类型!");
|
|
return;
|
|
}
|
|
|
|
StopStep(1);
|
|
}
|
|
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
List<dynamic> SNDefectLDt = new DataTable();
|
|
SNDefectLDt = _app.getSNDefect(_sn, _terminalID);
|
|
|
|
if (SNDefectLDt.Count > 0)
|
|
{
|
|
ShowMessage(this, "red|【" + _sn + "】有不良项,请重新确认!");
|
|
return;
|
|
}
|
|
|
|
// 工步执行完成后调用此方法
|
|
Complate(this, e);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|