Ejemplo n.º 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());
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 存在返回id,不存在插入新纪录并返回id
 /// </summary>
 /// <returns>The add.</returns>
 /// <param name="item">Item.</param>
 public string Add(Passport passport, BillCustomer item)
 {
     //新客户,插入客户,再插入账单
     if (item.CustomerId == "")
     {
         item.Id         = TimeParser.GetTimeRandom();
         item.CustomerId = TimeParser.GetTimeRandom();
         dal.AddBillCustomerAndCustomer(passport.EnterpriseId, item);
         return(item.Id);
     }
     else
     {
         object result = dal.GetSingleBillCustomer(item);
         if (result == null)
         {
             item.Id = TimeParser.GetTimeRandom();
             dal.AddBillCustomer(item);
             return(item.Id);
         }
         else
         {
             return(result.ToString());
         }
     }
 }
Ejemplo n.º 3
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());
     }
 }
Ejemplo n.º 4
0
 public string Add(User user)
 {
     user.Id       = TimeParser.GetTimeRandom();
     user.Password = DESEncrypt.Encrypt(user.Password);
     return(dal.Add(user) > 0 ? "" : ErrorMsg.AddFailMsg());
 }