Пример #1
0
    protected void btn_Exec_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";

            if (CheckInputValuesNotNull())
            {
                ALOModel.MaintainStoreRank BCO = new PIC.VDS2G.BSM.ALO.MaintainStoreRank(ConnectionDB);
                bool bResult = false;
                Hashtable ht = GetInputValues();

                #region 檢查是否可進行複製

                #region STEP 1:SYS_PROC_FLAG
                ht.Add("Module", "ALO");
                ht.Add("FlagName", "SET_STORERANK_YN");
                ht.Add("InProcess", "Y");

                DataTable dtTemp;
                dtTemp = BCO.CheckSysProcFlag();//檢查是否可進行複製

                if (dtTemp != null && dtTemp.Rows.Count > 0)
                {
                    #region
                    if (dtTemp.Rows[0]["errStoreRank"].ToString().Trim() != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errStoreRank"].ToString().Trim().Replace("請稍後再計算", "請稍後再複製")), true);
                        return;
                    }

                    if (dtTemp.Rows[0]["errDisRec"].ToString().Trim() != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errDisRec"].ToString().Trim().Replace("請稍後再計算", "請稍後再複製")), true);
                        return;
                    }

                    if (dtTemp.Rows[0]["errMultiDisRec"].ToString().Trim() != "")
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errMultiDisRec"].ToString().Trim().Replace("請稍後再計算", "請稍後再複製")), true);
                        return;
                    }
                    #endregion
                }
                #endregion

                #region STEP 2:VDS_ALO_STORERANK_MAIN & VDS_ALO_STORERANK_DETL

                bool bTMP = BCO.CheckCanCopy(ht);
                if (!bTMP)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", "查無資料可複製"), true);
                    return;
                }

                #endregion

                #endregion

                #region 進行複製

                try
                {
                    BCO.SetSYS_PROC_FLAG(ht, null);//設定複製執行中

                    if (rbtn_CopyStore.Checked)
                    {
                        bResult = BCO.CopyStoreRankByStore(ht, null);
                    }
                    else if (rbtn_CopyPattern.Checked)
                    {
                        bResult = BCO.CopyStoreRankByPattern(ht, null);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    ht["InProcess"] = null;
                    BCO.SetSYS_PROC_FLAG(ht, null);//複製完畢
                }

                if (bResult)
                {
                    ResultMsgLabel.Text = "複製成功";
                }
                else
                {
                    ResultMsgLabel.Text = "複製失敗";
                }
                #endregion
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            fmStatus = FormStatus.fmBrowse;
            UpdatePanel1.Update();
        }
        #endregion
    }
Пример #2
0
    private void TempDataToDataBase()
    {
        #region

        try
        {
            #region 檢查是否可進行匯入
            Hashtable ht = new Hashtable();
            ht.Add("Module", "ALO");
            ht.Add("FlagName", "SET_STORERANK_YN");
            ht.Add("InProcess", "Y");
            ALOModel.MaintainStoreRank BCO1 = new ALOModel.MaintainStoreRank(ConnectionDB);
            ALOModel.ImportStoreRank BCO2 = new ALOModel.ImportStoreRank(ConnectionDB);

            DataTable dtTemp;
            dtTemp = BCO1.CheckSysProcFlag();//檢查是否可進行匯入

            if (dtTemp != null && dtTemp.Rows.Count > 0)
            {
                #region
                if (dtTemp.Rows[0]["errStoreRank"].ToString().Trim() != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errStoreRank"].ToString().Trim().Replace("請稍後再計算", "請稍後再匯入")), true);
                    return;
                }

                if (dtTemp.Rows[0]["errDisRec"].ToString().Trim() != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errDisRec"].ToString().Trim().Replace("請稍後再計算", "請稍後再匯入")), true);
                    return;
                }

                if (dtTemp.Rows[0]["errMultiDisRec"].ToString().Trim() != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", string.Format("alert('{0}');", dtTemp.Rows[0]["errMultiDisRec"].ToString().Trim().Replace("請稍後再計算", "請稍後再匯入")), true);
                    return;
                }
                #endregion
            }
            #endregion

            #region 進行匯入

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

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


            if (s_AP_FileName != string.Empty)
            {
                try
                {
                    BCO1.SetSYS_PROC_FLAG(ht, null);//設定匯入執行中
                    arl_Return = BCO2.TmpToDB(s_AP_FileName, s_LoginUser, PageTimeStamp.Value);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally 
                {
                    ht["InProcess"] = null;
                    BCO1.SetSYS_PROC_FLAG(ht, null);//匯入完畢
                }
            }
            else
            { this.Response.Write("請重新匯入 EXCEL 檔"); }

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

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

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

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

                #endregion
            }
            #endregion
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        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_Back.Enabled = true;
        }
        #endregion
    }