//檢視異常報表 protected void but_Unusual_Report_Click(object sender, EventArgs e) { #region try { #region DataTable dt_Return = new DataTable(); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(PageTimeStamp.Value.Substring(0, 14)); Int32 iTopRowNum; Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum); ParameterList.Add(iTopRowNum); VGIModel.ImportAccept111 BCO_VGI = new PIC.VDS2G.LGT.VGI.ImportAccept111(ConnectionDB); dt_Return = BCO_VGI.QueryError(ParameterList); if (dt_Return.Rows.Count > 0) { string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session["SessionID"] = SessionIDName; Session[SessionIDName] = dt_Return; this.gv_ErrorData.DataSource = dt_Return.DefaultView; this.gv_ErrorData.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); this.gv_ErrorData.PageIndex = 0; this.gv_ErrorData.DataBind(); btn_Export.Enabled = true; } else { btn_Export.Enabled = false; this.gv_ErrorData.DataBind(); ResultMsgLabel.Text = "查無資料"; //System.Web.UI.ScriptManager.RegisterStartupScript(this.up_GridView, this.GetType(), "TO_VGI111.aspx", "alert('查無資料')", true); } #endregion } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; up_ErrorMsg.Update(); } #endregion }
private bool ClientFileToServerTemp() { #region bool bResult = false; try { if (FileUpload1.FileName == "") return bResult = false; string s_UploadPath = string.Empty; string s_BackPath = string.Empty; ArrayList arl_FileUpload_Return = null; ArrayList arl_FileToTmp_Return = null; VGIModel.ImportAccept111 BCO_VGI = new PIC.VDS2G.LGT.VGI.ImportAccept111(ConnectionDB); //清除舊資料 ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(PageTimeStamp.Value.Substring(0, 14)); BCO_VGI.ClearTemp(ParameterList, null); #region 上傳檔案到AP端 //取得要上傳的路徑 s_UploadPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["UploadPath"]).Replace("VGI\\", "") + "\\VGI\\"; arl_FileUpload_Return = BCO_VGI.FileUpload(s_UploadPath, this.FileUpload1, Session["UID"].ToString()); #endregion if (arl_FileUpload_Return[0].ToString() == "FALSE")//檔案上傳至AP端錯誤 { #region bResult = false;//檔案上傳至AP端錯誤,後面直接不做了 #endregion } else if (arl_FileUpload_Return[0].ToString() == "TRUE")//檔案上傳至AP端正常 { #region #region 讀取 Excel 資料 DataSet ds_Excel = BCO_VGI.ReadDataFromExcel(arl_FileUpload_Return[1].ToString()); #endregion #region 將檔案匯入TmpTable s_AP_FileName = string.Empty; s_AP_FileName = arl_FileUpload_Return[3].ToString(); arl_FileToTmp_Return = BCO_VGI.FileToTmp(ds_Excel, PageTimeStamp.Value.Substring(0, 14), Session["UID"].ToString(), s_AP_FileName); #endregion if (arl_FileToTmp_Return[0].ToString() == "FALSE") { this.but_Temp_To_DB.Enabled = false; bResult = false; ErrorMsgLabel.Text = arl_FileToTmp_Return[1].ToString(); //System.Web.UI.ScriptManager.RegisterStartupScript(this.but_File_To_Temp, this.GetType(), "TO_VGI11.aspx", "alert('" + arl_FileToTmp_Return[1].ToString() + "')", true); } else if (arl_FileToTmp_Return[0].ToString() == "TRUE") { #region #region 將資料從 UploadPath 移至 BackPath s_BackPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["BackPath"]).Replace("VGI\\", "") + "\\VGI\\"; s_UploadPath += s_AP_FileName; s_BackPath += s_AP_FileName; System.IO.File.Copy(s_UploadPath, s_BackPath); System.IO.File.Delete(s_UploadPath); #endregion #region 將結果顯示在 UploadStatusPanel 中 //上傳結果 this.UploadStatusPanel1.UploadSum = Int32.Parse(arl_FileToTmp_Return[2].ToString()); this.UploadStatusPanel1.UploadOK = Int32.Parse(arl_FileToTmp_Return[3].ToString()); this.UploadStatusPanel1.UploadNG = Int32.Parse(arl_FileToTmp_Return[4].ToString()); iProcessingCounts = Int32.Parse(arl_FileToTmp_Return[2].ToString()); #endregion this.but_Unusual_Report.Enabled = true; #endregion bResult = bool.Parse(arl_FileToTmp_Return[1].ToString()); this.but_Temp_To_DB.Enabled = bResult; if (Int32.Parse(arl_FileToTmp_Return[4].ToString()) == 0) { ResultMsgLabel.Text = "資料檢查成功,請繼續執行匯入"; } else { if (bool.Parse(arl_FileToTmp_Return[1].ToString())) { ResultMsgLabel.Text = "資料檢查有異常,仍可繼續執行匯入"; } else { ResultMsgLabel.Text = "資料檢查有異常,請檢視異常報表"; } } } return bResult; #endregion } } catch (Exception ex) { throw ex; } return bResult; #endregion }
private void TempDataToDataBase() { #region try { ArrayList arl_Return = null; string s_UploadPath_File = string.Empty; string s_BackPath_File = string.Empty; string strMsg = ""; ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(PageTimeStamp.Value.Substring(0, 14)); VGIModel.ImportAccept111 BCO_VGI = new PIC.VDS2G.LGT.VGI.ImportAccept111(ConnectionDB); if (s_AP_FileName != string.Empty) { arl_Return = BCO_VGI.TmpToDB(ParameterList, out strMsg); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "VGI111", "alert('請重新匯入 EXCEL 檔')", true); } //匯入結果 UploadStatusPanel1.ImportSum = Int32.Parse(arl_Return[0].ToString()); UploadStatusPanel1.ImportOK = Int32.Parse(arl_Return[1].ToString()); UploadStatusPanel1.ImportNG = Int32.Parse(arl_Return[2].ToString()); } catch (Exception ex) { throw ex; } finally { this.but_Temp_To_DB.Enabled = false; this.but_File_To_Temp.Enabled = true; this.but_Unusual_Report.Enabled = true; this.ButtonQuery.Enabled = true; } #endregion }
private void QueryData() { #region DataTable dt_Return = new DataTable(); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(this.txt_User.Text.Trim()); ParameterList.Add(this.txt_Date.Text.Trim()); Int32 iTopRowNum; Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum); ParameterList.Add(iTopRowNum); VGIModel.ImportAccept111 BCO_VGI = new PIC.VDS2G.LGT.VGI.ImportAccept111(ConnectionDB); dt_Return = BCO_VGI.QueryError(ParameterList); if (dt_Return.Rows.Count > 0) { string SessionIDName = string.Format("{0}_{1}", PAGE_DT_01, PageTimeStamp.Value); Session["SessionID"] = SessionIDName; Session[SessionIDName] = dt_Return; this.gv_ErrorData.DataSource = dt_Return.DefaultView; this.gv_ErrorData.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) <= 0) ? 10 : int.Parse(TextBoxPagesize.Text); this.gv_ErrorData.PageIndex = 0; this.gv_ErrorData.DataBind(); btn_Export.Enabled = true; } else { btn_Export.Enabled = false; this.gv_ErrorData.DataBind(); ResultMsgLabel.Text = "查無資料"; //System.Web.UI.ScriptManager.RegisterStartupScript(this.up_GridView, this.GetType(), "TO_VGI111.aspx", "alert('查無資料')", true); } #endregion }