Query_DateRate.cs 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_DateRate : Form
  15. {
  16. DataHelper dh = SystemInf.dh;
  17. DataTable Dbfind;
  18. public Query_DateRate()
  19. {
  20. InitializeComponent();
  21. }
  22. private void Export_Click(object sender, EventArgs e)
  23. {
  24. if (pr_code.Text == "")
  25. {
  26. MessageBox.Show("请输入产品代码");
  27. return;
  28. }
  29. if (EndDate.Value < BeginDate.Value)
  30. {
  31. MessageBox.Show("结束日期不能小于起始日期");
  32. }
  33. ExcelExport("");
  34. }
  35. //选择导出Excel时是选择导出数据的还是模板
  36. private void ExcelExport(string DataOrTemplet)
  37. {
  38. folderBrowserDialog1.Description = "选择导出的路径";
  39. DialogResult result = folderBrowserDialog1.ShowDialog();
  40. if (result == DialogResult.OK)
  41. {
  42. string v_sql = "";
  43. string v_sql1 = "";
  44. string 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') ";
  45. if (pr_code.Text != "")
  46. {
  47. condition += " and sp_prodcode = '" + pr_code.Text + "'";
  48. }
  49. if (ma_code.Text != "")
  50. {
  51. condition += " and sp_makecode = '" + ma_code.Text + "'";
  52. }
  53. LogicHandler.GetQuerySql(condition, out v_sql, out v_sql1);
  54. DataTable dt = (DataTable)dh.ExecuteSql(v_sql + v_sql1, "select");
  55. string FolderPath = folderBrowserDialog1.SelectedPath;
  56. ExcelHandler eh = new ExcelHandler();
  57. string begindate = BeginDate.Value.ToString("yyyy-mm-dd");
  58. string enddate = EndDate.Value.ToString("yyyy-mm-dd");
  59. string path = eh.ExportExcel_BAIDU(dt, BeginDate.Value, (EndDate.Value - BeginDate.Value).Days + 1, FolderPath);
  60. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  61. if (close.ToString() == "Yes")
  62. System.Diagnostics.Process.Start(path);
  63. }
  64. }
  65. private void Query_SpecialReport_Load(object sender, EventArgs e)
  66. {
  67. //工单号放大镜配置
  68. pr_code.TableName = " product ";
  69. pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 型号";
  70. pr_code.FormName = Name;
  71. pr_code.SetValueField = new string[] { "pr_code" };
  72. pr_code.Condition = "pr_statuscode='AUDITED'";
  73. pr_code.DbChange += pr_code_DbChange;
  74. ma_code.TableName = " make left join product on ma_prodcode=pr_code";
  75. ma_code.SelectField = "ma_code # 工单编号,ma_prodcode # 产品编号,pr_spec # 型号";
  76. ma_code.FormName = Name;
  77. ma_code.SetValueField = new string[] { "ma_code" };
  78. ma_code.Condition = "ma_statuscode='STARTED'";
  79. ma_code.DbChange += pr_code_DbChange;
  80. }
  81. private void pr_code_DbChange(object sender, EventArgs e)
  82. {
  83. Dbfind = pr_code.ReturnData;
  84. BaseUtil.SetFormValue(this.Controls, Dbfind);
  85. }
  86. }
  87. }