Query_DateRate.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. LogStringBuilder sql = new LogStringBuilder();
  43. sql.Append("select * from MES_OKNG_DATE where sp_date between ");
  44. sql.Append("to_date('" + BeginDate.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') and ");
  45. sql.Append("to_date('" + EndDate.Value.ToString("yyyy-MM-dd") + "','yyyy-mm-dd') and sp_prodcode='" + pr_code.Text + "' order by sp_date");
  46. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  47. string FolderPath = folderBrowserDialog1.SelectedPath;
  48. ExcelHandler eh = new ExcelHandler();
  49. string begindate = BeginDate.Value.ToString("yyyy-mm-dd");
  50. string enddate = EndDate.Value.ToString("yyyy-mm-dd");
  51. string path = eh.ExportExcel_BAIDU(dt, BeginDate.Value, (EndDate.Value - BeginDate.Value).Days + 1, FolderPath);
  52. string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  53. if (close.ToString() == "Yes")
  54. System.Diagnostics.Process.Start(path);
  55. }
  56. }
  57. private void Query_SpecialReport_Load(object sender, EventArgs e)
  58. {
  59. //工单号放大镜配置
  60. pr_code.TableName = " product ";
  61. pr_code.SelectField = "pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 型号";
  62. pr_code.FormName = Name;
  63. pr_code.SetValueField = new string[] { "pr_code" };
  64. pr_code.Condition = "pr_statuscode='AUDITED'";
  65. pr_code.DbChange += pr_code_DbChange;
  66. }
  67. private void pr_code_DbChange(object sender, EventArgs e)
  68. {
  69. Dbfind = pr_code.ReturnData;
  70. BaseUtil.SetFormValue(this.Controls, Dbfind);
  71. }
  72. }
  73. }