public bool Save(ContractDetail contractDetail, out string strResult) { strResult = string.Empty; bool result = false; var con = ContractDetailRepository.GetQueryable().FirstOrDefault(c => c.ContractCode == contractDetail.Contract.ContractCode); if (con != null) { try { con.BrandCode = contractDetail.BrandCode; con.Quantity = contractDetail.Quantity; con.Price = contractDetail.Price; con.Amount = contractDetail.Amount; con.TaxAmount = contractDetail.TaxAmount; ContractDetailRepository.SaveChanges(); result = true; } catch (Exception ex) { strResult = "原因:" + ex.Message; } } return(result); }
public bool Add(ContractDetail contractDetail, out string strResult) { strResult = string.Empty; bool result = false; var c = new ContractDetail(); if (c != null) { try { c.ID = Guid.NewGuid(); c.ContractCode = contractDetail.ContractCode; c.BrandCode = contractDetail.BrandCode; c.Quantity = contractDetail.Quantity; c.Price = contractDetail.Price; c.Amount = contractDetail.Amount; c.TaxAmount = contractDetail.TaxAmount; ContractDetailRepository.Add(c); ContractDetailRepository.SaveChanges(); result = true; } catch (Exception ex) { strResult = "原因:" + ex.InnerException; } } else { strResult = "原因:找不到当前登陆用户!请重新登陆!"; } return(result); }