Query_DateRate.cs 3.5 KB

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