Make_BurnInfo.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.Make
  13. {
  14. public partial class Make_BurnInfo : Form
  15. {
  16. public Make_BurnInfo()
  17. {
  18. InitializeComponent();
  19. }
  20. LogStringBuilder sql = new LogStringBuilder();
  21. DataTable Dbfind;
  22. DataHelper dh;
  23. DataTable dt;
  24. string remainQty;
  25. private void Make_BurnInfo_Load(object sender, EventArgs e)
  26. {
  27. //设置锁定工单
  28. LockMakeCode.GetMakeCodeCtl(ma_code);
  29. ma_code.SetLockCheckBox(LockMakeCode);
  30. //工单号放大镜配置
  31. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  32. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称";
  33. ma_code.FormName = Name;
  34. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail" };
  35. ma_code.Condition = "ma_statuscode='STARTED'";
  36. ma_code.DbChange += Ma_code_DbChange;
  37. dh = SystemInf.dh;
  38. dt = (DataTable)dh.ExecuteSql("SELECT * FROM line WHERE li_wcname = 'SMT' ORDER BY li_auditdate", "select");
  39. if (dt.Rows.Count > 0)
  40. {
  41. foreach (DataRow item in dt.Rows)
  42. {
  43. LineVal.Items.Add(item["li_code"].ToString());
  44. }
  45. }
  46. }
  47. private void Ma_code_DbChange(object sender, EventArgs e)
  48. {
  49. Dbfind = ma_code.ReturnData;
  50. BaseUtil.SetFormValue(this.Controls, Dbfind);
  51. //获取工单的其他信息
  52. sql.Clear();
  53. sql.Append("select ma_code,nvl(mcd_okqty,0) mcd_okqty,ma_prodcode as pr_code ,pr_detail,");
  54. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,ma_qty from make left join makecraftdetail on ");
  55. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "'");
  56. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  57. if (dt.Rows.Count > 0)
  58. {
  59. BaseUtil.SetFormValue(this.Controls, dt);
  60. }
  61. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME,BURN_QTY,inspect_res,IC_DETAIL FROM burn_info LEFT JOIN burn_inspect ON burn_id = burnid WHERE work_order = '{ma_code.Text}'", "select");
  62. DataBox.DataSource = dt;
  63. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  64. if (dt.Rows.Count > 0)
  65. {
  66. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  67. }
  68. ShowMsg(1, $"工单: {ma_code.Text} 已找到{dt.Rows.Count}条烧录记录");
  69. }
  70. private void Confirm_Click(object sender, EventArgs e)
  71. {
  72. if (string.IsNullOrEmpty(ma_code.Text))
  73. {
  74. ShowMsg(0, "请选择归属工单");
  75. ma_code.Focus();
  76. return;
  77. }
  78. /*if (string.IsNullOrEmpty(LineVal.Text))
  79. {
  80. ShowMsg(0, "请选择线体");
  81. LineVal.Focus();
  82. LineVal.SelectAll();
  83. return;
  84. }*/
  85. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  86. {
  87. ShowMsg(0, "请扫描包批次号");
  88. BurnLotnoVal.Focus();
  89. BurnLotnoVal.SelectAll();
  90. return;
  91. }
  92. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  93. if (dt.Rows.Count > 0)
  94. {
  95. ShowMsg(0, $"批号 {BurnLotnoVal.Text}已记录,请勿重复使用");
  96. return;
  97. }
  98. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  99. check_code,dot_detail,line,burn_qty,
  100. update_name,update_time,work_order) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  101. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}','{remainQty}',
  102. '{User.UserName}',sysdate,'{ma_code.Text.Trim()}')", "insert");
  103. BurnLotnoVal.Focus();
  104. BurnLotnoVal.SelectAll();
  105. BurnSwVal.Text = "";
  106. CheckCodeVal.Text = "";
  107. DotVal.Text = "";
  108. ShowMsg(1, "添加烧录信息成功");
  109. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME,BURN_QTY,inspect_res,IC_DETAIL FROM burn_info LEFT JOIN burn_inspect ON burn_id = burnid WHERE work_order = '{ma_code.Text}'", "select");
  110. DataBox.DataSource = dt;
  111. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  112. if (dt.Rows.Count > 0)
  113. {
  114. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  115. }
  116. }
  117. private void ShowMsg(int type, string msg)
  118. {
  119. string fullDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  120. if (type == 0)
  121. {
  122. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Red);
  123. }
  124. else if (type == 1)
  125. {
  126. OperateResult.AppendText($"{fullDateTime}: {msg}\n", Color.Green);
  127. }
  128. }
  129. private void BurnLotnoVal_KeyDown(object sender, KeyEventArgs e)
  130. {
  131. if (e.KeyCode != Keys.Enter) return;
  132. BurnLotnoVal.Text = BurnLotnoVal.Text.Trim();
  133. if (!string.IsNullOrEmpty(BurnLotnoVal.Text))
  134. {
  135. dt = (DataTable)dh.ExecuteSql($"select * from barcode where bar_code = '{BurnLotnoVal.Text}'", "select");
  136. if (dt.Rows.Count == 0)
  137. {
  138. ShowMsg(0, $"条码:{BurnLotnoVal.Text} 不是MES系统中库存条码");
  139. BurnLotnoVal.Text = "";
  140. return;
  141. }
  142. remainQty = dt.Rows[0]["BAR_REMAIN"].ToString();
  143. }
  144. if (string.IsNullOrEmpty(ma_code.Text))
  145. {
  146. ShowMsg(0, "请选择归属工单");
  147. ma_code.Focus();
  148. return;
  149. }
  150. if(Convert.ToInt32(CurrQtyVal.Text) > Convert.ToInt32(ma_qty.Text))
  151. {
  152. ShowMsg(0, "烧录数量已达标,超过工单批量");
  153. ma_code.Focus();
  154. return;
  155. }
  156. if (string.IsNullOrEmpty(EmployeeVal.Text))
  157. {
  158. ShowMsg(0, "请输入操作人员");
  159. ma_code.Focus();
  160. return;
  161. }
  162. /*if (string.IsNullOrEmpty(LineVal.Text))
  163. {
  164. ShowMsg(0, "请选择线体");
  165. LineVal.Focus();
  166. LineVal.SelectAll();
  167. return;
  168. }*/
  169. if (string.IsNullOrEmpty(BurnLotnoVal.Text))
  170. {
  171. ShowMsg(0, "请扫描包批次号");
  172. BurnLotnoVal.Focus();
  173. BurnLotnoVal.SelectAll();
  174. return;
  175. }
  176. dt = (DataTable)dh.ExecuteSql($@"select * from burn_info where burn_lotno = '{BurnLotnoVal.Text}'", "select");
  177. if (dt.Rows.Count > 0)
  178. {
  179. ShowMsg(0, $"批号:{BurnLotnoVal.Text} 已记录,请勿重复使用");
  180. return;
  181. }
  182. dh.ExecuteSql($@"insert INTO burn_info (burn_id,burn_lotno,burn_software,
  183. check_code,dot_detail,line,burn_qty,
  184. update_name,update_time,work_order,ic_detail) VALUES (BURN_INFO_SEQ.nextval,'{BurnLotnoVal.Text.Trim()}','{BurnSwVal.Text.Trim()}',
  185. '{CheckCodeVal.Text.Trim()}','{DotVal.Text.Trim()}','{LineVal.Text.Trim()}','{remainQty}',
  186. '{EmployeeVal.Text}',sysdate,'{ma_code.Text.Trim()}','{IcDetailVal.Text.Trim()}')", "insert");
  187. BurnLotnoVal.Focus();
  188. BurnLotnoVal.SelectAll();
  189. BurnLotnoVal.Text = "";
  190. /*BurnSwVal.Text = "";
  191. CheckCodeVal.Text = "";
  192. DotVal.Text = "";*/
  193. ShowMsg(1, $"批号:{BurnLotnoVal.Text} 添加烧录信息成功");
  194. dt = (DataTable)dh.ExecuteSql($"SELECT BURN_LOTNO,WORK_ORDER,LINE,BURN_SOFTWARE,CHECK_CODE,DOT_DETAIL,UPDATE_TIME,UPDATE_NAME,BURN_QTY,inspect_res,IC_DETAIL FROM burn_info LEFT JOIN burn_inspect ON burn_id = burnid WHERE work_order = '{ma_code.Text}'", "select");
  195. DataBox.DataSource = dt;
  196. dt = (DataTable)dh.ExecuteSql($"select nvl(sum(burn_qty),0) allqty from burn_info where work_order = '{ma_code.Text}'", "select");
  197. if (dt.Rows.Count > 0)
  198. {
  199. CurrQtyVal.Text = dt.Rows[0]["allqty"].ToString();
  200. }
  201. }
  202. private void BurnSwVal_KeyDown(object sender, KeyEventArgs e)
  203. {
  204. if (e.KeyCode != Keys.Enter) return;
  205. CheckCodeVal.Focus();
  206. CheckCodeVal.SelectAll();
  207. }
  208. private void CheckCodeVal_KeyDown(object sender, KeyEventArgs e)
  209. {
  210. if (e.KeyCode != Keys.Enter) return;
  211. DotVal.Focus();
  212. DotVal.SelectAll();
  213. }
  214. private void DotVal_KeyDown(object sender, KeyEventArgs e)
  215. {
  216. if (e.KeyCode != Keys.Enter) return;
  217. Confirm.Focus();
  218. }
  219. private void ClearMsg_Click(object sender, EventArgs e)
  220. {
  221. OperateResult.Clear();
  222. }
  223. }
  224. }