public OperationResult Insert(TaxBaseEveryMonthVM model) { try { TaxBaseEveryMonth taxBaseEveryMonth = _TaxBaseEveryMonthRepository.Entities.FirstOrDefault(c => c.CertificateID.ToLower() == model.CertificateID.Trim().ToLower()); if (taxBaseEveryMonth != null) { return(new OperationResult(OperationResultType.Warning, "数据库中已经存在相同的基本工资信息,请修改后重新提交!")); } if (model.Name == null || model.Name.Trim() == "") { return(new OperationResult(OperationResultType.Warning, "姓名不能为空,请修改后重新提交!")); } var entity = new TaxBaseEveryMonth { Period = model.Period, Name = model.Name, CertificateType = model.CertificateType, CertificateID = model.CertificateID, InitialEaring = model.InitialEaring, TaxFreeIncome = model.TaxFreeIncome, EndowmentInsurance = model.EndowmentInsurance, UnemployedInsurance = model.UnemployedInsurance, MedicalInsurance = model.MedicalInsurance, OccupationalAnnuity = model.OccupationalAnnuity, HousingFund = model.HousingFund, //TaxFree = model.TaxFree, AmountDeducted = model.AmountDeducted, InitialTaxPayable = model.InitialTaxPayable, //InitialTax = model.InitialTax, SpecialDeduction = model.SpecialDeduction, CutTax = model.CutTax, //TotalIncome = model.TotalIncome, TotalSalaryIncomeBeforeTax = model.TotalSalaryIncomeBeforeTax, TotalLaborIncomeBeforeTax = model.TotalLaborIncomeBeforeTax, TotalTax = model.TotalTax, TotalTemp = model.TotalTemp, LastMonths = model.LastMonths, //PersonType = model.PersonType, //Title = model.Title, UpdateDate = DateTime.Now }; _TaxBaseEveryMonthRepository.Insert(entity); return(new OperationResult(OperationResultType.Success, "新增数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "新增数据失败,数据库插入数据时发生了错误!")); } }
public OperationResult Update(TaxBaseEveryMonthVM model) { try { TaxBaseEveryMonth taxBaseEveryMonth = _TaxBaseEveryMonthRepository.Entities.FirstOrDefault(c => c.CertificateID.ToLower() == model.CertificateID.Trim().ToLower()); if (taxBaseEveryMonth == null) { throw new Exception(); } taxBaseEveryMonth.Period = model.Period; taxBaseEveryMonth.Name = model.Name; taxBaseEveryMonth.CertificateType = model.CertificateType; taxBaseEveryMonth.CertificateID = model.CertificateID; taxBaseEveryMonth.InitialEaring = model.InitialEaring; taxBaseEveryMonth.TaxFreeIncome = model.TaxFreeIncome; taxBaseEveryMonth.EndowmentInsurance = model.EndowmentInsurance; taxBaseEveryMonth.MedicalInsurance = model.MedicalInsurance; taxBaseEveryMonth.UnemployedInsurance = model.UnemployedInsurance; taxBaseEveryMonth.HousingFund = model.HousingFund; taxBaseEveryMonth.OccupationalAnnuity = model.OccupationalAnnuity; //taxBaseEveryMonth.InitialTax = model.InitialTax; taxBaseEveryMonth.InitialTaxPayable = model.InitialTaxPayable; taxBaseEveryMonth.AmountDeducted = model.AmountDeducted; //taxBaseByMonth.PersonType = model.PersonType; // taxBaseEveryMonth.TaxFree = model.TaxFree; taxBaseEveryMonth.SpecialDeduction = model.SpecialDeduction; taxBaseEveryMonth.CutTax = model.CutTax; // taxBaseEveryMonth.TotalIncome = model.TotalIncome; taxBaseEveryMonth.TotalTax = model.TotalTax; taxBaseEveryMonth.TotalSalaryIncomeBeforeTax = model.TotalSalaryIncomeBeforeTax; taxBaseEveryMonth.TotalLaborIncomeBeforeTax = model.TotalLaborIncomeBeforeTax; taxBaseEveryMonth.TotalTemp = model.TotalTemp; taxBaseEveryMonth.LastMonths = model.LastMonths; //taxBaseByMonth.Title = model.Title; taxBaseEveryMonth.UpdateDate = DateTime.Now; _TaxBaseEveryMonthRepository.Update(taxBaseEveryMonth); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }