예제 #1
0
        /// <summary>
        /// 产生幸运码,并返回用于输出的Html
        /// </summary>
        public string CreateLuckCode(M_OrderList orderMod)
        {
            List <M_Product> proList = new List <M_Product>();
            B_Product        proBll  = new B_Product();
            B_Order_LuckCode codeBll = new B_Order_LuckCode();
            B_CartPro        cartBll = new B_CartPro();
            string           result  = "";
            //*一个购物车中,可能会有多个商品,
            DataTable cartDT = cartBll.GetCartProOrderID(orderMod.id);//购物车记录

            //判断出购物车中哪些是云购商品
            for (int i = 0; i < cartDT.Rows.Count; i++)
            {
                int       proID  = Convert.ToInt32(cartDT.Rows[i]["ProID"]);
                M_Product proMod = proBll.GetproductByid(proID);
                if (proMod.ProClass == 5)
                {
                    //减去相应的库存
                    proMod.Stock = proMod.Stock - Convert.ToInt32(cartDT.Rows[i]["ProNum"]);
                    proBll.updateinfo(proMod);
                    proMod.Class = Convert.ToInt32(cartDT.Rows[i]["ProNum"]);//购买数量,用备用字段存着
                    proList.Add(proMod);
                }
            }
            //根据购买的数量与信息,生成对应条数的幸运码,与上面分离开,便于后期扩展
            for (int i = 0; i < proList.Count; i++)
            {
                //获取该商品在数据库中的最大幸运码数
                int code = codeBll.GetMaxLuckCode(proList[i].ID);
                M_Order_LuckCode codeMod = new M_Order_LuckCode();
                codeMod.ProID   = proList[i].ID;
                codeMod.UserID  = orderMod.Userid;
                codeMod.OrderID = orderMod.id;
                codeMod.OrderNO = orderMod.OrderNo;
                DateTime now = DateTime.Now;
                codeMod.CreateTime  = now.ToString("yyyy/MM/dd HH:mm:ss:fff");
                codeMod.CreateTime2 = now.ToString("yyyyMMddHHmmssfff");
                result += "商品名:" + proList[i].Proname + "<br/>幸运码:";
                for (int j = 1; j <= proList[i].Class; j++)
                {
                    codeMod.Code = (code + j);
                    codeBll.Insert(codeMod);
                    result += codeMod.Code + ",";
                }
                result += "<br/>";
            }
            return(result.TrimEnd(','));;
        }
예제 #2
0
 //------------Update
 public bool UpdateModel(M_Order_LuckCode model)
 {
     return(DBCenter.UpdateByID(model, model.ID));
 }
예제 #3
0
 //------------Update
 public bool UpdateModel(M_Order_LuckCode model)
 {
     return(Sql.UpdateByIDs(TbName, PK, model.ID.ToString(), BLLCommon.GetFieldAndPara(model), model.GetParameters()));
 }
예제 #4
0
 //-----------------Insert
 public int Insert(M_Order_LuckCode model)
 {
     return(DBCenter.Insert(model));
 }
예제 #5
0
 //-----------------Insert
 public int Insert(M_Order_LuckCode model)
 {
     return(Sql.insert(TbName, model.GetParameters(), BLLCommon.GetParas(model), BLLCommon.GetFields(model)));
 }