Ejemplo n.º 1
0
    protected void btnAdd_B_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件
            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage(sender, "B");

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            #endregion
            string SessionIDName = "STM193_gvB" + PageTimeStamp.Value;
            DataTable dtB = new DataTable();
            if (Session[SessionIDName] == null)
            {
                dtB = this.MakeDTForPriceDis();
            }
            else
            {
                dtB = (DataTable)Session[SessionIDName];
            }

            DataRow[] drB2 = (DataRow[])dtB.Select("ID=" + (this.HidIDB.Value == "" ? "0" : this.HidIDB.Value) + " AND EFF_START =CONVERT('" + Convert.ToDateTime(SLP_SLPDate1.Text).ToShortDateString() + "','System.DateTime')");

            if (drB2.Length == 0)
            {
                #region 檢查生效日期
                DataRow[] drB1 = (DataRow[])dtB.Select("STORE='" + SLP_Store1.Text.Trim() + "' AND ROOT_NO ='" + SLP_RootNo_B.Text.Trim() + "' AND  PMA ='" + SLP_PMA_B.Text.Trim()
                             + "' AND  CATEGORY ='" + SLP_Category_B.Text.Trim() + "'"
                             + " AND  EFF_END >=CONVERT('" + Convert.ToDateTime(SLP_SLPDate1.Text).ToShortDateString() + "','System.DateTime')");
                if (drB1.Length > 0)
                {
                    ErrorMsgLabel.Text = "有效開始日期輸入有誤,應大於相同中分類折扣的有效結束日";
                    return;
                }

                ArrayList ArrPar = new ArrayList();
                ArrPar.Add(this.SLP_Store1.Text.Trim());
                ArrPar.Add(16);
                ArrPar.Add(Convert.ToDateTime(this.SLP_SLPDate1.Text.Trim()));
                ArrPar.Add(this.SLP_RootNo_B.Text.Trim());
                ArrPar.Add(this.SLP_PMA_B.Text.Trim());
                ArrPar.Add(this.SLP_Category_B.Text.Trim());
                ArrPar.Add(System.DBNull.Value);
                ArrPar.Add(System.DBNull.Value);

                BCO.MaintainStoreDiscount bco = new BCO.MaintainStoreDiscount(ConnectionDB);
                int iResult;
                bco.QueryDisCountStartDate(ArrPar, out iResult);
                if (iResult > 0)
                {
                    ErrorMsgLabel.Text = "有效開始日期輸入有誤,應大於相同中分類折扣的有效結束日";
                    return;
                }
                #endregion
            }

            if (this.HidIDB.Value != "")
            {
                DataRow drB = dtB.Select("ID=" + this.HidIDB.Value)[0];
                drB["PRICE_DISCOUNT"] = this.SLP_SLPNumber1.Text.Trim();
                drB["FIX_PRICE_DISCOUNT"] = System.DBNull.Value;
                if (this.SLP_SLPDate1.Text.Trim() != "")
                    drB["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate1.Text.Trim());
                else
                    drB["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate2.Text.Trim() != "")
                    drB["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate2.Text.Trim());
                else
                    drB["EFF_END"] = System.DBNull.Value;

                drB["UPDATEUID"] = Session["UID"].ToString();
                drB["FUN_TYPE"] = "U";
            }
            else
            {
                DataView dv = dtB.DefaultView;
                dv.Sort = "ID desc";

                DataRow drB = dtB.NewRow();
                drB["ID"] = Convert.ToInt64(dv.Count == 0 ? 0 : dv[0]["ID"]) + 1;
                drB["STORE"] = this.SLP_Store1.Text.Trim();
                drB["ROOT_NO"] = this.SLP_RootNo_B.Text.Trim();
                drB["PMA"] = this.SLP_PMA_B.Text.Trim();
                drB["CATEGORY"] = this.SLP_Category_B.Text.Trim();
                drB["PRICE_DISCOUNT"] = this.SLP_SLPNumber1.Text.Trim();
                if (this.SLP_SLPDate1.Text.Trim() != "")
                    drB["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate1.Text.Trim());
                else
                    drB["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate2.Text.Trim() != "")
                    drB["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate2.Text.Trim());
                else
                    drB["EFF_END"] = System.DBNull.Value;

                drB["DISCOUNT_KIND"] = 16;
                drB["CONFIRM_CODE"] = 0;
                drB["FUN_TYPE"] = "A";
                dtB.Rows.Add(drB);
            }
            this.GridViewB.Visible = true;
            DataView dvB = dtB.DefaultView;
            dvB.Sort = "ROOT_NO,PMA,CATEGORY";
            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dtB;
            this.GridViewB.DataSource = dvB;
            this.GridViewB.DataBind();

            SLP_RootNo_B.Text = "";
            SLP_PMA_B.Text = "";
            SLP_Category_B.Text = "";
            SLP_SLPNumber1.Text = "";
            this.SLP_SLPDate1.Text = DateTime.Today.ToString("yyyy/MM/dd");
            this.SLP_SLPDate2.Text = "9999/12/31";
            if (this.HidIDB.Value != "")
            {
                this.panB.Visible = false;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
    }
Ejemplo n.º 2
0
    protected void btnAdd_C_Click(object sender, EventArgs e)
    {

        try
        {
            #region 檢查條件
            this.ErrorMsgLabel.Text = "";
            string strROOT_NO = "";
            string strPMA = "";
            string strCATEGORY = "";
            string s_CheckPage = CheckPage(sender, "C");

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            #endregion

            string SessionIDName = "STM193_gvC" + PageTimeStamp.Value;
            DataTable dtC = new DataTable();
            if (Session[SessionIDName] == null)
            {
                dtC = this.MakeDTForPriceDis();
            }
            else
            {
                dtC = (DataTable)Session[SessionIDName];
            }

            //取得ROOT_NO,PMA,CATEGORY的值
            DataTable dtItem = new DataTable();
            dtItem = this.GetItem(this.SLP_SKU_C.Text.Trim());
            if (dtItem.Rows.Count > 0)
            {
                for (int i = 0; i < dtItem.Rows.Count; i++)
                {
                    strROOT_NO = dtItem.Rows[i]["ROOT_NO"].ToString();
                    strPMA = dtItem.Rows[i]["PMA"].ToString();
                    strCATEGORY = dtItem.Rows[i]["CATEGORY"].ToString();
                }
            }

            DataRow[] drC2 = (DataRow[])dtC.Select("ID=" + (this.HidIDC.Value == "" ? "0" : this.HidIDC.Value) + " AND EFF_START =CONVERT('" + Convert.ToDateTime(SLP_SLPDate3.Text).ToShortDateString() + "','System.DateTime')");

            if (drC2.Length == 0)
            {
                #region 檢查生效日期
                //DataRow[] drC1 = (DataRow[])dtC.Select("STORE='" + SLP_Store1.Text.Trim() + "' AND ROOT_NO ='" + strROOT_NO + "' AND  PMA ='" + strPMA
                //            + "' AND  CATEGORY ='" + strCATEGORY + "' AND  ITEM ='" + SLP_SKU_C.Text.Trim() + "' AND  PERIOD ='" + SLP_ItemPeriod_C.Text.Trim()
                //            + "' AND  EFF_END >=CONVERT('" + Convert.ToDateTime(SLP_SLPDate3.Text).ToShortDateString() + "','System.DateTime')");
                //string strCn = "STORE='" + SLP_Store1.Text.Trim() + "' AND ITEM ='" + SLP_SKU_C.Text.Trim()
                //            + @"' AND  PERIOD ='" + SLP_ItemPeriod_C.Text.Trim()
                //            + "' AND  EFF_END >=CONVERT('" + Convert.ToDateTime(SLP_SLPDate3.Text).ToShortDateString() + "','System.DateTime')";
                //DataRow[] drC1 = (DataRow[])dtC.Select(strCn);
                //if (drC1.Length > 0)
                //{
                //    ErrorMsgLabel.Text = "a有效開始日期輸入有誤,應大於相同商品期別折扣的有效結束日" + strCn;
                //    return;
                //}

                //檢查生效日期
                ArrayList ArrPar = new ArrayList();
                ArrPar.Add(this.SLP_Store1.Text.Trim());
                ArrPar.Add(32);
                ArrPar.Add(Convert.ToDateTime(this.SLP_SLPDate3.Text.Trim()));
                ArrPar.Add(strROOT_NO);
                ArrPar.Add(strPMA);
                ArrPar.Add(strCATEGORY);
                ArrPar.Add(this.SLP_SKU_C.Text.Trim());
                ArrPar.Add(SLP_ItemPeriod_C.Text.Trim());

                BCO.MaintainStoreDiscount bco = new BCO.MaintainStoreDiscount(ConnectionDB);
                int iResult;
                bco.QueryDisCountStartDate(ArrPar, out iResult);
                if (iResult > 0)
                {
                    ErrorMsgLabel.Text = "有效開始日期輸入有誤,應大於相同商品期別折扣的有效結束日";
                    return;
                }
                #endregion
            }


            if (this.HidIDC.Value != "")
            {
                DataRow drC = dtC.Select("ID=" + this.HidIDC.Value)[0];
                drC["PERIOD"] = this.SLP_ItemPeriod_C.Text.Trim();
                drC["PERIOD_END"] = this.txtItemPeriod_END_C.Text.Trim();
                drC["PRICE_DISCOUNT"] = GetValueSetParameter(this.SLP_SLPNumber_C.Text.Trim(), "string", false);
                drC["FIX_PRICE_DISCOUNT"] = GetValueSetParameter(this.SLP_SLPNumber_C2.Text.Trim(), "string", false);
                drC["VENDOR_SUBSIDY_PERCENT"] = GetValueSetParameter(this.SLP_SLPNumber2.Text.Trim(), "string", false);
                drC["COST_PERCENT"] = GetValueSetParameter(this.SLP_SLPNumber3.Text.Trim(), "string", false);
                if (this.SLP_SLPDate3.Text.Trim() != "")
                    drC["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate3.Text.Trim());
                else
                    drC["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate4.Text.Trim() != "")
                    drC["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate4.Text.Trim());
                else
                    drC["EFF_END"] = System.DBNull.Value;

                drC["UPDATEUID"] = Session["UID"].ToString();
                drC["FUN_TYPE"] = "U";
            }
            else
            {
                DataView dv = dtC.DefaultView;
                dv.Sort = "ID desc";

                DataRow drC = dtC.NewRow();
                drC["ID"] = Convert.ToInt64(dv.Count == 0 ? 0 : dv[0]["ID"]) + 1;
                drC["STORE"] = this.SLP_Store1.Text.Trim();
                drC["ROOT_NO"] = strROOT_NO;
                drC["PMA"] = strPMA;
                drC["CATEGORY"] = strCATEGORY;
                drC["ITEM"] = this.SLP_SKU_C.Text.Trim();
                drC["PERIOD"] = this.SLP_ItemPeriod_C.Text.Trim();
                drC["PERIOD_END"] = this.txtItemPeriod_END_C.Text.Trim();
                drC["PRICE_DISCOUNT"] = GetValueSetParameter(this.SLP_SLPNumber_C.Text.Trim(), "string", false);
                drC["FIX_PRICE_DISCOUNT"] = GetValueSetParameter(this.SLP_SLPNumber_C2.Text.Trim(), "string", false);
                drC["VENDOR_SUBSIDY_PERCENT"] = GetValueSetParameter(this.SLP_SLPNumber2.Text.Trim(), "string", false);
                drC["COST_PERCENT"] = GetValueSetParameter(this.SLP_SLPNumber3.Text.Trim(), "string", false);
                if (this.SLP_SLPDate3.Text.Trim() != "")
                    drC["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate3.Text.Trim());
                else
                    drC["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate4.Text.Trim() != "")
                    drC["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate4.Text.Trim());
                else
                    drC["EFF_END"] = System.DBNull.Value;

                drC["DISCOUNT_KIND"] = 32;
                drC["CONFIRM_CODE"] = 0;
                drC["FUN_TYPE"] = "A";
                dtC.Rows.Add(drC);

            }
            this.GridViewC.Visible = true;
            DataView dvC = dtC.DefaultView;
            dvC.Sort = "EFF_START DESC,ROOT_NO,PMA,CATEGORY,ITEM,PERIOD desc";
            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dtC;
            this.GridViewC.DataSource = dvC;
            this.GridViewC.DataBind();

            SLP_SKU_C.Text = "";
            SLP_ItemPeriod_C.Text = "";
            txtItemPeriod_END_C.Text = "";
            SLP_SLPNumber_C2.Text = "";
            SLP_SLPNumber_C.Text = "";
            SLP_SLPNumber2.Text = "";
            SLP_SLPNumber3.Text = "";
            this.SLP_SLPDate3.Text = string.Empty;//DateTime.Today.ToString("yyyy/MM/dd");
            this.SLP_SLPDate4.Text = string.Empty;//"9999/12/31";
            if (this.HidIDC.Value != "")
            {
                this.panC.Visible = false;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
    }
Ejemplo n.º 3
0
    protected void btnAdd_A_Click(object sender, EventArgs e)
    {
        try
        {
            #region 檢查條件
            this.ErrorMsgLabel.Text = "";
            string s_CheckPage = CheckPage(sender, "A");

            if (s_CheckPage != string.Empty)
            {
                this.ErrorMsgLabel.Text = s_CheckPage;
                return;
            }

            string SessionIDName = "STM192_gvA" + PageTimeStamp.Value;
            DataTable dtA = new DataTable();
            if (Session[SessionIDName] == null)
            {
                dtA = this.MakeDTForPriceDis();
            }
            else
            {
                dtA = (DataTable)Session[SessionIDName];
            }

            #endregion

            DataRow[] drA1 = (DataRow[])dtA.Select("STORE='" + SLP_Store1.Text.Trim() + "' AND ROOT_NO ='" + SLP_RootNo_A.Text.Trim() + "' AND  PMA ='" + SLP_PMA_A.Text.Trim()
                             + "' AND  CATEGORY IS NULL AND  ITEM IS NULL AND  PERIOD  IS NULL"
                             + " AND  EFF_START =CONVERT('" + Convert.ToDateTime(SLP_SLPDate_EFF_S_A.Text).ToShortDateString() + "','System.DateTime')");
            if (drA1.Length > 0)
            {
                drA1[0].BeginEdit();
                drA1[0]["STORE"] = this.SLP_Store1.Text.Trim();
                drA1[0]["ROOT_NO"] = this.SLP_RootNo_A.Text.Trim();
                drA1[0]["PMA"] = this.SLP_PMA_A.Text.Trim();
                drA1[0]["PRICE_DISCOUNT"] = this.SLP_SLPNumber_PRICE_DIS_A.Text.Trim();
                if (this.SLP_SLPDate_EFF_S_A.Text.Trim() != "")
                    drA1[0]["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate_EFF_S_A.Text.Trim());
                else
                    drA1[0]["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate_EFF_S_B.Text.Trim() != "")
                    drA1[0]["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate_EFF_S_B.Text.Trim());
                else
                    drA1[0]["EFF_END"] = System.DBNull.Value;
                drA1[0].EndEdit();
            }
            else
            {
                DataRow[] drA2 = (DataRow[])dtA.Select("STORE='" + SLP_Store1.Text.Trim() + "' AND ROOT_NO ='" + SLP_RootNo_A.Text.Trim() + "' AND  PMA ='" + SLP_PMA_A.Text.Trim()
                         + "' AND  EFF_END >=CONVERT('" + Convert.ToDateTime(SLP_SLPDate_EFF_S_A.Text).ToShortDateString() + "','System.DateTime')");
                if (drA2.Length > 0)
                {
                    ErrorMsgLabel.Text = "有效開始日期輸入有誤,應大於相同大分類折扣的有效結束日";
                    return;
                }

                //檢查生效日期
                ArrayList ArrPar = new ArrayList();
                ArrPar.Add(this.SLP_Store1.Text.Trim());
                ArrPar.Add(8);
                ArrPar.Add(Convert.ToDateTime(this.SLP_SLPDate_EFF_S_A.Text.Trim()));
                ArrPar.Add(this.SLP_RootNo_A.Text.Trim());
                ArrPar.Add(this.SLP_PMA_A.Text.Trim());
                ArrPar.Add(System.DBNull.Value);
                ArrPar.Add(System.DBNull.Value);
                ArrPar.Add(System.DBNull.Value);

                BCO.MaintainStoreDiscount bco = new BCO.MaintainStoreDiscount(ConnectionDB);
                int iResult;
                bco.QueryDisCountStartDate(ArrPar, out iResult);
                if (iResult > 0)
                {
                    ErrorMsgLabel.Text = "有效開始日期輸入有誤,應大於相同大分類折扣的有效結束日";
                    return;
                }

                DataRow drA = dtA.NewRow();
                drA["STORE"] = this.SLP_Store1.Text.Trim();
                drA["ROOT_NO"] = this.SLP_RootNo_A.Text.Trim();
                drA["PMA"] = this.SLP_PMA_A.Text.Trim();
                drA["PRICE_DISCOUNT"] = this.SLP_SLPNumber_PRICE_DIS_A.Text.Trim();
                if (this.SLP_SLPDate_EFF_S_A.Text.Trim() != "")
                    drA["EFF_START"] = Convert.ToDateTime(this.SLP_SLPDate_EFF_S_A.Text.Trim());
                else
                    drA["EFF_START"] = System.DBNull.Value;

                if (this.SLP_SLPDate_EFF_S_B.Text.Trim() != "")
                    drA["EFF_END"] = Convert.ToDateTime(this.SLP_SLPDate_EFF_S_B.Text.Trim());
                else
                    drA["EFF_END"] = System.DBNull.Value;

                drA["DISCOUNT_KIND"] = 8;
                drA["CONFIRM_CODE"] = 0;
                drA["FUN_TYPE"] = "A";
                dtA.Rows.Add(drA);
            }

            this.GridViewA.Visible = true;
            DataView dvA = dtA.DefaultView;
            dvA.Sort = "ROOT_NO,PMA";
            Session["SessionID"] = SessionIDName;
            Session[SessionIDName] = dtA;
            this.GridViewA.DataSource = dvA;
            this.GridViewA.DataBind();

            SLP_RootNo_A.Text = "";
            SLP_PMA_A.Text = "";
            SLP_SLPNumber_PRICE_DIS_A.Text = "";
            this.SLP_SLPDate_EFF_S_A.Text = DateTime.Today.ToString("yyyy/MM/dd");
            this.SLP_SLPDate_EFF_S_B.Text = "9999/12/31";
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
    }