| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- using NPOI.SS.Formula.Functions;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Configuration.Assemblies;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using System.Xml;
- using UAS_MES_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Make
- {
- public partial class Make_BurnInspection : Form
- {
- StringBuilder SQL = new StringBuilder();
- LogStringBuilder sql = new LogStringBuilder();
- DataHelper dh = new DataHelper();
- DataTable Dbfind;
- DataTable dt = new DataTable();
- string SN,WO = "";
- string burnId;
- public Make_BurnInspection()
- {
- InitializeComponent();
- }
- private void Make_WirelessTest_Load(object sender, EventArgs e)
- {
- //设置锁定工单
- LockMakeCode.GetMakeCodeCtl(ma_code);
- ma_code.SetLockCheckBox(LockMakeCode);
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += Ma_code_DbChange;
- dh = SystemInf.dh;
- StartDateTime.Value = EndDateTime.Value.AddDays(-1);
- }
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- //获取工单的其他信息
- sql.Clear();
- sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
- sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,ma_qty from make left join makecraftdetail on ");
- sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "'");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- if (dt.Rows.Count > 0)
- {
- BaseUtil.SetFormValue(this.Controls, dt);
- }
- dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
- if (dt.Rows.Count > 0)
- {
- CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
- }
- SQL.Clear();
- if (!string.IsNullOrEmpty(ma_code.Text))
- {
- SQL.Append($"AND a.work_order = '{ma_code.Text}'");
- }
- if (DateTimeCheck.Checked)
- {
- string startTime = StartDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- string endTime = EndDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
- {
- SQL.Append($"AND a.update_time between to_date('{startTime}','YYYY-MM-DD HH24:MI:SS') AND to_date('{endTime}','YYYY-MM-DD HH24:MI:SS')");
- }
- }
- //if(DataBox.Rows.Count > 0)
- //{
- // DataTable DgvDs = (DataTable)DataBox.DataSource;
- // DgvDs.Clear();
- //}
- dt = (DataTable)dh.ExecuteSql($@"SELECT * FROM (SELECT a.burn_id,a.burn_lotno,a.work_order,
- a.line,a.burn_software,a.check_code,a.dot_detail,a.burn_qty,a.ic_detail,a.update_time,
- b.inspect_time,b.inspect_name,b.inspect_res
- FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burnid
- WHERE 1 = 1 {SQL.ToString()}) WHERE inspect_res IS NULL", "select");
- DataBox.DataSource = dt;
- ShowMsg(1, $"工单: {ma_code.Text} 需抽检烧录 {dt.Rows.Count} 条");
- }
- private void ClearMsg_Click(object sender, EventArgs e)
- {
- OperatResult.Clear();
- }
- private void OK_Click(object sender, EventArgs e)
- {
- PassStation("OK");
- }
- private void NG_Click(object sender, EventArgs e)
- {
- PassStation("NG");
- }
- private void PassStation(string testResult)
- {
- BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
- if (string.IsNullOrEmpty(EmployeeVal.Text))
- {
- ShowMsg(0, $"请填写抽检人员");
- return;
- }
- if (!Regex.IsMatch(EmployeeVal.Text, @"^[\u4e00-\u9fa5][\u4e00-\u9fa5\s·]{0,13}[\u4e00-\u9fa5]$"))
- {
- EmployeeVal.Focus();
- EmployeeVal.SelectAll();
- ShowMsg(0, $"请填写中文抽检人员");
- return;
- }
- if (DataBox.Rows.Count == 0)
- {
- ShowMsg(0, $"请选择筛选出待抽检的烧录信息");
- return;
- }
- if (string.IsNullOrEmpty(BurnLotnoVal.Text))
- {
- ShowMsg(0, $"请扫描烧录批号");
- return;
- }
- if (string.IsNullOrEmpty(InspectNumVal.Text))
- {
- ShowMsg(0, $"请输入抽检数量");
- return;
- }
- burnId = "";
- foreach (DataGridViewRow item in DataBox.Rows)
- {
- string currLotNo = item.Cells["burn_lotno"].Value.ToString();
- if (currLotNo == BurnLotnoVal.Text.Trim())
- {
- burnId = item.Cells["BURN_ID"].Value.ToString();
- }
- }
- if (string.IsNullOrEmpty(burnId))
- {
- ShowMsg(0, $"请抽检筛选出的烧录批号");
- return;
- }
- dt = (DataTable)dh.ExecuteSql($@"select * from burn_inspect where burnlotno = '{BurnLotnoVal.Text}'", "select");
- if (dt.Rows.Count > 0)
- {
- ShowMsg(0, $"批号 {BurnLotnoVal.Text}已抽检");
- return;
- }
- SQL.Clear();
- SQL.Append($@"INSERT INTO burn_inspect (burn_inspect_id,BURNLOTNO,BURNID,
- inspect_res,inspect_time,inspect_name,inspect_num) VALUES (burn_inspect_seq.NEXTVAL, '{BurnLotnoVal.Text}',{burnId},
- '{testResult}',sysdate,'{EmployeeVal.Text.Trim()}','{InspectNumVal.Text.Trim()}')");
- dh.ExecuteSql(SQL.ToString(), "insert");
- ShowMsg(1, $"{BurnLotnoVal.Text} 记录抽检结果{testResult} 成功");
- dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
- if (dt.Rows.Count > 0)
- {
- CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
- }
- SQL.Clear();
- if (!string.IsNullOrEmpty(ma_code.Text))
- {
- SQL.Append($"AND a.work_order = '{ma_code.Text}'");
- }
- if (DateTimeCheck.Checked)
- {
- string startTime = StartDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- string endTime = EndDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
- {
- SQL.Append($"AND a.update_time between to_date('{startTime}','YYYY-MM-DD HH24:MI:SS') AND to_date('{endTime}','YYYY-MM-DD HH24:MI:SS')");
- }
- }
- dt = (DataTable)dh.ExecuteSql($@"SELECT * FROM (SELECT a.burn_id,a.burn_lotno,a.work_order,
- a.line,a.burn_software,a.check_code,a.dot_detail,a.burn_qty,a.ic_detail,a.update_time,
- b.inspect_time,b.inspect_name,b.inspect_res
- FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burnid
- WHERE 1 = 1 {SQL.ToString()}) WHERE inspect_res IS NULL", "select");
- DataBox.DataSource = dt;
- BurnLotnoVal.Focus();
- BurnLotnoVal.SelectAll();
- }
- private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode != Keys.Enter) return;
- if (OkBox.Checked)
- {
- PassStation("OK");
- }
- else
- {
- PassStation("NG");
- }
- }
- private void OkBox_Click(object sender, EventArgs e)
- {
- NgBox.Checked = false;
- }
- private void NgBox_Click(object sender, EventArgs e)
- {
- OkBox.Checked = false;
- }
- private void StartDateTime_ValueChanged(object sender, EventArgs e)
- {
- if (StartDateTime.Value > EndDateTime.Value)
- {
- StartDateTime.Value = EndDateTime.Value.AddDays(-1);
- ShowMsg(0, $"不得大于最早时间");
- return;
- }
- StringBuilder searchSql = new StringBuilder();
- if (!string.IsNullOrEmpty(ma_code.Text))
- {
- searchSql.Append($"AND a.work_order = '{ma_code.Text}'");
- }
- if (DateTimeCheck.Checked)
- {
- string startTime = StartDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- string endTime = EndDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
- {
- searchSql.Append($"AND a.update_time between to_date('{startTime}','YYYY-MM-DD HH24:MI:SS') AND to_date('{endTime}','YYYY-MM-DD HH24:MI:SS')");
- }
- }
- if (!string.IsNullOrEmpty(ma_code.Text) || DateTimeCheck.Checked)
- {
- dt = (DataTable)dh.ExecuteSql($@"SELECT * FROM (SELECT a.burn_id,a.burn_lotno,a.work_order,
- a.line,a.burn_software,a.check_code,a.dot_detail,a.burn_qty,a.ic_detail,a.update_time,
- b.inspect_time,b.inspect_name,b.inspect_res
- FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burnid
- WHERE 1 = 1 {searchSql.ToString()}) WHERE inspect_res IS NULL", "select");
- DataBox.DataSource = dt;
- ShowMsg(1, $"工单: {ma_code.Text} 需抽检烧录 {dt.Rows.Count} 条");
- }
- }
- private void EndDateTime_ValueChanged(object sender, EventArgs e)
- {
- if (StartDateTime.Value > EndDateTime.Value)
- {
- StartDateTime.Value = EndDateTime.Value.AddDays(-1);
- ShowMsg(0, $"不得小于最晚时间");
- return;
- }
- StringBuilder searchSql = new StringBuilder();
- if (!string.IsNullOrEmpty(ma_code.Text))
- {
- searchSql.Append($"AND a.work_order = '{ma_code.Text}'");
- }
- if (DateTimeCheck.Checked)
- {
- string startTime = StartDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- string endTime = EndDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
- if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
- {
- searchSql.Append($"AND a.update_time between to_date('{startTime}','YYYY-MM-DD HH24:MI:SS') AND to_date('{endTime}','YYYY-MM-DD HH24:MI:SS')");
- }
- }
- if (!string.IsNullOrEmpty(ma_code.Text) || DateTimeCheck.Checked)
- {
- dt = (DataTable)dh.ExecuteSql($@"SELECT * FROM (SELECT a.burn_id,a.burn_lotno,a.work_order,
- a.line,a.burn_software,a.check_code,a.dot_detail,a.burn_qty,a.ic_detail,a.update_time,
- b.inspect_time,b.inspect_name,b.inspect_res
- FROM burn_info a LEFT JOIN burn_inspect b ON a.burn_id = b.burnid
- WHERE 1 = 1 {searchSql.ToString()}) WHERE inspect_res IS NULL", "select");
- DataBox.DataSource = dt;
- ShowMsg(1, $"工单: {ma_code.Text} 需抽检烧录 {dt.Rows.Count} 条");
- }
- }
- private void DateTimeCheck_Click(object sender, EventArgs e)
- {
- EndDateTime_ValueChanged(null, null);
- }
- private void ShowMsg(int type, string msg)
- {
- string fullDateTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- if (type == 0)
- {
- OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
- }
- else if (type == 1)
- {
- OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
- }
- else if (type == 1)
- {
- OperatResult.AppendText($"{fullDateTime}: {msg}\n", Color.YellowGreen);
- }
- }
- }
- }
|