Пример #1
0
    }//databind_Dtl

    /// <summary>
    /// Check MST data
    /// </summary>
    private void CheckMstData(string strItem, string strPeriod, out string strPID)
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            strPID = "0";
            BCO.MaintainChainGift bco = new BCO.MaintainChainGift(ConnectionDB);

            ParameterList.Clear();

            ParameterList.Add(strItem);
            ParameterList.Add(strPeriod);

            //取得通路贈品資料 by ITEM,PERIOD
            DataTable dt = bco.QueryChainGiftByPK(ParameterList);

            if (dt != null && dt.Rows.Count > 0)
            {
                strPID = dt.Rows[0]["ID"].ToString();
            }



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

        #endregion
    }
Пример #2
0
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        try
        {

            #region 資料儲存

            BCO.MaintainChainGift bco = new BCO.MaintainChainGift(ConnectionDB);

            {
                switch (this.hid_PageStatus.Value)
                {
                    case "INSERT":
                        #region  處理新增作業

                        {
                            DataTable dtExist = new DataTable();
                            dtExist = bco.QueryChainGiftByPK(this.getParameterList());
                            if (dtExist != null && dtExist.Rows.Count > 0)
                            {
                                ErrorMsgLabel.Text = "已有相同的資料存在,請確認";
                                return;
                            }

                            #region 儲存新增資料


                            // 做資料儲存的動作
                            int v_ID = 0;
                            v_ID = bco.CreateMasterAndDetail(this.getParameterList(), (DataTable)Session["MKT153_DTL_" + PageTimeStamp.Value], null);

                            if (v_ID == 0)
                            {
                                throw new Exception("新增0筆資料!");
                            }
                            else
                            {
                                //由新增模式切換至檢視模式
                                this.hid_PageStatus.Value = "VIEW";
                                this.txt_PageStatus.Text = "VIEW";
                                this.hiddenID.Value = v_ID.ToString();
                            }


                            #endregion

                        }

                        #endregion


                        break;
                    case "EDIT":
                        {

                            #region  處理修改作業
                            try
                            {

                                if (this.hid_DetlStatus.Value != "VIEW")
                                {
                                    //ShowErrorMessage("請將編輯的資料列做[更新]或[取消],再按此鈕");
                                    ErrorMsgLabel.Text = "請將編輯的資料列做[更新]或[取消],再按此鈕";
                                    return;
                                }
                                else
                                {
                                    if (1 == 1)//this.checkDetailData())
                                    {
                                        #region 取得更新前舊值


                                        #region 使用XML轉回DataSet

                                        DataSet DsMaster = new DataSet();
                                        System.IO.StringReader srM = new System.IO.StringReader(MasterOLDData.InnerHtml);
                                        DsMaster.ReadXml(srM);
                                        DataTable dtMasterOLD = DsMaster.Tables[0];

                                        DataTable dtDetailOLD = (DataTable)Session["MKT153_OLDDTL_" + PageTimeStamp.Value];

                                        DataTable dtDetailNEW = (DataTable)Session["MKT153_DTL_" + PageTimeStamp.Value];

                                        ArrayList alDeleteDtl = (ArrayList)Session["MKT153_DTLDELETE_" + PageTimeStamp.Value];

                                        #endregion

                                        #endregion


                                        bco.UpdateMasterAndDetail(this.getParameterList(), dtDetailNEW, null, dtMasterOLD, dtDetailOLD, alDeleteDtl);


                                    }

                                }

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

                            #endregion  處理修改作業

                            break;
                        }
                        break;
                }

            #endregion

                #region 存檔後資料重新讀取
                databind_Mst();

                #endregion

                #region 存檔後狀態設定

                this.hid_PageStatus.Value = "VIEW";
                this.txt_PageStatus.Text = "VIEW";

                #endregion

            }

        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.ToString();
        }
        finally
        {
            if (this.ErrorMsgLabel.Text == "")
            {
                SetPageStatus();
                SetDefaultValue();
            }

        }
    }
Пример #3
0
    /// <summary>
    /// 繫結資料 MST
    /// </summary>
    private void databind_Mst()
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";
            BCO.MaintainChainGift bco = new BCO.MaintainChainGift(ConnectionDB);

            ParameterList.Clear();

            ParameterList.Add(this.SLP_SKU1.Text);
            ParameterList.Add(this.SLP_ItemPeriod1.Text);

            DataTable Dt = bco.QueryChainGiftByPK(ParameterList);

            #region 使用XML放置到前端資料
            MasterOLDData.InnerHtml = Dt.DataSet.GetXml();
            #endregion

            //檢查是否配本過了            
            ViewState["ChkDis"] = CheckDis(this.SLP_SKU1.Text, this.SLP_ItemPeriod1.Text, "");

            databind_Dtl();


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

        #endregion
    }//databind_Mst