}//Page_Load protected void btn_ConfirmRank_Click(object sender, EventArgs e) { //lblCount.Text = FileUpload1.PostedFile.FileName; //lblQty.Text = FileUpload1.TemplateSourceDirectory; if (this.FileUpload1.HasFile) { //ScriptManager.RegisterStartupScript(Page, this.GetType(), "VGR023.aspx", "alert(' " + FileUpload1.AppRelativeTemplateSourceDirectory + " ');", true); try { string[] bResult; string[] bResult1; if (FileUpload1.HasFile) { //if (System.IO.Path.GetFileName(FileUpload1.FileName).IndexOf(ddlGroupDDD.SelectedItem.Text) == -1) //{ // ErrorMsgLabel.Text = "輸入之檔名非此店群統稱"; // return; //} string tempDir = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["UploadPath"] + "VGR\\"; string backupDir = Server.MapPath("..\\") + System.Configuration.ConfigurationManager.AppSettings["BackPath"] + "VGR\\"; string strfileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();//副檔名 string strfileWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.FileName).ToLower();//檔名 string strFileName = strfileWithoutExtension + DateTime.Now.ToString("yyyyMMddHHmmss") + strfileExtension; //FileUpload1.SaveAs(tempDir + strFileName); string user = Session["UID"].ToString(); MaintainChanReturnData bco = new MaintainChanReturnData(ConntionDB); //CAMCommon bco1 = new CAMCommon(); //DbTransaction transaction = bco.GetTransaction(); try { try { using (StreamReader sr = new StreamReader(FileUpload1.FileContent, System.Text.Encoding.GetEncoding(950))) { string s = null; bco.DoDelImportFile(); while ((s = sr.ReadLine()) != null) { if (s.Trim() != "") bco.DoImportFile(s); //ParameterList.Clear(); //ParameterList.Add(DateTime.Parse(Request.QueryString["BackWardDate"].ToString())); ////ParameterList.Add(Request.QueryString["ChanNo"].ToString()); ////ParameterList.Add(Request.QueryString["Store"].ToString()); //ParameterList.Add(Session["StoreChain"].ToString()); //ParameterList.Add(Session["Store"].ToString()); //ParameterList.Add(Request.QueryString["IsCheck"].ToString()); //ParameterList.Add(Session["UID"].ToString()); //if (s.Length > 52 && s.Substring(36, 10).Trim() != "" && s.Substring(46, 6).Trim() != "") //{ // ParameterList.Add(s.Substring(36,10)); // ParameterList.Add(s.Substring(46, 6)); //} ////bResult = bco.DoImportCheck(ParameterList); //DataTable dtResult = bco.DoImportCheck(ParameterList); //if (dtResult.Rows.Count > 0) //{ // lblCount.Text = dtResult.Rows[0][0].ToString(); // lblQty.Text = dtResult.Rows[0][1].ToString(); // lblErrQty.Text = dtResult.Rows[0][2].ToString(); //} } sr.Close(); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' " + ex.Message + " ');", true); } #region 轉入系統 ////轉入 ParameterList.Clear(); ParameterList.Add(DateTime.Parse(Request.QueryString["BackWardDate"].ToString())); //ParameterList.Add(Request.QueryString["ChanNo"].ToString()); //ParameterList.Add(Request.QueryString["Store"].ToString()); ParameterList.Add(Session["StoreChain"].ToString()); ParameterList.Add(Session["Store"].ToString()); ParameterList.Add(Request.QueryString["IsCheck"].ToString()); ParameterList.Add(Session["UID"].ToString()); //bResult = bco.DoImportCheck(ParameterList); DataTable dtResult = bco.DoImportCheck(ParameterList); if (dtResult.Rows.Count > 0) { lblCount.Text = dtResult.Rows[0][0].ToString(); lblQty.Text = dtResult.Rows[0][1].ToString(); lblErrQty.Text = dtResult.Rows[0][2].ToString(); } dtForBrowse = bco.GetImpData(Session["UID"].ToString()); gv_Result.DataSource = dtForBrowse; gv_Result.DataBind(); #endregion //System.IO.File.Move(tempDir + strFileName, backupDir + strFileName); } catch (Exception ex) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' " + "載入失敗,請檢查檔案格式:" + ex.Message + " ');", true); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' 請輸入檔案路徑 ');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' " + ex.Message + " ');", true); } finally { } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "POP_VGR023_2.aspx", "alert(' 請先選擇檔案 ');", true); } }