BadSn.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 BadSn : Form
  15. {
  16. DataHelper dh = SystemInf.dh;
  17. AutoSizeFormClass asc = new AutoSizeFormClass();
  18. string _linecode;
  19. string _prodcode;
  20. string _wccode;
  21. string _begindate;
  22. string _enddate;
  23. string _stepcode;
  24. string _makind;
  25. string _badname;
  26. string _macode;
  27. public BadSn(string macode,string linecode, string prodcode, string wccode, string begindate, string enddate, string stepcode,string makind,string badname)
  28. {
  29. InitializeComponent();
  30. _macode = macode;
  31. _linecode = linecode;
  32. _prodcode = prodcode;
  33. _wccode = wccode;
  34. _begindate = begindate;
  35. _enddate = enddate;
  36. _stepcode = stepcode;
  37. _makind = makind;
  38. _badname = badname;
  39. }
  40. private void BadItem_SizeChanged(object sender, EventArgs e)
  41. {
  42. asc.controlAutoSize(this);
  43. }
  44. private void BadItem_Load(object sender, EventArgs e)
  45. {
  46. string condition = " mb_indate between to_date('" + _begindate + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + _enddate + "', 'yyyy-mm-dd hh24:mi:ss') ";
  47. if (_prodcode != "")
  48. {
  49. //condition += " and ma_prodcode = '" + _prodcode + "'";
  50. condition += " and ma_prodcode in ('" + _prodcode.Replace("|", "','") + "')";
  51. }
  52. if (_macode != "")
  53. {
  54. //condition += " and ma_code = '" + _macode + "'";
  55. condition += " and ma_code in ('" + _macode.Replace("|", "','") + "')";
  56. }
  57. if (_linecode != "")
  58. {
  59. //condition += " and mb_linecode = '" + _linecode + "'";
  60. condition += " and mb_linecode in ('" + _linecode.Replace("|", "','") + "')";
  61. }
  62. if (_wccode != "")
  63. {
  64. condition += " and ma_wccode = '" + _wccode + "'";
  65. }
  66. if (_makind != "")
  67. {
  68. // condition += " and ma_kind = '" + _makind + "'";
  69. condition += " and ma_kind in ('" + _makind.Replace("|", "','") + "')";
  70. }
  71. if (_stepcode != "")
  72. {
  73. condition += " and mb_stepcode = '" + _stepcode + "'";
  74. }
  75. if (_badname != "")
  76. {
  77. condition += " and mb_badname = '" + _badname + "'";
  78. }
  79. string v_sql = "";
  80. LogicHandler.GetQuerySQL(condition, "不良明细", out v_sql);
  81. DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select");
  82. BaseUtil.FillDgvWithDataTable(Data, dt);
  83. }
  84. private void normalButton1_Click(object sender, EventArgs e)
  85. {
  86. //Data表示导出数据
  87. //Templet表示导出模板
  88. folderBrowserDialog1.Description = "选择导出的路径";
  89. DialogResult result = folderBrowserDialog1.ShowDialog();
  90. if (result == DialogResult.OK)
  91. {
  92. string FolderPath = folderBrowserDialog1.SelectedPath;
  93. ExcelHandler eh = new ExcelHandler();
  94. //DataTable dt = (DataTable)Data.DataSource;
  95. //导出Excel的时候返回一个文件名,用户选择是否打开
  96. string filePath = eh.ExportExcel(Data, FolderPath);
  97. //用户选择导出之后是否立即打开
  98. MessageBoxButtons messButton = MessageBoxButtons.YesNo;
  99. string openFile = MessageBox.Show(this.ParentForm, "是否打开文件" + filePath, "提示", messButton).ToString();
  100. if (openFile == "Yes")
  101. {
  102. System.Diagnostics.Process.Start(filePath);
  103. }
  104. }
  105. }
  106. }
  107. }