Make_BurnInfo.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using NPOI.SS.Formula;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.CustomControl.ButtonUtil;
  11. using UAS_MES_NEW.DataOperate;
  12. using UAS_MES_NEW.Entity;
  13. using UAS_MES_NEW.PublicMethod;
  14. namespace UAS_MES_NEW.Make
  15. {
  16. public partial class Make_BurnInfo : Form
  17. {
  18. public Make_BurnInfo()
  19. {
  20. InitializeComponent();
  21. }
  22. LogStringBuilder sql = new LogStringBuilder();
  23. DataTable Dbfind;
  24. DataHelper dh;
  25. DataTable dt;
  26. private void Make_BurnInfo_Load(object sender, EventArgs e)
  27. {
  28. //设置锁定工单
  29. LockMakeCode.GetMakeCodeCtl(ma_code);
  30. ma_code.SetLockCheckBox(LockMakeCode);
  31. //工单号放大镜配置
  32. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  33. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  34. ma_code.FormName = Name;
  35. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  36. ma_code.Condition = "ma_statuscode='STARTED'";
  37. ma_code.DbChange += Ma_code_DbChange;
  38. dh = SystemInf.dh;
  39. dt = (DataTable)dh.ExecuteSql("SELECT * FROM line WHERE li_wcname = 'SMT' ORDER BY li_auditdate", "select");
  40. if (dt.Rows.Count > 0)
  41. {
  42. foreach (DataRow item in dt.Rows)
  43. {
  44. LineVal.Items.Add(item["li_code"].ToString());
  45. }
  46. }
  47. }
  48. private void Ma_code_DbChange(object sender, EventArgs e)
  49. {
  50. Dbfind = ma_code.ReturnData;
  51. BaseUtil.SetFormValue(this.Controls, Dbfind);
  52. //获取工单的其他信息
  53. sql.Clear();
  54. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
  55. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail on ");
  56. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  57. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  58. if (dt.Rows.Count > 0)
  59. {
  60. BaseUtil.SetFormValue(this.Controls, dt);
  61. }
  62. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME FROM burn_info WHERE work_order = '{ma_code.Text}'", "select");
  63. if (dt.Rows.Count > 0)
  64. {
  65. DataBox.DataSource = dt;
  66. }
  67. }
  68. private void Confirm_Click(object sender, EventArgs e)
  69. {
  70. if (string.IsNullOrEmpty(ma_code.Text))
  71. {
  72. ShowMsg(0, "请选择归属工单");
  73. ma_code.Focus();
  74. return;
  75. }
  76. if (string.IsNullOrEmpty(LineVal.Text))
  77. {
  78. ShowMsg(0, "请选择线体");
  79. LineVal.Focus();
  80. LineVal.SelectAll();
  81. return;
  82. }
  83. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  84. {
  85. ShowMsg(0, "请扫描包批次号");
  86. BurnLotnoVal.Focus();
  87. BurnLotnoVal.SelectAll();
  88. return;
  89. }
  90. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  91. if (dt.Rows.Count > 0)
  92. {
  93. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已记录,请勿重复使用");
  94. return;
  95. }
  96. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  97. check_code,dot_detail,line,
  98. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  99. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}',
  100. '{User.UserName}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  101. BurnLotnoVal.Focus();
  102. BurnLotnoVal.SelectAll();
  103. BurnSwVal.Text = "";
  104. CheckCodeVal.Text = "";
  105. DotVal.Text = "";
  106. ShowMsg(1, "添加烧录信息成功");
  107. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME FROM burn_info WHERE work_order = '{ma_code.Text}'", "select");
  108. if (dt.Rows.Count > 0)
  109. {
  110. DataBox.DataSource = dt;
  111. }
  112. }
  113. private void ShowMsg(int type, string msg)
  114. {
  115. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  116. if (type == 0)
  117. {
  118. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  119. }
  120. else if (type == 1)
  121. {
  122. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  123. }
  124. }
  125. private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
  126. {
  127. if (e.KeyCode != Keys.Enter) return;
  128. BurnSwVal.Focus();
  129. BurnSwVal.SelectAll();
  130. }
  131. private void BurnSwVal_KeyDown(object sender, KeyEventArgs e)
  132. {
  133. if (e.KeyCode != Keys.Enter) return;
  134. CheckCodeVal.Focus();
  135. CheckCodeVal.SelectAll();
  136. }
  137. private void CheckCodeVal_KeyDown(object sender, KeyEventArgs e)
  138. {
  139. if (e.KeyCode != Keys.Enter) return;
  140. DotVal.Focus();
  141. DotVal.SelectAll();
  142. }
  143. private void DotVal_KeyDown(object sender, KeyEventArgs e)
  144. {
  145. if (e.KeyCode != Keys.Enter) return;
  146. Confirm.Focus();
  147. }
  148. private void ClearMsg_Click(object sender, EventArgs e)
  149. {
  150. OperateResult.Clear();
  151. }
  152. }
  153. }