/// <summary> /// 周文斌添加 /// 获取一个时间段内的考勤方案, /// 例如:员工请假从5月10-8月30日 /// 这里跨越了5,6,7,8三个月的考勤时间段 /// StartToEndDate的格式为:StartDate|EndDate; yyyy-MM-dd|yyyy-MM-dd /// /// </summary> /// <param name="EmployeeID"></param> /// <param name="StartToEndDate"></param> /// <returns></returns> public List <T_HR_ATTENDANCESOLUTION> GetAttendenceSolutionByEmployeeIDAndStartDateAndEndDate(string EmployeeID, List <string> StartToEndDate) { List <T_HR_ATTENDANCESOLUTION> solutionList = new List <T_HR_ATTENDANCESOLUTION>(); foreach (string str in StartToEndDate) { DateTime StartDate = Convert.ToDateTime(str.Split('|')[0]); DateTime EndDate = Convert.ToDateTime(str.Split('|')[1]); AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); T_HR_ATTENDANCESOLUTION entAttSol = dalAttendanceSolution.GetAttendanceSolutionByEmployeeIDAndDate(EmployeeID, StartDate, EndDate); if (entAttSol != null) { solutionList.Add(entAttSol); } else { StartDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); AttendanceSolutionAsignBLL bllAttSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttSolAsign = bllAttSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(EmployeeID, StartDate); solutionList.Add(entAttSolAsign.T_HR_ATTENDANCESOLUTION); } } return(solutionList); }
/// <summary> /// 根据考勤初始化记录获取考勤方案,获取不到则获取员工最新分配的考勤方案 /// </summary> /// <param name="strEmployeeID">员工ID</param> /// <param name="dtStart">考勤记录参考起始日期</param> /// <param name="dtEnd">考勤记录参考截止日期</param> /// <returns></returns> public T_HR_ATTENDANCESOLUTION GetAttendanceSolutionByEmployeeIDAndDate(string strEmployeeID, DateTime dtStart, DateTime dtEnd) { if (string.IsNullOrEmpty(strEmployeeID)) { return(null); } AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); T_HR_ATTENDANCESOLUTION entAttSol = dalAttendanceSolution.GetAttendanceSolutionByEmployeeIDAndDate(strEmployeeID, dtStart, dtEnd); if (entAttSol == null) { dtStart = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); AttendanceSolutionAsignBLL bllAttSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttSolAsign = bllAttSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(strEmployeeID, dtStart); if (entAttSolAsign == null) { return(null); } return(entAttSolAsign.T_HR_ATTENDANCESOLUTION); } return(entAttSol); }
/// <summary> /// 根据主键索引,删除加班报酬信息(注:暂定为物理删除) /// </summary> /// <param name="strVacationId">主键索引</param> /// <returns></returns> public string DeleteOvertimeReward(string strOvertimeRewardId) { string strMsg = string.Empty; try { if (string.IsNullOrEmpty(strOvertimeRewardId)) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); strFilter.Append(" OVERTIMEREWARDID == @0"); objArgs.Add(strOvertimeRewardId); OvertimeRewardDAL dalOvertimeReward = new OvertimeRewardDAL(); flag = dalOvertimeReward.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } T_HR_OVERTIMEREWARD entDel = dalOvertimeReward.GetOvertimeRewardRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); if (entDel != null) { //查找考勤方案定义是否有使用 AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); StringBuilder strFilterOver = new StringBuilder(); List <string> objArgss = new List <string>(); strFilterOver.Append(" T_HR_OVERTIMEREWARD.OVERTIMEREWARDID == @0"); objArgss.Add(entDel.OVERTIMEREWARDID); bool flagfalse = false; flagfalse = dalAttendanceSolution.IsExistsRd(strFilterOver.ToString(), objArgss.ToArray()); //如果flagfalse为true,那么说明此加班设置有用到,不容许删除 if (flagfalse) { strMsg = "falseOver"; } else { dalOvertimeReward.Delete(entDel); strMsg = "{DELETESUCCESSED}"; } } } catch (Exception ex) { strMsg = ex.Message.ToString(); } return(strMsg); }
/// <summary> /// 新增考勤方案信息 /// </summary> /// <param name="entTemp"></param> /// <returns></returns> public string AddAttSol(T_HR_ATTENDANCESOLUTION entTemp) { string strMsg = string.Empty; try { if (entTemp == null) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <object> objArgs = new List <object>(); strFilter.Append(" ATTENDANCESOLUTIONNAME == @0"); objArgs.Add(entTemp.ATTENDANCESOLUTIONNAME); AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); flag = dalAttendanceSolution.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (flag) { return("{ALREADYEXISTSRECORD}"); } T_HR_ATTENDANCESOLUTION ent = new T_HR_ATTENDANCESOLUTION(); Utility.CloneEntity <T_HR_ATTENDANCESOLUTION>(entTemp, ent); ent.T_HR_OVERTIMEREWARDReference.EntityKey = new System.Data.EntityKey("TM_SaaS_OA_EFModelContext.T_HR_OVERTIMEREWARD", "OVERTIMEREWARDID", entTemp.T_HR_OVERTIMEREWARD.OVERTIMEREWARDID); ent.T_HR_SCHEDULINGTEMPLATEMASTERReference.EntityKey = new System.Data.EntityKey("TM_SaaS_OA_EFModelContext.T_HR_SCHEDULINGTEMPLATEMASTER", "TEMPLATEMASTERID", entTemp.T_HR_SCHEDULINGTEMPLATEMASTER.TEMPLATEMASTERID); Utility.RefreshEntity(ent); dalAttendanceSolution.Add(ent); SaveMyRecord(ent); strMsg = "{SAVESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message.ToString(); if (ex.InnerException == null) { Utility.SaveLog(strMsg); } else { Utility.SaveLog(ex.InnerException.Message); } } return(strMsg); }
/// <summary> /// 获取考勤方案信息 /// </summary> /// <param name="strAttendanceSolutionId">主键索引</param> /// <returns>返回考勤方案信息</returns> public T_HR_ATTENDANCESOLUTION GetAttendanceSolutionByID(string strAttendanceSolutionId) { if (string.IsNullOrEmpty(strAttendanceSolutionId)) { return(null); } AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); StringBuilder strfilter = new StringBuilder(); List <object> objArgs = new List <object>(); if (!string.IsNullOrEmpty(strAttendanceSolutionId)) { strfilter.Append(" ATTENDANCESOLUTIONID == @0"); objArgs.Add(strAttendanceSolutionId); } T_HR_ATTENDANCESOLUTION entRd = dalAttendanceSolution.GetAttendanceSolutionRdByMultSearch(strfilter.ToString(), objArgs.ToArray()); return(entRd); }
/// <summary> /// 根据加班设置id查找考勤方案定义表是否有用到 /// </summary> /// <param name="OVERTimeId">加班设置id</param> /// <returns>返回考勤方案信息</returns> public T_HR_ATTENDANCESOLUTION GetAttendanceSolutionByOVERTime(string OVERTimeId) { if (string.IsNullOrEmpty(OVERTimeId)) { return(null); } AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); StringBuilder strfilter = new StringBuilder(); List <object> objArgs = new List <object>(); if (!string.IsNullOrEmpty(OVERTimeId)) { strfilter.Append(" OVERTIMEREWARDID == @0"); objArgs.Add(OVERTimeId); } T_HR_ATTENDANCESOLUTION entRd = dalAttendanceSolution.GetAttendanceSolutionRdByOVERId(strfilter.ToString(), objArgs.ToArray()); return(entRd); }
public EntityObject[] GetLookupData(int pageIndex, int pageSize, string sort, string filterString, IList <object> paras, ref int pageCount, string userID) { AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); List <object> queryParas = new List <object>(); if (paras.Count() > 0) { for (int i = 0; i < paras.Count(); i++) { queryParas.Add(paras[i]); } } SetOrganizationFilter(ref filterString, ref queryParas, userID, "T_HR_ATTENDANCESOLUTION"); string strOrderBy = string.Empty; strOrderBy = " ATTENDANCESOLUTIONID "; IQueryable <T_HR_ATTENDANCESOLUTION> ents = dalAttendanceSolution.GetAttendanceSolutionRdListByMultSearch(strOrderBy, filterString, queryParas.ToArray()); return(ents.Count() > 0 ? ents.ToArray() : null); }
/// <summary> /// 根据主键索引,删除考勤方案信息(注:暂定为物理删除) /// </summary> /// <param name="strVacationId">主键索引</param> /// <returns></returns> public string DeleteAttSol(string strAttendanceSolutionId) { //SalarySolutionItemBLL bll = new SalarySolutionItemBLL(); //foreach (string id in IDs) //{ // var ents = from e in dal.GetObjects<T_HR_SALARYSOLUTION>() // where e.SALARYSOLUTIONID == id // select e; // var ent = ents.Count() > 0 ? ents.FirstOrDefault() : null; // if (ent != null) // { // bll.SalarySolutionItemsDeleteBySID(ent.SALARYSOLUTIONID); // var taxItems = from c in dal.GetObjects<T_HR_SALARYTAXES>() // where c.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == ent.SALARYSOLUTIONID // select c; // if (taxItems.Count() > 0) // { // foreach (var taxitem in taxItems) // { // dal.DeleteFromContext(taxitem); // } // dal.SaveContextChanges(); // } // //dal.DeleteFromContext(ent); // Delete(ent); // //BLLCommonServices.Utility.SubmitMyRecord<T_HR_SALARYSOLUTION>(ent); // } // //TODO:删除项目所包含的明细 //} //return dal.SaveContextChanges(); string strMsg = string.Empty; try { if (string.IsNullOrEmpty(strAttendanceSolutionId)) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <object> objArgs = new List <object>(); strFilter.Append(" ATTENDANCESOLUTIONID == @0"); objArgs.Add(strAttendanceSolutionId); AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); flag = dalAttendanceSolution.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } T_HR_ATTENDANCESOLUTION entDel = dalAttendanceSolution.GetAttendanceSolutionRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); if (entDel.CHECKSTATE != Convert.ToInt32(Common.CheckStates.UnSubmit).ToString()) { return("{DELETEAUDITERROR}"); } #region 除考勤方案对应信息 var ents = from ent in dal.GetObjects <T_HR_ATTENDANCESOLUTIONDEDUCT>().Include("T_HR_ATTENDANCESOLUTION") where ent.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID == entDel.ATTENDANCESOLUTIONID select ent; if (ents.Count() > 0) { foreach (var taxitem in ents) { dal.DeleteFromContext(taxitem); } dal.SaveContextChanges(); } //删除假期设置 var entsLeaves = from ent in dal.GetObjects <T_HR_ATTENDFREELEAVE>().Include("T_HR_ATTENDANCESOLUTION") where ent.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID == entDel.ATTENDANCESOLUTIONID select ent; if (entsLeaves.Count() > 0) { foreach (var taxitem in entsLeaves) { dal.DeleteFromContext(taxitem); } dal.SaveContextChanges(); } #endregion //dalAttendanceSolution.Delete(entDel); Delete(entDel); dal.SaveContextChanges(); strMsg = "{DELETESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message.ToString(); if (ex.InnerException == null) { Utility.SaveLog(strMsg); } else { Utility.SaveLog(ex.InnerException.Message); } } return(strMsg); }
/// <summary> /// 审核当前考勤方案 /// </summary> /// <returns></returns> public string AuditAttSol(string strAttendanceSolutionId, string strCheckState) { string strMsg = string.Empty; try { if (string.IsNullOrEmpty(strAttendanceSolutionId)) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <object> objArgs = new List <object>(); strFilter.Append(" ATTENDANCESOLUTIONID == @0"); objArgs.Add(strAttendanceSolutionId); AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); flag = dalAttendanceSolution.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } //审核状态变为审核中或者审核通过时,生成对应的员工考勤记录(应用的员工范围,视应用对象而定) string strEditState = string.Empty; if (strCheckState == Convert.ToInt32(CheckStates.Approved).ToString()) { strEditState = Convert.ToInt32(EditStates.Actived).ToString(); } else if (strCheckState == Convert.ToInt32(CheckStates.Approving).ToString()) { strEditState = Convert.ToInt32(EditStates.Actived).ToString(); } else if (strCheckState == Convert.ToInt32(CheckStates.UnApproved).ToString()) { strEditState = Convert.ToInt32(EditStates.Canceled).ToString(); } T_HR_ATTENDANCESOLUTION entAudit = dalAttendanceSolution.GetAttendanceSolutionRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); //已审核通过的记录禁止再次提交审核 if (entAudit.CHECKSTATE == Convert.ToInt32(CheckStates.Approved).ToString()) { return("{REPEATAUDITERROR}"); } entAudit.EDITSTATE = strEditState; entAudit.CHECKSTATE = strCheckState; dal.Update(entAudit); SaveMyRecord(entAudit); strMsg = "{SAVESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message; if (ex.InnerException != null) { Utility.SaveLog(ex.InnerException.Message); } else { Utility.SaveLog(strMsg); } } return(strMsg); }
/// <summary> /// 根据条件,获取考勤方案信息 /// </summary> /// <param name="strOwnerID">权限控制所有人的员工序号</param> /// <param name="strCheckState">审核状态</param> /// <param name="strAttendanceSolutionName">考勤方案名称</param> /// <param name="strAttendanceType">考勤方式</param> /// <param name="strSortKey">排序字段</param> /// <returns>返回考勤方案信息</returns> public IQueryable <T_HR_ATTENDANCESOLUTION> GetAllAttendanceSolutionRdListByMultSearch(string strOwnerID, string strCheckState, string strAttendanceSolutionName, string strAttendanceType, string strSortKey) { AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); StringBuilder strfilter = new StringBuilder(); List <object> objArgs = new List <object>(); string strOrderBy = string.Empty; int iIndex = 0; if (!string.IsNullOrEmpty(strAttendanceSolutionName)) { strfilter.Append(" @0.Contains(ATTENDANCESOLUTIONNAME)"); objArgs.Add(strAttendanceSolutionName); } if (!string.IsNullOrEmpty(strAttendanceType)) { if (!string.IsNullOrEmpty(strfilter.ToString())) { strfilter.Append(" AND"); } if (objArgs.Count() > 0) { iIndex = objArgs.Count(); } strfilter.Append(" ATTENDANCETYPE == @" + iIndex.ToString()); objArgs.Add(strAttendanceType); } if (!string.IsNullOrEmpty(strSortKey)) { strOrderBy = strSortKey; } else { strOrderBy = " ATTENDANCESOLUTIONID "; } string filterString = strfilter.ToString(); if (strCheckState != Convert.ToInt32(CheckStates.WaittingApproval).ToString()) { if (strCheckState == Convert.ToInt32(CheckStates.All).ToString()) { strCheckState = string.Empty; } SetOrganizationFilter(ref filterString, ref objArgs, strOwnerID, "T_HR_ATTENDANCESOLUTION"); } else { string strCheckfilter = string.Copy(filterString); SetFilterWithflow("ATTENDANCESOLUTIONID", "T_HR_ATTENDANCESOLUTION", strOwnerID, ref strCheckState, ref filterString, ref objArgs); if (string.Compare(strCheckfilter, filterString) == 0) { return(null); } } if (!string.IsNullOrEmpty(strCheckState)) { if (!string.IsNullOrEmpty(filterString)) { filterString += " AND"; } if (objArgs.Count() > 0) { iIndex = objArgs.Count(); } filterString += " CHECKSTATE == @" + iIndex.ToString(); objArgs.Add(strCheckState); } var q = dalAttendanceSolution.GetAttendanceSolutionRdListByMultSearch(strOrderBy, filterString, objArgs.ToArray()); return(q); }