Example #1
0
        /// <summary>
        /// 存在返回id,不存在插入新记录并返回id
        /// </summary>
        /// <returns>The add.</returns>
        /// <param name="item">Item.</param>
        public Object Add(Passport passport, BillGoods item)
        {
            decimal taxRate = dal.GetTaxRate(item.BillId);

            item.InTotalPrice  = item.InUnitPrice * item.Quantity * (item.IsRMB ? 1 : taxRate);
            item.OutTotalPrice = item.OutUnitPrice * item.Quantity;
            item.Profit        = item.OutTotalPrice - item.InTotalPrice;
            //新商品,插入商品,再插入账单
            int result = 0;

            if (item.GoodsId == "")
            {
                item.Id      = TimeParser.GetTimeRandom();
                item.GoodsId = TimeParser.GetTimeRandom();
                result       = dal.AddBillGoodsAndGoods(passport.EnterpriseId, item);
            }
            else
            {
                item.Id = TimeParser.GetTimeRandom();
                result  = dal.AddBillGoods(item);
            }
            //计算
            ProfitDal profitDal = new ProfitDal();

            if (result > 0)
            {
                return(CustomerDataConverter.RowToProfit(profitDal.UpdateBillGoods(item.BillId, item.BillCustomerId, item.Id)));
            }
            else
            {
                return(ErrorMsg.AddFailMsg());
            }
        }
Example #2
0
 public Object Add(Passport passport, Bill item)
 {
     item.Id    = TimeParser.GetTimeRandom();
     item.DocNo = dal.GetMaxDocNumber(passport);
     if (dal.AddBill(passport, item) > 0)
     {
         return(item);
     }
     else
     {
         return(ErrorMsg.AddFailMsg());
     }
 }
Example #3
0
 public string Add(User user)
 {
     user.Id       = TimeParser.GetTimeRandom();
     user.Password = DESEncrypt.Encrypt(user.Password);
     return(dal.Add(user) > 0 ? "" : ErrorMsg.AddFailMsg());
 }
Example #4
0
 public string Add(Passport passport, Address item)
 {
     return(dal.AddAddress(passport, item) > 0 ? "" : ErrorMsg.AddFailMsg());
 }
Example #5
0
 public string Add(Passport passport, Customer item)
 {
     return(dal.AddCustomer(passport, item) > 0 ? "" : ErrorMsg.AddFailMsg());
 }
Example #6
0
 public string Add(Passport passport, Goods item)
 {
     return(dal.AddGoods(passport, item) > 0 ? "" : ErrorMsg.AddFailMsg());
 }