Make_CollectSoft.cs 7.2 KB

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