protected void bt_Out_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0)
        {
            return;
        }

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_StandardPrice_Detail       item2   = _bll.GetDetailModel(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
                PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                history.Model.StandardPrice    = _bll.Model.ID;
                history.Model.ChangeType       = 3;
                history.Model.ChageTime        = DateTime.Now;
                history.Model.ChangeStaff      = (int)Session["UserID"];
                history.Model.Product          = item2.Product;
                history.Model.PreFactoryPrice  = item2.FactoryPrice;
                history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                history.Model.PreTradeInPrice  = item2.TradeInPrice;
                history.Model.PreStdPrice      = item2.StdPrice;
                history.Add();
                _bll.DeleteDetail(int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString()));
            }
        }
        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
Esempio n. 2
0
            public TDPStandardPriceDetail(PDT_StandardPrice_Detail m)
            {
                Product = m.Product;
                Price   = m.Price;
                Remark  = m.Remark;

                PDT_Product p = new PDT_ProductBLL(m.Product).Model;

                if (p != null)
                {
                    ProductName = p.ShortName == "" ? p.FullName : p.ShortName;
                }
            }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();
        if ((int)ViewState["PriceID"] == 0)
        {
            return;
        }

        PDT_StandardPriceBLL _bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List_FacProd.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_check.Checked)
            {
                PDT_Product product = new PDT_ProductBLL((int)gv_List_FacProd.DataKeys[row.RowIndex]["ID"]).Model;
                if (product != null)
                {
                    PDT_StandardPrice_Detail detail = new PDT_StandardPrice_Detail();
                    detail.StandardPrice = (int)ViewState["PriceID"];
                    detail.Product       = product.ID;
                    detail.FactoryPrice  = product.FactoryPrice;
                    detail.TradeOutPrice = product.TradePrice;
                    detail.TradeInPrice  = product.NetPrice;
                    detail.StdPrice      = product.StdPrice;
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice    = _bll.Model.ID;
                    history.Model.ChangeType       = 1;
                    history.Model.ChageTime        = DateTime.Now;
                    history.Model.ChangeStaff      = (int)Session["UserID"];
                    history.Model.Product          = detail.Product;
                    history.Model.AftFactoryPrice  = detail.FactoryPrice;
                    history.Model.AftTradeOutPrice = detail.TradeOutPrice;
                    history.Model.AftTradeInPrice  = detail.TradeInPrice;
                    history.Model.AftStdPrice      = detail.StdPrice;
                    history.Add();

                    _bll.AddDetail(detail);
                }
            }
        }

        Response.Redirect("PDT_StandardPriceDetail.aspx?PriceID=" + ViewState["PriceID"].ToString());
    }
    protected void bt_In_Click(object sender, EventArgs e)
    {
        Save();

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

                PDT_StandardPrice_Detail pd = new PDT_StandardPrice_Detail();
                pd.Product = int.Parse(gv_NotInList.DataKeys[row.RowIndex]["ID"].ToString());

                PDT_ProductBLL     productbll = new PDT_ProductBLL(pd.Product);
                PDT_ProductExtInfo extinfo    = productbll.GetProductExtInfo((int)Session["OwnerClient"]);
                if (extinfo != null)
                {
                    pd.Price = extinfo.SalesPrice;
                }
                else
                {
                    pd.Price = productbll.Model.StdPrice;
                }
                _bll.AddDetail(pd);
            }
        }
        Response.Redirect("StandardPriceDetail.aspx?ID=" + ViewState["ID"].ToString());
    }
    private bool Save()
    {
        PDT_StandardPriceBLL _bll;

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll = new PDT_StandardPriceBLL((int)ViewState["ID"]);
        }
        else
        {
            //新增
            _bll = new PDT_StandardPriceBLL();
        }

        pl_detail.GetData(_bll.Model);

        #region 判断必填项

        #endregion

        #region 判断是否与默认价表重复
        if (_bll.Model.IsDefault.ToUpper() == "Y")
        {
            int _priceid = PDT_StandardPriceBLL.GetDefaultPrice((int)Session["OwnerClient"]);
            if (_priceid != _bll.Model.ID)
            {
                MessageBox.Show(this, "对不起,不能重复新增默认价表,新增的价表必须限制区域或渠道!");
                return(false);
            }
        }

        #endregion

        if ((int)ViewState["ID"] != 0)
        {
            //修改
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
        }
        else
        {
            //新增
            _bll.Model.Supplier    = (int)Session["OwnerClient"];
            _bll.Model.ApproveFlag = 2;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            ViewState["ID"]        = _bll.Add();
        }

        #region 保存修改明细
        foreach (GridViewRow row in gv_List.Rows)
        {
            PDT_StandardPrice_Detail item = new PDT_StandardPrice_Detail();
            item.PriceID = _bll.Model.ID;
            item.ID      = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
            item.Product = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());

            PDT_Product p = new PDT_ProductBLL(item.Product).Model;

            if (row.FindControl("tbx_Price") != null)
            {
                decimal d = 0;
                if (decimal.TryParse(((TextBox)row.FindControl("tbx_Price")).Text, out d))
                {
                    item.Price = d;
                }

                PDT_ProductBLL productbll = new PDT_ProductBLL(item.Product);
                item.Price = item.Price / productbll.Model.ConvertFactor;

                PDT_ProductExtInfo extinfo = productbll.GetProductExtInfo((int)Session["OwnerClient"]);
                if (extinfo != null)
                {
                    if (extinfo.MinSalesPrice > 0 && item.Price < extinfo.MinSalesPrice)
                    {
                        MessageBox.Show(this, "对不起,您发布的价格不能小于建议零售价!");
                        return(false);
                    }
                    else if (extinfo.MaxSalesPrice > 0 && item.Price > extinfo.MaxSalesPrice)
                    {
                        MessageBox.Show(this, "对不起,您发布的价格不能过高于建议零售价!");
                        return(false);
                    }
                }
            }


            if (row.FindControl("tbx_Remark") != null)
            {
                item.Remark = ((TextBox)row.FindControl("tbx_Remark")).Text;
            }

            _bll.UpdateDetail(item);
        }

        #endregion

        return(true);
    }
Esempio n. 6
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());
    }
    protected void bt_CompareStdPrice_Click(object sender, EventArgs e)
    {
        decimal MaxRate = 0.000M;

        PDT_StandardPriceBLL bll = new PDT_StandardPriceBLL((int)ViewState["PriceID"]);

        foreach (GridViewRow row in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[row.RowIndex]["ID"];
            PDT_StandardPrice_Detail d = bll.Items.FirstOrDefault(p => p.ID == id);
            if (d == null)
            {
                continue;
            }

            PDT_Product product = new PDT_ProductBLL(d.Product).Model;
            if (product == null)
            {
                continue;
            }


            Label lb_FactoryPrice_Rate  = (Label)row.FindControl("lb_FactoryPrice_Rate");
            Label lb_TradeOutPrice_Rate = (Label)row.FindControl("lb_TradeOutPrice_Rate");
            Label lb_TradeInPrice_Rate  = (Label)row.FindControl("lb_TradeInPrice_Rate");
            Label lb_StdPrice_Rate      = (Label)row.FindControl("lb_StdPrice_Rate");

            if (product.FactoryPrice != 0 && lb_FactoryPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_FactoryPrice")).Text);
                decimal rate  = (price - product.FactoryPrice) / product.FactoryPrice;
                if (sender != null)
                {
                    lb_FactoryPrice_Rate.Text = rate.ToString("0.#%");
                }

                if (Math.Abs(rate) > MaxRate)
                {
                    MaxRate = Math.Abs(rate);
                }
            }

            if (product.TradePrice != 0 && lb_TradeOutPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_TradeOutPrice")).Text);
                decimal rate  = (price - product.TradePrice) / product.TradePrice;
                if (sender != null)
                {
                    lb_TradeOutPrice_Rate.Text = rate.ToString("0.#%");
                }

                if (Math.Abs(rate) > MaxRate)
                {
                    MaxRate = Math.Abs(rate);
                }
            }

            if (product.NetPrice != 0 && lb_TradeInPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_TradeInPrice")).Text);
                decimal rate  = (price - product.NetPrice) / product.NetPrice;
                if (sender != null)
                {
                    lb_TradeInPrice_Rate.Text = rate.ToString("0.#%");
                }

                if (Math.Abs(rate) > MaxRate)
                {
                    MaxRate = Math.Abs(rate);
                }
            }

            if (product.StdPrice != 0 && lb_StdPrice_Rate != null)
            {
                decimal price = decimal.Parse(((TextBox)row.FindControl("tbx_StdPrice")).Text);
                decimal rate  = (price - product.StdPrice) / product.StdPrice;
                if (sender != null)
                {
                    lb_StdPrice_Rate.Text = rate.ToString("0.#%");
                }

                if (Math.Abs(rate) > MaxRate)
                {
                    MaxRate = Math.Abs(rate);
                }
            }
        }

        if (sender != null)
        {
            lb_MaxRate.Text = string.Format("价格最大偏差{0:0.#%}", MaxRate);
        }
        ViewState["MaxRate"] = MaxRate;
    }
    private void Save()
    {
        PDT_StandardPriceBLL _bll;

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

        panel1.GetData(_bll.Model);

        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "适用管理片区必填!");
            return;
        }

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

            #region 修改明细
            foreach (GridViewRow row in gv_List.Rows)
            {
                PDT_StandardPrice_Detail item1 = new PDT_StandardPrice_Detail();
                item1.ID            = int.Parse(gv_List.DataKeys[row.RowIndex]["ID"].ToString());
                item1.StandardPrice = _bll.Model.ID;
                item1.Product       = int.Parse(gv_List.DataKeys[row.RowIndex]["Product"].ToString());
                item1.FactoryPrice  = decimal.Parse(((TextBox)row.FindControl("tbx_FactoryPrice")).Text);
                item1.TradeOutPrice = decimal.Parse(((TextBox)row.FindControl("tbx_TradeOutPrice")).Text);
                item1.TradeInPrice  = decimal.Parse(((TextBox)row.FindControl("tbx_TradeInPrice")).Text);
                item1.StdPrice      = decimal.Parse(((TextBox)row.FindControl("tbx_StdPrice")).Text);
                TextBox tbx_RebatePrice = row.FindControl("tbx_RebatePrice") == null ? null : (TextBox)row.FindControl("tbx_RebatePrice");
                if (tbx_RebatePrice != null)
                {
                    decimal rebateprice = 0;
                    decimal.TryParse(tbx_RebatePrice.Text, out rebateprice);
                    item1.RebatePrice = rebateprice;
                }
                TextBox tbx_DIRebatePrice = row.FindControl("tbx_DIRebatePrice") == null ? null : (TextBox)row.FindControl("tbx_DIRebatePrice");
                if (tbx_DIRebatePrice != null)
                {
                    decimal direbateprice = 0;
                    decimal.TryParse(tbx_DIRebatePrice.Text, out direbateprice);
                    item1.DIRebatePrice = direbateprice;
                }
                CheckBox cbx_ISFL = row.FindControl("cbx_ISFL") == null ? null : (CheckBox)row.FindControl("cbx_ISFL");
                if (cbx_ISFL != null)
                {
                    item1.ISFL = cbx_ISFL.Checked ? 1 : 2;
                }
                CheckBox cbx_ISJH = row.FindControl("cbx_ISJH") == null ? null : (CheckBox)row.FindControl("cbx_ISJH");
                if (cbx_ISJH != null)
                {
                    item1.ISJH = cbx_ISJH.Checked ? 1 : 2;
                }

                CheckBox cbx_ISCheckJF = row.FindControl("cbx_ISCheckJF") == null ? null : (CheckBox)row.FindControl("cbx_ISCheckJF");
                if (cbx_ISCheckJF != null)
                {
                    item1.ISCheckJF = cbx_ISCheckJF.Checked ? 1 : 2;
                }
                PDT_StandardPrice_Detail item2 = _bll.GetDetailModel(item1.ID);
                if (item1.FactoryPrice != item2.FactoryPrice || item1.TradeInPrice != item2.TradeInPrice || item1.TradeOutPrice != item2.TradeOutPrice || item1.StdPrice != item2.StdPrice)
                {
                    PDT_StandPriceChangeHistoryBLL history = new PDT_StandPriceChangeHistoryBLL();
                    history.Model.StandardPrice    = _bll.Model.ID;
                    history.Model.ChangeType       = 2;
                    history.Model.ChageTime        = DateTime.Now;
                    history.Model.ChangeStaff      = (int)Session["UserID"];
                    history.Model.Product          = item1.Product;
                    history.Model.PreFactoryPrice  = item2.FactoryPrice;
                    history.Model.PreTradeOutPrice = item2.TradeOutPrice;
                    history.Model.PreTradeInPrice  = item2.TradeInPrice;
                    history.Model.PreStdPrice      = item2.StdPrice;
                    history.Model.AftFactoryPrice  = item1.FactoryPrice;
                    history.Model.AftTradeInPrice  = item1.TradeInPrice;
                    history.Model.AftTradeOutPrice = item1.TradeOutPrice;
                    history.Model.AftStdPrice      = item1.StdPrice;
                    history.Add();
                }
                _bll.UpdateDetail(item1);
            }
            #endregion
        }
        else
        {
            _bll.Model.ApproveFlag = 2;
            _bll.Model.ActiveFlag  = 2;
            _bll.Model.InsertStaff = int.Parse(Session["UserID"].ToString());
            _bll.Add();
            ViewState["PriceID"] = _bll.Model.ID;
        }
    }