@@ -26,7 +26,7 @@ namespace Learun.Application.Web.Areas.PersonnelManagement.Controllers | |||
[HttpGet] | |||
public ActionResult Index() | |||
{ | |||
return View(); | |||
return View(); | |||
} | |||
/// <summary> | |||
/// 表单页 | |||
@@ -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<ContractCategoryEntity>(); | |||
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 | |||
@@ -118,6 +118,54 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
} | |||
} | |||
/// <summary> | |||
/// 去重 | |||
/// </summary> | |||
/// <param name="No"></param> | |||
/// <param name="Name"></param> | |||
/// <returns></returns> | |||
public ContractCategoryEntity GetNoEntity(string No) | |||
{ | |||
try | |||
{ | |||
return contractCategoryService.GetNoEntity(No); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 去重 | |||
/// </summary> | |||
/// <param name="No"></param> | |||
/// <param name="Name"></param> | |||
/// <returns></returns> | |||
public ContractCategoryEntity GetNameEntity(string Name) | |||
{ | |||
try | |||
{ | |||
return contractCategoryService.GetNameEntity(Name); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -44,6 +44,13 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
/// <returns></returns> | |||
void SaveEntity(string keyValue, ContractCategoryEntity entity); | |||
#endregion | |||
/// <summary> | |||
/// 去重 | |||
/// </summary> | |||
/// <param name="No"></param> | |||
/// <param name="Name"></param> | |||
/// <returns></returns> | |||
ContractCategoryEntity GetNoEntity(string No); | |||
ContractCategoryEntity GetNameEntity(string Name); | |||
} | |||
} |
@@ -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<ContractCategoryEntity>(strSql.ToString(),dp, pagination); | |||
return this.BaseRepository("CollegeMIS").FindList<ContractCategoryEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -97,7 +97,7 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
{ | |||
try | |||
{ | |||
this.BaseRepository("CollegeMIS").Delete<ContractCategoryEntity>(t=>t.Id == keyValue); | |||
this.BaseRepository("CollegeMIS").Delete<ContractCategoryEntity>(t => t.Id == keyValue); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -144,7 +144,54 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 去重 | |||
/// </summary> | |||
/// <param name="No"></param> | |||
/// <param name="Name"></param> | |||
/// <returns></returns> | |||
public ContractCategoryEntity GetNoEntity(string No) | |||
{ | |||
try | |||
{ | |||
return this.BaseRepository("CollegeMIS").FindEntity<ContractCategoryEntity>(t => t.Code == No); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 去重 | |||
/// </summary> | |||
/// <param name="No"></param> | |||
/// <param name="Name"></param> | |||
/// <returns></returns> | |||
public ContractCategoryEntity GetNameEntity(string Name) | |||
{ | |||
try | |||
{ | |||
return this.BaseRepository("CollegeMIS").FindEntity<ContractCategoryEntity>(t => t.Name == Name); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||