Make_BurnInfo.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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,ma_qty 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 + "'");
  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. ShowMsg(1, $"工单: {ma_code.Text} 已找到{dt.Rows.Count}条烧录记录");
  68. }
  69. private void Confirm_Click(object sender, EventArgs e)
  70. {
  71. if (string.IsNullOrEmpty(ma_code.Text))
  72. {
  73. ShowMsg(0, "请选择归属工单");
  74. ma_code.Focus();
  75. return;
  76. }
  77. /*if (string.IsNullOrEmpty(LineVal.Text))
  78. {
  79. ShowMsg(0, "请选择线体");
  80. LineVal.Focus();
  81. LineVal.SelectAll();
  82. return;
  83. }*/
  84. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  85. {
  86. ShowMsg(0, "请扫描包批次号");
  87. BurnLotnoVal.Focus();
  88. BurnLotnoVal.SelectAll();
  89. return;
  90. }
  91. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  92. if (dt.Rows.Count > 0)
  93. {
  94. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已记录,请勿重复使用");
  95. return;
  96. }
  97. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  98. check_code,dot_detail,line,
  99. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  100. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}',
  101. '{User.UserName}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  102. BurnLotnoVal.Focus();
  103. BurnLotnoVal.SelectAll();
  104. BurnSwVal.Text = "";
  105. CheckCodeVal.Text = "";
  106. DotVal.Text = "";
  107. ShowMsg(1, "添加烧录信息成功");
  108. 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");
  109. if (dt.Rows.Count > 0)
  110. {
  111. DataBox.DataSource = dt;
  112. }
  113. }
  114. private void ShowMsg(int type, string msg)
  115. {
  116. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  117. if (type == 0)
  118. {
  119. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  120. }
  121. else if (type == 1)
  122. {
  123. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  124. }
  125. }
  126. private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
  127. {
  128. if (e.KeyCode != Keys.Enter) return;
  129. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  130. if (!string.IsNullOrEmpty(BurnLotnoVal.Text))
  131. {
  132. dt = (DataTable)dh.ExecuteSql($"select * from barcode where bar_code = '{BurnLotnoVal.Text}'", "select");
  133. if (dt.Rows.Count == 0)
  134. {
  135. ShowMsg(0, $"条码:{BurnLotnoVal.Text} 不是MES系统中库存条码");
  136. BurnLotnoVal.Text = "";
  137. return;
  138. }
  139. }
  140. if (string.IsNullOrEmpty(ma_code.Text))
  141. {
  142. ShowMsg(0, "请选择归属工单");
  143. ma_code.Focus();
  144. return;
  145. }
  146. if (string.IsNullOrEmpty(EmployeeVal.Text))
  147. {
  148. ShowMsg(0, "请输入操作人员");
  149. ma_code.Focus();
  150. return;
  151. }
  152. /*if (string.IsNullOrEmpty(LineVal.Text))
  153. {
  154. ShowMsg(0, "请选择线体");
  155. LineVal.Focus();
  156. LineVal.SelectAll();
  157. return;
  158. }*/
  159. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  160. {
  161. ShowMsg(0, "请扫描包批次号");
  162. BurnLotnoVal.Focus();
  163. BurnLotnoVal.SelectAll();
  164. return;
  165. }
  166. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  167. if (dt.Rows.Count > 0)
  168. {
  169. ShowMsg(0, $"批号:{BurnLotnoVal.Text} 已记录,请勿重复使用");
  170. return;
  171. }
  172. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  173. check_code,dot_detail,line,
  174. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  175. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}',
  176. '{EmployeeVal.Text}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  177. BurnLotnoVal.Focus();
  178. BurnLotnoVal.SelectAll();
  179. BurnLotnoVal.Text = "";
  180. /*BurnSwVal.Text = "";
  181. CheckCodeVal.Text = "";
  182. DotVal.Text = "";*/
  183. ShowMsg(1, $"批号:{BurnLotnoVal.Text} 添加烧录信息成功");
  184. 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");
  185. if (dt.Rows.Count > 0)
  186. {
  187. DataBox.DataSource = dt;
  188. }
  189. }
  190. private void BurnSwVal_KeyDown(object sender, KeyEventArgs e)
  191. {
  192. if (e.KeyCode != Keys.Enter) return;
  193. CheckCodeVal.Focus();
  194. CheckCodeVal.SelectAll();
  195. }
  196. private void CheckCodeVal_KeyDown(object sender, KeyEventArgs e)
  197. {
  198. if (e.KeyCode != Keys.Enter) return;
  199. DotVal.Focus();
  200. DotVal.SelectAll();
  201. }
  202. private void DotVal_KeyDown(object sender, KeyEventArgs e)
  203. {
  204. if (e.KeyCode != Keys.Enter) return;
  205. Confirm.Focus();
  206. }
  207. private void ClearMsg_Click(object sender, EventArgs e)
  208. {
  209. OperateResult.Clear();
  210. }
  211. }
  212. }