示例#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);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string phone = context.Request["CheckPhone"];

            if (context.Request["buyId"] != null)
            {
                int res = AdminMng.CheckBuy(Convert.ToInt32(context.Request["buyId"]));
                if (res == 0)
                {
                    context.Response.Write("ok");
                }
                else
                {
                    context.Response.Write("no");
                }
                return;
            }
            if (PersonSvc.RetrieveByPhone(phone).Count != 0)
            {
                context.Response.Write("no");
                return;
            }
            context.Response.Write("ok");
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="person"></param>
 /// <returns>-1: fail; 0: success</returns>
 public static int Reg(Person person)
 {
     if (PersonSvc.RetrieveByPhone(person.Phone).Count > 0)
     {
         return(-1);
     }
     else
     {
         PersonSvc.Create(person);
         return(0);
     }
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="person"></param>
        /// <returns>-2: >1; -1: <=0; 0: success </returns>
        public static int Detail(int id, ref Person person)
        {
            List <Person> list = PersonSvc.RetrieveById(id);

            if (list.Count > 1)
            {
                return(-2);
            }
            else if (list.Count <= 0)
            {
                return(-1);
            }
            else
            {
                person = list[0];
                return(0);
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="person"></param>
        /// <returns>-3: >1; -2 <=0; -1 fail; 0:success </returns>
        public static int Log(ref Person person)
        {
            List <Person> list = PersonSvc.RetrieveByPhone(person.Phone);

            if (list.Count > 1)
            {
                return(-3);
            }
            else if (list.Count <= 0)
            {
                return(-2);
            }
            else if (list[0].Psd.Equals(person.Psd) == false)
            {
                return(-1);
            }
            else
            {
                person = list[0];
                return(0);
            }
        }
示例#6
0
        public static int EditPerson(Person person)
        {
            Person per = PersonSvc.RetrieveById(person.Id)[0];

            if (per.Phone != person.Phone || per.Psd != person.Psd)
            {
                return(-1);
            }
            else
            {
                if (per.Value != person.Value)
                {
                    Value value = new Value();
                    value.PersonId = per.Id;
                    value.Num      = person.Value - per.Value;
                    value.Date     = System.DateTime.Now.ToString();
                    value.Other    = "管理员修改积分";
                    ValueSvc.Create(value);
                }
                PersonSvc.Update(person);
                return(0);
            }
        }
示例#7
0
 public static int QueryPersonByName(string name, ref List <Person> persons)
 {
     persons = PersonSvc.RetrieveByName(name);
     return(0);
 }
示例#8
0
 public static int QueryPersonByPhone(string phone, ref Person person)
 {
     person = PersonSvc.RetrieveByPhone(phone)[0];
     return(0);
 }
示例#9
0
 public static int QueryPersonAll(ref List <Person> persons)
 {
     persons = PersonSvc.RetrieveAll();
     return(0);
 }
示例#10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="list"></param>
 /// <returns>-3: >1; -2: <0; -1: fail; 0: success </returns>
 public static int Edit(Person person)
 {
     PersonSvc.Update(person);
     return(0);
 }
示例#11
0
 public static int GetPersonById(int id, ref Person person)
 {
     person = PersonSvc.RetrieveById(id)[0];
     return(0);
 }