Ejemplo n.º 1
0
 /// <summary>
 /// Create a new ConsumptionRecord object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="memberId">Initial value of the MemberId property.</param>
 /// <param name="goodsId">Initial value of the GoodsId property.</param>
 /// <param name="goodsName">Initial value of the GoodsName property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="operater">Initial value of the Operater property.</param>
 /// <param name="memberName">Initial value of the MemberName property.</param>
 /// <param name="money">Initial value of the Money property.</param>
 public static ConsumptionRecord CreateConsumptionRecord(global::System.Int32 id, global::System.DateTime date, global::System.Int32 memberId, global::System.Int32 goodsId, global::System.String goodsName, global::System.Int32 userId, global::System.String operater, global::System.String memberName, global::System.Double money)
 {
     ConsumptionRecord consumptionRecord = new ConsumptionRecord();
     consumptionRecord.Id = id;
     consumptionRecord.Date = date;
     consumptionRecord.MemberId = memberId;
     consumptionRecord.GoodsId = goodsId;
     consumptionRecord.GoodsName = goodsName;
     consumptionRecord.UserId = userId;
     consumptionRecord.Operater = operater;
     consumptionRecord.MemberName = memberName;
     consumptionRecord.Money = money;
     return consumptionRecord;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ConsumptionRecord EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToConsumptionRecord(ConsumptionRecord consumptionRecord)
 {
     base.AddObject("ConsumptionRecord", consumptionRecord);
 }
Ejemplo n.º 3
0
        public string Consumption(int id,double money,int gid,int uid)
        {
            YogaEntities ye = new YogaEntities();
            Member cc = ye.Member.FirstOrDefault((ccc) => ccc.Id == id);
            if (cc == null) return string.Format("编号为{0}的会员不存在", id);
            if (cc.CardRestMoney < money) return "余额不足";
            Goods g = ye.Goods.FirstOrDefault((gg) => gg.Id == gid);
            if (g == null) return string.Format("编号为{0}的商品不存在", gid);
            User u = ye.User.FirstOrDefault((uu) => uu.Id == uid);
            if (u == null) return string.Format("编号为{0}的操作员不存在", uid);
            cc.CardRestMoney -= money;
            cc.Score += (int)money;
            var cr = new ConsumptionRecord()
            {
                Date = DateTime.Now,
                MemberId = id,
                 MemberName = cc.Name,
                 GoodsId = gid,
                 GoodsName = g.Name,
                UserId = uid,
                Operater = u.Name
            };

            ye.AddToConsumptionRecord(cr);
            return ye.SaveChanges() == 2 ? "扣值成功" : "扣值失败";
        }