Query_OnlineTraceBack.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_OnlineTraceBack : Form
  15. {
  16. DataHelper dh;
  17. LogStringBuilder sql = new LogStringBuilder();
  18. AutoSizeFormClass asc = new AutoSizeFormClass();
  19. DataTable ComBoxData = new DataTable();
  20. DataTable Dbfind;
  21. public Query_OnlineTraceBack()
  22. {
  23. InitializeComponent();
  24. }
  25. private void Query_OnlineTraceBack_Load(object sender, EventArgs e)
  26. {
  27. asc.controllInitializeSize(this);
  28. dh = SystemInf.dh;
  29. DataColumn status = new DataColumn("status");
  30. DataColumn statuscode = new DataColumn("statuscode");
  31. ComBoxData.Columns.Add(status);
  32. ComBoxData.Columns.Add(statuscode);
  33. DataRow dr = ComBoxData.NewRow();
  34. dr[0] = "全部"; dr[1] = "ALL"; ComBoxData.Rows.Add(dr);
  35. dr = ComBoxData.NewRow();
  36. dr[0] = "未生产"; dr[1] = "null"; ComBoxData.Rows.Add(dr);
  37. dr = ComBoxData.NewRow();
  38. dr[0] = "已归属"; dr[1] = "0"; ComBoxData.Rows.Add(dr);
  39. dr = ComBoxData.NewRow();
  40. dr[0] = "在线"; dr[1] = "1"; ComBoxData.Rows.Add(dr);
  41. dr = ComBoxData.NewRow();
  42. dr[0] = "已完工"; dr[1] = "2"; ComBoxData.Rows.Add(dr);
  43. dr = ComBoxData.NewRow();
  44. dr[0] = "不良待维修"; dr[1] = "3"; ComBoxData.Rows.Add(dr);
  45. dr = ComBoxData.NewRow();
  46. dr[0] = "已报废"; dr[1] = "4"; ComBoxData.Rows.Add(dr);
  47. ms_status.DataSource = ComBoxData;
  48. ms_status.DisplayMember = "status";
  49. ms_status.ValueMember = "statuscode";
  50. //工单号放大镜配置
  51. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  52. ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本";
  53. ma_code.FormName = Name;
  54. ma_code.SetValueField = new string[] { "ma_code" };
  55. ma_code.Condition = "ma_statuscode='STARTED'";
  56. ma_code.DbChange += Ma_code_DbChange;
  57. }
  58. private void Ma_code_DbChange(object sender, EventArgs e)
  59. {
  60. Dbfind = ma_code.ReturnData;
  61. BaseUtil.SetFormValue(this.Controls, Dbfind);
  62. Query.PerformClick();
  63. }
  64. private void Query_OnlineTraceBack_SizeChanged(object sender, EventArgs e)
  65. {
  66. asc.controlAutoSize(this);
  67. }
  68. private void Query_Click(object sender, EventArgs e)
  69. {
  70. if (dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
  71. {
  72. string condition = BaseUtil.GetScreenSqlCondition(ma_code, ms_stepcode, ms_nextstepcode);
  73. string statuscode = ms_status.SelectedValue.ToString();
  74. sql.Clear();
  75. sql.Append("select ms_sncode,ms_linecode,ms_stepcode,ms_nextstepcode,ms_craftcode, ms_makecode,");
  76. sql.Append("case when ms_status is null then '未生产' when ms_status=0 then '已归属' when ms_status=1 then '在线' when ms_status=2 then '已完工' when ms_status=3 ");
  77. sql.Append(" then '不良待维修' when ms_status=4 then '已报废' else 'null' end ms_status from makeserial ");
  78. sql.Append("left join makesnlist on ms_firstsn=msl_sncode and ms_makecode=msl_makecode ");
  79. sql.Append(condition);
  80. if (statuscode == "null")
  81. {
  82. sql.Append("and ms_status is null");
  83. }
  84. else if (statuscode == "ALL")
  85. {
  86. }
  87. else
  88. {
  89. sql.Append("and ms_status ='" + statuscode + "'");
  90. }
  91. sql.Append(" order by ms_sncode ");
  92. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  93. BaseUtil.FillDgvWithDataTable(SnInf, dt);
  94. Count.Text = SnInf.Rows.Count.ToString();
  95. ma_qty.Text = dh.getFieldDataByCondition("make", "ma_qty", "ma_code='" + ma_code.Text + "'").ToString();
  96. }
  97. else
  98. {
  99. MessageBox.Show("工单号" + ma_code.Text + "不存在");
  100. BaseUtil.CleanDataGridView(SnInf);
  101. ma_code.Text = "";
  102. }
  103. }
  104. private void ms_status_SelectedIndexChanged(object sender, EventArgs e)
  105. {
  106. if (ma_code.Text != "")
  107. Query.PerformClick();
  108. }
  109. }
  110. }