コード例 #1
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;
     }
 }
コード例 #2
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);
     }
 }
コード例 #3
0
ファイル: Manager.cs プロジェクト: Red-Night-Aria/UWP
 /// <summary>
 /// 修改商品价格
 /// </summary>
 /// <param name="Mes"></param>
 /// <returns></returns>
 public bool modifyPrice(CommodityMessage Mes)
 {
     try
     {
         DB.modityCommodity(Mes);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: Seller.cs プロジェクト: Red-Night-Aria/UWP
        /// <summary>
        /// 添加售货信息
        /// </summary>
        /// <param name="Mes"></param>
        /// <returns></returns>
        public sellCode sellCommodity(LogMessage Mes)
        {
            //TODO
            CommodityMessage com;

            try {
                com      = DB.findCommodityByName(Mes.commodityName);
                com.num -= Mes.num;
                DB.modityCommodity(com);
                DB.addLog(Mes);
            }
            catch (Exception) {
                return(sellCode.miss);
            }
            return(sellCode.success);
        }
コード例 #5
0
        /// <summary>
        /// 进货。若是已存在的商品,则不需要填入comId
        /// </summary>
        /// <param name="id">对于已存在的商品,comId默认为""</param>
        /// <returns></returns>
        public stockCode Stock(string name, int num, float price, DateTime time, string logId, string comId = "")
        {
            try {
                if (comId != "")
                {
                    CommodityMessage newCommodity = new CommodityMessage();
                    newCommodity.commodityName = name;
                    newCommodity.id            = comId;
                    newCommodity.inPrice       = price;
                    newCommodity.num           = num;
                    DB.addCommodity(newCommodity);
                }
                else
                {
                    CommodityMessage dbcommodity = DB.findCommodityByName(name);
                    dbcommodity.num += num;
                    DB.modityCommodity(dbcommodity);
                }
            }
            catch (RepeatException) {
                return(stockCode.repeat);
            }
            catch (NotFindException) {
                return(stockCode.miss);
            }
            LogMessage log = new LogMessage();

            log.commodityName = name;
            log.flag          = true;
            log.id            = logId;
            log.num           = num;
            log.price         = price;
            log.time          = time;
            DB.addLog(log);
            return(stockCode.success);
        }
コード例 #6
0
 /// <summary>
 /// 修改商品价格
 /// </summary>
 /// <param name="Mes"></param>
 /// <returns></returns>
 public bool modifyPrice(CommodityMessage Mes) {
     return DB.modityCommodity(Mes);
 }