/// <summary> /// 获取请假类型设置信息 /// </summary> /// <param name="strLeaveTypeSetId">主键索引</param> /// <returns></returns> public T_HR_LEAVETYPESET GetLeaveTypeSetByID(string strLeaveTypeSetId) { try { if (string.IsNullOrEmpty(strLeaveTypeSetId)) { return(null); } LeaveTypeSetDAL dalLeaveTypeSet = new LeaveTypeSetDAL(); StringBuilder strfilter = new StringBuilder(); List <string> objArgs = new List <string>(); if (!string.IsNullOrEmpty(strLeaveTypeSetId)) { strfilter.Append(" LEAVETYPESETID == @0"); objArgs.Add(strLeaveTypeSetId); } T_HR_LEAVETYPESET entLTRd = dalLeaveTypeSet.GetLeaveTypeSetRdByMultSearch(strfilter.ToString(), objArgs.ToArray()); return(entLTRd); } catch (Exception) { return(null); } }
/// <summary> /// 修改请假类型设置信息 /// </summary> /// <param name="entTemp"></param> /// <returns></returns> public string ModifyLeaveTypeSet(T_HR_LEAVETYPESET entTemp) { string strMsg = string.Empty; try { if (entTemp == null) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); strFilter.Append(" LEAVETYPESETID == @0"); objArgs.Add(entTemp.LEAVETYPESETID); LeaveTypeSetDAL dalLeaveTypeSet = new LeaveTypeSetDAL(); flag = dalLeaveTypeSet.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } T_HR_LEAVETYPESET entUpdate = dalLeaveTypeSet.GetLeaveTypeSetRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); Utility.CloneEntity(entTemp, entUpdate); dalLeaveTypeSet.Update(entUpdate); strMsg = "{SAVESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message.ToString(); } return(strMsg); }
/// <summary> /// 根据主键索引,删除请假类型设置信息(注:暂定为物理删除) /// </summary> /// <param name="strVacationId">主键索引</param> /// <returns></returns> public string DeleteLeaveTypeSet(string strLeaveTypeSetId) { string strMsg = string.Empty; try { if (string.IsNullOrEmpty(strLeaveTypeSetId)) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); strFilter.Append(" LEAVETYPESETID == @0"); objArgs.Add(strLeaveTypeSetId); LeaveTypeSetDAL dalLeaveTypeSet = new LeaveTypeSetDAL(); flag = dalLeaveTypeSet.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } T_HR_LEAVETYPESET entDel = dalLeaveTypeSet.GetLeaveTypeSetRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); var entAL = from s in dal.GetObjects <T_HR_ATTENDFREELEAVE>().Include("T_HR_ATTENDANCESOLUTION").Include("T_HR_LEAVETYPESET") where s.T_HR_LEAVETYPESET.LEAVETYPESETID == strLeaveTypeSetId select s; if (entAL.Count() > 0) { return("{EXISTRELATIONRECORD}"); } var entLR = from r in dal.GetObjects <T_HR_EMPLOYEELEAVERECORD>().Include("T_HR_LEAVETYPESET") where r.T_HR_LEAVETYPESET.LEAVETYPESETID == strLeaveTypeSetId select r; if (entLR.Count() > 0) { return("{EXISTRELATIONRECORD}"); //dal.Delete(entLR); } entDel.T_HR_FREELEAVEDAYSET.Load(); dal.DeleteFromContext(entDel); dal.SaveContextChanges(); strMsg = "{DELETESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message.ToString(); } return(strMsg); }
/// <summary> /// 修改请假类型设置信息 /// </summary> /// <param name="entTemp"></param> /// <returns></returns> public string ModifyLeaveTypeSet(T_HR_LEAVETYPESET entTemp) { string strMsg = string.Empty; try { if (entTemp == null) { return("{REQUIREDFIELDS}"); } bool flag = false; StringBuilder strFilter = new StringBuilder(); List <string> objArgs = new List <string>(); strFilter.Append(" LEAVETYPESETID == @0"); objArgs.Add(entTemp.LEAVETYPESETID); LeaveTypeSetDAL dalLeaveTypeSet = new LeaveTypeSetDAL(); flag = dalLeaveTypeSet.IsExistsRd(strFilter.ToString(), objArgs.ToArray()); if (!flag) { return("{NOTFOUND}"); } T_HR_LEAVETYPESET entUpdate = dalLeaveTypeSet.GetLeaveTypeSetRdByMultSearch(strFilter.ToString(), objArgs.ToArray()); Utility.CloneEntity(entTemp, entUpdate); if (entTemp.LEAVETYPEVALUE != (Convert.ToInt32(Common.LeaveTypeValue.AdjustLeave) + 1).ToString() && entTemp.LEAVETYPEVALUE != (Convert.ToInt32(Common.LeaveTypeValue.AnnualLeave) + 1).ToString()) { try { DateTime dtNow = DateTime.Now; var entFrees = from ent in dal.GetObjects <T_HR_FREELEAVEDAYSET>() where ent.T_HR_LEAVETYPESET.LEAVETYPESETID == entTemp.LEAVETYPESETID select ent; //不存在设置的情况则修改最大请假天数 if (entFrees.Count() == 0) { //格式化为当前年份 //dtNow = DateTime.Parse(dtNow.Year.ToString() + "-01-01"); var ents = from ent in dal.GetObjects <T_HR_EMPLOYEELEVELDAYCOUNT>() where ent.LEAVETYPESETID == entTemp.LEAVETYPESETID && ent.EFFICDATE.Value.Year == dtNow.Year select ent; if (ents.Count() > 0) { foreach (var ent in ents) { ent.REMARK += "原来为:" + ent.DAYS.ToString() + ";修改后重新设置天数:" + entTemp.MAXDAYS.ToString(); ent.DAYS = entTemp.MAXDAYS; dal.UpdateFromContext(ent); } int intResult = dal.SaveContextChanges(); if (intResult > 0) { SMT.Foundation.Log.Tracer.Debug("公共假期类型:" + entTemp.LEAVETYPENAME + "修改带薪假天数成功"); } else { SMT.Foundation.Log.Tracer.Debug("公共假期类型:" + entTemp.LEAVETYPENAME + "修改带薪假天数失败"); } } } } catch (Exception ex) { SMT.Foundation.Log.Tracer.Debug("公共假期类型:" + entTemp.LEAVETYPENAME + "修改带薪假天数出现错误:" + ex.ToString()); } } dalLeaveTypeSet.Update(entUpdate); strMsg = "{SAVESUCCESSED}"; } catch (Exception ex) { strMsg = ex.Message.ToString(); } return(strMsg); }