Example #1
0
 /// <summary>
 /// 保存订单商品详细
 /// </summary>
 /// <param name="orderDtl"></param>
 public void addOrderDtl(Bs_OrdersDtl orderDtl)
 {
     CSA.DAL.SQLBuilder builder = new CSA.DAL.SQLBuilder();
     builder.TblName = "bs_ordersdtl";
     builder.AddData("Bs_OrdersCode", orderDtl.Bs_OrdersCode);
     builder.AddData("Bs_ProductsCode", orderDtl.Bs_ProductsCode);
     builder.AddData("Quantity", orderDtl.Quantity);
     builder.AddData("Price", orderDtl.Price);
     //builder.AddData("Amount", orderDtl.Amount);
     builder.AddData("Dimension", orderDtl.Dimension);
     builder.AutoInsert();
 }
Example #2
0
    /// <summary>
    /// 新增订单
    /// </summary>
    /// <param name="order"></param>
    /// <param name="cart"></param>
    /// <param name="proCode"></param>
    /// <param name="pay"></param>
    /// <param name="userId"></param>
    public void addOrder(Bs_Orders order, Cart cart, ref string proCode, ref decimal pay, int userId)
    {
        decimal deliverPay = 0;

        DataTable dtDeliver = dao.getDeliverByCode(order.Sy_DeliverCode);

        if (dtDeliver.Rows.Count > 0)
        {
            deliverPay       = decimal.Parse(dtDeliver.Rows[0]["amount"].ToString());
            order.DeliverFee = deliverPay;
        }
        Random rd        = new Random();
        string orderCode = DateTime.Now.ToString("yyMMddHHmmssff") + rd.Next(1000, 9999).ToString();

        order.Code = orderCode;
        // order.Discount = BLL.BsUser.User.GetDisCount();
        decimal Amount = 0;
        int     qty    = 0;

        foreach (Product cartPro in cart.Values.Values)
        {
            Bs_Products  pro      = Factory.getProBllInstance().getProById(cartPro.ProId);
            Bs_OrdersDtl orderDtl = new Bs_OrdersDtl();
            orderDtl.Bs_OrdersCode   = orderCode;
            orderDtl.Price           = decimal.Parse(cartPro.Price.ToString());
            orderDtl.Quantity        = cartPro.Qty;
            orderDtl.Bs_ProductsCode = pro.ID.ToString();
            orderDtl.Amount          = (decimal)(cartPro.Price * cartPro.Qty);
            orderDtl.Color           = cartPro.Color;
            orderDtl.Width           = cartPro.Width;
            orderDtl.Dimension       = cartPro.Size;
            dao.addOrderDtl(orderDtl);
            qty    += cartPro.Qty;
            Amount += (decimal)orderDtl.Amount;
        }
        order.DeliverFee = (decimal)deliverPay;
        order.ProductFee = Amount;

        Amount         += (decimal)deliverPay;
        pay             = Amount;
        order.Bs_UserID = userId;
        order.Quantity  = qty;
        order.Amount    = pay;
        order.ModTime   = DateTime.Now.ToString("s");
        order.AddTime   = DateTime.Now.ToString("s");
        order.Status    = Const.orderState_new;
        proCode         = order.Code;
        dao.addOrder(order);
    }