using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Query { public partial class BadSn : Form { DataHelper dh = SystemInf.dh; AutoSizeFormClass asc = new AutoSizeFormClass(); string _linecode; string _prodcode; string _wccode; string _begindate; string _enddate; string _stepcode; string _makind; string _badname; string _macode; public BadSn(string macode,string linecode, string prodcode, string wccode, string begindate, string enddate, string stepcode,string makind,string badname) { InitializeComponent(); _macode = macode; _linecode = linecode; _prodcode = prodcode; _wccode = wccode; _begindate = begindate; _enddate = enddate; _stepcode = stepcode; _makind = makind; _badname = badname; } private void BadItem_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } private void BadItem_Load(object sender, EventArgs e) { string condition = " mb_indate between to_date('" + _begindate + "', 'yyyy-mm-dd hh24:mi:ss') and to_date('" + _enddate + "', 'yyyy-mm-dd hh24:mi:ss') "; if (_prodcode != "") { //condition += " and ma_prodcode = '" + _prodcode + "'"; condition += " and ma_prodcode in ('" + _prodcode.Replace("|", "','") + "')"; } if (_macode != "") { //condition += " and ma_code = '" + _macode + "'"; condition += " and ma_code in ('" + _macode.Replace("|", "','") + "')"; } if (_linecode != "") { //condition += " and mb_linecode = '" + _linecode + "'"; condition += " and mb_linecode in ('" + _linecode.Replace("|", "','") + "')"; } if (_wccode != "") { condition += " and ma_wccode = '" + _wccode + "'"; } if (_makind != "") { // condition += " and ma_kind = '" + _makind + "'"; condition += " and ma_kind in ('" + _makind.Replace("|", "','") + "')"; } if (_stepcode != "") { condition += " and mb_stepcode = '" + _stepcode + "'"; } if (_badname != "") { condition += " and mb_badname = '" + _badname + "'"; } string v_sql = ""; LogicHandler.GetQuerySQL(condition, "不良明细", out v_sql); DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select"); BaseUtil.FillDgvWithDataTable(Data, dt); } private void normalButton1_Click(object sender, EventArgs e) { //Data表示导出数据 //Templet表示导出模板 folderBrowserDialog1.Description = "选择导出的路径"; DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { string FolderPath = folderBrowserDialog1.SelectedPath; ExcelHandler eh = new ExcelHandler(); //DataTable dt = (DataTable)Data.DataSource; //导出Excel的时候返回一个文件名,用户选择是否打开 string filePath = eh.ExportExcel(Data, FolderPath); //用户选择导出之后是否立即打开 MessageBoxButtons messButton = MessageBoxButtons.YesNo; string openFile = MessageBox.Show(this.ParentForm, "是否打开文件" + filePath, "提示", messButton).ToString(); if (openFile == "Yes") { System.Diagnostics.Process.Start(filePath); } } } } }