Make_AgingOver.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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_AgingOver : 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. int printcount = 0;
  30. int ma_unlimitin;
  31. string ErrorMessage = "";
  32. string LastSncode;
  33. public Make_AgingOver()
  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. }
  43. private void sncode_KeyDown(object sender, KeyEventArgs e)
  44. {
  45. if (e.KeyCode == Keys.Enter)
  46. {
  47. //采集序列号
  48. if (sncode.Text == "")
  49. {
  50. OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
  51. return;
  52. }
  53. OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
  54. dt = (DataTable)dh.ExecuteSql("select ms_status,ms_id,ms_makecode,ms_nextstepcode,ms_craftcode,ms_prodcode from makeserial left join product on ms_prodcode = pr_code where ms_sncode ='" + sncode.Text + "' order by ms_id desc", "select");
  55. if (dt.Rows.Count == 0)
  56. {
  57. OperateResult.AppendText(">>SN:" + sncode.Text + "不存在\n", Color.Red, sncode);
  58. return;
  59. }
  60. DataTable dtB = (DataTable)dh.ExecuteSql("select ag_code from ageingdetail left join ageing on agd_agid = ag_id where agd_sncode = '" + sncode.Text + "' and ag_status =1", "select");
  61. if (dtB.Rows.Count > 0)
  62. {
  63. agcode.Text = dtB.Rows[0]["ag_code"].ToString();
  64. snCollectionBox1_KeyDown(this, new KeyEventArgs(Keys.Enter));
  65. }
  66. else
  67. {
  68. OperateResult.AppendText(">>SN:" + sncode.Text + "未处于老化中批次\n", Color.Red, sncode);
  69. return;
  70. }
  71. }
  72. }
  73. private void Make_CollectNetCode_SizeChanged(object sender, EventArgs e)
  74. {
  75. asc.controlAutoSize(this);
  76. }
  77. private void Make_CollectNetCode_Activated(object sender, EventArgs e)
  78. {
  79. sncode.Focus();
  80. }
  81. private void deleteButton1_Click(object sender, EventArgs e)
  82. {
  83. string Seal = MessageBox.Show(this.ParentForm, "是否确认老化?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  84. if (Seal == "Yes")
  85. {
  86. fildgv();
  87. if (agcode.Text != "")
  88. {
  89. dt = (DataTable)dh.ExecuteSql("select * from ageing where ag_code = '" + agcode.Text + "' and ag_status <>1 ", "select");
  90. if (dt.Rows.Count > 0)
  91. {
  92. OperateResult.AppendText(">>老化编号" + agcode.Text + "未处于老化中\n", Color.Red, agcode);
  93. return;
  94. }
  95. else
  96. {
  97. int endtime = int.Parse(dh.GetConfig("oldtime", "MESSetting").ToString());
  98. DataTable dg = (DataTable)dh.ExecuteSql("select round((sysdate-AG_STARTDATE)*24*60,2) overtime from ageing where ag_code = '" + agcode.Text + "' and (sysdate-AG_STARTDATE)*24*60 <" + endtime + "", "select");
  99. if (dg.Rows.Count > 0)
  100. {
  101. OperateResult.AppendText(">>老化编号" + agcode.Text + "已老化"+dg.Rows[0]["overtime"].ToString() +"分钟,未达到设定时长"+endtime+"分钟\n", Color.Red);
  102. return;
  103. }
  104. dh.ExecuteSql("update ageing set ag_enddate = sysdate,ag_status = 2 where ag_code = '" + agcode.Text + "'", "update");
  105. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "老化结束" + agcode.Text, "采集结束", agcode.Text, "");
  106. OperateResult.AppendText(">>" + agcode.Text + "老化批次结束\n", Color.LightGreen, agcode);
  107. BaseUtil.CleanControls(this.Controls);
  108. agcode.Focus();
  109. }
  110. }
  111. else
  112. {
  113. OperateResult.AppendText(">>老化编号" + agcode.Text + "不可为空\n", Color.Red, agcode);
  114. return;
  115. }
  116. }
  117. }
  118. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  119. {
  120. }
  121. void fildgv()
  122. {
  123. DataTable dtc;
  124. if (agcode.Text != "")
  125. {
  126. dtc = (DataTable)dh.ExecuteSql("select * from ageingdetail left join ageing on agd_agid = ag_id where ag_code = '" + agcode.Text + "' and ag_status =1 ", "select");
  127. if (dtc.Rows.Count > 0)
  128. {
  129. dtc = (DataTable)dh.ExecuteSql("select * from ageingdetail left join ageing on agd_agid = ag_id where ag_code = '" + agcode.Text + "' ", "select");
  130. agsum.Text = dh.getFieldDataByCondition("ageingdetail", "count(1) cn", " agd_agcode = '" + agcode.Text + "'").ToString();
  131. }
  132. else
  133. {
  134. OperateResult.AppendText(">>老化编号" + agcode.Text + "未处于老化中\n", Color.Red, agcode);
  135. return;
  136. }
  137. BaseUtil.FillDgvWithDataTable(LabelDataGridView, dtc);
  138. }
  139. }
  140. private void snCollectionBox1_KeyDown(object sender, KeyEventArgs e)
  141. {
  142. if (e.KeyCode == Keys.Enter)
  143. {
  144. fildgv();
  145. //sncode.Focus();
  146. //sncode.SelectAll();
  147. }
  148. }
  149. }
  150. }