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_LabelMachine.Entity; namespace UAS_LabelMachine { public partial class ExportExcel : Form { ExcelHandler eh = new ExcelHandler(); DataHelper dh = SystemInf.dh; string inoutno; public ExportExcel(string pi_inoutno) { InitializeComponent(); inoutno = pi_inoutno; } private void Export_Click(object sender, EventArgs e) { ExportFileDialog.Description = "选择导出的路径"; DialogResult result = ExportFileDialog.ShowDialog(); if (result == DialogResult.OK) { StringBuilder sql = new StringBuilder(); string SqlField = ""; if (!CH_PBCODE.Checked && BoxCode.Checked) { MessageBox.Show("勾选盒号分页,打印内容请勾选盒号"); return; } if (!CH_SPLITBATCH.Checked && BatchCode.Checked) { MessageBox.Show("勾选扩撒批分页,打印内容请勾选扩撒批号"); return; } if (CH_BLUEFILM.Checked) { SqlField += "CH_BLUEFILM " + CH_BLUEFILM.Text + ","; } if (CH_PBCODE.Checked) { SqlField += "CH_PBCODE " + CH_PBCODE.Text + ","; } if (CH_REMARK.Checked) { SqlField += "CH_REMARK " + CH_REMARK.Text + ","; } if (CH_SPLITBATCH.Checked) { SqlField += "CH_SPLITBATCH " + CH_SPLITBATCH.Text + ","; } if (CH_WATERID.Checked) { SqlField += "CH_WATERID " + CH_WATERID.Text + ","; } if (ch_code.Checked) { SqlField += "ch_code " + ch_code.Text + ","; } if (percent.Checked) { SqlField += "chw_percent1,chw_percent2,chw_itemname1,chw_itemname2,"; } if (TS.Checked) { SqlField += "TS1,TS2,TS3,"; } if (BVCEO.Checked) { SqlField += "BVCEO1,BVCEO2,BVCEO3,"; } SqlField += "pd_ordercode,pr_spec,"; string SplitType = ""; if (FixRow.Checked) { SplitType = FixRow.Name; } else if (BatchCode.Checked) { SplitType = BatchCode.Name; } else if (BoxCode.Checked) { SplitType = BoxCode.Name; } //分页信息的DataTable sql.Clear(); sql.Append("select '客户:'||pi_title,'出货单号:'||pi_inoutno,'型号'||pr_spec||' 销售类型:市场部','销售日期:'||pi_date,rownum 序号,io_qty,"); sql.Append("" + SqlField.Substring(0, SqlField.Length - 1) + " from prodinout left join prodiodetail on pi_id=pd_piid left join chip_in_out "); sql.Append("on pd_id=io_pdid left join chip on ch_code=io_chipcode left join CHIP_WAFERTEST_VIEW on ch_code=chw_chipcode "); sql.Append("left join CHIP_EDCDATA_VIEW on che_chipcode=ch_code left join product on pr_code=pd_prodcode where pi_inoutno='" + inoutno + "' order by io_detno"); DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select"); //首页信息的DataTable sql.Clear(); sql.Append("select '客户:'||pi_title 客户,'出货单号:'||pi_inoutno 出货单号,'型号'||pr_spec||' 销售类型:市场部' 型号,"); sql.Append("'销售日期:'||pi_date 销售日期,pd_ordercode,pr_spec,ch_splitbatch,ch_waterid,num,io_qty from FIRSTPAGE_BATCH_VIEW where pi_inoutno='" + inoutno + "'"); DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select"); eh.ExportExcel(dt1, dt, ExportFileDialog.SelectedPath, inoutno, SplitType, int.Parse(RowNum.Text), FirstPage_WID.Checked); } } private void ExportExcel_Load(object sender, EventArgs e) { } } }