Make_CollectElec.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_CollectElec : Form
  15. {
  16. DataHelper dh;
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. LogStringBuilder sql = new LogStringBuilder();
  19. DataTable dt;
  20. //当前序列号记录
  21. string sn_code;
  22. //制造单号
  23. string macode;
  24. //采集网标号
  25. float net_code;
  26. //网标查询条件ms_id
  27. string oMsID;
  28. //判断是否输入网标
  29. Boolean isnetcode = false;
  30. //打印计数
  31. int printcount = 0;
  32. int ma_unlimitin;
  33. public Make_CollectElec()
  34. {
  35. InitializeComponent();
  36. }
  37. private void Make_CollectNetCode_Load(object sender, EventArgs e)
  38. {
  39. asc.controllInitializeSize(this);
  40. sncode.Focus();
  41. dh = SystemInf.dh;
  42. StepCount.StepCode = User.CurrentStepCode;
  43. StepCount.Source = User.UserSourceCode;
  44. StepCount.LineCode = User.UserLineCode;
  45. StepCount.Dh = dh;
  46. StepCount.Start();
  47. }
  48. private void sncode_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. if (e.KeyCode == Keys.Enter)
  51. {
  52. string ErrorMessage2;
  53. string oMakeCode;
  54. //采集序列号
  55. if (!isnetcode)
  56. {
  57. if (sncode.Text == "")
  58. {
  59. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  60. return;
  61. }
  62. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage2))
  63. {
  64. //判断界面工单是否为空时的序列号是否自动归属工单
  65. string oStatus = "";
  66. if (!LogicHandler.GetMakeInfo(sncode.Text, out oMakeCode, out oStatus, out ErrorMessage2))
  67. {
  68. if (ms_makecode.Text == "")
  69. {
  70. OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  71. return;
  72. }
  73. }
  74. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  75. // 获取工单归属工单下一工序是否正确
  76. if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
  77. {
  78. sql.Clear();
  79. sql.Append("select ms_makecode,ms_prodcode,pr_detail,nvl(pr_electricmax,0)pr_electricmax,nvl(pr_electricmin,0)pr_electricmin from makeserial left join product on ");
  80. sql.Append(" ms_prodcode = pr_code where ms_id = '" + oMsID + "'");
  81. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  82. BaseUtil.SetFormValue(this.Controls, dt);
  83. OperateResult.AppendText(">>请输入电量\n", Color.Black);
  84. sn_code = sncode.Text;
  85. sncode.Text = "";
  86. isnetcode = true;
  87. return;
  88. }
  89. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  90. }
  91. else OperateResult.AppendText(">>" + ErrorMessage2 + "\n", Color.Red, sncode);
  92. }
  93. //采集netcode
  94. else
  95. {
  96. if (sncode.Text == "")
  97. {
  98. OperateResult.AppendText(">>电量信息不能为空\n", Color.Red);
  99. return;
  100. }
  101. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  102. string ErrorMessage = "";
  103. try
  104. {
  105. net_code = float.Parse(sncode.Text);
  106. if (!(net_code <= float.Parse(pr_electricmax.Text) && (net_code >= float.Parse(pr_electricmin.Text))))
  107. {
  108. sncode.Text = "";
  109. OperateResult.AppendText("<<输入值" + sncode.Text + "不符合维护范围,重新输入\n", Color.Red);
  110. return;
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. sncode.Text = "";
  116. OperateResult.AppendText("<<输入值" + sncode.Text + "错误,重新输入\n", Color.Red);
  117. return;
  118. }
  119. if (LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code, "电量采集", "电量采集完成", User.UserCode, out ErrorMessage))
  120. {
  121. //提示正确返回时传递的信息
  122. if (ErrorMessage.Contains("AFTERSUCCESS"))
  123. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  124. dh.BatchInsert("update makeserial set MS_ELEC = :netcode where ms_id = :oMsId", new String[] { "netcode", "oMsId" }, new string[] { sncode.Text }, new string[] { oMsID.ToString() });
  125. OperateResult.AppendText(">>电量信息采集完成\n", Color.Green);
  126. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "电量采集", "采集成功", sn_code, "");
  127. isnetcode = false;
  128. sncode.Text = "";
  129. sncode.Focus();
  130. }
  131. else
  132. {
  133. OperateResult.AppendText(">>更新错误" + ErrorMessage + "\n", Color.Red);
  134. }
  135. OperateResult.AppendText(">>请输入SN\n", Color.Black);
  136. }
  137. }
  138. }
  139. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  140. {
  141. asc.controlAutoSize(this);
  142. }
  143. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  144. {
  145. sncode.Focus();
  146. }
  147. private void deleteButton1_Click(object sender, EventArgs e)
  148. {
  149. if (isnetcode)
  150. {
  151. BaseUtil.CleanForm(this);
  152. OperateResult.AppendText(">>清除完成,清重新输入SN号\n", Color.Green);
  153. isnetcode = false;
  154. sncode.Focus();
  155. }
  156. }
  157. }
  158. }