Query_DateRate2.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.Query
  13. {
  14. public partial class Query_DateRate2 : Form
  15. {
  16. AutoSizeFormClass asc = new AutoSizeFormClass();
  17. string querysql = "";
  18. DataHelper dh = SystemInf.dh;
  19. DataTable Dbfind;
  20. string condition;
  21. public Query_DateRate2()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Query_SpecialReport_Load(object sender, EventArgs e)
  26. {
  27. asc.controllInitializeSize(this);
  28. //工单号放大镜配置
  29. pr_code.TableName = " product ";
  30. pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_orispeccode # 型号";
  31. pr_code.FormName = Name;
  32. pr_code.SetValueField = new string[] { "pr_code" };
  33. pr_code.Condition = "pr_statuscode='AUDITED'";
  34. pr_code.DbChange += pr_code_DbChange;
  35. wc_code.TableName = " workcenter ";
  36. wc_code.SelectField = "wc_code # 车间编号,wc_name # 车间名称";
  37. wc_code.FormName = Name;
  38. wc_code.SetValueField = new string[] { "wc_code" };
  39. wc_code.Condition = "wc_statuscode='AUDITED'";
  40. wc_code.DbChange += pr_code_DbChange;
  41. li_code.TableName = " line ";
  42. li_code.SelectField = "li_code # 车间编号,li_name # 车间名称";
  43. li_code.FormName = Name;
  44. li_code.SetValueField = new string[] { "li_code" };
  45. li_code.Condition = "li_statuscode='AUDITED'";
  46. li_code.DbChange += pr_code_DbChange;
  47. ma_code.TableName = " make left join product on ma_prodcode=pr_code left join workcenter on ma_wccode = wc_code";
  48. ma_code.SelectField = "ma_code # 工单编号,ma_prodcode # 产品编号,pr_spec # 型号,wc_code # 工作中心";
  49. ma_code.FormName = Name;
  50. ma_code.SetValueField = new string[] { "ma_code", "wc_code" };
  51. ma_code.Condition = "ma_statuscode='STARTED'";
  52. ma_code.DbChange += pr_code_DbChange;
  53. //EndDate.Value = DateTime.Now;
  54. // BeginDate.Value = DateTime.Now - 1;
  55. }
  56. private void Export_Click(object sender, EventArgs e)
  57. {
  58. if (wc_code.Text == "")
  59. {
  60. MessageBox.Show("请输入车间");
  61. return;
  62. }
  63. if (EndDate.Value < BeginDate.Value)
  64. {
  65. MessageBox.Show("结束日期不能小于起始日期");
  66. }
  67. condition = "";
  68. condition = " sp_date between to_date('" + BeginDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-mm-dd hh24:mi:ss') ";
  69. if (wc_code.Text != "")
  70. {
  71. condition += " and sp_wccode = '" + wc_code.Text + "'";
  72. }
  73. if (pr_code.Text != "")
  74. {
  75. condition += " and sp_prodcode = '" + pr_code.Text + "'";
  76. }
  77. if (ma_code.Text != "")
  78. {
  79. condition += " and sp_makecode = '" + ma_code.Text + "'";
  80. }
  81. if (li_code.Text != "")
  82. {
  83. condition += " and sp_linecode = '" + li_code.Text + "'";
  84. }
  85. string v_sql = "";
  86. //string v_sql1 = "";
  87. LogicHandler.GetQuerySQL(condition, "直通率", out v_sql);
  88. DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select");
  89. DataRow dr = dt.NewRow();
  90. dr[3] = "ALL";
  91. dt.Rows.InsertAt(dr, dt.Rows.Count);
  92. BaseUtil.FillDgvWithDataTable(Data, dt);
  93. }
  94. private void pr_code_DbChange(object sender, EventArgs e)
  95. {
  96. Dbfind = pr_code.ReturnData;
  97. BaseUtil.SetFormValue(this.Controls, Dbfind);
  98. }
  99. private void Query_DateRate_SizeChanged(object sender, EventArgs e)
  100. {
  101. asc.controlAutoSize(this);
  102. }
  103. private void Data_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
  104. {
  105. if (e.RowIndex >= 0)
  106. {
  107. Console.WriteLine(Data.Rows[e.RowIndex].Cells["sp_stepname"].Value.ToString());
  108. Console.WriteLine(condition);
  109. }
  110. }
  111. }
  112. }