Esempio n. 1
0
    private void TempDataToDataBase()
    {
        #region

        DataTable dtBatchImportResult = null;

        try
        {

            ArrayList arl_Return = null;
            string s_LoginUser = string.Empty;
            string s_UploadPath_File = string.Empty;
            string s_BackPath_File = string.Empty;

            string strSerialBatchNo = "";

            s_LoginUser = Session["UID"].ToString();//登入人員

            Int32 iCurrentImportType = GetCurrentImportType();

            Hashtable HtParams = new Hashtable();
            HtParams.Clear();
            HtParams.Add("IMP_TYPE", iCurrentImportType);
            HtParams.Add("DIS_DATE", SLP_SLPDate1.Text);
            HtParams.Add("ST_ACCEPT_DATE", SLP_SLPDate2.Text);
            HtParams.Add("USER_ID", s_LoginUser);
            HtParams.Add("SESSION_ID", PageTimeStamp.Value);

            if (iCurrentImportType == 1 || iCurrentImportType == 2)
            {
                ALOModel.ImportDisRecord BCO = new ALOModel.ImportDisRecord(ConnectionDB);

                if (s_AP_FileName != string.Empty)
                {
                    arl_Return = BCO.TmpToDB(HtParams, out strSerialBatchNo, out dtBatchImportResult);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ALO141", "alert('請重新匯入 EXCEL 檔')", true);
                }
            }
            else if (iCurrentImportType == 3)
            {
                ALOModel.ImportDisCRMRecord BCO = new ALOModel.ImportDisCRMRecord(ConnectionDB);

                if (s_AP_FileName != string.Empty)
                {
                    arl_Return = BCO.TmpToDB(HtParams, out strSerialBatchNo, out dtBatchImportResult);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ALO141", "alert('請重新匯入 EXCEL 檔')", true);
                }

            }

            if (arl_Return[0].ToString() == "TEMPTODB 正確")
            {
                #region 設定 UploadStatusPanel 的值

                //匯入結果
                UploadStatusPanel1.ImportSum = iProcessingCounts;
                UploadStatusPanel1.ImportOK = iProcessingCounts;
                UploadStatusPanel1.ImportNG = 0;

                #endregion

                ShowBatchImportGridView(true, dtBatchImportResult);
            }
            else if (arl_Return[0].ToString() == "CHECKDATA 不正確")
            {
                #region 設定 UploadStatusPanel 的值

                //匯入結果
                UploadStatusPanel1.ImportSum = iProcessingCounts;
                UploadStatusPanel1.ImportOK = 0;
                UploadStatusPanel1.ImportNG = iProcessingCounts;

                #endregion

              ShowBatchImportGridView(false, dtBatchImportResult);
            }
            else //程式錯誤
            {
              #region 設定 UploadStatusPanel 的值
              //上傳結果
              this.UploadStatusPanel1.UploadSum = 0;
              this.UploadStatusPanel1.UploadOK = 0;
              this.UploadStatusPanel1.UploadNG = 0;
              //匯入結果
              this.UploadStatusPanel1.ImportSum = -1;
              this.UploadStatusPanel1.ImportOK = -1;
              this.UploadStatusPanel1.ImportNG = -1;

              #endregion
              throw new Exception(arl_Return[1].ToString());

            }

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel_PostBack.Text = ex.Message;
            ShowBatchImportGridView(false, dtBatchImportResult);
        }
        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;
            this.btn_Exit.Enabled = true;
        }
        #endregion
    }
Esempio n. 2
0
    //檢視異常報表
    protected void but_Unusual_Report_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            string s_LoginUser = string.Empty;
            DataTable dt_Return = new DataTable();
            ArrayList ParameterList = new ArrayList();

            s_LoginUser = Session["UID"].ToString();//登入人員

            ParameterList.Clear();
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(string.Empty);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(DateTime.Now);

            Int32 iTopRowNum;
            Int32.TryParse(TextBoxRowCountLimit.Text.Trim(), out iTopRowNum);
            ParameterList.Add(iTopRowNum);
            ParameterList.Add(PageTimeStamp.Value);


            Int32 iCurrentImportType = GetCurrentImportType();

            if (iCurrentImportType == 1 || iCurrentImportType == 2)
            {
                ALOModel.ImportDisRecord BCO = new ALOModel.ImportDisRecord(ConnectionDB);
                dt_Return = BCO.QueryErrorByFind(ParameterList);
            }
            else if (iCurrentImportType == 3)
            {
                ALOModel.ImportDisCRMRecord BCO = new ALOModel.ImportDisCRMRecord(ConnectionDB);
                dt_Return = BCO.QueryErrorByFind(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.DataSource = dt_Return.DefaultView;
                this.gv_ErrorData.DataBind();
                //System.Web.UI.ScriptManager.RegisterStartupScript(this.up_GridView, this.GetType(), "TO_ALO141.aspx", "alert('查無資料')", true);
                ResultMsgLabel.Text = "查無資料";

            }

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
        #endregion
    }
Esempio n. 3
0
    /// <summary>
    /// 有單號商品(客服手開單)
    /// </summary>
    /// <returns></returns>
    private bool ClientFileToServerTemp_AvecNumero()
    {
        #region

        bool bResult = false;

        try
        {
            if (FileUpload1.FileName == "") return bResult = false; ;

            string s_UploadPath = string.Empty;
            string s_BackPath = string.Empty;
            string s_LoginUser = string.Empty;
            ArrayList arl_FileUpload_Return = null;
            ArrayList arl_FileToTmp_Return = null;

            ALOModel.ImportDisCRMRecord BCO = new ALOModel.ImportDisCRMRecord(ConnectionDB);

            #region 上傳檔案到AP端


            //取得要上傳的路徑
            s_UploadPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["UploadPath"]).Replace("ALO\\", "") + "\\ALO\\";

            s_LoginUser = Session["UID"].ToString();

            arl_FileUpload_Return = BCO.FileUpload(s_UploadPath, this.FileUpload1, s_LoginUser);

            #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.ReadDataFromExcel(arl_FileUpload_Return[1].ToString());

                #endregion

                #region 將檔案匯入TmpTable

                DateTime d_CreateDate = Convert.ToDateTime(arl_FileUpload_Return[2]);
                s_AP_FileName = string.Empty;
                s_AP_FileName = arl_FileUpload_Return[3].ToString();

                arl_FileToTmp_Return = BCO.FileToTmp2(ds_Excel, d_CreateDate, s_LoginUser, s_AP_FileName, SLP_SLPDate1.Text, SLP_SLPDate2.Text, GetCurrentImportType(),PageTimeStamp.Value);

                #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_ALO141.aspx", "alert('" + arl_FileToTmp_Return[1].ToString() + "')", true);
                }
                else if (arl_FileToTmp_Return[0].ToString() == "TRUE")
                {
                    #region
                    if (((bool)arl_FileToTmp_Return[1]) == false)
                    { this.but_Temp_To_DB.Enabled = false; }//代表內容邏輯不正確

                    else
                    { this.but_Temp_To_DB.Enabled = true; }

                    #region 將資料從 UploadPath 移至 BackPath

                    s_BackPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["BackPath"]).Replace("ALO\\", "") + "\\ALO\\";

                    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 = ((int)arl_FileToTmp_Return[2]);
                    this.UploadStatusPanel1.UploadOK = ((int)arl_FileToTmp_Return[3]);
                    this.UploadStatusPanel1.UploadNG = ((int)arl_FileToTmp_Return[4]);
                    //匯入結果
                    this.UploadStatusPanel1.ImportSum = 0;
                    this.UploadStatusPanel1.ImportOK = 0;
                    this.UploadStatusPanel1.ImportNG = 0;

                    iProcessingCounts = ((int)arl_FileToTmp_Return[2]);


                    #endregion

                    this.but_Unusual_Report.Enabled = true;
                    #endregion

                    if ((int)arl_FileToTmp_Return[4] == 0)
                    {
                        bResult = true;
                    }
                    else
                    {
                        bResult = false;
                    }
                }

                return bResult;

                #endregion
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel_PostBack.Text = ex.Message;
            return bResult = false;
        }

        return bResult;

        #endregion
    }