/// <summary> /// export Csv file /// </summary> public void F12() { if (ErrorCheck()) { if (DSP_MSG("Q002", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty).Equals("1")) { string Folderpath = txtpath.Text.Remove(txtpath.Text.LastIndexOf('\\')); if (Path.GetExtension(txtpath.Text).Equals(".csv")) { DataTable dtImport = new DataTable(); dtImport = CsvToDataTable(txtpath.Text); dtImport.Select("ステータス='900'").ToList().ForEach(x => x.Delete()); dtImport.AcceptChanges(); if (dtImport != null) { if (!string.IsNullOrWhiteSpace(Folderpath)) { if (!Directory.Exists(Folderpath)) { string newPath = @"c:\"; Directory.CreateDirectory(newPath); } DataTableToCSV.Program ptj = new DataTableToCSV.Program(); //datatable to csv ptj.CSV(dtImport, txtpath.Text, true); } } //DSP_MSG("I201", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); mme.fields = "Char1,Char2"; mme.tableName = "M_MultiPorpose"; mme.condition = "Where ID=113 And [Key]='1'"; DataTable dt = psks0103ibl.M_MultiPorpose_DynamicSelect(mme); if (dt.Rows.Count > 0) { folderPath = dt.Rows[0]["Char1"].ToString(); fileName = dt.Rows[0]["Char2"].ToString(); } OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = folderPath; dlg.FileName = dt.Rows[0]["Char1"].ToString() + "\\" + fileName; dlg.RestoreDirectory = true; Process.Start(Path.GetDirectoryName(dlg.FileName)); } else { MessageBox.Show("Your File need to be CSV Type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// export csv file /// </summary> public void F12() { if (ErrorCheck()) { if (DSP_MSG("Q002", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty).Equals("1")) { string Folderpath = txtpath.Text.Remove(txtpath.Text.LastIndexOf('\\')); if (Path.GetExtension(txtpath.Text).Equals(".csv")) { DataTable dtImport = new DataTable(); dtImport = CsvToDataTable(txtpath.Text); // move csv file to datatable for (int i = 0; i < dtImport.Rows.Count; i++) // to check full_width character { string str = dtImport.Rows[i]["Q"].ToString(); foreach (char c in str) { var sjis = System.Text.Encoding.GetEncoding("shift_JIS"); int byteCount = sjis.GetByteCount(c.ToString()); if (byteCount == 2) { dtImport.Rows[i]["Q"] = null; break; } } } dtImport.AcceptChanges(); if (dtImport != null) { if (!string.IsNullOrWhiteSpace(Folderpath)) { if (!Directory.Exists(Folderpath)) { string newPath = @"c:\"; Directory.CreateDirectory(newPath); } DataTableToCSV.Program ptj = new DataTableToCSV.Program(); //datatable to csv ptj.CSV(dtImport, txtpath.Text, false); } } DSP_MSG("I201", string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); mme.fields = "Char1,Char2"; mme.tableName = "M_MultiPorpose"; mme.condition = "Where ID=112 And [Key]='1'"; DataTable dt = psks0103ibl.M_MultiPorpose_DynamicSelect(mme); if (dt.Rows.Count > 0) { folderPath = dt.Rows[0]["Char2"].ToString(); fileName = dt.Rows[0]["Char1"].ToString(); } OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = folderPath; dlg.FileName = dt.Rows[0]["Char2"].ToString() + "\\" + fileName; dlg.RestoreDirectory = true; Process.Start(Path.GetDirectoryName(dlg.FileName)); } else { MessageBox.Show("Your File need to be CSV Type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }