Esempio n. 1
0
        /// <summary>
        /// 购物车结算加入待付款
        /// </summary>
        /// <param name="s"></param>
        /// <param name="num"></param>
        public void add_deil(ShopManagement s, int num)
        {
            SportsDBEntities sde = new SportsDBEntities();
            //生成不重复的订单编号
            string str = Guid.NewGuid().ToString().Replace("-", "");
            //总价
            decimal?money = num * s.cart_price;
            //用户编号
            int uid = Convert.ToInt32(Session["uid"]);

            //添加订单表
            OrderBySeller obs = new OrderBySeller();

            obs.order_createTime    = DateTime.Now;
            obs.order_status        = 1;
            obs.orderdetails_status = -1;
            obs.order_cost          = money;
            obs.userid        = uid;
            obs.GoodsInfo_ID  = s.GoodsInfo_ID;
            obs.order_no      = str;
            obs.order_paytime = DateTime.Now;

            sde.Entry(obs).State = System.Data.EntityState.Added;//执行添加操作
            sde.SaveChanges();

            //查询当前的订单编号
            OrderBySeller os = sde.OrderBySeller.Where(a => a.order_no == str).FirstOrDefault();

            //当前订单编号
            int orderId = Convert.ToInt32(os.order_id);

            //添加订单详情表
            tbl_orderdetailsInfo tod = new tbl_orderdetailsInfo();

            tod.orderdetails_totalprice = money;
            tod.orderdetails_quantity   = num;
            tod.cart_color             = s.cart_color;
            tod.cart_CodeNumber        = s.cart_CodeNumber;
            tod.cart_photo             = s.cart_photo;
            tod.cart_remark            = s.cart_remark;
            tod.orderdetails_unitprice = s.cart_price;
            tod.GoodsInfo_id           = s.GoodsInfo_ID;
            tod.order_id           = orderId;
            tod.orderdetails_price = money;
            tod.StoreInfo_ID       = s.StoreInfo_ID;
            tod.UserInfo_id        = uid;

            //添加操作
            sde.Entry(tod).State = System.Data.EntityState.Added;

            //数据库执行操作返回状态
            sde.SaveChanges();
        }
Esempio n. 2
0
        /// <summary>
        /// 添加订单与订单详情(立即付款)
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="uid"></param>
        /// <param name="money"></param>
        /// <param name="num"></param>
        public void Add_dd(string[] msg, int uid, Decimal?money, int num)
        {
            SportsDBEntities sde = new SportsDBEntities();

            string str = Guid.NewGuid().ToString().Replace("-", "");
            //添加订单表
            OrderBySeller obs = new OrderBySeller();

            obs.order_createTime    = DateTime.Now;
            obs.order_status        = 1;
            obs.orderdetails_status = 0;
            obs.order_cost          = money;
            obs.userid        = uid;
            obs.GoodsInfo_ID  = Convert.ToInt32(msg[0]);
            obs.order_no      = str;
            obs.order_paytime = DateTime.Now;

            sde.Entry(obs).State = System.Data.EntityState.Added;//执行添加操作
            sde.SaveChanges();

            //查询当前的订单编号
            OrderBySeller os = sde.OrderBySeller.Where(a => a.order_no == str).FirstOrDefault();

            //当前订单编号
            int orderId = Convert.ToInt32(os.order_id);

            //添加订单详情表
            tbl_orderdetailsInfo tod = new tbl_orderdetailsInfo();

            tod.orderdetails_totalprice = money;
            tod.orderdetails_quantity   = num;
            tod.cart_color             = msg[3];
            tod.cart_CodeNumber        = msg[4];
            tod.cart_photo             = msg[2];
            tod.cart_remark            = msg[1];
            tod.orderdetails_unitprice = Convert.ToDecimal(msg[5]);
            tod.GoodsInfo_id           = Convert.ToInt32(msg[0]);
            tod.order_id           = orderId;
            tod.orderdetails_price = money;
            tod.StoreInfo_ID       = Convert.ToInt32(msg[7]);
            tod.UserInfo_id        = Convert.ToInt32(Session["uid"]);

            //添加操作
            sde.Entry(tod).State = System.Data.EntityState.Added;

            //数据库执行操作返回状态
            sde.SaveChanges();
        }