Example #1
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();
    }
Example #2
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();
    }
Example #3
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);
    }