public OperationResult Delete(TaxBaseByMonth model) { try { // model.UpdateDate = DateTime.Now; _TaxBaseByMonthRepository.Delete(model); return(new OperationResult(OperationResultType.Success, "删除数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "删除数据失败!")); } }
public OperationResult Insert(TaxBaseByMonthVM model) { try { TaxBaseByMonth taxBaseByMonth = _TaxBaseByMonthRepository.Entities.FirstOrDefault(c => c.CertificateID.ToLower() == model.CertificateID.Trim().ToLower()); if (taxBaseByMonth != null) { return(new OperationResult(OperationResultType.Warning, "数据库中已经存在相同的基本工资信息,请修改后重新提交!")); } if (model.Name == null || model.Name.Trim() == "") { return(new OperationResult(OperationResultType.Warning, "姓名不能为空,请修改后重新提交!")); } var entity = new TaxBaseByMonth { 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, InitialAfterTaxIncome = model.InitialAfterTaxIncome, //TaxFree = model.TaxFree, AmountDeducted = model.AmountDeducted, InitialTaxPayable = model.InitialTaxPayable, InitialTax = model.InitialTax, SpecialDeduction = model.SpecialDeduction, CutTax = model.CutTax, //PersonType = model.PersonType, //Title = model.Title, UpdateDate = DateTime.Now }; _TaxBaseByMonthRepository.Insert(entity); return(new OperationResult(OperationResultType.Success, "新增数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "新增数据失败,数据库插入数据时发生了错误!")); } }
public OperationResult Import(String fileName, Service.Excel.ImportData importData) { try { var columns = importData == null ? null : importData.Columns; var maps = ImportUtil.GetColumns(columns, new TaxBaseByMonth()); var items = ExcelService.GetObjects(fileName, columns); if (importData != null) { int num = 1; foreach (var item in items) { TaxBaseByMonth record = new TaxBaseByMonth(); List <ImportFeedBack> errors = ImportUtil.ValidateImportRecord(item, num++, maps, ref record); if (errors.Count > 0) { return(new OperationResult(OperationResultType.Error, "导入数据失败", ImportUtil.ParseToHtml(errors))); } //插入或更新数据 _TaxBaseByMonthRepository.InsertOrUpdate(record); } } return(new OperationResult(OperationResultType.Success, "导入数据成功!")); } catch (Exception ex) { _log.Error(ex); ImportFeedBack feedBack = new ImportFeedBack(); feedBack.ExceptionType = "未知错误"; feedBack.ExceptionContent.Add(ex.Message); List <ImportFeedBack> erros = new List <ImportFeedBack>(); return(new OperationResult(OperationResultType.Error, "导入数据失败!", ImportUtil.ParseToHtml(new List <ImportFeedBack>() { feedBack }))); } }
public OperationResult Update(TaxBaseByMonthVM model) { try { TaxBaseByMonth taxBaseByMonth = _TaxBaseByMonthRepository.Entities.FirstOrDefault(c => c.CertificateID == model.CertificateID.Trim()); if (taxBaseByMonth == null) { throw new Exception(); } taxBaseByMonth.Period = model.Period; taxBaseByMonth.Name = model.Name; taxBaseByMonth.CertificateType = model.CertificateType; taxBaseByMonth.CertificateID = model.CertificateID; taxBaseByMonth.InitialEaring = model.InitialEaring; taxBaseByMonth.InitialTax = model.InitialTax; taxBaseByMonth.InitialTaxPayable = model.InitialTaxPayable; taxBaseByMonth.AmountDeducted = model.AmountDeducted; taxBaseByMonth.TaxFreeIncome = model.TaxFreeIncome; taxBaseByMonth.EndowmentInsurance = model.EndowmentInsurance; taxBaseByMonth.UnemployedInsurance = model.UnemployedInsurance; taxBaseByMonth.MedicalInsurance = model.MedicalInsurance; taxBaseByMonth.OccupationalAnnuity = model.OccupationalAnnuity; taxBaseByMonth.InitialAfterTaxIncome = model.InitialAfterTaxIncome; taxBaseByMonth.HousingFund = model.HousingFund; //taxBaseByMonth.PersonType = model.PersonType; // taxBaseByMonth.TaxFree = model.TaxFree; taxBaseByMonth.SpecialDeduction = model.SpecialDeduction; taxBaseByMonth.CutTax = model.CutTax; //taxBaseByMonth.Title = model.Title; taxBaseByMonth.UpdateDate = DateTime.Now; _TaxBaseByMonthRepository.Update(taxBaseByMonth); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }