using Learun.Application.Base.SystemModule;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Learun.Application.Organization;
namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
public class EmpInfoEnternalController : Controller
{
// GET: EducationalAdministration/EmpInfoEnternal
DataSourceIBLL dataSourceIBLL = new DataSourceBLL();
DataItemIBLL dataItemIBLL = new DataItemBLL();
UserIBLL userIBLL = new UserBLL();
EmpInfoIBLL empInfoIBLL = new EmpInfoBLL();
AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
public ActionResult FormAdd()
{
return View();
}
///
/// 获取数据源数据
///
/// 数据源编号
/// sql查询条件语句
/// 数据源请求条件字串
///
[HttpGet]
[AjaxOnly]
public ActionResult GetMap(string code, string ver, string where)
{
var data = dataSourceIBLL.GetDataTable(code, where);
string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
if (md5 == ver)
{
return Success("no update");
}
else
{
var jsondata = new
{
data = data,
ver = md5
};
return JsonResult(jsondata);
}
}
///
/// 获取数据字典数据
///
/// 数据源编号
/// sql查询条件语句
/// 数据源请求条件字串
///
[HttpGet]
[AjaxOnly]
public ActionResult GetDataItemMap(string code, string ver)
{
var data = dataItemIBLL.GetDetailList(code, null);
return JsonResult(data);
}
public ActionResult UploadImg(HttpPostedFileBase Filedata)
{
//没有文件上传,直接返回
if (Filedata == null || string.IsNullOrEmpty(Filedata.FileName) || Filedata.ContentLength == 0)
{
if (Request.Files.Count > 0)
{
return Success(new { folderId = annexesFileIBLL.SaveAnnexesInfo(Request.Files[0]) });
}
else
{
return HttpNotFound();
}
}
return Success("保存成功");
}
protected virtual ActionResult Success(string info)
{
return Content(new ResParameter { code = ResponseCode.success, info = info, data = new object { } }.ToJson());
}
protected virtual ActionResult Success(object data)
{
return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
}
protected virtual ActionResult JsonResult(object data)
{
return Content(new ResParameter { code = ResponseCode.success, info = "响应成功", data = data }.ToJson());
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, string strEntity)
{
EmpInfoEntity entity = strEntity.ToObject();
if (!string.IsNullOrEmpty(entity.EmpNo))
{
var empentity = empInfoIBLL.GetEmpInfoEntityByEmpNo(entity.EmpNo);
var userEntity = userIBLL.GetEntityByAccount(entity.EmpNo);
if (null != empentity || null != userEntity)
{
return Success(new { data = entity, info = "有重复的职工编号" });
}
}
entity.EmpId = Guid.NewGuid().ToString();
empInfoIBLL.SaveEntity(keyValue, entity);
return Success(new { data = entity, info = "保存成功" });
}
}
}