Example #1
0
    /// <summary>
    /// 取得用户所选的商品集合
    /// </summary>
    /// <returns></returns>
    public IList <MemberDetailsModel> AddMemberDetails()
    {
        /*************************************************************************************/
        //for (int i = 0; i < productModelList.Count; i++)
        //{
        #region
        //object pNumber = Request["N" + productModelList[i].ProductID];
        //int ptNum = 0;
        //if (pNumber != null)
        //{
        //    try
        //    {
        //        ptNum = Convert.ToInt32(pNumber);
        //    }
        //    catch
        //    {
        //       // return null;
        //    }
        //    if (ptNum > 0)
        //    {
        //        if (productModelList[i].IsCombineProduct == 1) { hasGroupItem = "true"; } else { }
        //        arrayList.Add(new RegistermemberBLL().GetUserChooseProduct(ptNum, productModelList[i]));
        //    }
        //}
        //else
        //{
        //    ptNum = 0;
        //}
        #endregion
        //}
        double totalMoney = 0.00;
        double totalPv    = 0.00;

        ViewState["StateCount"] = false;//声明一个状态,判断选择的产品数量是否超出库存

        //获取用户选择商品id集合
        List <MemberDetailsModel> details = new List <MemberDetailsModel>();
        //获取商品集合
        List <ProductModel> productModelList = new RegistermemberBLL().GetProductModelList();
        //用户选择商品到总商品集合里去匹配
        for (int i = 0; i < productModelList.Count; i++)
        {
            string productid   = productModelList[i].ProductID.ToString();
            string productName = productModelList[i].ProductName.ToString();
            string numStr      = Request["N" + productid];

            if (numStr == null)
            {
                numStr = "0";
            }
            //读取用户输入的数量
            double pdtNum;
            if (numStr != "")
            {
                try
                {
                    pdtNum = Convert.ToInt32(numStr);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                pdtNum = 0;
            }

            // 读取用户输入的订货信息
            if (pdtNum > 0)
            {
                //保存订单信息和汇总信息
                double price = Convert.ToDouble(productModelList[i].PreferentialPrice);
                double pv    = Convert.ToDouble(productModelList[i].PreferentialPV);
                totalMoney += price * pdtNum;
                totalPv    += pv * pdtNum;

                MemberDetailsModel md = new MemberDetailsModel();
                md.Price       = (decimal)price;
                md.Pv          = (decimal)pv;
                md.Quantity    = (int)pdtNum;
                md.ProductId   = (int)productModelList[i].ProductID;
                md.ProductName = productName;

                details.Add(md);


                //判断不可销售的产品是否超出库存
                if (MemberOrderAgainBLL.GetIsSellByProId(Convert.ToInt32(productModelList[i].ProductID)) == "1")
                {
                    int shuliang = md.Quantity;
                    if (IsEdit())
                    {
                        DataTable dtdetail = MemberOrderAgainBLL.GetMemberDetailsByOrderID(GetOrderId());
                        for (int j = 0; j < dtdetail.Rows.Count; j++)
                        {
                            if (dtdetail.Rows[j]["productid"].ToString() == productModelList[i].ProductID.ToString())
                            {
                                shuliang = shuliang - Convert.ToInt32(dtdetail.Rows[j]["Quantity"]);
                            }
                        }
                    }

                    if (MemberOrderAgainBLL.GetCountByProIdAndStoreId(Convert.ToInt32(productModelList[i].ProductID), GetStoreId()) + shuliang < 0)
                    {
                        ViewState["StateCount"] = true;
                    }
                }
            }
        }
        ViewState["TotalMoney"] = totalMoney;
        ViewState["TotalPv"]    = totalPv;

        return(details);
    }
Example #2
0
    /// <summary>
    /// 取得用户所选的商品集合
    /// </summary>
    /// <returns></returns>
    public IList <MemberDetailsModel> AddMemberDetails()
    {
        double totalMoney = 0.00;
        double totalPv    = 0.00;

        ViewState["StateCount"] = false;//声明一个状态,判断选择的产品数量是否超出库存

        //获取用户选择商品id集合
        List <MemberDetailsModel> details = new List <MemberDetailsModel>();

        //获取用户提交的选中商品id串
        string pids = hidpids.Value;

        string[] orpids = pids.Split(',');
        if (orpids.Length > 1)
        {
            //用户选择商品到总商品集合里去匹配
            for (int i = 1; i < orpids.Length; i++)
            {
                int          productid  = Convert.ToInt32(orpids[i].Substring(1));
                ProductModel productuse = ProductDAL.GetProductById(productid); //获取对象


                string productName = productuse.ProductName.ToString();
                string numStr      = Request[orpids[i]];

                if (numStr == null)
                {
                    numStr = "0";
                }
                //读取用户输入的数量
                double pdtNum;
                if (numStr != "")
                {
                    try
                    {
                        pdtNum = Convert.ToInt32(numStr);
                    }
                    catch
                    {
                        return(null);
                    }
                }
                else
                {
                    pdtNum = 0;
                }

                // 读取用户输入的订货信息
                if (pdtNum > 0)
                {
                    //保存订单信息和汇总信息
                    double price = Convert.ToDouble(productuse.PreferentialPrice);
                    double pv    = Convert.ToDouble(productuse.PreferentialPV);
                    totalMoney += price * pdtNum;
                    totalPv    += pv * pdtNum;

                    MemberDetailsModel md = new MemberDetailsModel();
                    md.Price       = (decimal)price;
                    md.Pv          = (decimal)pv;
                    md.Quantity    = (int)pdtNum;
                    md.ProductId   = (int)productuse.ProductID;
                    md.ProductName = productName;

                    details.Add(md);

                    //判断不可销售的产品是否超出库存
                    if (MemberOrderAgainBLL.GetIsSellByProId(Convert.ToInt32(productuse.ProductID)) == "1")
                    {
                        int shuliang = md.Quantity;
                        if (IsEdit())
                        {
                            DataTable dtdetail = MemberOrderAgainBLL.GetMemberDetailsByOrderID(GetOrderId());
                            for (int j = 0; j < dtdetail.Rows.Count; j++)
                            {
                                if (dtdetail.Rows[j]["productid"].ToString() == productuse.ProductID.ToString())
                                {
                                    shuliang = shuliang - Convert.ToInt32(dtdetail.Rows[j]["Quantity"]);
                                }
                            }
                        }

                        if (MemberOrderAgainBLL.GetCountByProIdAndStoreId(Convert.ToInt32(productuse.ProductID), GetStoreId()) + shuliang < 0)
                        {
                            ViewState["StateCount"] = true;
                        }
                    }
                }
            }
        }
        ViewState["TotalMoney"] = totalMoney;
        ViewState["TotalPv"]    = totalPv;

        return(details);
    }