Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["LogisticsOrderApplyDetail"] == null)
            {
                MessageBox.ShowAndRedirect(this, "加载购物车失败,请重新选购!", "OrderApplyDetail0.aspx");
                return;
            }
            else
            {
                ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
                ViewState["Publish"] = cart.Publish;
                if (cart.Type == 2)
                {
                    //促销品申请
                    #region 绑定赠品申请预算信息
                    BindBudgetInfo(cart.OrganizeCity, cart.AccountMonth, cart.Client, cart.GiftFeeType, cart.Brand, cart.GiftClassify, cart.Receiver);
                    tb_GiftBudgetInfo.Visible = true;
                    #endregion
                }

                BindGrid();
            }
        }
    }
Пример #2
0
    protected void gv_List_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
            switch (cart.AddProduct((int)gv_List.DataKeys[e.NewSelectedIndex]["Product"], (decimal)gv_List.DataKeys[e.NewSelectedIndex]["Price"]))
            {
            case 0:
                gv_List.Rows[e.NewSelectedIndex].FindControl("cb_Check").Visible    = false;
                gv_List.Rows[e.NewSelectedIndex].FindControl("imbt_Select").Visible = false;
                lb_CartCount.Text = cart.Items.Count.ToString();
                //MessageBox.Show(this, "成功将该品项加入购物车中!");
                break;

            case -1:
                MessageBox.Show(this, "发布目录中不包括此品项!");
                break;

            case -2:
                MessageBox.Show(this, "已超可申请数量!");
                break;

            case -3:
                MessageBox.Show(this, "该产品已在购物车中!");
                break;

            default:
                MessageBox.Show(this, "加入购物车失败!");
                break;
            }
        }
        e.Cancel = true;
    }
Пример #3
0
    protected void bt_Confirm_Click(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

        if (cart.Type == 2)
        {
            //促销品申请
            //预算不足允许保存,但不可提交申请
            //int month = AC_AccountMonthBLL.GetCurrentMonth();

            //ORD_ApplyPublish publish = new ORD_ApplyPublishBLL((int)ViewState["Publish"]).Model;
            //decimal budget = FNA_BudgetBLL.GetUsableAmount(month, cart.OrganizeCity, publish.FeeType);
            //decimal totalcost = cart.Items.Sum(m => m.BookQuantity * m.Price);

            //if (budget < totalcost)
            //{
            //    MessageBox.Show(this, "对不起,当前预算不够申请当前申请的品项,请申请预算或调整申请品项!");
            //    return;
            //}
            Response.Redirect("OrderApplyDetail3.aspx");
        }
        else
        {
            Response.Redirect("OrderProductApplyDetail.aspx");
        }
    }
Пример #4
0
 private void BindGrid()
 {
     if (Session["LogisticsOrderApplyDetail"] != null)
     {
         //有购物车内容,从购物车绑定
         ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
         gv_List.DataSource = cart.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = cart.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     else
     {
         //从申请单明细绑定
         ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);
         gv_List.DataSource = apply.Items.Where(p => p.BookQuantity > 0).OrderByDescending(p => p.Price).ToList();
         gv_List.DataBind();
         lb_TotalCost.Text = apply.Items.Sum(m => (m.BookQuantity + m.AdjustQuantity) * m.Price).ToString("0.00");
     }
     if (lb_BalanceAmount.Text != "" && decimal.Parse(lb_BalanceAmount.Text) != 0)
     {
         lb_AfterSubmitBalance.Text    = (decimal.Parse(lb_BalanceAmount.Text) - decimal.Parse(lb_TotalCost.Text)).ToString("0.00");
         lb_Percent.Text               = (decimal.Parse(lb_TotalCost.Text) / decimal.Parse(lb_BalanceAmount.Text)).ToString("0.##%");
         td_Percent.Visible            = true;
         td_AfterSubmitBalance.Visible = true;
     }
     if (lb_TotalCost.Text != "" && decimal.Parse(lb_TotalCost.Text) != 0 && ViewState["SalesVolume"] != null && (decimal)ViewState["SalesVolume"] > 0)
     {
         lb_ActFeeRate.Text    = Math.Round((decimal.Parse(lb_TotalCost.Text) / (decimal)ViewState["SalesVolume"] * 100), 2).ToString();
         td_actfeerate.Visible = true;
     }
 }
Пример #5
0
    protected void bt_EditCart_Click(object sender, EventArgs e)
    {
        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            Response.Redirect("OrderApplyDetail2.aspx");
        }
        else
        {
            ORD_OrderCartBLL cart = ORD_OrderCartBLL.InitByOrderApply((int)ViewState["ID"]);
            if (cart == null)
            {
                MessageBox.Show(this, "创建购物车对象失败!" + ViewState["ID"].ToString());
                return;
            }
            else
            {
                if ((int)ViewState["ID"] > 0)
                {
                    Session["LogisticsOrderApplyID"] = (int)ViewState["ID"];
                }
                Session["LogisticsOrderApplyDetail"] = cart;

                Response.Redirect("OrderApplyDetail2.aspx");
            }
        }
    }
Пример #6
0
    protected void gv_List_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        int product           = (int)gv_List.DataKeys[e.RowIndex]["Product"];

        cart.RemoveProduct(product);
        BindGrid();
    }
Пример #7
0
    protected void bt_Add_Click(object sender, ImageClickEventArgs e)
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        ImageButton      b    = (ImageButton)sender;
        TextBox          tbx_BookQuantity_T = (TextBox)b.Parent.FindControl("tbx_BookQuantity_T");
        GridViewRow      row = (GridViewRow)tbx_BookQuantity_T.Parent.Parent;

        int quantity = int.Parse(tbx_BookQuantity_T.Text);
        int product  = (int)gv_List.DataKeys[row.RowIndex]["Product"];
        int factor   = new PDT_ProductBLL(product, true).Model.ConvertFactor;

        cart.ModifyQuantity(product, quantity * factor + factor);
        BindGrid();
    }
Пример #8
0
    protected void tbx_BookQuantity_T_TextChanged(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        TextBox          tbx_BookQuantity_T = (TextBox)sender;
        GridViewRow      row = (GridViewRow)tbx_BookQuantity_T.Parent.Parent;

        int product  = (int)gv_List.DataKeys[row.RowIndex]["Product"];
        int quantity = 0;

        if (int.TryParse(((TextBox)sender).Text, out quantity))
        {
            int factor = new PDT_ProductBLL(product, true).Model.ConvertFactor;
            if (factor > 0)
            {
                quantity = quantity * factor;
            }
            switch (cart.ModifyQuantity(product, quantity))
            {
            case 0:
                break;

            case -1:
                MessageBox.Show(this, "购物车中不包括此产品!");
                break;

            case -2:
                MessageBox.Show(this, "申请数量已超可申请数量!");
                break;

            case -3:
                MessageBox.Show(this, "申请数量小于最小单次申请数量!");
                break;

            case -4:
                MessageBox.Show(this, "申请数量大于最大单次申请数量!");
                break;

            default:
                MessageBox.Show(this, "数量更新错误!");
                break;
            }
        }
        else
        {
            MessageBox.Show(this, "数字格式不对,必须为整数类型!");
        }

        BindGrid();
    }
Пример #9
0
    protected void gv_List_DataBound(object sender, EventArgs e)
    {
        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
            foreach (GridViewRow row in gv_List.Rows)
            {
                int product = (int)gv_List.DataKeys[row.RowIndex]["Product"];

                if (cart.Items.FirstOrDefault(m => m.Product == product) != null)
                {
                    row.FindControl("cb_Check").Visible    = false;
                    row.FindControl("imbt_Select").Visible = false;
                }
            }
        }
    }
Пример #10
0
    protected void bt_Delete_Click(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

        foreach (GridViewRow row in gv_List.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
            if (cb_SelectAll.Checked)
            {
                int product = (int)gv_List.DataKeys[row.RowIndex]["Product"];

                cart.RemoveProduct(product);
            }
        }

        BindGrid();
    }
Пример #11
0
    protected void bt_Confirm_Click(object sender, ImageClickEventArgs e)
    {
        if (ddl_Publish.SelectedValue != "0")
        {
            int Client = 0;
            int.TryParse(select_Client.SelectValue, out Client);
            if (Client == 0)
            {
                MessageBox.Show(this, "请选择申请的客户!");
                return;
            }
            int Receiver = 0;
            int.TryParse(select_Receiver.SelectValue, out Receiver);
            if (Receiver == 0)
            {
                MessageBox.Show(this, "请选择收货客户!");
                return;
            }
            //if (ddl_Address.SelectedValue == "0")
            //{
            //    MessageBox.Show(this, "该客户没有对应ERP地址ID!");
            //    return;
            //}
            if (ORD_OrderApplyBLL.CheckClientCanApply(int.Parse(ddl_AccountMonth.SelectedValue), int.Parse(select_Client.SelectValue), int.Parse(ddl_Publish.SelectedValue)) <= 0)
            {
                MessageBox.Show(this, "该申请品项目录当月申请已达到可申请上限!");
                ddl_Publish.Focus();
                return;
            }
            int Publish      = int.Parse(ddl_Publish.SelectedValue);
            int OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            int AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue);

            Session["LogisticsOrderApplyDetail"] = new ORD_OrderCartBLL(Publish, OrganizeCity, Client, AccountMonth, 0, Receiver, "");
            Response.Redirect("OrderApplyDetail1.aspx");
        }
        else
        {
            ddl_Publish.Focus();
            MessageBox.Show(this, "请正确选择要申请的发布目录!");
        }
    }
Пример #12
0
    private void BindGrid()
    {
        ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

        gv_List.DataSource = cart.Items.OrderByDescending(p => p.Price).ToList();
        gv_List.DataBind();

        #region 求合计
        lb_TotalCost.Text          = cart.Items.Sum(m => m.BookQuantity * m.Price).ToString("0.00");
        lb_AfterSubmitBalance.Text = (decimal.Parse(lb_BalanceAmount.Text) - decimal.Parse(lb_TotalCost.Text)).ToString("0.00");
        if (decimal.Parse(lb_BalanceAmount.Text) != 0)
        {
            lb_Percent.Text = (decimal.Parse(lb_TotalCost.Text) / decimal.Parse(lb_BalanceAmount.Text)).ToString("0.##%");
        }
        if (lb_TotalCost.Text != "" && decimal.Parse(lb_TotalCost.Text) != 0 && ViewState["SalesVolume"] != null && (decimal)ViewState["SalesVolume"] > 0)
        {
            lb_ActFeeRate.Text = Math.Round((decimal.Parse(lb_TotalCost.Text) / (decimal)ViewState["SalesVolume"] * 100), 2).ToString();
        }
        #endregion
    }
    protected void bt_Confirm_Click(object sender, ImageClickEventArgs e)
    {
        if (ddl_Publish.SelectedValue != "0")
        {
            int OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            int Publish      = int.Parse(ddl_Publish.SelectedValue);
            int Client       = 0;
            int.TryParse(select_Client.SelectValue, out Client);

            if (rbl_Type.SelectedValue == "1")
            {
                if (Client == 0)
                {
                    MessageBox.Show(this, "请选择申请的客户!");
                    return;
                }
                else
                {
                    OrganizeCity = new CM_ClientBLL(Client).Model.OrganizeCity;
                }
                if (rbl_IsSpecial.SelectedValue == "2" && ddl_OrderType.SelectedValue == "1")
                {
                    ORD_OrderApplyBLL      bll       = new ORD_OrderApplyBLL();
                    double                 DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
                    IList <ORD_OrderApply> orderlist = bll._GetModelList(" Client=" + Client.ToString() + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',4)='1'  AND AccountMonth=" + ddl_AccountMonth.SelectedValue + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + ddl_Brand.SelectedValue);
                    if (orderlist.Count >= 2)
                    {
                        MessageBox.Show(this, "对不起,非特殊订单只能申请两次。");
                        return;
                    }
                }
            }
            Session["LogisticsOrderApplyDetail"] = new ORD_OrderCartBLL(Publish, OrganizeCity, int.Parse(ddl_OrderType.SelectedValue), int.Parse(ddl_Brand.SelectedValue), int.Parse(rbl_IsSpecial.SelectedValue), Client);
            Response.Redirect("OrderApplyDetail1.aspx");
        }
        else
        {
            ddl_Publish.Focus();
            MessageBox.Show(this, "请正确选择要申请的产品目录!");
        }
    }
Пример #14
0
 protected void bt_BuyIn_Click(object sender, ImageClickEventArgs e)
 {
     if (Session["LogisticsOrderApplyDetail"] != null)
     {
         int count             = 0;
         ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
         foreach (GridViewRow row in gv_List.Rows)
         {
             CheckBox cb_check = (CheckBox)row.FindControl("cb_Check");
             if (cb_check.Visible && cb_check.Checked)
             {
                 if (cart.AddProduct((int)gv_List.DataKeys[row.RowIndex]["Product"], (decimal)gv_List.DataKeys[row.RowIndex]["Price"]) == 0)
                 {
                     row.FindControl("cb_Check").Visible    = false;
                     row.FindControl("imbt_Select").Visible = false;
                     count++;
                 }
             }
         }
         lb_CartCount.Text = cart.Items.Count.ToString();
         MessageBox.Show(this, "成功将" + count.ToString() + "个品项加入购物车中!");
     }
 }
Пример #15
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();
    }
Пример #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 判断传入参数是否为SheetCode
            if (Request.QueryString["SheetCode"] != null)
            {
                string code = Request.QueryString["SheetCode"];

                IList <ORD_OrderApply> list = ORD_OrderApplyBLL.GetModelList("SheetCode='" + code + "'");
                if (list.Count > 0)
                {
                    Response.Redirect("OrderProductApplyDetail.aspx?ID=" + list[0].ID.ToString());
                }
                else
                {
                    Response.Redirect("OrderApplyList.aspx");
                }
            }
            #endregion
            ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]);

            BindDropDown();
            ViewState["Product"] = 0;

            #region 创建空的列表
            ListTable <ORD_OrderApplyDetail> _details = new ListTable <ORD_OrderApplyDetail>(new ORD_OrderApplyBLL((int)ViewState["ID"]).Items, "Product");
            ViewState["Details"] = _details;
            #endregion

            if (Session["LogisticsOrderApplyDetail"] != null && (int)ViewState["ID"] == 0)
            {
                #region 新费用申请时,初始化申请信
                ORD_OrderCartBLL cart  = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
                ORD_OrderApply   model = new ORD_OrderApply();
                if (cart.Client != 0)
                {
                    model.OrganizeCity = new CM_ClientBLL(cart.Client).Model.OrganizeCity;
                    model.Client       = cart.Client;
                }
                model.InsertStaff     = (int)Session["UserID"];
                model.InsertTime      = DateTime.Now;
                model["IsSpecial"]    = cart.IsSpecial.ToString();
                model.Type            = cart.Type;
                ViewState["Type"]     = cart.Type;
                model["ProductBrand"] = cart.Brand.ToString();
                model["ProductType"]  = cart.OrderType.ToString();
                if (cart.OrderType != 1)
                {
                    priceEnable = true;
                }
                model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth();

                ORD_OrderLimitFactorBLL limitbll = new ORD_OrderLimitFactorBLL();
                ViewState["Limit"] = limitbll.GetLimitInfo(Convert.ToInt32(model.AccountMonth), cart.Client);
                bt_Submit.Visible  = false;


                foreach (ORD_OrderCart item in cart.Items)
                {
                    ORD_OrderApplyDetail _detailmodel = new ORD_OrderApplyDetail();
                    _detailmodel.Price        = item.Price;
                    _detailmodel.Product      = item.Product;
                    _detailmodel.BookQuantity = item.BookQuantity;
                    _details.Add(_detailmodel);
                }
                ViewState["Details"] = _details;
                pn_OrderApply.BindData(model);
                BindGrid();
                #endregion
            }
            else
            {
                BindData();
            }

            Header.Attributes["WebPageSubCode"] = "Type=" + ViewState["Type"].ToString();
        }
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState["ID"] = Request.QueryString["ID"] == null ? 0 : int.Parse(Request.QueryString["ID"]);

            if ((int)ViewState["ID"] > 0)
            {
                Session["LogisticsOrderApplyID"]     = null;        //申请单ID
                Session["LogisticsOrderApplyDetail"] = null;        //购物车明细
            }
            else if (Session["LogisticsOrderApplyID"] != null)
            {
                //Session中存有申请单ID,说明是对现有申请单进行编辑
                ViewState["ID"] = (int)Session["LogisticsOrderApplyID"];
            }

            if ((int)ViewState["ID"] > 0)
            {
                BindData();
            }
            else if (Session["LogisticsOrderApplyDetail"] != null)
            {
                #region 新增申请单
                //当无申请单ID,但有购物车中有明细时,则说明是新增申请单
                ORD_OrderCartBLL cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];

                if (Session["LogisticsOrderApplyID"] == null)
                {
                    ViewState["Publish"] = cart.Publish;
                    ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(cart.Publish).Model;
                    if (publish == null)
                    {
                        Response.Redirect("OrderApplyDetail0.aspx");
                    }

                    int month = publish.AccountMonth;

                    #region 初始化申请单详细信息控件
                    ORD_OrderApply apply = new ORD_OrderApply();
                    apply.OrganizeCity    = cart.OrganizeCity;
                    apply.AccountMonth    = cart.AccountMonth;
                    apply.Type            = cart.Type;
                    apply.Client          = cart.Client;
                    apply.PreArrivalDate  = DateTime.Today.AddMonths(1);
                    apply["ProductBrand"] = cart.Brand.ToString();
                    apply["GiftClassify"] = cart.GiftClassify.ToString();
                    apply.State           = 1;
                    apply.InsertStaff     = (int)Session["UserID"];
                    apply.InsertTime      = DateTime.Now;
                    apply.PublishID       = cart.Publish;
                    apply["AddressID"]    = cart.AddressID.ToString();
                    apply["Receiver"]     = cart.Receiver.ToString();
                    pn_OrderApply.BindData(apply);
                    #endregion

                    if (cart.Type == 2)
                    {
                        //促销品申请
                        #region 绑定赠品申请预算信息
                        BindBudgetInfo(cart.OrganizeCity, cart.AccountMonth, cart.Client, cart.GiftFeeType, cart.Brand, cart.GiftClassify);
                        tb_GiftBudgetInfo.Visible = true;
                        #endregion
                    }

                    BindGrid();

                    bt_Finish.Visible = false;
                    bt_Delete.Visible = false;
                    //bt_Submit.Visible = false;
                }
                #endregion
            }
            else
            {
                if (Session["SubmitOrderApplyID"] == null)
                {
                    MessageBox.ShowAndRedirect(this, "加载购物车失败,请重新选购!", "OrderApplyDetail0.aspx");
                    return;
                }
                else
                {
                    ViewState["ID"] = (int)Session["SubmitOrderApplyID"];
                    BindData();
                }
            }
        }

        #region 注册弹出窗口脚本
        string script = "function PopAdjust(id){\r\n";
        script += "var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("Pop_OrderApplyDetailAdjust.aspx") +
                  "?ID=' + id + '&tempid='+tempid, window, 'dialogWidth:500px;DialogHeight=600px;status:yes;resizable=yes');}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PopAdjust", script, true);

        #endregion
    }
Пример #18
0
    private bool Save()
    {
        ORD_OrderCartBLL cart = null;

        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        }

        if ((int)ViewState["ID"] == 0)
        {
            if (cart == null || cart.Items.Count == 0)
            {
                MessageBox.Show(this, "对不起,定单申请明细不能为空!");
                return(false);
            }

            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL();
            pn_OrderApply.GetData(bll.Model);

            #region 判断有没有填写经销商
            if (bll.Model.Client == 0)
            {
                MessageBox.Show(this, "对不起,请填写申请定购的经销商!");
                return(false);
            }
            #endregion

            #region 初始化定单字段
            bll.Model.OrganizeCity = cart.OrganizeCity;
            bll.Model.PublishID    = cart.Publish;
            bll.Model.AccountMonth = cart.AccountMonth;
            bll.Model.SheetCode    = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth); //自动产生备案号
            bll.Model.ApproveFlag  = 2;
            bll.Model.State        = 1;
            bll.Model.InsertStaff  = (int)Session["UserID"];
            bll.Model["AddressID"] = cart.AddressID.ToString();
            bll.Model["Receiver"]  = cart.Receiver.ToString();
            if (cart.Publish > 0)
            {
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(cart.Publish).Model;
                if (publish != null)
                {
                    bll.Model["ProductBrand"] = publish["ProductBrand"];
                    bll.Model["GiftClassify"] = publish["GiftClassify"];
                }
            }
            #endregion

            ViewState["ID"] = bll.Add();

            #region 新增定单明细明细
            foreach (ORD_OrderCart cartitem in cart.Items)
            {
                if (cartitem.BookQuantity == 0)
                {
                    continue;
                }
                ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                m.ApplyID          = (int)ViewState["ID"];
                m.Product          = cartitem.Product;
                m.Price            = cartitem.Price;
                m.BookQuantity     = cartitem.BookQuantity;
                m.AdjustQuantity   = 0;
                m.DeliveryQuantity = 0;

                bll.AddDetail(m);
            }
            #endregion
        }
        else
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            pn_OrderApply.GetData(bll.Model);
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细
            if (cart != null)
            {
                //先将现有定单中每个品项与购物中的比较
                //如果购物车中没有该产品,则删除,如有且数量不同,则更新,并从购物车中移除该品项
                foreach (ORD_OrderApplyDetail m in bll.Items)
                {
                    ORD_OrderCart cartitem = cart.Items.FirstOrDefault(p => p.Product == m.Product);
                    if (cartitem == null)
                    {
                        bll.DeleteDetail(m.ID);
                    }
                    else
                    {
                        if (cartitem.BookQuantity != m.BookQuantity)
                        {
                            m.BookQuantity = cartitem.BookQuantity;
                            bll.UpdateDetail(m);
                        }
                        cart.RemoveProduct(m.Product);
                    }
                }

                //新购物车中新增的品项加入定单明细中
                foreach (ORD_OrderCart cartitem in cart.Items)
                {
                    ORD_OrderApplyDetail m = new ORD_OrderApplyDetail();
                    m.ApplyID          = (int)ViewState["ID"];
                    m.Product          = cartitem.Product;
                    m.Price            = cartitem.Price;
                    m.BookQuantity     = cartitem.BookQuantity;
                    m.AdjustQuantity   = 0;
                    m.DeliveryQuantity = 0;

                    bll.AddDetail(m);
                }
            }
            #endregion
        }

        return(true);
    }
Пример #19
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        ORD_OrderCartBLL cart = null;

        if (Session["LogisticsOrderApplyDetail"] != null)
        {
            cart = (ORD_OrderCartBLL)Session["LogisticsOrderApplyDetail"];
        }

        ListTable <ORD_OrderApplyDetail> _details = ViewState["Details"] as ListTable <ORD_OrderApplyDetail>;
        ORD_OrderApplyBLL bll;

        if ((int)ViewState["ID"] == 0)
        {
            bll = new ORD_OrderApplyBLL();
        }
        else
        {
            bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
        }

        pn_OrderApply.GetData(bll.Model);

        #region 保存明细
        foreach (GridViewRow row in gv_ProductList.Rows)
        {
            int productid = (int)gv_ProductList.DataKeys[row.RowIndex]["Product"];

            ORD_OrderApplyDetail m       = _details[productid.ToString()];
            PDT_Product          product = new PDT_ProductBLL(m.Product).Model;

            TextBox tbx_price          = (TextBox)row.FindControl("tbx_Price");
            TextBox tbx_BookQuantity_T = (TextBox)row.FindControl("tbx_BookQuantity_T");
            TextBox tbx_BookQuantity   = (TextBox)row.FindControl("tbx_BookQuantity");

            int quantity = int.Parse(tbx_BookQuantity_T.Text) * product.ConvertFactor + int.Parse(tbx_BookQuantity.Text);

            m.BookQuantity = quantity;
            m.Price        = decimal.Parse(tbx_price.Text);

            _details.Update(m);
        }
        #endregion

        if ((int)ViewState["ID"] == 0)
        {
            double DelayDays = Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["OrderDelayDays"]);
            bll.Model.OrganizeCity    = cart.OrganizeCity;
            bll.Model.Client          = cart.Client;
            bll.Model.PublishID       = cart.Publish;
            bll.Model.AccountMonth    = AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-DelayDays));
            bll.Model.SheetCode       = ORD_OrderApplyBLL.GenerateSheetCode(bll.Model.OrganizeCity, bll.Model.AccountMonth); //自动产生备案号
            bll.Model.ApproveFlag     = 2;
            bll.Model.State           = 1;
            bll.Model.InsertStaff     = (int)Session["UserID"];
            bll.Model["IsSpecial"]    = cart.IsSpecial.ToString();
            bll.Model.Type            = cart.Type;
            bll.Model["ProductBrand"] = cart.Brand.ToString();
            bll.Model["ProductType"]  = cart.OrderType.ToString();
            bll.Items = _details.GetListItem();

            ViewState["ID"] = bll.Add();
        }
        else
        {
            bll.Model.UpdateStaff = (int)Session["UserID"];
            bll.Update();

            #region 修改明细

            bll.Items = _details.GetListItem(ItemState.Modified);
            bll.UpdateDetail();

            #endregion
        }

        if (sender != null)
        {
            Response.Redirect("OrderProductApplyDetail.aspx?ID=" + ViewState["ID"].ToString());
        }
    }