/// <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()); } }
public object RemoveAndReturnProfit(Passport passport, DeleteBillGoods item) { ProfitDal profitDal = new ProfitDal(); if (dal.DeleteBillGoods(item.BillGoodsId) > 0) { return(CustomerDataConverter.RowToProfit(profitDal.DeleteBillGoods(item.BillId, item.BillCustomerId))); } else { return(ErrorMsg.DeleteFailMsg()); } }
public string UpdateBillCustomerGoods(Passport passport, Bill item) { ProfitDal profitDal = new ProfitDal(); int result = dal.UpdateBillCustomerGoods(passport, item); if (result > 0) { return(profitDal.UpdateBillAllProfit(item.Id) > 0 ? "" : "计算利润失败"); } else { return("保存数据失败"); } }