예제 #1
0
        /// <summary>
        /// 根据商品id查看商品信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CommodityMessage? getCommodityMessage(string id) {
            CommodityMessage? result = null;
            try {
                result = DB.findCommodityById(id);
            }
            catch (NotFindException) {

            }
            return result;
        }
예제 #2
0
 /// <summary>
 /// 减少某商品的数量
 /// </summary>
 /// <param name="num"></param>
 /// <returns>如果传入的id不正确,或num大于剩余数量则返回false</returns>
 public bool clearRepo(string id, int num) {
     try {
         CommodityMessage com = DB.findCommodityById(id);
         if (com.num < num) return false;
         com.num -= num;
         return DB.modityCommodity(com);
     }
     catch (NotFindException) {
         return false;
     }
 }
예제 #3
0
 /// <summary>
 /// 清空某商品的库存
 /// </summary>
 /// <param name="num"></param>
 /// <returns>如果传入的id不正确则返回false</returns>
 public bool clearRepo(string id)
 {
     try {
         CommodityMessage com = DB.findCommodityById(id);
         com.num = 0;
         return(DB.modityCommodity(com));
     }
     catch (NotFindException) {
         return(false);
     }
 }
예제 #4
0
        public CommodityMessage?getCommodityById(string id)
        {
            CommodityMessage?com = null;

            try {
                com = DB.findCommodityById(id);
                if (com.Value.outPrice == 0)
                {
                    com = null;
                }
            }
            catch (Exception) {
            }
            return(com);
        }