コード例 #1
0
ファイル: STM193.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    public static string GetEffictiveRange(string txtItem, string txtPeriod)
    {
        BCO.MaintainStoreGroupDiscount bco = new BCO.MaintainStoreGroupDiscount(ConnectionDB);
        DataTable dt = bco.GetPeriodDate(txtItem, txtPeriod);
        if (dt.Rows.Count == 0)
        {
            throw new Exception("品號期別不存在!!");
        }
        return dt.Rows[0]["StartDate"].ToString() + "," + dt.Rows[0]["EndDate"].ToString();


    }
コード例 #2
0
ファイル: STM272.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void btnConfirmItem_Click(object sender, EventArgs e)
    {

        try
        {

            string txtItem = SLP_ITEM.Text.Trim();
            string txtPeriod = SLP_PERIOD2.Text.Trim();
            if (txtItem.Length == 0 || txtPeriod.Length == 0)
            {
                throw new Exception("商品或期別不能為空值 !! ");
            }
            if (SLP_ACCEPT_DATE_START.Text.Trim() == string.Empty)
            {
                throw new Exception("進貨開始日未設定 !! ");
            }
            if (SLP_ACCEPT_FIRST_DATE.Text.Trim() == string.Empty)
            {
                throw new Exception("首次出貨日未設定 !! ");
            }

            DataSet ds = (DataSet)Session["STM272_" + PageTimeStamp.Value];

            DataRow[] dritem = (DataRow[])ds.Tables[0].Select("STORE='" + txtITEM_STORE.Text + "' AND ITEM='" + SLP_ITEM.Text + "' AND PERIOD='" + SLP_PERIOD2.Text + "'");

            if (dritem.Length > 0)
            {
                throw new Exception("品號期別不能重複 ");
            }

            if (this.SLP_COST_SUBSIDY_PERCENT2.Text.Length > 0)
            {
                if (Convert.ToDecimal(this.SLP_COST_SUBSIDY_PERCENT2.Text.Trim()) > 100 || Convert.ToDecimal(this.SLP_COST_SUBSIDY_PERCENT2.Text.Trim()) < 0)
                {
                    throw new Exception("[出版社補貼%]欄位請輸入100>出版社補貼>0值<br/>");
                }
                else
                {
                    String[] strCOST_SUBSIDY_PERCENT2 = SLP_COST_SUBSIDY_PERCENT2.Text.Trim().Split('.');
                    if (strCOST_SUBSIDY_PERCENT2.Length == 2)
                    {
                        if (Convert.ToDecimal(strCOST_SUBSIDY_PERCENT2[1]) > 99)
                        {
                            throw new Exception("[出版社補貼%]欄位小數只能二位<br/>");
                        }
                    }
                }
            }

            #region 檢查品號期別是否存在
            STMModel.MaintainStoreGroupDiscount bco = new STMModel.MaintainStoreGroupDiscount(ConnectionDB);
            DataTable dtk = bco.GetPeriodDate(txtItem, txtPeriod);
            if (dtk.Rows.Count == 0)
            {
                throw new Exception("品號期別不存在!! ");
            }
            #endregion

            DataRow[] drNoItem = (DataRow[])ds.Tables[0].Select("STORE='" + txtITEM_STORE.Text + "' AND ITEM='NOITEM'");

            if (drNoItem.Length > 0)
            {
                drNoItem[0].Delete();
            }

            DataRow dr = ds.Tables[0].NewRow();

            dr["PROMOTE_CODE"] = txtPROMOTE_ID.Text;
            dr["GROUP_NO"] = lblITEM_GROUP_NO.Text;
            dr["STORE"] = txtITEM_STORE.Text;
            dr["ITEM"] = SLP_ITEM.Text;
            dr["PERIOD"] = SLP_PERIOD2.Text;
            dr["COST_SUBSIDY_PERCENT"] = Decimal.Parse(SLP_COST_SUBSIDY_PERCENT2.Text);
            if (lblITEM_COST.Text == "" || lblITEM_COST.Text == null)
                dr["PRICE_SUBSIDY_PERCENT"] = 0;
            else
                dr["PRICE_SUBSIDY_PERCENT"] = Decimal.Parse(lblITEM_COST.Text.ToString());
            dr["COST_DIS_RATE"] = 0;
            dr["LIST_DIS_RATE"] = 0;
            dr["NEW_COST_DIS_RATE"] = Decimal.Parse(dr["COST_DIS_RATE"].ToString()) - Decimal.Parse(SLP_COST_SUBSIDY_PERCENT2.Text);
            dr["NEW_LIST_DIS_RATE"] = Decimal.Parse(dr["LIST_DIS_RATE"].ToString()) - Decimal.Parse(SLP_COST_SUBSIDY_PERCENT2.Text);

            ds.Tables[0].Rows.Add(dr);
            Session["STM272_" + PageTimeStamp.Value] = ds;
            DataView dv_Item = new DataView(ds.Tables[0]);
            dv_Item.RowFilter = "STORE = '" + this.txtITEM_STORE.Text + "'";
            GridView2.DataSource = dv_Item;
            string SessionIDName2 = string.Format("{0}_{1}", PAGE_DT_02, PageTimeStamp.Value);
            Session[SessionIDName2] = dv_Item;
            GridView2.DataBind();


            //筆數加1
            int count_item = 0;
            if (txtCount_Item.Value.Length == 0)
                count_item = 1;
            else
                count_item = int.Parse(this.txtCount_Item.Value) + 1;
            txtCount_Item.Value = count_item.ToString();

            //取得商品Table
            DataSet ds_item = new DataSet();
            DataTable Dt_Item = new DataTable();
            ds_item = (DataSet)Session["STM272_" + PageTimeStamp.Value];
            Dt_Item = ds_item.Tables[0];

            //自動展開門市
            Store_Open(txtITEM_STORE.Text, SLP_ITEM.Text, SLP_PERIOD2.Text, SLP_COST_SUBSIDY_PERCENT2.Text, Dt_Item);

            //UPDATE折扣價格
            Price_Into(txtITEM_STORE.Text, Dt_Item);

            btnConfirmItem.Visible = true;
            btnCancleItem.Visible = true;
            btnUpdateItem.Visible = false;
            btnItemCancel.Visible = true;

            btnItemCancel_Click(sender, e);//清除商品的所有欄位

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0];  //直接取第一個
        }
        finally
        {
            ScriptManager.RegisterStartupScript(
             this.UpdatePanel2,
              typeof(UpdatePanel),
              "js",
              "window.setTimeout(function set_focus(){bConfirmState = true ;},1);", true);

        }
    }