| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_EquiConnect : Form
- {
- public Make_EquiConnect()
- {
- InitializeComponent();
- }
- StringBuilder SQL = new StringBuilder();
- DataHelper dh = SystemInf.dh;
- DataTable dt;
- private void Make_EquiConnect_Load(object sender, EventArgs e)
- {
- dt = (DataTable)dh.ExecuteSql("SELECT * FROM line WHERE li_wcname = 'SMT' ORDER BY li_auditdate", "select");
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- LineVal.Items.Add(item["li_code"].ToString());
- }
- }
- }
- private void OK_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(EmployeeVal.Text))
- {
- ShowMsg(0, "请输入抽检人员姓名");
- return;
- }
- /*if (string.IsNullOrEmpty(LineVal.Text))
- {
- ShowMsg(0, "请选择线体");
- return;
- }*/
- if (string.IsNullOrEmpty(SNVal.Text))
- {
- ShowMsg(0, "请选择扫描序列号");
- return;
- }
- //InsertLog("OK");
- }
- private void NG_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(EmployeeVal.Text))
- {
- ShowMsg(0, "请输入抽检人员姓名");
- return;
- }
- /*if (string.IsNullOrEmpty(LineVal.Text))
- {
- ShowMsg(0, "请选择线体");
- return;
- }*/
- if (string.IsNullOrEmpty(SNVal.Text))
- {
- ShowMsg(0, "请选择扫描序列号");
- return;
- }
- //InsertLog("NG");
- }
- private void InsertLog(string sn, string resType, string main_sn = "")
- {
- dt = (DataTable)dh.ExecuteSql($@"select * from steptestdetail where std_class = 'Xray抽检' and std_sn = '{sn}'", "select");
- if (dt.Rows.Count > 0)
- {
- if (string.IsNullOrEmpty(main_sn))
- {
- ShowMsg(0, $"序列号:{sn} 已采集Xray信息");
- return;
- }
- else
- {
- ShowMsg(0, $"拼板号:{main_sn} 中序列号:{sn} ,已采集Xray信息");
- return;
- }
- }
- UpdateSN("L", sn);
- SQL.Clear();
- SQL.Append($@"INSERT INTO steptestdetail (std_id,std_sn,std_makecode,std_class,std_testresult,std_indate,STD_SUBCLASS1,STD_SUBCLASS2)
- VALUES (steptestdetail_seq.NEXTVAL, '{sn}','{workOrder.Text.Trim()}','Xray抽检','{resType}',sysdate, '{LineVal.Text}','{EmployeeVal.Text.Trim()}')");
- dh.ExecuteSql(SQL.ToString(), "insert");
- if (string.IsNullOrEmpty(main_sn))
- {
- ShowMsg(1, $"已记录 {sn},测试结果为 {resType}");
- }
- else
- {
- ShowMsg(1, $"拼板号:{main_sn} 已记录序列号:{sn} ,测试结果为 {resType}");
- }
- }
- private void ShowMsg(int type, string msg)
- {
- msg = msg.Replace("\r", "").Replace("\n", "");
- string msgTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- string showMsg = $"{msgTime}: {msg}\n";
- if (type == 0)
- {
- OperatResult.AppendText(showMsg, Color.Red);
- }
- else if (type == 1)
- {
- OperatResult.AppendText(showMsg, Color.Green);
- }
- else if (type == 2)
- {
- OperatResult.AppendText(showMsg, Color.GreenYellow);
- }
- }
- private void UpdateSN(string type, string sn)
- {
- if (type == "C")
- {
- serialNumber.Text = "";
- workOrder.Text = "";
- productCode.Text = "";
- productName.Text = "";
- TargetQty.Text = "";
- }
- else if (type == "L")
- {
- SQL.Clear();
- SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec,ma_qty FROM makeserial,make,product
- WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
- dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
- if (dt.Rows.Count > 0)
- {
- serialNumber.Text = dt.Rows[0]["ms_sncode"].ToString();
- workOrder.Text = dt.Rows[0]["ma_code"].ToString();
- productCode.Text = dt.Rows[0]["pr_code"].ToString();
- productName.Text = dt.Rows[0]["pr_spec"].ToString();
- TargetQty.Text = dt.Rows[0]["ma_qty"].ToString();
- }
- else
- {
- UpdateSN("C", sn);
- }
- }
- }
- private void EmployeeVal_KeyDown_1(object sender, KeyEventArgs e)
- {
- if (e.KeyCode != Keys.Enter) return;
- if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
- /*dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
- if (dt.Rows.Count == 0)
- {
- MessageBox.Show("请输入正确人员账号");
- EmployeeVal.Text = "";
- EmployeeVal.Focus();
- EmployeeVal.SelectAll();
- return;
- }*/
- }
- private void EmployeeVal_Leave_1(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(EmployeeVal.Text)) return;
- /*dt = (DataTable)dh.ExecuteSql($"select * from employee where em_name = '{EmployeeVal.Text.Trim()}'", "select");
- if (dt.Rows.Count == 0)
- {
- MessageBox.Show("请输入正确人员账号");
- EmployeeVal.Text = "";
- EmployeeVal.Focus();
- EmployeeVal.SelectAll();
- return;
- }*/
- }
- private void NgBox_Click(object sender, EventArgs e)
- {
- OkBox.Checked = false;
- }
- private void OkBox_Click(object sender, EventArgs e)
- {
- NgBox.Checked = false;
- }
- private void SnType1_Click(object sender, EventArgs e)
- {
- SnType2.Checked = false;
- }
- private void SnType2_Click(object sender, EventArgs e)
- {
- SnType1.Checked = false;
- }
- private void SNVal_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode != Keys.Enter) return;
- SNVal.Text = SNVal.Text.Trim();
- if (string.IsNullOrEmpty(EmployeeVal.Text))
- {
- ShowMsg(0, "请输入抽检人员姓名");
- return;
- }
- if (!OkBox.Checked && !NgBox.Checked)
- {
- ShowMsg(0, "请勾选判定结果");
- return;
- }
- /*if (!SnType1.Checked && !SnType2.Checked)
- {
- ShowMsg(0, "请勾选序列号类型");
- return;
- }*/
- if (string.IsNullOrEmpty(SNVal.Text))
- {
- ShowMsg(0, "请选择扫描序列号");
- return;
- }
- List<string> snList = new List<string>();
- dt = (DataTable)dh.ExecuteSql($@"select * from smtbind where sb_maincode = '{SNVal.Text.Trim()}'", "select");
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- snList.Add(dr["sb_barcode"].ToString());
- }
- foreach (string str in snList)
- {
- dt = (DataTable)dh.ExecuteSql($@"SELECT ms_makecode,ms_prodcode,cd_stepcode,cd_stepname,cd_stepno FROM makeserial,craft,craftdetail
- WHERE ms_sncode = '{str}' AND ms_prodcode = cr_prodcode AND cr_id = cd_crid AND cd_stepno = 1 ORDER BY cd_stepno", "select");
- if (dt.Rows.Count == 0)
- {
- ShowMsg(0, $"拼板号:{SNVal.Text} 中序列号:{str} 无归属记录,请过投入站后再采集Xray信息");
- return;
- }
- dt = (DataTable)dh.ExecuteSql($@"SELECT mp_linecode FROM makeprocess WHERE mp_sncode = '{str}' AND mp_stepcode = '{dt.Rows[0]["cd_stepcode"]}'", "select");
- if (dt.Rows.Count == 0)
- {
- ShowMsg(0, $"拼板号:{SNVal.Text} 中序列号:{str} 无投入过站记录,请过投入站后再采集Xray信息");
- return;
- }
- for (int i = 0; i <= LineVal.Items.Count; i++)
- {
- string mplinecode = dt.Rows[0]["mp_linecode"].ToString();
- string allLine = LineVal.Items[i].ToString();
- if (mplinecode == allLine)
- {
- LineVal.SelectedIndex = i;
- break;
- }
- }
- InsertLog(str, OkBox.Checked ? "OK" : "NG", SNVal.Text.Trim());
- }
- }
- else
- {
- dt = (DataTable)dh.ExecuteSql($@"SELECT ms_makecode,ms_prodcode,cd_stepcode,cd_stepname,cd_stepno FROM makeserial,craft,craftdetail
- WHERE ms_sncode = '{SNVal.Text}' AND ms_prodcode = cr_prodcode AND cr_id = cd_crid AND cd_stepno = 1 ORDER BY cd_stepno", "select");
- if (dt.Rows.Count == 0)
- {
- ShowMsg(0, $"序列号:{SNVal.Text} 无归属记录,请过投入站后再采集Xray信息");
- return;
- }
- dt = (DataTable)dh.ExecuteSql($@"SELECT mp_linecode FROM makeprocess WHERE mp_sncode = '{SNVal.Text}' AND mp_stepcode = '{dt.Rows[0]["cd_stepcode"]}'", "select");
- if (dt.Rows.Count == 0)
- {
- ShowMsg(0, $"序列号:{SNVal.Text} 无投入过站记录,请过投入站后再采集Xray信息");
- return;
- }
- for (int i = 0; i <= LineVal.Items.Count; i++)
- {
- string mplinecode = dt.Rows[0]["mp_linecode"].ToString();
- string allLine = LineVal.Items[i].ToString();
- if (mplinecode == allLine)
- {
- LineVal.SelectedIndex = i;
- break;
- }
- }
- InsertLog(SNVal.Text.Trim(), OkBox.Checked ? "OK" : "NG");
- }
- //if (string.IsNullOrEmpty(LineVal.Text))
- //{
- // ShowMsg(0, "请选择线体");
- // return;
- //}
- SNVal.Focus();
- SNVal.SelectAll();
- SNVal.Text = "";
- }
- }
- }
|