|
@@ -1367,15 +1367,30 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void ExportData_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
+ ShowMenu.Items.Clear();
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTING where es_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTING where es_custcode is null", "select");
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ ShowMenu.Items.Add(new ToolStripMenuItem(dt.Rows[i]["el_remark"].ToString() + "#" + dt.Rows[i]["el_type"].ToString()));
|
|
|
+ }
|
|
|
+ ShowMenu.Show(new Point(ExportData.Location.X, ExportData.Location.Y + 20));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ShowMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|
|
+ {
|
|
|
+ //获取类型,单盘或者外箱
|
|
|
+ string type = e.ClickedItem.Text.Split('#')[1];
|
|
|
ExportFileDialog.Description = "选择导出的路径";
|
|
|
DialogResult result = ExportFileDialog.ShowDialog();
|
|
|
if (result == DialogResult.OK)
|
|
|
{
|
|
|
ExcelHandler eh = new ExcelHandler();
|
|
|
- DataTable Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode='" + pi_cardcode.Text + "' and esd_enable=-1 and esd_filed is not null order by esd_detno", "select");
|
|
|
+ DataTable Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode='" + pi_cardcode.Text + "' and esd_enable=-1 and esd_filed is not null and el_type='" + type + "' order by esd_detno", "select");
|
|
|
if (Field.Rows.Count == 0)
|
|
|
{
|
|
|
- Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode is null and es_isdefault=-1 and esd_enable=-1 and esd_filed is not null order by esd_detno", "select");
|
|
|
+ Field = (DataTable)dh.ExecuteSql("select * from CS_EXPORTSETTINGdetail left join CS_EXPORTSETTING on es_id=esd_esid where es_custcode is null and es_isdefault=-1 and esd_enable=-1 and esd_filed is not null and el_type='" + type + "' order by esd_detno", "select");
|
|
|
}
|
|
|
string Fileds = "";
|
|
|
for (int i = 0; i < Field.Rows.Count; i++)
|
|
@@ -1383,13 +1398,14 @@ namespace UAS_LabelMachine
|
|
|
Fileds += Field.Rows[i]["esd_filed"].ToString() + ",";
|
|
|
}
|
|
|
sql.Clear();
|
|
|
- sql.Append("select " + Fileds.Substring(0, Fileds.Length - 1) + " from ExportView where pib_inoutno='" + pi_inoutno.Text + "' order by pib_pdno");
|
|
|
-
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
- eh.ExportExcel(dt, Field, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text);
|
|
|
+ sql.Append("select " + Fileds.Substring(0, Fileds.Length - 1) + " from ExportView where pib_inoutno='" + pi_inoutno.Text + "'");
|
|
|
+ string finnalSQL = "";
|
|
|
+ LogicHandler.GetExportDataSQL(pi_cardcode.Text, type, sql.ToString(), out finnalSQL);
|
|
|
+ dt = (DataTable)dh.ExecuteSql(finnalSQL, "select");
|
|
|
+ eh.ExportExcel(dt, Field, ExportFileDialog.SelectedPath, pi_date.Text + "-" + pi_inoutno.Text+ type);
|
|
|
string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
|
|
|
if (close.ToString() == "Yes")
|
|
|
- Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + ".xls");
|
|
|
+ Process.Start(ExportFileDialog.SelectedPath + "\\" + pi_date.Text + "-" + pi_inoutno.Text + type + ".xls");
|
|
|
}
|
|
|
}
|
|
|
|