Make_MakeCancelDown.cs 8.2 KB

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