Beispiel #1
0
        /// <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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
 /// <summary>
 /// 添加售货信息
 /// </summary>
 /// <param name="Mes"></param>
 /// <returns></returns>
 public sellCode sellCommodity(LogMessage Mes)
 {
     //TODO
     DB.addLog(Mes);
     return(sellCode.success);
 }