Make_MakeCancelDown.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using HslCommunication.Profinet.Knx;
  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.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Make
  14. {
  15. public partial class Make_MakeCancelDown : Form
  16. {
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. DataTable dt;
  19. DataTable dt1;
  20. DataTable dtbar;
  21. LogStringBuilder sql = new LogStringBuilder();
  22. DataHelper dh;
  23. public Make_MakeCancelDown()
  24. {
  25. InitializeComponent();
  26. }
  27. private void Make_MakeCancelDown_Load(object sender, EventArgs e)
  28. {
  29. asc.controllInitializeSize(this);
  30. md_code_rb.Focus();
  31. ChooseAll.ChooseAll(LabelDataGridView);
  32. dh = SystemInf.dh;
  33. }
  34. private void Make_MakeCancelDown_SizeChanged(object sender, EventArgs e)
  35. {
  36. asc.controlAutoSize(this);
  37. }
  38. private void md_code_rb_Click(object sender, EventArgs e)
  39. {
  40. if (((RadioButton)sender).Checked == true)
  41. {
  42. if (((RadioButton)sender).Name == "md_code_rb")
  43. {
  44. BaseUtil.CleanForm(this);
  45. inputreson.Text = "";
  46. mdcode.Enabled = true;
  47. sn_code.Enabled = false;
  48. mdcode.Focus();
  49. }
  50. else if (((RadioButton)sender).Name == "sn_code_rb")
  51. {
  52. BaseUtil.CleanForm(this);
  53. inputreson.Text = "";
  54. sn_code.Enabled = true;
  55. mdcode.Enabled = false;
  56. sn_code.Focus();
  57. }
  58. }
  59. }
  60. private void md_code_KeyDown(object sender, KeyEventArgs e)
  61. {
  62. if (e.KeyCode == Keys.Enter)
  63. {
  64. if (dh.CheckExist("MakeDown", "md_code = '" + mdcode.Text + "'"))
  65. {
  66. sql.Clear();
  67. sql.Append("select md_code,md_sncode,md_macode,md_prodcode,pr_detail from makedown left join product on pr_code=md_prodcode where md_code='" + mdcode.Text + "' and md_status=-1");
  68. dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  69. if (dt1.Rows.Count > 0)
  70. {
  71. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
  72. }
  73. else
  74. {
  75. OperateResult.AppendText(">>事件号" + mdcode.Text + "无未取消下地的数据\n", Color.Red);
  76. BaseUtil.CleanDGVData(LabelDataGridView);
  77. }
  78. sum.Text = dt1.Rows.Count.ToString();
  79. make_count.Text = dt1.Rows.Count.ToString();
  80. }
  81. else
  82. {
  83. OperateResult.AppendText(">>事件号" + mdcode.Text + "不存在\n", Color.Red);
  84. }
  85. }
  86. }
  87. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  88. {
  89. if (e.KeyCode == Keys.Enter)
  90. {
  91. sql.Clear();
  92. sql.Append("select md_code,md_sncode,md_macode,md_prodcode,pr_detail from makedown left join product on pr_code=md_prodcode left join makeserial on ms_sncode=md_sncode and ms_makecode=md_macode where md_sncode='" + sn_code.Text + "' or ms_imei1='" + sn_code.Text + "' or ms_imei2='" + sn_code.Text + "' or ms_imei3='" + sn_code.Text + "' and md_status=-1");
  93. dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  94. if (dtbar.Rows.Count > 0)
  95. {
  96. sn_code.Text = dtbar.Rows[0]["md_sncode"].ToString();
  97. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dtbar);
  98. }
  99. else
  100. {
  101. OperateResult.AppendText(">>序列号" + sn_code.Text + "无未取消下地的数据\n", Color.Red);
  102. }
  103. sum.Text = dtbar.Rows.Count.ToString();
  104. }
  105. }
  106. private void Sure_Click(object sender, EventArgs e)
  107. {
  108. if (inputreson.Text.Trim() != "")
  109. {
  110. Boolean cancle = false;
  111. Boolean haveclick = false;
  112. for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
  113. {
  114. if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
  115. {
  116. if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
  117. {
  118. haveclick = true;
  119. }
  120. }
  121. }
  122. if (!haveclick)
  123. {
  124. OperateResult.AppendText(">>>没有勾选下地记录\n", Color.Red);
  125. return;
  126. }
  127. for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
  128. {
  129. if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
  130. {
  131. if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
  132. {
  133. //更新取消下地原因
  134. dh.UpdateByCondition("makedown", "md_status=0,MD_UPREASON='" + inputreson.Text + "', MD_UPDATE=sysdate, MD_UPMAN='" + User.UserCode + "' ", " md_code = '" + LabelDataGridView.Rows[i].Cells["md_code"].Value.ToString() + "' and md_sncode = '" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "'");
  135. //更新序列号状态
  136. sql.Clear();
  137. sql.Append("update makeserial set ms_downstatus=0 where ms_sncode='" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "' and ms_makecode='" + LabelDataGridView.Rows[i].Cells["md_macode"].Value.ToString() + "'");
  138. dh.ExecuteSql(sql.GetString(), "update");
  139. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, LabelDataGridView.Rows[i].Cells["md_macode"].Value.ToString(), User.UserLineCode, User.UserSourceCode, "取消下地操作", "序列号" + LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString() + "下地成功", LabelDataGridView.Rows[i].Cells["md_sncode"].Value.ToString(), "");
  140. }
  141. }
  142. }
  143. if (sn_code.Enabled)
  144. {
  145. OperateResult.AppendText(">>>序列号" + sn_code.Text + "取消下地成功\n", Color.Green);
  146. sn_code.Text = "";
  147. sn_code.Focus();
  148. inputreson.Text = "";
  149. sum.Text = "";
  150. choosenum.Text = "";
  151. BaseUtil.CleanDGVData(LabelDataGridView);
  152. }
  153. else if (mdcode.Enabled)
  154. {
  155. sum.Text = "";
  156. choosenum.Text = "";
  157. OperateResult.AppendText(">>>事件号" + mdcode.Text + "取消下地成功\n", Color.Green);
  158. mdcode.Focus();
  159. md_code_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  160. }
  161. }
  162. else
  163. {
  164. OperateResult.AppendText(">>>没有填写取消下地原因\n", Color.Red);
  165. return;
  166. }
  167. }
  168. //已选数据更新
  169. private void LabelDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  170. {
  171. int choosecount = 0;
  172. for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
  173. {
  174. if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
  175. {
  176. if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
  177. {
  178. choosecount++;
  179. }
  180. }
  181. }
  182. choosenum.Text = choosecount.ToString();
  183. }
  184. //勾选框更改提交
  185. private void LabelDataGridView_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  186. {
  187. if (LabelDataGridView.IsCurrentCellDirty)
  188. {
  189. LabelDataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
  190. }
  191. }
  192. }
  193. }