Exemplo n.º 1
0
    protected void btnExecute_Click(object sender, EventArgs e)
    {
        try
        {
            string s_Chan_No, s_Chan_Option;// 通路,計算類別
            //計算類別
            if (this.rbtn_Chan.Checked)
            {
                s_Chan_No = null;
                s_Chan_Option = "0";
            }
            else
            {
                s_Chan_No = (this.SLP_StoreChain1.Text.Trim() == "") ? null : this.SLP_StoreChain1.Text.Trim();
                s_Chan_Option = "1";
            }
            #region 執行計算
            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO);
            ParameterList.Add(s_ITEM);
            ParameterList.Add(s_PERIOD);
            ParameterList.Add(s_Chan_No);
            ParameterList.Add(s_Chan_Option);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(s_SESSION_ID);

            ALOModel.MaintainDisRecord BCO = new ALOModel.MaintainDisRecord(ConnectionDB);
            bool bResult;
            if (this.rbtn_Chan.Checked) //通路計算
            {
                bResult = BCO.CalculateDisQtyByChanRatio(ParameterList, null);
            }
            else
            {
                bResult = BCO.CalculateDisQtyByAreaRatio(ParameterList, null);
            }
            if (bResult)
            {
                #region  new

                #region 取得待處理資訊

                #region 產生暫存檔資訊
                try
                {
                    ALOModel.MaintainDisRecord BCO2 = new ALOModel.MaintainDisRecord(ConnectionDB);
                    ParameterList.Clear();
                    ParameterList.Add(s_DIS_NO);
                    ParameterList.Add(s_ITEM);
                    ParameterList.Add(s_PERIOD);
                    ParameterList.Add(Session["UID"].ToString());
                    ParameterList.Add(s_SESSION_ID);

                    bool bResult2 = BCO2.CreateALO116TMP(ParameterList);

                    if (!bResult2)
                    {
                        throw new Exception("建立暫存檔失敗");
                    }

                }
                catch (Exception ex)
                {
                    this.ErrorMsgLabel.Text = ex.Message;
                    return;
                }

                #endregion

                QueryAllChanData(); //取得通路資料

                QueryAllAreaData(); //取得區域資料

                #endregion

                this.up_Chan.Update();
                this.up_Area.Update();

                if (this.rbtn_Chan.Checked)//通路比例分配
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "",
                        "LockOrUnLockButtonInGridviewControl(false,'gv_Chan','btn');LockOrUnLockButtonInGridviewControl(true,'gv_Area','btn');", true);
                }
                else//區域比例分配
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "",
                        "LockOrUnLockButtonInGridviewControl(true,'gv_Chan','btn');LockOrUnLockButtonInGridviewControl(false,'gv_Area','btn');", true);
                }
                #endregion

                this.RightMsgLabel.Text = "計算完成";
                this.up_Msg.Update();

                #region old
                //if (this.rbtn_Chan.Checked) //通路計算
                //{
                //    QueryAllChanData();
                //    this.up_Chan.Update();
                //}
                //else
                //{
                //    QueryAllAreaData();
                //    this.up_Area.Update();
                //}
                #endregion
            }

            #endregion
        }
        catch (Exception ex)
        {
            WaringLogProcess(ex.Message);
            this.ErrorMsgLabel.Text = ex.Message;
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region
        ErrorMsgLabel.Text = "";
        RightMsgLabel.Text = "";

        if (!IsPostBack)
        {
            #region
            if (Request.QueryString["PageTimeStamp"] != null)
                PageTimeStamp.Value = Request.QueryString["PageTimeStamp"];
            else
                PageTimeStamp.Value = string.Format("{0}{1}{2}{3}{4}{5}",
                                                DateTime.Now.Year.ToString(),
                                                DateTime.Now.Month.ToString().PadLeft(2, '0'),
                                                DateTime.Now.Day.ToString().PadLeft(2, '0'),
                                                DateTime.Now.Hour.ToString().PadLeft(2, '0'),
                                                DateTime.Now.Minute.ToString().PadLeft(2, '0'),
                                                DateTime.Now.Second.ToString().PadLeft(2, '0')
                                                );


            #region 取傳入參數
            //string s_DIS_NO, s_ITEM, s_PERIOD;
            try
            {
                s_DIS_NO = Request.QueryString["DIS_NO"];
            }
            catch
            {
                s_DIS_NO = null;
            }

            try
            {
                s_ITEM = Request.QueryString["ITEM"];
            }
            catch
            {
                s_ITEM = null;
            }
            try
            {
                s_PERIOD = Request.QueryString["PERIOD"];
            }
            catch
            {
                s_PERIOD = null;
            }

            if (s_DIS_NO == null || s_ITEM == null || s_PERIOD == null)
            {
                this.ErrorMsgLabel.Text = "傳入參數(配本序號,品號,期別)有誤,無法執行計算!請回前頁重新執行";
                return;
            }
            s_SESSION_ID = this.PageTimeStamp.Value.ToString() + "_" + Session["UID"].ToString();
            #endregion

            #region 設定TextOnChange

            //TextBox txtChanCode = this.SLP_StoreChain1.TextBox_Code;
            //txtChanCode.TextChanged += new System.EventHandler(txtChanCode_TextChanged);
            //this.SLP_StoreChain1.TextBox_Code.Attributes["onchange"] += "__doPostBack(document.all['" + up_Slp_Chan.ClientID + "'].id,'txtChanCode_OnChange');";
            //txtChanCode.AutoPostBack = true;

            //AsyncPostBackTrigger trigger1 = new AsyncPostBackTrigger();
            //trigger1.EventName = "TextChanged";
            //trigger1.ControlID = SLP_StoreChain1.TextBox_Code.UniqueID;
            //this.up_Slp_Chan.Triggers.Add(trigger1);
            #endregion

            #region 取得可調整之有效配本門市數

            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(s_DIS_NO);
            ParameterList.Add(s_ITEM);
            ParameterList.Add(s_PERIOD);
            ALOModel.MaintainDisStore bco_store = new ALOModel.MaintainDisStore(ConnectionDB);
            vNonLokcCnt = bco_store.QueryNonLockStoreCount(ParameterList);
            if (vNonLokcCnt <= 0)
            {
                this.ErrorMsgLabel.Text = "可調整之配本門市數=0, 無法進行計算比例, 請回前頁!";
                HasUpdateData = false;
                //return;
            }

            #endregion

            #region 取得待處理資訊

            #region 產生暫存檔資訊
            try
            {
                ALOModel.MaintainDisRecord BCO = new ALOModel.MaintainDisRecord(ConnectionDB);
                ParameterList.Clear();
                ParameterList.Add(s_DIS_NO);
                ParameterList.Add(s_ITEM);
                ParameterList.Add(s_PERIOD);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(s_SESSION_ID);

                bool bResult = BCO.CreateALO116TMP(ParameterList);

                if (!bResult)
                {
                    throw new Exception("建立暫存檔失敗");
                }

            }
            catch (Exception ex)
            {
                this.ErrorMsgLabel.Text = ex.Message;
                return;
            }

            #endregion

            QueryAllChanData(); //取得通路資料

            QueryAllAreaData(); //取得區域資料

            #endregion

            this.btnExecute.Enabled = true;
            //this.Form.DefaultButton = btnExecute.UniqueID;

            rbtn_Chan.Attributes.Add("onclick", "CheckOPType(this);");
            rbtn_Area.Attributes.Add("onclick", "CheckOPType(this);");

            ScriptManager.RegisterStartupScript(this, this.GetType(), "",
                "LockOrUnLockButtonInGridviewControl(false,'gv_Chan','btn');LockOrUnLockButtonInGridviewControl(true,'gv_Area','btn');", true);

            #endregion
        }
        else
        {
            //if (Request.Form["__EVENTARGUMENT"] == "txtChanCode_OnChange")
            //    txtChanCode_OnChange();
        }

        ToolBarInit();
        #region 頁面狀態設定
        //SetPageControlStatus();
        if (Request.QueryString["APPROVE_DATE"] != null && Request.QueryString["APPROVE_DATE"].ToString().Trim() != "")
        {
            ConfirmData = true;
        }
        #endregion
        AuthorityControls(this);
        #endregion
    }