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 BadItem : Form { DataHelper dh = SystemInf.dh; AutoSizeFormClass asc = new AutoSizeFormClass(); string _linecode; string _prodcode; string _wccode; string _begindate; string _enddate; string _stepcode; string _makind; string _macode; public BadItem(string macode,string linecode, string prodcode, string wccode, string begindate, string enddate, string stepcode,string makind) { InitializeComponent(); _macode = macode; _prodcode = prodcode; _linecode = linecode; _wccode = wccode; _begindate = begindate; _enddate = enddate; _stepcode = stepcode; _makind = makind; } 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 (_linecode != "") { //condition += " and mb_linecode = '" + _linecode + "'"; condition += " and mb_linecode in ('" + _linecode.Replace("|", "','") + "')"; } if (_macode != "") { condition += " and ma_code in ('" + _macode.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 + "'"; } string v_sql = ""; if (_stepcode != "") { if (_stepcode == "CT1" || _stepcode == "CT2") { LogicHandler.GetQuerySQL(condition, "不良代码CT", out v_sql); } else { LogicHandler.GetQuerySQL(condition, "不良代码", out v_sql); } }else { LogicHandler.GetQuerySQL(condition, "不良代码ALL", out v_sql); } DataTable dt = (DataTable)dh.ExecuteSql(v_sql, "select"); BaseUtil.FillDgvWithDataTable(Data, dt); } private void Data_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (Data.Columns[e.ColumnIndex].Name == "times"&& _stepcode != "CT1" && _stepcode != "CT2") { Form badsn = new BadSn(_macode,_linecode, _prodcode, _wccode, _begindate, _enddate, _stepcode, _makind, Data.Rows[e.RowIndex].Cells["mb_badname"].Value.ToString()); badsn.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void normalButton12_Click(object sender, EventArgs e) { //Data表示导出数据 //Templet表示导出模板 folderBrowserDialog12.Description = "选择导出的路径"; DialogResult result = folderBrowserDialog12.ShowDialog(); if (result == DialogResult.OK) { string FolderPath = folderBrowserDialog12.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); } } } } }