|
|
@@ -1,5 +1,6 @@
|
|
|
using DevExpress.Printing.Core.PdfExport.Metafile;
|
|
|
using DevExpress.XtraCharts.Native;
|
|
|
+using ExcelHelper;
|
|
|
using LabelManager2;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
@@ -74,37 +75,47 @@ namespace UAS_MES_NEW.Query
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ ExcelHandler excel = new ExcelHandler();
|
|
|
private void ExportData()
|
|
|
{
|
|
|
- Stream fs = new FileStream(ExportFileDialog.SelectedPath + @"\" + pr_code.Text + ".txt", FileMode.CreateNew, FileAccess.ReadWrite);
|
|
|
- fs.Dispose();
|
|
|
- List<string> list = new List<string>();
|
|
|
- for (int i = 0; i < importdata.Rows.Count; i++)
|
|
|
+ try
|
|
|
{
|
|
|
- string Refer = importdata.Rows[i]["Refer"].ToString();
|
|
|
- DataTable bom = (DataTable)dh.ExecuteSql("select replace(wm_concat(bd_location||';'||nvl(bd_soncode,PRE_SONCODE)||' '||PRE_REPCODE),',',' ') from BOMDetail " +
|
|
|
- "LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code left join ProdReplace on pre_bdid =bd_id where " +
|
|
|
- "bo_mothercode='" + pr_code.Text + "' and instr(','||bd_location||',',',"+Refer+",')>0", "select");
|
|
|
- if (bom.Rows.Count > 0)
|
|
|
+ string time = System.DateTime.Now.ToString("yyyyMMddhhmmss");
|
|
|
+ Stream fs = new FileStream(ExportFileDialog.SelectedPath + @"\" + time + pr_code.Text + ".txt", FileMode.CreateNew, FileAccess.ReadWrite);
|
|
|
+ fs.Dispose();
|
|
|
+ List<string> list = new List<string>();
|
|
|
+ for (int i = 0; i < importdata.Rows.Count; i++)
|
|
|
{
|
|
|
- if (bom.Rows[0][0].ToString() != "")
|
|
|
+ string Refer = importdata.Rows[i]["Refer"].ToString();
|
|
|
+ DataTable bom = (DataTable)dh.ExecuteSql("select bd_soncode,replace(wm_concat(bd_location||';'||nvl(bd_soncode,PRE_SONCODE)||' '||PRE_REPCODE),',',' ') from BOMDetail " +
|
|
|
+ "LEFT JOIN bom on bd_bomid=bo_id left join Product ON bd_soncode=pr_code left join ProdReplace on pre_bdid =bd_id where " +
|
|
|
+ "bo_mothercode='" + pr_code.Text + "' and instr(','||bd_location||',','," + Refer + ",')>0 group by bd_soncode", "select");
|
|
|
+ if (bom.Rows.Count > 0)
|
|
|
{
|
|
|
- if (!list.Contains(bom.Rows[0][0].ToString()))
|
|
|
+ if (bom.Rows[0][1].ToString() != "")
|
|
|
{
|
|
|
- list.Add(bom.Rows[0][0].ToString());
|
|
|
+ if (!list.Contains(bom.Rows[0][1].ToString()))
|
|
|
+ {
|
|
|
+ list.Add(bom.Rows[0][1].ToString());
|
|
|
+ }
|
|
|
}
|
|
|
+ importdata.Rows[i][1] = bom.Rows[0][0].ToString();
|
|
|
}
|
|
|
+ Process.Text = (i + 1) + "/" + importdata.Rows.Count;
|
|
|
}
|
|
|
- Process.Text = (i + 1) + "/" + importdata.Rows.Count;
|
|
|
+ excel.ExportExcel(importdata, ExportFileDialog.SelectedPath + @"\" + time + pr_code.Text + ".xls");
|
|
|
+ StreamWriter sw = File.AppendText(ExportFileDialog.SelectedPath + @"\" + time + pr_code.Text + ".txt");
|
|
|
+ for (int i = 0; i < list.Count; i++)
|
|
|
+ {
|
|
|
+ Console.WriteLine(list[i]);
|
|
|
+ sw.WriteLine(list[i]);
|
|
|
+ }
|
|
|
+ sw.Close();
|
|
|
}
|
|
|
- StreamWriter sw = File.AppendText(ExportFileDialog.SelectedPath + @"\" + pr_code.Text + ".txt");
|
|
|
- for (int i = 0; i < list.Count; i++)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- Console.WriteLine(list[i]);
|
|
|
- sw.WriteLine(list[i]);
|
|
|
+ MessageBox.Show(ex.Message);
|
|
|
}
|
|
|
- sw.Close();
|
|
|
}
|
|
|
|
|
|
|