Beispiel #1
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {

            if (dtMultiSaveMKT21 != null && dtMultiSaveMKT21.Rows.Count > 0)
            {

                bool bResult = false;
                string strID = "", strErrMsg = "";
                ArrayList ParameterList = new ArrayList();
                //-------------------------
                ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                MKTModel.VDS_MKT21_BCO BCO = new MKTModel.VDS_MKT21_BCO(ConnectionDB);

                try
                {

                    for (Int32 i = 0; i <= dtMultiSaveMKT21.Rows.Count - 1; i++)
                    {
                        ParameterList.Clear();
                        ParameterList.Add(dtMultiSaveMKT21.Rows[i]["CHAN_NO"].ToString().Trim());
                        ParameterList.Add(dtMultiSaveMKT21.Rows[i]["STORE"].ToString().Trim());
                        ParameterList.Add(Session["UID"].ToString());

                        bResult = BCO.ADD_UN_TAG_STORE(ParameterList, DBT, out strID, out strErrMsg);

                        if (!bResult || strErrMsg != "")
                        {
                            throw new Exception(strErrMsg);
                        }
                    }


                    DBT.Commit();//交易成功
                    ErrorMsgLabel.Text = "新增完成";


                    btn_StoreSelect.Enabled = false;
                    btn_Save.Enabled = false;
                    btn_InsertAgain.Visible = true;
                    btn_InsertAgain.Attributes.Add("onclick", "ReloadMKT213();return false;");
                    GridView1.Columns[6].Visible = false;
                }
                catch (Exception ex)
                {
                    DBT.Rollback();//交易失敗
                    throw ex;
                }
                //-------------------------
            }
            else
            {
                ErrorMsgLabel.Text = "請先加入門市";
            }

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally 
        {
            UpdatePanel1.Update();
            UpdatePanel2.Update();
        }
        #endregion
    }
Beispiel #2
0
    protected void btn_SaveDisSetting_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            DateTime ProcessingDateTime = DateTime.Now;

            string strItem = SLP_SKU1.Text;
            string strPeriod = SLP_ItemPeriod1.Text;
            string strDisType = SLP_PARAM1.Text;
            string strDisDate = SLP_SLPDate1.Text;
            string strStAcceptDate = SLP_SLPDate2.Text;
            string strUserId = Session["UID"].ToString();

            if (strDisType == "109" && (dtDisTypeTmp109 == null || dtDisTypeTmp109.Rows.Count <= 0))
            {
                //如果Rank類別=109 且未設定pattern等級設定則不繼續執行
                ErrorMsgLabel.Text = "無設定等級資料,請確認配本方式或重新設定";
                return;
            }


            DataTable NewDisChanReferDt = dtDisChanReferFromPOP;
            string strChan = "";

            if (NewDisChanReferDt != null && NewDisChanReferDt.Rows.Count > 0)
            {
                //檢核【確認通路參照】之個別通路參照比例是否為100%
                if (!CheckChanReferRateIs100(NewDisChanReferDt, out strChan))
                {
                    ErrorMsgLabel.Text = string.Format("通路:{0}參照比率必須為100%!", strChan);
                    return;
                }
            }


            ALOModel.MaintainDisRecord BCO = new ALOModel.MaintainDisRecord(ConnectionDB);
            ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
            System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
           
            try
            {

                SetDisTmpRec(strDisDate, strStAcceptDate, strItem, strPeriod, strDisType, strUserId, ProcessingDateTime);
                SetDisItem(strItem, strPeriod, strDisType, strUserId, ProcessingDateTime);
                SetDisItemRefer(strUserId, ProcessingDateTime);
                SetDisChan(strItem, strPeriod, strStAcceptDate, strDisType, strUserId, ProcessingDateTime);


                #region 重新指定PK欄位
                if (dtDisChan.PrimaryKey.Length <= 0)
                {
                    DataColumn[] PrimaryKeys32 = new DataColumn[4];
                    PrimaryKeys32[0] = dtDisChan.Columns["DIS_NO"];
                    PrimaryKeys32[1] = dtDisChan.Columns["ITEM"];
                    PrimaryKeys32[2] = dtDisChan.Columns["PERIOD"];
                    PrimaryKeys32[3] = dtDisChan.Columns["CHAN_NO"];
                    dtDisChan.PrimaryKey = PrimaryKeys32;
                }

                if (dtDisItemRefer.PrimaryKey.Length <= 0) 
                {
                    DataColumn[] PrimaryKeys42 = new DataColumn[5];
                    PrimaryKeys42[0] = dtDisItemRefer.Columns["DIS_NO"];
                    PrimaryKeys42[1] = dtDisItemRefer.Columns["ITEM"];
                    PrimaryKeys42[2] = dtDisItemRefer.Columns["PERIOD"];
                    PrimaryKeys42[3] = dtDisItemRefer.Columns["RITEM"];
                    PrimaryKeys42[4] = dtDisItemRefer.Columns["RPERIOD"];
                    dtDisItemRefer.PrimaryKey = PrimaryKeys42;
                }

                if (dtDisTypeTmp109.PrimaryKey.Length <= 0)
                {
                    DataColumn[] PrimaryKeys62 = new DataColumn[6];
                    PrimaryKeys62[0] = dtDisTypeTmp109.Columns["DIS_NO"];
                    PrimaryKeys62[1] = dtDisTypeTmp109.Columns["ITEM"];
                    PrimaryKeys62[2] = dtDisTypeTmp109.Columns["PERIOD"];
                    PrimaryKeys62[3] = dtDisTypeTmp109.Columns["RANK_CODE"];
                    PrimaryKeys62[4] = dtDisTypeTmp109.Columns["RANK_LEVEL"];
                    PrimaryKeys62[5] = dtDisTypeTmp109.Columns["PATTERN_NO"];
                    dtDisTypeTmp109.PrimaryKey = PrimaryKeys62;
                }

                #endregion


                bool bResult = BCO.UpdateDisRecordFor131(dtDisTmpRec, dtDisTmpRecOld,
                  dtDisMain, dtDisMainOld, dtDisItem, dtDisItemOld,
                  dtDisChan, dtDisChanOld, dtDisItemRefer, dtDisItemReferOld,
                  dtDisTypeTmp109, dtDisType109TmpOld,
                  dtDisTypeTmp, dtDisTypeTmpOld, NewDisChanReferDt, s_DISNO, strItem, strPeriod, strUserId, strStAcceptDate, DBT);

                if (bResult)
                {
                    ALOModel.MaintainDisTmpRec BCO2 = new ALOModel.MaintainDisTmpRec(ConnectionDB);
                    BCO2.UpdateDisTmpRec(dtDisTmpRec, dtDisTmpRecOld, s_DISNO, DBT);
                }


                DBT.Commit();//交易成功

            }
            catch (Exception ex)
            {
                DBT.Rollback();//交易失敗
                throw ex;
            }

            GetAllOriginalDatatables();
            BindingData();

            dtDisChanReferFromPOP = null;
            ConfirmItemReferPressed = false;


            ResultMsgLabel.Text = "更新成功";

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

        #endregion
    }
Beispiel #3
0
    protected void btn_SaveAssist_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            DateTime ProcessingDateTime = OperationProcessingDateTime;
            string strUserId = Session["UID"].ToString();
            bool bResult = false;

            DataTable dtAssistMain = null;

            if (CheckAndSetAssistMainByAssistCodeChecked(ProcessingDateTime,strUserId,out dtAssistMain))
            {

                #region
                DataTable dtTemp = dtDisAssistDetlAll;

                if (dtTemp != null && dtTemp.Rows.Count > 0)
                {
                    string strChanNo = GetChanNo_AssistSetting();

                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        if (dr.RowState != DataRowState.Deleted)
                        {
                            dr["CHAN_NO"] = strChanNo;
                        }
                    }

                    dtDisAssistDetlAll = dtTemp;
                }
                #endregion

                ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();

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

                ALOModel.MaintainDisItem BCO2 = new ALOModel.MaintainDisItem(ConnectionDB);

                ArrayList ParameterList = new ArrayList();//20091106
                ParameterList.Clear();
                ParameterList.Add(txt_DisNo.Text.Trim());
                ParameterList.Add(SLP_SKU1.Text.Trim());
                ParameterList.Add(SLP_ItemPeriod1.Text.Trim());
                ParameterList.Add(GetChanNo_AssistSetting());
                ParameterList.Add(ProcessingDateTime);
                ParameterList.Add(strUserId);



                try
                {
                    bResult = BCO.DeleteOldDisAssist(ParameterList, DBT);

                    if (bResult)
                    {
                        #region 重新將09、10類型之輔助項目填回DB
                        if (dtDisAssistMainALO131 != null && dtDisAssistMainALO131.Rows.Count > 0)
                        {
                            for (Int32 i = 0; i <= dtDisAssistMainALO131.Rows.Count - 1; i++)
                            {
                                if (dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"].ToString().Trim() == "09" ||
                                    dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"].ToString().Trim() == "10")
                                {

                                    ParameterList.Clear();
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["DIS_NO"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ITEM"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["PERIOD"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHAN_NO"]); 
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OPERATOR1"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OP_VALUE1"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OPERATOR2"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OP_VALUE2"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHANGE_TYPE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHANGE_RATE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ORDER_CHANGE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["UPDATEDATE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["UPDATEUID"]);
                                    bResult = BCO.CreateAssistMain(ParameterList, DBT);
                                }
                            }

                        }
                        #endregion

                        if (BCO.CreateAssistMain(dtAssistMain, DBT))
                        {
                            bResult = BCO.CreateAssistDetl(dtDisAssistDetlAll, DBT);

                            ArrayList ParameterList1 = new ArrayList();//20091106
                            ParameterList1.Clear();
                            ParameterList1.Add(txt_Remark.Text.Trim());
                            ParameterList1.Add(s_ID_DisItem);
                            ParameterList1.Add(s_UPDATEDATE);
                            ParameterList1.Add(s_UPDATEUID);
                            ParameterList1.Add(s_DISNO);
                            ParameterList1.Add(s_ITEM);
                            ParameterList1.Add(s_PERIOD);

                            BCO2.SaveAssistMemo(ParameterList1, DBT);
                        

                            ResultMsgLabel.Text = "存檔成功";

                        }
                    }

                    DBT.Commit();//交易成功


                }
                catch (Exception ex)
                {
                    DBT.Rollback();//交易失敗
                    throw ex;
                }
                finally 
                {
                    GetAssistMainAndDetl();
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Beispiel #4
0
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            ResultMsgLabel.Text = "";
            hiddenErrMsg.Value = "";

            DateTime ProcessingDateTime = DateTime.Now;

            string strItem = SLP_SKU1.Text;
            string strPeriod = SLP_ItemPeriod1.Text;
            string strDisType = SLP_PARAM1.Text;
            string strDisDate = SLP_SLPDate1.Text;
            string strStAcceptDate = SLP_SLPDate2.Text;
            string strUserId = Session["UID"].ToString();
            string strErrMsgTmp = "";
            #region


            if (!GetItemPeriodDisStateByItemPeriod(strItem, strPeriod, strStAcceptDate, out strErrMsgTmp))
            {
                ErrorMsgLabel.Text = strErrMsgTmp;
                return;
            }

            //如果Rank類別=109 且未設定pattern等級設定則不繼續執行
            if (strDisType == "109" && (dtDisTypeTmp109 == null || dtDisTypeTmp109.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "無設定等級資料,請確認配本方式或重新設定";
                return;
            }

            SetDisTmpRec(strDisDate, strStAcceptDate, strItem, strPeriod, strDisType, strUserId, ProcessingDateTime);
            SetDisMain(strDisDate, strStAcceptDate, strUserId, ProcessingDateTime);
            SetDisItem(strItem, strPeriod, strDisType, strUserId, ProcessingDateTime);
            SetDisChan(strItem, strPeriod, strStAcceptDate, strDisType, strUserId, ProcessingDateTime);

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

            //當為新增模式時,或編輯模式下改變配本方式
            if (CurrentPageMode == PageCurrentMode.Insert || (CurrentPageMode == PageCurrentMode.Edit && s_DIS_TYPE_Original != strDisType))
            {
                if (strDisType == "101" || strDisType == "103" || strDisType == "104")
                {
                    dtDisItemRefer = BCO.QueryDisItemReferByDisType(dtParam, dtDisItem, strDisType, strItem, strPeriod, vItemReferCount);

                    currentGvMode = CurrentGridviewMode.View;
                    gv_ItemRefer.DataSource = dtDisItemRefer;
                    gv_ItemRefer.DataBind();
                    hiddenDtDisItemReferCounts.Value = dtDisItemRefer.Rows.Count.ToString();
                    CalculateReferRateSum();

                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", string.Format("SwitchControlDisplay('{0}','{1}',1);", Panel_ItemRefer.ClientID, hiddenItemReferDisplayMode.ClientID), true);
                }
            }

            SetDisItemRefer(strUserId, ProcessingDateTime);
            #endregion

            if (CurrentPageMode == PageCurrentMode.Insert)
            {
                #region

                ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                try
                {
                    string strDisNo = BCO.CreateDisRecordFor131(dtDisTmpRec, dtDisMain, dtDisItem, dtDisChan, dtDisItemRefer, dtDisTypeTmp109, dtDisTypeTmp, strItem, strPeriod, strUserId, DBT);

                    if (strDisNo != "")
                    {
                        ALOModel.MaintainDisTmpRec BCO2 = new ALOModel.MaintainDisTmpRec(ConnectionDB);
                        BCO2.CreateDisTmpRec(dtDisTmpRec, strDisNo, DBT);
                    }


                    DBT.Commit();//交易成功

                }
                catch (Exception ex)
                {
                    DBT.Rollback();//交易失敗
                    throw ex;
                }

                QueryData();

                ResultMsgLabel.Text = "新增成功";
                #endregion
            }
            else if (CurrentPageMode == PageCurrentMode.Edit)
            {
                #region

                SetPrimaryKeyForDataTable();

                ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();
                try
                {

                    bool bResult = BCO.UpdateDisRecordFor131(dtDisTmpRec, dtDisTmpRecOld,
                      dtDisMain, dtDisMainOld, dtDisItem, dtDisItemOld,
                      dtDisChan, dtDisChanOld, dtDisItemRefer, dtDisItemReferOld,
                      dtDisTypeTmp109, dtDisType109TmpOld,
                      dtDisTypeTmp, dtDisTypeTmpOld, null, s_DISNO, strItem, strPeriod, strUserId, strStAcceptDate, DBT);

                    if (bResult)
                    {
                        ALOModel.MaintainDisTmpRec BCO2 = new ALOModel.MaintainDisTmpRec(ConnectionDB);
                        BCO2.UpdateDisTmpRec(dtDisTmpRec, dtDisTmpRecOld, s_DISNO, DBT);
                    }


                    DBT.Commit();//交易成功

                }
                catch (Exception ex)
                {
                    DBT.Rollback();//交易失敗
                    throw ex;
                }

                QueryData();

                ResultMsgLabel.Text = "更新成功";
                #endregion
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(), "SwitchControlDisplay", string.Format("SwitchControlDisplay('{0}','{1}',0);", Panel_AddNewItem.ClientID, hiddenDisplayMode.ClientID), true);

            SwitchSaveCancelButton(false);

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }