Special_ReSNBD.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.Special
  13. {
  14. public partial class Special_ReSNBD : Form
  15. {
  16. AutoSizeFormClass asc = new AutoSizeFormClass();
  17. DataHelper dh;
  18. string bsncode = "";//序列号录入框值
  19. LogStringBuilder sql = new LogStringBuilder();
  20. public Special_ReSNBD()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Special_BoxSplit_Load(object sender, EventArgs e)
  25. {
  26. asc.controllInitializeSize(this);
  27. dh = SystemInf.dh;
  28. sncode.Focus();
  29. OperateResult.AppendText(">>请输入返修SN号\n", Color.Black);
  30. }
  31. private void ClearSn_code_Click(object sender, EventArgs e)
  32. {
  33. bsncode = "";
  34. if (ChangeResult.Checked)
  35. {
  36. //勾选的时候提示输入TSN
  37. OperateResult.AppendText(">>请输入待转换新SN号\n", Color.Black,show_sncode);
  38. }
  39. else
  40. {
  41. OperateResult.AppendText(">>请输入返修SN号\n", Color.Black, show_sncode);
  42. }
  43. ChangeResult.Enabled = true;
  44. }
  45. string makecode;
  46. string prodcode;
  47. string orispeccode;
  48. private void sncode_KeyDown(object sender, KeyEventArgs e)
  49. {
  50. if (e.KeyCode == Keys.Enter)
  51. {
  52. if (sncode.Text != "")
  53. {
  54. if (bsncode == "")
  55. {
  56. if (!ChangeResult.Checked)
  57. {
  58. if (!dh.CheckExist("makeserial", "ms_sncode = '" + sncode.Text + "'"))
  59. {
  60. if (!dh.CheckExist("AFSALES", "as_sn = '" + sncode.Text + "'"))
  61. {
  62. OperateResult.AppendText(">>SN" + sncode.Text + "未查询到生产记录以及售后判定记录,无法采集\n", Color.Red, sncode);
  63. return;
  64. }
  65. else
  66. {
  67. makecode = "";
  68. prodcode = "";
  69. orispeccode = "";
  70. }
  71. }
  72. else
  73. {
  74. DataTable dt = (DataTable)dh.ExecuteSql("select * from makeserial left join product on ms_prodcode = pr_code where ms_sncode = '"+sncode.Text+"' order by ms_id desc", "select");
  75. makecode = dt.Rows[0]["ms_makecode"].ToString();
  76. prodcode = dt.Rows[0]["ms_prodcode"].ToString();
  77. orispeccode = dt.Rows[0]["pr_orispeccode"].ToString();
  78. }
  79. if (dh.CheckExist("returnsnbd", "rsb_oldsn = '" + sncode.Text + "'"))
  80. {
  81. string newsn = dh.getFieldDataByCondition("returnsnbd", "rsb_newsn", "rsb_oldsn = '" + sncode.Text + "'").ToString();
  82. OperateResult.AppendText(">>返修SN" + sncode.Text + "已关联SN"+newsn+",无法直接采集,需转换\n", Color.Red, sncode);
  83. return;
  84. }
  85. bsncode = sncode.Text;
  86. show_sncode.Text = bsncode;
  87. sncode.Text = "";
  88. ChangeResult.Enabled = false;
  89. OperateResult.AppendText(">>返修SN" + bsncode + "采集\n", Color.Green, sncode);
  90. return;
  91. }
  92. else
  93. {
  94. if (!dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'"))
  95. {
  96. OperateResult.AppendText(">>待转换新SN" + sncode.Text + "无采集记录,不可转换\n", Color.Red, sncode);
  97. return;
  98. }
  99. bsncode = sncode.Text;
  100. show_sncode.Text = bsncode;
  101. sncode.Text = "";
  102. ChangeResult.Enabled = false;
  103. OperateResult.AppendText(">>待转换新SN" + bsncode + "采集\n", Color.Green, sncode);
  104. return;
  105. }
  106. }
  107. else
  108. {
  109. if (sncode.Text == bsncode)
  110. {
  111. OperateResult.AppendText(">>不允许自己转自己\n", Color.Red, sncode);
  112. return;
  113. }
  114. if (!ChangeResult.Checked)
  115. {
  116. if (dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'"))
  117. {
  118. string oldsn = dh.getFieldDataByCondition("returnsnbd", "rsb_oldsn", "rsb_newsn = '" + sncode.Text + "'").ToString();
  119. OperateResult.AppendText(">>采集新SN:" + sncode.Text + "已关联返修SN:" + oldsn + ",无法采集\n", Color.Red, sncode);
  120. return;
  121. }
  122. dh.ExecuteSql("insert into returnsnbd (rsb_id,rsb_newsn,rsb_oldsn,RSB_MAKECODE,RSB_PRODCODE,RSB_ORISPECCODE) values (returnsnbd_seq.nextval,'" + sncode.Text + "','"+ show_sncode.Text + "','"+makecode+"','"+prodcode+"','"+orispeccode+"') ", "insert");
  123. bsncode = "";
  124. ChangeResult.Enabled = true;
  125. OperateResult.AppendText(">>返修SN:" + show_sncode.Text + "与新SN:"+ sncode.Text + "关联成功\n", Color.LawnGreen, sncode, show_sncode);
  126. return;
  127. }
  128. else
  129. {
  130. if (dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'"))
  131. {
  132. string oldsn = dh.getFieldDataByCondition("returnsnbd", "rsb_oldsn", "rsb_newsn = '" + sncode.Text + "'").ToString();
  133. OperateResult.AppendText(">>采集新SN:" + sncode.Text + "已关联返修SN:" + oldsn + ",无法采集\n", Color.Red, sncode);
  134. return;
  135. }
  136. dh.ExecuteSql(" update returnsnbd set rsb_newsn = '"+ sncode.Text + "' where rsb_newsn = '"+show_sncode.Text+"' ", "update");
  137. bsncode = "";
  138. ChangeResult.Enabled = true;
  139. OperateResult.AppendText(">>待转换新SN:" + show_sncode.Text + "更换至新SN:" + sncode.Text + "成功\n", Color.LawnGreen, sncode, show_sncode);
  140. return;
  141. }
  142. }
  143. }
  144. else
  145. {
  146. OperateResult.AppendText("<<序列号不能为空\n", Color.Red);
  147. }
  148. }
  149. }
  150. private void ChangeResult_CheckedChanged(object sender, EventArgs e)
  151. {
  152. if (ChangeResult.Checked)
  153. {
  154. //勾选的时候提示输入TSN
  155. OperateResult.AppendText(">>请输入待转换新SN号\n", Color.Black);
  156. }
  157. else {
  158. OperateResult.AppendText(">>请输入返修SN号\n", Color.Black);
  159. }
  160. }
  161. private void Special_ReSNBD_SizeChanged(object sender, EventArgs e)
  162. {
  163. asc.controlAutoSize(this);
  164. }
  165. }
  166. }