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.
356 lines
10 KiB
C#
356 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Configuration;
|
|
using MainProgram.BLL;
|
|
using MainProgram;
|
|
using Estsh.Client.Base;
|
|
using Estsh.Client;
|
|
|
|
namespace Com.Estsh.MES.AssemblyInput
|
|
{
|
|
public partial class YYNGFacadeCheck :Form
|
|
{
|
|
/// <summary>
|
|
/// 返回工位值
|
|
/// </summary>
|
|
private string _input = string.Empty;
|
|
public string Input
|
|
{
|
|
get { return _input; }
|
|
}
|
|
|
|
|
|
//工位
|
|
public int _terminalID;
|
|
//区段
|
|
public int stegeid;
|
|
public string _sn;
|
|
public string _parent_desc;
|
|
private StepLibraryAPP _app = null;
|
|
private int Inum = 1;
|
|
|
|
public YYNGFacadeCheck(StepLibraryAPP app, string sn, int terminalID, string parent_desc)
|
|
{
|
|
|
|
_app = app;
|
|
_terminalID = terminalID;
|
|
_sn = sn;
|
|
_parent_desc=parent_desc;
|
|
|
|
InitializeComponent();
|
|
|
|
LoadDefect();
|
|
}
|
|
|
|
|
|
|
|
private void btnNGType1_Click(object sender, EventArgs e)
|
|
{
|
|
defectOperation(btnNGType1.Name);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入或修改不良项
|
|
/// </summary>
|
|
/// <param name="btnName"></param>
|
|
private void defectOperation(string btnName)
|
|
{
|
|
string button = btnName;
|
|
|
|
foreach (Control ctrl in tableLayoutPanel3.Controls)
|
|
{
|
|
if (ctrl is Button)
|
|
{
|
|
if (ctrl.Name.Equals(button))
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(ctrl.Text.ToString()))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (ctrl.BackColor == Color.Gainsboro)
|
|
{
|
|
operationDefectdetail(_sn, _terminalID, ctrl.Text.ToString(),_parent_desc, "ADD");
|
|
ctrl.BackColor = Color.Red;
|
|
// ShowMessage(this, "Green|【" + ctrl.Text.ToString() + "】不良,新增成功!");
|
|
}
|
|
else if (ctrl.BackColor == Color.Red)
|
|
{
|
|
operationDefectdetail(_sn, _terminalID, ctrl.Text.ToString(), _parent_desc, "DEL");
|
|
ctrl.BackColor = Color.Gainsboro;
|
|
// ShowMessage(this, "Green|【" + ctrl.Text.ToString() + "】不良,删除成功!");
|
|
}
|
|
else
|
|
{
|
|
ctrl.BackColor = Color.Yellow;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增不良明细
|
|
/// </summary>
|
|
private void operationDefectdetail(string sn, int terminalID, string defectName,string parent_desc, string operationType)
|
|
{
|
|
if (operationType.ToUpper() == "ADD")
|
|
{
|
|
_app.addYYSndefectdetail(sn, terminalID, defectName, parent_desc);
|
|
}
|
|
else if ((operationType.ToUpper() == "DEL"))
|
|
{
|
|
_app.delYYSndefectdetail(sn, terminalID, defectName, parent_desc);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取btnNGType值
|
|
/// </summary>
|
|
public void ForeachPanelControls()
|
|
{
|
|
string ctrlName = "btnNGType";
|
|
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
ctrlName = "btnNGType" + i.ToString();
|
|
foreach (Control ctrl in tableLayoutPanel3.Controls)
|
|
{
|
|
if (ctrl is Button)
|
|
{
|
|
if (ctrl.Name.Equals(ctrlName))
|
|
ctrl.Text = "";
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载二级菜单不良类型
|
|
/// </summary>
|
|
private void LoadDefect()
|
|
{
|
|
List<dynamic> DefectList = _app.getDefectDetail(_terminalID,_parent_desc);
|
|
|
|
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 = new DataTable();
|
|
SNDefectLDt = _app.getSNDefectDetail(_sn, _terminalID,_parent_desc);
|
|
|
|
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]["item_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("item_defect_desc" + "='" + strDefect + "'").Length > 0)
|
|
{
|
|
btn.BackColor = Color.Red;
|
|
}
|
|
else
|
|
{
|
|
btn.BackColor = Color.Gainsboro;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上一页
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnLastPage_Click(object sender, EventArgs e)
|
|
{
|
|
Inum--;
|
|
LoadDefect();
|
|
}
|
|
|
|
/// <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 YYNGFacadeCheck_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// 确定
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
/// <summary>
|
|
/// 重置
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
List<dynamic> dt = _app.getSNDefectDetail(_sn, _terminalID, _parent_desc);
|
|
if (dt.Count > 0)
|
|
{
|
|
bool delete = _app.delDefectDetail(_sn, _terminalID, _parent_desc);
|
|
LoadDefect();//重新加载二级菜单不良类型界面
|
|
}
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|