Query_DateRate.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. public Query_DateRate()
  18. {
  19. InitializeComponent();
  20. }
  21. private void Export_Click(object sender, EventArgs e)
  22. {
  23. if (EndDate.Value < BeginDate.Value)
  24. {
  25. MessageBox.Show("结束日期不能小于起始日期");
  26. }
  27. ExcelExport("");
  28. }
  29. //选择导出Excel时是选择导出数据的还是模板
  30. private void ExcelExport(string DataOrTemplet)
  31. {
  32. folderBrowserDialog1.Description = "选择导出的路径";
  33. DialogResult result = folderBrowserDialog1.ShowDialog();
  34. if (result == DialogResult.OK)
  35. {
  36. LogStringBuilder sql = new LogStringBuilder();
  37. sql.Append("select * from MES_OKNG_DATE where sp_date between ");
  38. sql.Append("to_date('" + BeginDate.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') and ");
  39. sql.Append("to_date('" + EndDate.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') order by sp_date");
  40. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  41. string FolderPath = folderBrowserDialog1.SelectedPath;
  42. ExcelHandler eh = new ExcelHandler();
  43. string begindate = BeginDate.Value.ToString("yyyy-mm-dd");
  44. string enddate = EndDate.Value.ToString("yyyy-mm-dd");
  45. string path = eh.ExportExcel_BAIDU(dt, BeginDate.Value, (EndDate.Value - BeginDate.Value).Days + 1, FolderPath);
  46. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  47. if (close.ToString() == "Yes")
  48. System.Diagnostics.Process.Start(path);
  49. }
  50. }
  51. private void Query_SpecialReport_Load(object sender, EventArgs e)
  52. {
  53. }
  54. }
  55. }