public OperationResult Update(TopContacts model) { try { //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } model.UpdateDate = DateTime.Now; model.AccountNumber = GetReplaceString(model.AccountNumber); model.BankDetailName = GetReplaceString(model.BankDetailName); model.ProvinceCity = GetReplaceString(model.ProvinceCity); model.CityField = GetReplaceString(model.CityField); model.Name = nameFormat; model.Nationality = GetReplaceString(model.Nationality); model.Tele = GetReplaceString(model.Tele); model.CertificateID = GetReplaceString(model.CertificateID); _TopContactsRepository.Update(model); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch { return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }
public OperationResult Update(TopContactsVM model) { try { String CertificateIDCk = GetReplaceString(model.CertificateID); String AccountNumberCk = GetReplaceString(model.AccountNumber); TopContacts topContacts = _TopContactsRepository.Entities.FirstOrDefault(c => c.UserID == model.UserID); if (topContacts == null) { throw new Exception(); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } String idType = GetReplaceString(model.CertificateType); String birthVar = ""; String genderVar = ""; if (!"居民身份证".Equals(idType)) { birthVar = GetReplaceString(model.Birth); genderVar = GetReplaceString(model.Gender); } topContacts.UserID = model.UserID; topContacts.Name = nameFormat; topContacts.CertificateID = GetReplaceString(model.CertificateID); topContacts.CertificateType = GetReplaceString(model.CertificateType); topContacts.Company = GetReplaceString(model.Company); topContacts.Tele = GetReplaceString(model.Tele); topContacts.PersonType = GetReplaceString(model.PersonType); topContacts.Nationality = GetReplaceString(model.Nationality); topContacts.Title = GetReplaceString(model.Title); topContacts.Bank = GetReplaceString(model.Bank); topContacts.BankDetailName = GetReplaceString(model.BankDetailName); topContacts.ProvinceCity = GetReplaceString(model.ProvinceCity); topContacts.CityField = GetReplaceString(model.CityField); topContacts.AccountNumber = GetReplaceString(model.AccountNumber); topContacts.Gender = genderVar; topContacts.Birth = birthVar; topContacts.UpdateDate = DateTime.Now; _TopContactsRepository.Update(topContacts); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }
public OperationResult Delete(TopContacts model) { try { model.UpdateDate = DateTime.Now; _TopContactsRepository.Delete(model); return(new OperationResult(OperationResultType.Success, "删除数据成功!")); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "删除数据失败!")); } }
public OperationResult Insert(TopContactsVM model) { try { String CertificateIDCk = GetReplaceString(model.CertificateID); String AccountNumberCk = GetReplaceString(model.AccountNumber); //1.检查是否有重复字段 TopContacts[] topContacts = _TopContactsRepository.Entities.Where(w => w.UserID == model.UserID && w.CertificateID == CertificateIDCk && w.AccountNumber == AccountNumberCk).ToArray(); if (topContacts != null && topContacts.Length > 0) { return(new OperationResult(OperationResultType.Warning, "常用领款人列表中已经存在相同的人员信息,请修改后重新提交!")); } if (String.IsNullOrEmpty(model.CertificateID)) { return(new OperationResult(OperationResultType.Warning, "证件号码不能为空,请修改后重新提交!")); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } String idType = GetReplaceString(model.CertificateType); String birthVar = ""; String genderVar = ""; if (!"居民身份证".Equals(idType)) { birthVar = GetReplaceString(model.Birth); genderVar = GetReplaceString(model.Gender); } var entity = new TopContacts { UserID = model.UserID, Name = nameFormat, CertificateID = GetReplaceString(model.CertificateID), CertificateType = GetReplaceString(model.CertificateType), Company = GetReplaceString(model.Company), Tele = GetReplaceString(model.Tele), PersonType = GetReplaceString(model.PersonType), Nationality = GetReplaceString(model.Nationality), Title = GetReplaceString(model.Title), Bank = GetReplaceString(model.Bank), BankDetailName = GetReplaceString(model.BankDetailName), ProvinceCity = GetReplaceString(model.ProvinceCity), CityField = GetReplaceString(model.CityField), Gender = genderVar, Birth = birthVar, AccountNumber = GetReplaceString(model.AccountNumber), UpdateDate = DateTime.Now }; _TopContactsRepository.Insert(entity); return(new OperationResult(OperationResultType.Success, "新增数据成功!", entity)); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "新增数据失败:" + ex.Message)); } }
public OperationResult Insert(PersonalRecordVM model, bool isSave) { try { string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData; //1.检查是否有重复字段 PersonalRecord[] personalRecords = _PersonalRecordRepository.Entities.Where(w => w.SerialNumber == model.SerialNumber && w.CertificateID == model.CertificateID.Trim()).ToArray(); if (personalRecords != null && personalRecords.Length > 0) { return(new OperationResult(OperationResultType.Warning, "该申请单中已经存在相同的人员信息,请修改后重新提交!")); } if (String.IsNullOrEmpty(model.CertificateID)) { return(new OperationResult(OperationResultType.Warning, "证件号码不能为空,请修改后重新提交!")); } if (String.IsNullOrEmpty(model.Nationality)) { return(new OperationResult(OperationResultType.Warning, "国籍不能为空,请修改后重新提交!")); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } String idType = GetReplaceString(model.CertificateType); String birthVar = ""; String genderVar = ""; if (!"居民身份证".Equals(idType)) { birthVar = GetReplaceString(model.Birth); genderVar = GetReplaceString(model.Gender); } var entity = new PersonalRecord { SerialNumber = model.SerialNumber, Name = nameFormat, CertificateID = GetReplaceString(model.CertificateID), CertificateType = GetReplaceString(model.CertificateType), Company = GetReplaceString(model.Company), Tele = GetReplaceString(model.Tele), PersonType = GetReplaceString(model.PersonType), Nationality = GetReplaceString(model.Nationality), Title = GetReplaceString(model.Title), Amount = model.Amount, TaxOrNot = GetReplaceString(model.TaxOrNot), Bank = GetReplaceString(model.Bank), BankDetailName = GetReplaceString(model.BankDetailName), AccountName = GetReplaceString(model.AccountName), AccountNumber = GetReplaceString(model.AccountNumber), ProvinceCity = GetReplaceString(model.ProvinceCity), CityField = GetReplaceString(model.CityField), Gender = genderVar, Birth = birthVar, PaymentType = GetReplaceString(model.PaymentType), UpdateDate = DateTime.Now }; _PersonalRecordRepository.Insert(entity, isSave); //保存时同步向常用领款人表TopContacts中保存 TopContacts contact = new TopContacts(); contact.UserID = userid; contact.Name = nameFormat; contact.CertificateType = GetReplaceString(model.CertificateType); contact.CertificateID = GetReplaceString(model.CertificateID); contact.Nationality = GetReplaceString(model.Nationality); contact.PersonType = GetReplaceString(model.PersonType); contact.Tele = GetReplaceString(model.Tele); contact.Title = GetReplaceString(model.Title); contact.Company = GetReplaceString(model.Company); if (!String.IsNullOrEmpty(model.Bank)) { contact.Bank = GetReplaceString(model.Bank); } if (!String.IsNullOrEmpty(model.BankDetailName)) { contact.BankDetailName = GetReplaceString(model.BankDetailName); } if (!String.IsNullOrEmpty(model.AccountNumber)) { contact.AccountNumber = GetReplaceString(model.AccountNumber); } if (!String.IsNullOrEmpty(model.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(model.ProvinceCity); } if (!String.IsNullOrEmpty(model.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(model.ProvinceCity); } if (!String.IsNullOrEmpty(model.CityField)) { contact.CityField = GetReplaceString(model.CityField); } if (!String.IsNullOrEmpty(genderVar)) { contact.Gender = genderVar; } if (!String.IsNullOrEmpty(birthVar)) { contact.Birth = birthVar; } _TopContactsService.Insert(contact); return(new OperationResult(OperationResultType.Success, "新增数据成功!", entity)); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "新增数据失败:" + ex.Message)); } }
public OperationResult Import(String fileName, Service.Excel.ImportData importData) { try { string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData; var columns = importData == null ? null : importData.Columns; var maps = ImportUtil.GetColumns(columns, new PersonalRecord()); var items = ExcelService.GetObjects(fileName, columns); if (importData != null) { String serialNumber = importData.Parameters[0].Value; String paymentType = importData.Parameters[1].Value; int num = 1; foreach (var item in items) { if (CheckAllNull(item[0]) && CheckAllNull(item[1]) && CheckAllNull(item[2]) && CheckAllNull(item[3]) && CheckAllNull(item[4]) && CheckAllNull(item[5]) && CheckAllNull(item[6]) && CheckAllNull(item[7]) && CheckAllNull(item[8])) { continue; } PersonalRecord record = new PersonalRecord(); record.SerialNumber = serialNumber; record.PaymentType = paymentType; if (paymentType.Equals("银行转账")) { if (item.Count < 16) { return(new OperationResult(OperationResultType.Error, "导入数据失败", "<li>请增加银行账户等相关信息或修改为现金支付类型</li>")); } record.AccountName = item[0]; record.Bank = item[10]; record.AccountNumber = item[11]; record.BankDetailName = item[12]; record.ProvinceCity = item[13]; record.CityField = item[14]; } List <ImportFeedBack> errors = ValidatePersonalRecord(item, num++, maps, ref record); if (errors.Count > 0) { return(new OperationResult(OperationResultType.Error, "导入数据失败", ImportUtil.ParseToHtml(errors))); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(record.Name.Trim())) { nameFormat = record.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(record.Name); } //插入或更新数据 _PersonalRecordRepository.InsertOrUpdate(record); //保存时同步向常用领款人表TopContacts中保存 TopContacts contact = new TopContacts(); contact.UserID = userid; contact.Name = nameFormat; contact.CertificateType = GetReplaceString(record.CertificateType); contact.CertificateID = GetReplaceString(record.CertificateID); contact.Nationality = GetReplaceString(record.Nationality); contact.PersonType = GetReplaceString(record.PersonType); contact.Tele = GetReplaceString(record.Tele); contact.Title = GetReplaceString(record.Title); contact.Company = GetReplaceString(record.Company); if (!String.IsNullOrEmpty(record.Bank)) { contact.Bank = GetReplaceString(record.Bank); } if (!String.IsNullOrEmpty(record.BankDetailName)) { contact.BankDetailName = GetReplaceString(record.BankDetailName); } if (!String.IsNullOrEmpty(record.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(record.ProvinceCity); } if (!String.IsNullOrEmpty(record.CityField)) { contact.CityField = GetReplaceString(record.CityField); } if (!String.IsNullOrEmpty(record.AccountNumber)) { contact.AccountNumber = GetReplaceString(record.AccountNumber); } if (!String.IsNullOrEmpty(record.Gender)) { contact.Gender = GetReplaceString(record.Gender); } if (!String.IsNullOrEmpty(record.Birth)) { contact.Birth = GetReplaceString(record.Birth); } _TopContactsService.Insert(contact); } } 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 }))); } }