Query_LoadMake.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using LabelManager2;
  2. using System;
  3. using System.Data;
  4. using System.Threading;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Query
  10. {
  11. public partial class Query_LoadMake : Form
  12. {
  13. DataHelper dh = SystemInf.dh;
  14. ApplicationClass lbl;
  15. Document doc;
  16. DataTable Dbfind;
  17. Thread InitPrint;
  18. public Query_LoadMake()
  19. {
  20. InitializeComponent();
  21. }
  22. private void Query_LoadMake_Load(object sender, EventArgs e)
  23. {
  24. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  25. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本";
  26. ma_code.FormName = Name;
  27. ma_code.SetValueField = new string[] { "ma_code" };
  28. ma_code.Condition = "ma_statuscode='STARTED'";
  29. ma_code.DbChange += Ma_code_DbChange;
  30. li_code.TableName = "line";
  31. li_code.SelectField = "li_code # 线别编号,li_name # 线别名称";
  32. li_code.FormName = Name;
  33. li_code.SetValueField = new string[] { "li_code" };
  34. li_code.Condition = "li_statuscode='AUDITED'";
  35. li_code.DbChange += Ma_code_DbChange;
  36. LoadGridData();
  37. }
  38. private void Ma_code_DbChange(object sender, EventArgs e)
  39. {
  40. Dbfind = ma_code.ReturnData;
  41. BaseUtil.SetFormValue(this.Controls, Dbfind);
  42. }
  43. private void UpLoadMake_Click(object sender, EventArgs e)
  44. {
  45. if (ma_code.Text == "" || li_code.Text == "")
  46. {
  47. MessageBox.Show("工单和线别不允许为空");
  48. return;
  49. }
  50. if (mancount.Value == 0)
  51. {
  52. MessageBox.Show("人数必须大于0");
  53. return;
  54. }
  55. if (dh.CheckExist("loadmake", "lm_linecode='" + li_code.Text + "' and lm_stepcode='" + User.CurrentStepCode + "' and lm_downtime is null"))
  56. {
  57. MessageBox.Show("线别" + li_code.Text + "存在在线工单,不允许上线");
  58. return;
  59. }
  60. dh.ExecuteSql("insert into loadmake(lm_id,lm_makecode,lm_linecode,lm_uptime,lm_inman,lm_mannum,lm_stepcode)" +
  61. "values(loadmake_seq.nextval,'" + ma_code.Text + "','" + li_code.Text + "',sysdate,'" + User.UserName + "','" + mancount.Value + "','" + User.CurrentStepCode + "')", "insert");
  62. LoadGridData();
  63. }
  64. private void DownLoadMake_Click(object sender, EventArgs e)
  65. {
  66. if (!ifcheckrow())
  67. {
  68. MessageBox.Show("请勾选需要操作的行");
  69. return;
  70. }
  71. for (int i = 0; i < DGV.Rows.Count; i++)
  72. {
  73. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  74. {
  75. dh.ExecuteSql("update loadmake set lm_downtime=sysdate,lm_output='" + output.Value.ToString() + "' where lm_id='" + DGV.Rows[i].Cells["lm_id"].Value.ToString() + "'", "update");
  76. }
  77. }
  78. LoadGridData();
  79. }
  80. private void LoadGridData()
  81. {
  82. DataTable dt = (DataTable)dh.ExecuteSql("select * from loadmake where lm_downtime is null and lm_stepcode='" + User.CurrentStepCode + "'", "select");
  83. BaseUtil.FillDgvWithDataTable(DGV, dt);
  84. }
  85. private void ChangeMan_Click(object sender, EventArgs e)
  86. {
  87. if (!ifcheckrow())
  88. {
  89. MessageBox.Show("请勾选需要操作的行");
  90. return;
  91. }
  92. for (int i = 0; i < DGV.Rows.Count; i++)
  93. {
  94. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  95. {
  96. dh.ExecuteSql("update loadmake set lm_downtime=sysdate where lm_id='" + DGV.Rows[i].Cells["lm_id"].Value.ToString() + "'", "update");
  97. string makecode = DGV.Rows[i].Cells["lm_makecode"].Value.ToString();
  98. string licode = DGV.Rows[i].Cells["lm_linecode"].Value.ToString();
  99. string mannum = DGV.Rows[i].Cells["LM_MANNUM"].Value.ToString();
  100. dh.ExecuteSql("insert into loadmake(lm_id,lm_makecode,lm_linecode,lm_uptime,lm_inman,lm_mannum,lm_stepcode)" +
  101. "values(loadmake_seq.nextval,'" + makecode + "','" + licode + "',sysdate,'" + User.UserName + "','" + mannum + "','" + User.CurrentStepCode + "')", "insert");
  102. }
  103. }
  104. LoadGridData();
  105. }
  106. private bool ifcheckrow()
  107. {
  108. for (int i = 0; i < DGV.Rows.Count; i++)
  109. {
  110. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. }
  118. }