Query_LoadMake.cs 5.0 KB

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