diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/ContractCategoryController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/ContractCategoryController.cs index 00f8b5a0f..4fb561967 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/ContractCategoryController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/PersonnelManagement/Controllers/ContractCategoryController.cs @@ -26,7 +26,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers [HttpGet] public ActionResult Index() { - return View(); + return View(); } /// /// 表单页 @@ -35,7 +35,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers [HttpGet] public ActionResult Form() { - return View(); + return View(); } #endregion @@ -69,8 +69,9 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers [AjaxOnly] public ActionResult GetFormData(string keyValue) { - var ContractCategoryData = contractCategoryIBLL.GetContractCategoryEntity( keyValue ); - var jsonData = new { + var ContractCategoryData = contractCategoryIBLL.GetContractCategoryEntity(keyValue); + var jsonData = new + { ContractCategory = ContractCategoryData, }; return Success(jsonData); @@ -102,7 +103,32 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers public ActionResult SaveForm(string keyValue, string strEntity) { ContractCategoryEntity entity = strEntity.ToObject(); - contractCategoryIBLL.SaveEntity(keyValue,entity); + var NoModel = contractCategoryIBLL.GetNoEntity(entity.Code); + var NameModel = contractCategoryIBLL.GetNameEntity(entity.Name); + + if (string.IsNullOrEmpty(keyValue)) + { + if (NoModel != null) + { + return Fail("类别编号已存在!"); + } + if (NameModel != null) + { + return Fail("类别名称已存在!"); + } + } + else + { + if (NoModel != null && NoModel.Id != keyValue) + { + return Fail("类别编号已存在!"); + } + if (NameModel != null && NameModel.Id != keyValue) + { + return Fail("类别名称已存在!"); + } + } + contractCategoryIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryBLL.cs index 236b04724..50bde560a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryBLL.cs @@ -118,6 +118,54 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } } + /// + /// 去重 + /// + /// + /// + /// + public ContractCategoryEntity GetNoEntity(string No) + { + try + { + return contractCategoryService.GetNoEntity(No); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } + /// + /// 去重 + /// + /// + /// + /// + public ContractCategoryEntity GetNameEntity(string Name) + { + try + { + return contractCategoryService.GetNameEntity(Name); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryIBLL.cs index 1b3740780..887c3f6be 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryIBLL.cs @@ -44,6 +44,13 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement /// void SaveEntity(string keyValue, ContractCategoryEntity entity); #endregion - + /// + /// 去重 + /// + /// + /// + /// + ContractCategoryEntity GetNoEntity(string No); + ContractCategoryEntity GetNameEntity(string Name); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryService.cs index 81535de0d..c3e11e903 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/ContractCategory/ContractCategoryService.cs @@ -45,7 +45,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement dp.Add("Name", "%" + queryParam["Name"].ToString() + "%", DbType.String); strSql.Append(" AND t.Name Like @Name "); } - return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(),dp, pagination); + return this.BaseRepository("CollegeMIS").FindList(strSql.ToString(), dp, pagination); } catch (Exception ex) { @@ -97,7 +97,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement { try { - this.BaseRepository("CollegeMIS").Delete(t=>t.Id == keyValue); + this.BaseRepository("CollegeMIS").Delete(t => t.Id == keyValue); } catch (Exception ex) { @@ -144,7 +144,54 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement } } } - + /// + /// 去重 + /// + /// + /// + /// + public ContractCategoryEntity GetNoEntity(string No) + { + try + { + return this.BaseRepository("CollegeMIS").FindEntity(t => t.Code == No); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } + /// + /// 去重 + /// + /// + /// + /// + public ContractCategoryEntity GetNameEntity(string Name) + { + try + { + return this.BaseRepository("CollegeMIS").FindEntity(t => t.Name == Name); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion }