123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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);
- }
- }
- }
- }
- }
|