protected void tr_OrganizeCity_Selected(object sender, SelectedEventArgs e)
    {
        Label lb_OrganizeCity = (Label)pn_OrderApply.FindControl("ORD_OrderApply_OrganizeCity");

        lb_OrganizeCity.Text = TreeTableBLL.GetFullPathName("MCS_Sys.dbo.Addr_OrganizeCity", e.CurSelectIndex);

        Label lb_SheetCode = (Label)pn_OrderApply.FindControl("ORD_OrderApply_SheetCode");

        lb_SheetCode.Text = ORD_OrderApplyBLL.GenerateSheetCode(e.CurSelectIndex, AC_AccountMonthBLL.GetCurrentMonth());

        MCSSelectControl select_Client = (MCSSelectControl)pn_OrderApply.FindControl("ORD_OrderApply_Client");

        select_Client.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCity=" + e.CurSelectIndex;
    }
Exemplo n.º 2
0
    protected void bt_ReApply_Click(object sender, EventArgs e)
    {
        ORD_OrderApplyBLL apply = new ORD_OrderApplyBLL((int)ViewState["ID"]);

        if (apply.Model == null)
        {
            Response.Redirect("OrderApplyList.aspx");
        }

        apply.Model.SheetCode = ORD_OrderApplyBLL.GenerateSheetCode(apply.Model.OrganizeCity, apply.Model.AccountMonth);
        apply.Model.State     = 1;
        apply.Model["TaskID"] = "";
        int c = apply.Items.Count;      //要激活一下Items对象才能在Add方法中被新增到数据库中

        int newid = apply.Add();

        Response.Redirect("OrderApplyDetail3.aspx?ID=" + newid.ToString());
    }
Exemplo n.º 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);
    }
Exemplo n.º 4
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());
        }
    }