public SqlDbType() { InitializeComponent(); cf = new CommonFunction(); multi_Entity = new multipurposeEntity(); dt_Main = new DataTable(); create_dt = new DataTable(); dt = new DataTable(); bbl = new BaseBL(); SEntity = new TorikomiEntity(); ShukkaTorikomi_BL = new ShukkaTorikomi_BL(); }
public DataTable ShukkaTorikomi_Select_Check(TorikomiEntity obj) { CKMDL ckmdl = new CKMDL(); var parameters = new SqlParameter[2]; //parameters[0] = new SqlParameter("@TorikomiDenpyouNO", SqlDbType.VarChar) { Value = obj.TorikomiDenpyouNO }; parameters[0] = new SqlParameter("@Datefrom", SqlDbType.VarChar) { Value = obj.DateFrom }; parameters[1] = new SqlParameter("@Dateto", SqlDbType.VarChar) { Value = obj.DateTo }; DataTable dt = ckmdl.SelectDatatable("ShukkaTorikomi_Select_Check", GetConnectionString(), parameters); return(dt); }
private (string, string) ChooseFile() { var filepath = string.Empty; TorikomiEntity obj = new TorikomiEntity(); string Xml_Main = string.Empty; string Xml_Detail = string.Empty; string error = string.Empty; //using (OpenFileDialog openFileDialog = new OpenFileDialog()) //Task 452 if (File.Exists(txtImportFolder.Text + txtImportFileName.Text)) //Task 452 { DataTable create_dt = new DataTable(); //HET Creat_Datatable_Column(create_dt); //openFileDialog.FileName = txtImportFolder.Text + txtImportFileName.Text; //Task 452 filepath = txtImportFolder.Text + txtImportFileName.Text; //Task 452 string[] csvRows = File.ReadAllLines(txtImportFolder.Text + txtImportFileName.Text, Encoding.GetEncoding(932)); var bl_List = new List <bool>(); for (int i = 1; i < csvRows.Length; i++) { error = "false"; var splits = csvRows[i].Split(','); DataRow dr = create_dt.NewRow(); for (int j = 0; j < splits.Length; j++) { if (string.IsNullOrEmpty(splits[j])) { dr[j] = DBNull.Value; } else { dr[j] = splits[j].ToString(); } } dr["InsertOperator"] = base_Entity.OperatorCD; dr["UpdateOperator"] = base_Entity.OperatorCD; dr["Error"] = error; create_dt.Rows.Add(dr); } DataTable dt_Main = new DataTable(); if (create_dt.Rows.Count > 0) { //dt_Main = create_dt.AsEnumerable() // .GroupBy(r => new { Col1 = r["TokuisakiCD"], Col2 = r["KouritenCD"], Col3 = r["TokuisakiRyakuName"], Col4 = r["KouritenRyakuName"], Col5 = r["DenpyouNO"], Col6 = r["DenpyouDate"], Col7 = r["ChangeDate"], Col8 = r["ShukkaDenpyouTekiyou"]}) // .Select(g => g.OrderBy(r => r["TokuisakiCD"]).First()) // .CopyToDataTable(); dt_Main = create_dt.AsEnumerable() .GroupBy(r => new { Col1 = r["TokuisakiCD"], Col2 = r["KouritenCD"], Col3 = r["ShukkaSiziNO"] }) .Select(g => g.OrderBy(r => r["TokuisakiCD"]).First()) .CopyToDataTable(); create_dt.Columns.Add("ShukkaNO", typeof(string)); create_dt.Columns.Add("ShukkaGyouNO", typeof(string)); dt_Main.Columns.Add("ShukkaNO", typeof(string)); for (int i = 0; i < dt_Main.Rows.Count; i++) { string changeDate = dt_Main.Rows[i]["ChangeDate"].ToString(); // begin For Task NO. 593 NMW TextBox txt = new TextBox(); txt.Text = dt_Main.Rows[i]["ChangeDate"].ToString(); string date = string.Empty; if (cf.DateCheck(txt)) { date = txt.Text; dt_Main.Rows[i]["ChangeDate"] = date; } TextBox d_txt = new TextBox(); d_txt.Text = dt_Main.Rows[i]["DenpyouDate"].ToString(); if (cf.DateCheck(d_txt)) { dt_Main.Rows[i]["DenpyouDate"] = d_txt.Text; } // end For Task NO. 593 NMW DataTable shukkano_dt = ShukkaTorikomi_BL.GetShukkaNO("6", date, "0"); dt_Main.Rows[i]["ShukkaNO"] = shukkano_dt.Rows[0]["Column1"]; string tokuisakiCD = dt_Main.Rows[i]["TokuisakiCD"].ToString(); string kouritenCD = dt_Main.Rows[i]["KouritenCD"].ToString(); //string tokuisakiryakuName = dt_Main.Rows[i]["TokuisakiRyakuName"].ToString(); //string kouritenryakuName = dt_Main.Rows[i]["KouritenRyakuName"].ToString(); //string denpyouNO = dt_Main.Rows[i]["DenpyouNO"].ToString(); //string shukkadenpyouTekiyou= dt_Main.Rows[i]["ShukkadenpyouTekiyou"].ToString(); string ShukkaSiziNO = dt_Main.Rows[i]["ShukkaSiziNO"].ToString(); string null_val = string.Empty; DataRow[] select_dr = null; //if (string.IsNullOrEmpty(shukkadenpyouTekiyou)) // null_val = " and [ShukkadenpyouTekiyou] IS NULL"; //if (!string.IsNullOrEmpty(null_val)) // select_dr = create_dt.Select("TokuisakiCD = '" + tokuisakiCD + "'and KouritenCD='" + kouritenCD + "' and TokuisakiRyakuName='" + tokuisakiryakuName + "' and KouritenRyakuName='" + kouritenryakuName + "' and DenpyouNO='" + denpyouNO + "'and DenpyouDate = '" + denpyouDate + "' and ChangeDate='" + changeDate + "'" + null_val + ""); //else select_dr = create_dt.Select("TokuisakiCD = '" + tokuisakiCD + "'and KouritenCD='" + kouritenCD + "' and TokuisakiRyakuName='" + tokuisakiryakuName + "' and KouritenRyakuName='" + kouritenryakuName + "' and DenpyouNO='" + denpyouNO + "'and DenpyouDate = '" + denpyouDate + "' and ChangeDate='" + changeDate + "'"); select_dr = create_dt.Select("TokuisakiCD = '" + tokuisakiCD + "'and KouritenCD='" + kouritenCD + "' and ShukkaSiziNO='" + ShukkaSiziNO + "'"); if (select_dr.Length > 0) { for (int j = 0; j < select_dr.Length; j++) { select_dr[j]["ShukkaNO"] = shukkano_dt.Rows[0]["Column1"]; select_dr[j]["ShukkaGyouNO"] = j + 1; } } } Column_Remove_Datatable(dt_Main); Xml_Main = cf.DataTableToXml(dt_Main); } if (create_dt.Rows.Count > 0) { for (int r = 0; r < create_dt.Rows.Count; r++) { //-- begin-- NMW Task 592 TextBox d_t1 = new TextBox(); d_t1.Text = create_dt.Rows[r]["DenpyouDate"].ToString(); //column_1 TextBox d_t2 = new TextBox(); d_t2.Text = create_dt.Rows[r]["ChangeDate"].ToString(); //column_2 if (cf.DateCheck(d_t1)) { create_dt.Rows[r]["DenpyouDate"] = string.IsNullOrEmpty(d_t1.Text) ? null : d_t1.Text; } if (cf.DateCheck(d_t2)) { create_dt.Rows[r]["ChangeDate"] = string.IsNullOrEmpty(d_t2.Text) ? null : d_t2.Text; } //--end -- NMW Task 592 string date1 = create_dt.Rows[r]["DenpyouDate"].ToString(); //column_1 string date2 = create_dt.Rows[r]["ChangeDate"].ToString(); //column_2 int line_No = r + 1; if (Date_Check(date1, line_No, "入力可能値外エラー", "項目:伝票日付") == "true") { return(null, null); //comment by NMW // r = create_dt.Rows.Count; //chg 24-05-2021 ssa } else if (Date_Check(date2, line_No, "入力可能値外エラー", "項目:出荷日") == "true") { return(null, null); //comment by NMW //r = create_dt.Rows.Count;//chg 24-05-2021 ssa } else if (r == create_dt.Rows.Count - 1) { Xml_Detail = cf.DataTableToXml(create_dt); } } } else { Xml_Detail = string.Empty; Xml_Main = string.Empty; } } else //2021 / 05 / 24 ssa CHG TaskNO 492 { bbl.ShowMessage("E281"); txtImportFolder.Focus(); } return(Xml_Detail, Xml_Main); }