コード例 #1
0
    private void Save()
    {
        PDT_ProductPriceBLL _bll;

        if ((int)ViewState["PriceID"] != 0)
        {
            _bll = new PDT_ProductPriceBLL((int)ViewState["PriceID"]);
        }
        else
        {
            _bll = new PDT_ProductPriceBLL();
        }

        _bll.Model.ApproveFlag = 2;
        _bll.Model.BeginDate   = DateTime.Parse(this.tbx_begin.Text.Trim());
        _bll.Model.EndDate     = ((DateTime.Parse(this.tbx_end.Text.Trim())).AddDays(1)).AddSeconds(-1);
        _bll.Model.Client      = int.Parse(ViewState["ClientID"].ToString());

        if ((int)ViewState["PriceID"] != 0)
        {
            _bll.Model.UpdateStaff = int.Parse(Session["UserID"].ToString());
            _bll.Update();

            #region 修改明细
            foreach (GridViewRow row in gv_List.Rows)
            {
                int detailid = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
                PDT_ProductPrice_Detail item1 = _bll.GetDetailModel(detailid);
                item1.BuyingPrice = decimal.Parse(((TextBox)row.FindControl("lbl_BuyingPrice")).Text);
                item1.SalesPrice  = decimal.Parse(((TextBox)row.FindControl("lbl_FactoryPrice")).Text);
                _bll.UpdateDetail(item1);
            }

            #endregion
        }
        else
        {
            _bll.Model.Client      = (int)ViewState["ClientID"];
            _bll.Model.InsertStaff = int.Parse(Session["UserID"].ToString());
            _bll.Add();
            ViewState["PriceID"] = _bll.Model.ID;
            foreach (GridViewRow row in gv_List.Rows)
            {
                PDT_ProductPrice_Detail item2 = new PDT_ProductPrice_Detail();
                item2.PriceID     = _bll.Model.ID;
                item2.Product     = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());
                item2.BuyingPrice = decimal.Parse(gv_List.DataKeys[row.RowIndex]["BuyingPrice"].ToString());
                item2.SalesPrice  = decimal.Parse(gv_List.DataKeys[row.RowIndex]["SalesPrice"].ToString());
                _bll.AddDetail(item2);
            }
        }
    }
コード例 #2
0
    protected void bt_AddProduct_Click(object sender, EventArgs e)
    {
        #region 验证必填项
        if (ViewState["Product"] == null || (int)ViewState["Product"] == 0)
        {
            lb_ErrInfo1.Text = "产品必填!";
            return;
        }

        #endregion

        ListTable <PDT_ProductPrice_Detail> _details = ViewState["Details"] as ListTable <PDT_ProductPrice_Detail>;

        PDT_ProductPrice_Detail item;

        #region 产品存在与否判断
        if (ViewState["Selected"] == null)
        {
            //新增产品
            if (_details.Contains(ViewState["Product"].ToString()))
            {
                lb_ErrInfo1.Text = "该产品已添加!";
                return;
            }

            item         = new PDT_ProductPrice_Detail();
            item.Product = (int)ViewState["Product"];
        }
        else
        {
            //修改科目
            if (!_details.Contains(ViewState["Product"].ToString()))
            {
                lb_ErrInfo1.Text = "要修改的产品不存在!";
                return;
            }
            item = _details[ViewState["Selected"].ToString()];

            select_ProductCode.Enabled = true;
            gv_List.SelectedIndex      = -1;
        }
        #endregion

        lb_ProductName.ForeColor = System.Drawing.Color.Black;

        item.BuyingPrice = tbx_BuyingPrice.Text == "" ? 0 : decimal.Parse(tbx_BuyingPrice.Text);
        item.SalesPrice  = tbx_SalesPrice.Text == "" ? 0 : decimal.Parse(tbx_SalesPrice.Text);

        if (ViewState["Selected"] == null)
        {
            _details.Add(item);             //新增产品
        }
        else
        {
            _details.Update(item);          //更新产品
        }
        BindGrid();

        lb_ErrInfo1.Text     = "";
        tbx_BuyingPrice.Text = "";
        tbx_SalesPrice.Text  = "";

        ViewState["Selected"] = null;
    }
コード例 #3
0
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();

        CM_Client client = new CM_ClientBLL((int)ViewState["ClientID"]).Model;

        if (client == null)
        {
            return;
        }

        PDT_StandardPriceBLL standardprice = new PDT_StandardPriceBLL((int)ViewState["StandardPrice"]);

        foreach (GridViewRow row in gv_List_FacProd.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_ProductPriceBLL _bll;
                if ((int)ViewState["PriceID"] != 0)
                {
                    _bll = new PDT_ProductPriceBLL((int)ViewState["PriceID"]);
                }
                else
                {
                    return;
                }

                PDT_ProductPrice_Detail pd = new PDT_ProductPrice_Detail();
                pd.PriceID = (int)ViewState["PriceID"];
                pd.Product = int.Parse(gv_List_FacProd.DataKeys[row.RowIndex]["ID"].ToString());

                #region 将标准价表中的价格设置到价表中
                if ((int)ViewState["StandardPrice"] > 0)
                {
                    PDT_StandardPrice_Detail d = standardprice.Items.FirstOrDefault(p => p.Product == pd.Product);
                    if (d != null)
                    {
                        pd.FactoryPrice = d.FactoryPrice;

                        if (client.ClientType == 3)      //门店
                        {
                            pd.BuyingPrice = d.TradeInPrice;
                            pd.SalesPrice  = d.StdPrice;
                        }
                        else if (client.ClientType == 2)
                        {
                            if (client["DIClassify"] == "1")    //一级经销商
                            {
                                pd.BuyingPrice = d.FactoryPrice;
                                pd.SalesPrice  = d.TradeInPrice;
                            }
                            else if (client["DIClassify"] == "2")     //分销商
                            {
                                pd.BuyingPrice = d.TradeOutPrice;
                                pd.SalesPrice  = d.TradeInPrice;
                            }
                        }
                    }
                }
                #endregion

                _bll.AddDetail(pd);
            }
        }
        Response.Redirect("PDT_ProductPriceDetail2.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
コード例 #4
0
    private void BindData()
    {
        ORD_OrderCartBLL    cart    = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(cart.Publish);

        if (publish == null)
        {
            Response.Redirect("OrderApplyDetail0.aspx");
        }

        ViewState["Publish"] = cart.Publish;
        pl_ApplyPublish.BindData(publish.Model);

        IList <ORD_ApplyPublishDetail> productlists;

        if (cart.Type == 1)
        {
            #region 成品取客户价表
            productlists = new List <ORD_ApplyPublishDetail>();
            IList <PDT_ProductPrice> pricelists = PDT_ProductPriceBLL.GetModelList
                                                      ("GETDATE() BETWEEN BeginDate AND EndDate AND Client=" + cart.Client.ToString());
            if (pricelists.Count == 0)
            {
                MessageBox.ShowAndRedirect(this, "对不起,该客户没有生效的价表,不可申请产品!", "OrderApplyDetail0.aspx");
                return;
            }

            PDT_ProductPriceBLL pricebll = new PDT_ProductPriceBLL(pricelists[0].ID);

            foreach (ORD_ApplyPublishDetail item in publish.Items)
            {
                PDT_ProductBLL _bll = new PDT_ProductBLL(item.Product);

                if (new PDT_BrandBLL(_bll.Model.Brand).Model.IsOpponent == "1")
                {
                    PDT_ProductPrice_Detail priceitem = pricebll.Items.FirstOrDefault(p => p.Product == item.Product);
                    if (priceitem == null)
                    {
                        continue;
                    }
                    item.Price = priceitem.BuyingPrice;
                }
                else
                {
                    item.Price = _bll.Model.FactoryPrice;
                }

                productlists.Add(item);
            }
            #endregion
        }
        else
        {
            #region 绑定赠品申请预算信息
            BindBudgetInfo(cart.OrganizeCity, cart.AccountMonth, cart.Client, cart.GiftFeeType, cart.Brand, cart.GiftClassify, cart.Receiver);
            tb_GiftBudgetInfo.Visible = true;
            #endregion


            productlists = publish.Items;
        }

        ViewState["PublishDetails"] = productlists;
        gv_List.PageIndex           = 0;
        BindGrid();

        lb_CartCount.Text = cart.Items.Count.ToString();
    }