using FineUIPro; using NPOI.SS.Formula.Functions; using System.Collections; using System.Linq; namespace BLL { public class Person_ShuntService { public static Model.SGGLDB db = Funs.DB; #region 获取人员列表信息 /// /// 记录数 /// public static int count { get; set; } /// /// 定义变量 /// private static IQueryable getDataLists = from x in db.Person_Persons where x.PersonId != Const.sysglyId && x.PersonId != Const.hfnbdId && x.UnitId == Const.UnitId_SEDIN && x.DepartId == Const.Depart_constructionId && x.CurrentProjectId == null && (!x.IsOffice.HasValue || x.IsOffice == false) select x; /// /// 数据列表 /// /// /// /// /// /// /// /// /// public static IEnumerable getListData(string workPostId, string postTitleId, string name, string certificateId, Grid Grid1) { IQueryable getDataList = getDataLists; if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null) { getDataList = getDataList.Where(e => e.WorkPostId == workPostId); } if (!string.IsNullOrEmpty(postTitleId) && postTitleId != Const._Null) { getDataList = getDataList.Where(e => e.PostTitleId == postTitleId); } if (!string.IsNullOrEmpty(name)) { getDataList = getDataList.Where(e => e.PersonName.Contains(name)); } if (!string.IsNullOrEmpty(certificateId) && postTitleId != Const._Null) { getDataList = getDataList.Where(e => e.CertificateId.Contains(certificateId)); } count = getDataList.Count(); if (count == 0) { return null; } getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); return from x in getDataList select new { x.PersonId, x.PersonName, x.JobNum, x.Account, x.IdentityCard, Sex = x.Sex ?? "1", x.Birthday, x.UnitId, x.DepartId, x.WorkPostId, WorkPostName = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId), x.Major, x.PostTitleId, PostTitleName = PostTitleService.getPostTitleNameById(x.PostTitleId), x.IsOffice, x.RoleIds, RoleName = RoleService.getRoleNamesRoleIds(x.RoleIds), x.CurrentProjectId, LastProjectName = getCurrentProjectName(x.PersonId), x.CurrentProjectWorkPostId, LastWorkPostName = getCurrentProjectWorkPostName(x.PersonId), IsPost = x.IsPost ?? true, IsPostName = x.IsPost == false ? "否" : "是", x.SignatureUrl, x.CertificateId, }; } #endregion #region 获取当前项目及岗位 /// /// /// /// /// /// public static string getCurrentProjectName(string PersonId) { var getItem = (from x in Funs.DB.SitePerson_PersonItem where x.PersonId == PersonId orderby x.InTime descending select x).FirstOrDefault(); if (getItem != null) { return ProjectService.GetShortNameByProjectId(getItem.ProjectId); } else { return null; } } /// /// /// /// /// /// public static string getCurrentProjectWorkPostName(string PersonId) { var getItem = (from x in Funs.DB.SitePerson_PersonItem where x.PersonId == PersonId orderby x.InTime descending select x).FirstOrDefault(); if (getItem != null) { return WorkPostService.getWorkPostNamesWorkPostIds(getItem.WorkPostId); } else { return null; } } #endregion /// /// 添加分流管理 /// /// public static void AddShunt(Model.Person_Shunt Shunt) { Model.Person_Shunt newShunt = new Model.Person_Shunt(); newShunt.ShuntId = Shunt.ShuntId; newShunt.Code = Shunt.Code; newShunt.ProjectId = Shunt.ProjectId; newShunt.State = Shunt.State; newShunt.CompileMan = Shunt.CompileMan; newShunt.CompileDate = Shunt.CompileDate; newShunt.SaveHandleMan = Shunt.SaveHandleMan; Funs.DB.Person_Shunt.InsertOnSubmit(newShunt); Funs.DB.SubmitChanges(); } /// /// 修改分流管理 /// /// public static void UpdateShunt(Model.Person_Shunt Shunt) { var newShunt = Funs.DB.Person_Shunt.FirstOrDefault(e => e.ShuntId == Shunt.ShuntId); if (newShunt != null) { newShunt.Code = Shunt.Code; newShunt.ProjectId = Shunt.ProjectId; newShunt.State = Shunt.State; newShunt.CompileMan = Shunt.CompileMan; newShunt.CompileDate = Shunt.CompileDate; newShunt.SaveHandleMan = Shunt.SaveHandleMan; Funs.DB.SubmitChanges(); } } /// /// 根据分流管理Id删除一个分流管理信息 /// /// public static void DeleteShunt(string ShuntId) { var Shunt = Funs.DB.Person_Shunt.FirstOrDefault(e => e.ShuntId == ShuntId); if (Shunt != null) { Funs.DB.Person_Shunt.DeleteOnSubmit(Shunt); Funs.DB.SubmitChanges(); } } /// /// 根据分流管理Id获取一个分流管理信息 /// /// public static Model.Person_Shunt GetShunt(string ShuntId) { return Funs.DB.Person_Shunt.FirstOrDefault(e => e.ShuntId == ShuntId); } /// /// 根据状态选择下一步办理类型 /// /// /// public static ListItem[] GetDHandleTypeByState(string state) { if (state == Const.Shunt_Compile || state == Const.Shunt_ReCompile) { ListItem[] lis = new ListItem[1]; lis[0] = new ListItem("审核", Const.Shunt_Audit); return lis; } else if (state == Const.Shunt_Audit) { ListItem[] lis = new ListItem[2]; lis[0] = new ListItem("审批完成", Const.Shunt_Complete); lis[1] = new ListItem("重新编制", Const.Shunt_ReCompile); return lis; } else return null; } public static void Init(FineUIPro.DropDownList dropName, string state, bool isShowPlease) { dropName.DataValueField = "Value"; dropName.DataTextField = "Text"; dropName.DataSource = GetDHandleTypeByState(state); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } } }