Example #1
0
        public static int CheckBuy(int id)
        {
            Buy    buy    = BuySvc.RetrieveById(id)[0];
            Good   good   = GoodSvc.RetrieveById(buy.GoodId)[0];
            Person person = PersonSvc.RetrieveById(buy.PersonId)[0];

            if (buy.IsCheck == false)
            {
                if (good.Num < buy.Num)
                {
                    return(-1);
                }
                good.Num -= buy.Num;
                GoodSvc.Update(good);
                buy.IsCheck = true;
                BuySvc.Update(buy);
                Value value = new Value();
                value.PersonId = buy.PersonId;
                value.Num      = Convert.ToInt32(good.Value * buy.Num);
                value.Date     = System.DateTime.Now.ToString();
                value.Other    = "购物获得";
                ValueSvc.Create(value);
                person.Value += value.Num;
                PersonSvc.Update(person);
            }
            return(0);
        }
Example #2
0
        public static int PseDelGood(int id)
        {
            Good good = GoodSvc.RetrieveById(id)[0];

            good.IsDel = true;
            GoodSvc.Update(good);
            return(0);
        }
Example #3
0
 public static int RealDelGood(int id)
 {
     GoodSvc.Delete(id);
     return(0);
 }
Example #4
0
 public static int AddGood(Good good)
 {
     GoodSvc.Create(good);
     return(0);
 }
Example #5
0
 public static int EditGood(Good good)
 {
     GoodSvc.Update(good);
     return(0);
 }
Example #6
0
 public static int GetGood(ref List <Good> goods)
 {
     goods = GoodSvc.RetrieveAll();
     return(0);
 }
Example #7
0
 public static int GetGoodById(int id, ref Good good)
 {
     good = GoodSvc.RetrieveById(id)[0];
     return(0);
 }
Example #8
0
 public static int GetGoodByName(string name, List <Good> goods)
 {
     goods = GoodSvc.RetrieveByName(name);
     return(0);
 }