public ActionResult CheckSubmit(VacationApply va) { try { //if (va.SubmitCheckVacation()) //{ // //X.Msg.Alert("消息", "操作成功!", new JFunction { Fn = "closewindow" }).Show();"parent.App.win.close();" // X.MessageBox.Alert("消息", "操作成功!", "history.go(-1);").Show(); // return this.Direct(); //} //else //{ // return View("Expire"); //} bool flag = va.SubmitCheckVacation(); bool newwindow = false; if (Session["NewWindow"] != null) { newwindow = Convert.ToBoolean(Session["NewWindow"]); } X.Msg.Alert("页面消息", flag ? "审核操作成功!" : "审核操作失败!", flag ? (newwindow ? "parent.App.win.close();" : "history.go(-1);"): null).Show(); if (flag) { X.AddScript("parent.App.storedata.reload();"); } return(this.Direct()); } catch (Exception e) { return(this.Direct(false, e.Message)); } }
public JsonResult MyPage(int pageIndex, int pageSize, int?typeID) { var sql = Sql.Builder.Where("user_id = @0", CurrUser.ID); if (typeID.HasValue) { sql.Where("vacation_type_id=@0", typeID.Value); } var page = VacationApply.Page(pageIndex, pageSize, sql); return(Json(new ResponseData { Total = page.TotalItems, Data = page.Items.Select(flow => new VacationApplyModel { ApplyTime = flow.ApplyTime.ToDateTimeString(), EndTime = flow.EndTime.ToDateTimeString(), ID = flow.ID, Opinion = flow.Opinion, Reason = flow.Reason, StartTime = flow.StartTime.ToDateTimeString(), Status = flow.Status.EnumToName(), VacationTypeName = flow.VacationTypeID.ToVacationType().Name, CanModify = CanModify(flow.Status) }) })); }
public JsonResult Modify(VacationApply apply) { ArtDialogResponseResult result = new ArtDialogResponseResult(); var old = VacationApply.Single(apply.ID); if (!CanModify(old.Status)) { result.Message = "此申请不允许修改,请刷新再操作!"; return(Json(result)); } old.Status = EnumVacationApplyStatus.Apply; old.StartTime = apply.StartTime; old.EndTime = apply.EndTime; old.Reason = apply.Reason; old.VacationTypeID = apply.VacationTypeID; var msg = GetNextFlow(old.UserID.ToUser(), null); if (msg.IsComplete) { old.FlowID = ((VacationAuditFlow)msg.Entity).ID; old.Update(); return(Json(ArtDialogResponseResult.SuccessResult)); } else { result.Message = msg.Message; return(Json(result)); } }
public ActionResult MyDelete(string id) { ArtDialogResponseResult result = new ArtDialogResponseResult(); var ids = id.ToIntList(); if (ids.HasElements()) { foreach (var item in VacationApply.Fetch("where id in (@0)", ids)) { if (CanModify(item.Status) && item.UserID == CurrUser.ID) { item.Delete(); } } result.IsSuccess = true; } else { result.IsSuccess = false; result.Message = "请选择至少一条记录操作!"; } return(Json(result)); }
public ActionResult VRSubmit(VacationApply vacation) { DirectResult r = new DirectResult(); string orid = vacation.ID; var prelists = from o in entities.T_HR_Vacation where o.VPDelete == true && o.LastID == orid select o; foreach (T_HR_Vacation item in prelists) { T_HR_Vacation prelist = entities.T_HR_Vacation.Find(item.ID); prelist.VPDelete = false; } T_HR_Vacation orlist = entities.T_HR_Vacation.Find(orid); orlist.VPDelete = true; orlist.EditOrDelete = "Delete"; vacation.ID = Guid.NewGuid().ToString(); vacation.OperationListID = Guid.NewGuid().ToString(); vacation.Valid = false; vacation.CreaterName = new LoginUser().EmployeeId; vacation.CreateTime = DateTime.Now; vacation.VPEdit = false; vacation.VPDelete = true; vacation.EditOrDelete = ""; vacation.LastID = orid; T_CH_Operation_list newList = new T_CH_Operation_list(); newList.ID = vacation.OperationListID; newList.State = (int)CheckState.Checking;//审核中 newList.Check_flowID = vacation.CheckFlowId; newList.Check_funcID = vacation.FuncId; newList.CreateTime = DateTime.Now; newList.Creator = new LoginUser().EmployeeId; newList.Url = Url.Action("CheckVacation", "Vacation", new { id = vacation.ID }); entities.T_HR_Vacation.Add(vacation.ToDB(1)); entities.T_CH_Operation_list.Add(newList); try { entities.SaveChanges(); r.Success = true; X.Msg.Alert("提示", "保存成功!", new JFunction { Fn = "closewindow" }).Show(); } catch (Exception e) { X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction { Fn = "closewindow" }).Show(); r.Success = false; } return(r); }
public ActionResult VacationDetail(string id) { VacationApply oritem = new VacationApply(); if (null != oritem.GetVacationDetail(id)) { if (oritem.VPEdit || oritem.VPDelete) { if (oritem.EditOrDelete == "Edit") { var prelist = from o in entities.T_HR_Vacation where o.LastID == oritem.ID && o.VPEdit == true select o; if (prelist.Any()) { //oritem.preitem = oritem.GetVacationDetail(prelist.First().ID); oritem.GetPreVacationDetail(prelist.First().ID); } //调整View } else if (oritem.EditOrDelete == "Delete") { var prelist = from o in entities.T_HR_Vacation where o.LastID == oritem.ID && o.VPDelete == true select o; if (prelist.Any()) { //oritem.preitem = oritem.GetVacationDetail(prelist.First().ID); oritem.GetPreVacationDetail(prelist.First().ID); } //调整View var x = X.GetCmp <Panel>("PrePanel"); x.Hidden = true; } else { //调整View var x = X.GetCmp <FieldSet>("PreList"); x.Hidden = true; } } else { //调整View var x = X.GetCmp <FieldSet>("PreList"); x.Hidden = true; } return(View(oritem)); } else { return(View()); } }
public JsonResult Audit(int id, bool isPass, string opinion) { ArtDialogResponseResult result = new ArtDialogResponseResult(); var apply = VacationApply.Single(id); if (!CanAudit(apply.Status)) { result.Message = "此申请不允许审核,请刷新再操作!"; return(Json(result)); } if (isPass) { var msg = GetNextFlow(apply.UserID.ToUser(), apply.FlowID); if (msg.IsComplete) { var nextFlow = msg.Entity as VacationAuditFlow; if (nextFlow == null) { apply.FlowID = null; apply.Status = EnumVacationApplyStatus.Pass; apply.Opinion = opinion; } else { apply.FlowID = nextFlow.ID; apply.Status = EnumVacationApplyStatus.Audited; apply.Opinion = opinion; } apply.Update(); return(Json(ArtDialogResponseResult.SuccessResult)); } else { result.Message = msg.Message; return(Json(result)); } } else { apply.Status = EnumVacationApplyStatus.Nopass; apply.Opinion = opinion; apply.Update(); return(Json(ArtDialogResponseResult.SuccessResult)); } }
public ActionResult Audit(int id) { var apply = VacationApply.Single(id); if (CanAudit(apply.Status)) { return(View(apply)); } else { return(Redirect("~/404")); } }
public ActionResult AddVacation(string id) //在修改时传递的为contractid { if (id == "-1") //-1为添加 { VacationApply va = new VacationApply(); va.CreaterName = new LoginUser().EmployeeName; va.CreateTime = DateTime.Now; return(View(va)); } else//否则为修改 { V_HR_VacationWithDepName va = entities.V_HR_VacationWithDepName.Find(id); if (va == null) { return(HttpNotFound()); } VacationApply vaa = new VacationApply(); vaa.ID = va.ID; vaa.StaffID = va.StaffID; vaa.Name = va.Name; vaa.Department = va.Department; vaa.VPType = va.VPType; vaa.StartTime = Convert.ToDateTime(va.StartTime); vaa.EndTime = Convert.ToDateTime(va.EndTime); vaa.StartTimeStr = vaa.StartTime.ToString("yyyy-MM-dd HH:mm"); vaa.EndTimeStr = vaa.EndTime.ToString("yyyy-MM-dd HH:mm"); vaa.TimeSpan = Convert.ToDecimal(va.TimeSpan); vaa.VPReason = va.VPReason; vaa.Valid = Convert.ToBoolean(va.Valid); vaa.Remark = va.Remark; vaa.CreaterName = va.CreaterName; vaa.CreateTime = Convert.ToDateTime(va.CreateTime); vaa.EditorName = va.EditorName; vaa.EditeTime = Convert.ToDateTime(va.EditeTime); vaa.OperationListID = va.OperationListID; if (vaa.OperationListID != null) { vaa.CheckFlowId = vaa.GetCheckFlowId; } vaa.LastID = va.LastID; vaa.VPEdit = Convert.ToBoolean(va.VPEdit); vaa.VPDelete = Convert.ToBoolean(va.VPDelete); vaa.EditOrDelete = va.EditOrDelete; return(View(vaa)); } }
public JsonResult Page(int pageIndex, int pageSize, int?typeID, int?deptID) { var sql = Sql.Builder; if (typeID.HasValue) { sql.Where("vacation_type_id=@0", typeID.Value); } // 如果没有查看总站的权限时 if (!SysHelper.HasPower("vacation_record_all")) { if (SysHelper.HasPower("vacation_record_site")) { if (!deptID.HasValue) { deptID = BasicDataCache.listDepts.Single(d => d.ID == CurrUser.DeptID).ParentID; } } else { if (!deptID.HasValue) { deptID = CurrUser.DeptID; } } } if (deptID.HasValue) { sql.Where("user_id in (select id from sys_users where dept_id in (@0))", BasicDataCache.GetSubDepts(deptID.Value).Select(d => d.ID)); } var page = VacationApply.Page(pageIndex, pageSize, sql); List <VacationApplyModel> result = CreateModel(page); return(Json(new ResponseData { Total = page.TotalItems, Data = result })); }
public ActionResult CheckVacation(string id) { VacationApply preitem = new VacationApply(); if (null != preitem.GetPreVacationDetail(id)) { if (preitem.PreVPEdit || preitem.PreVPDelete) { var orelist = (from o in entities.T_HR_Vacation where o.ID == preitem.PreLastID select o).First(); preitem.GetVacationDetail(orelist.ID); if (orelist.EditOrDelete == "Edit") { //调整View } else if (orelist.EditOrDelete == "Delete") { //调整View var x1 = X.GetCmp <FieldSet>("PreList"); x1.Title = "假期取消"; var x = X.GetCmp <Panel>("PrePanel"); x.Hidden = true; } } else { //调整View var x = X.GetCmp <FieldSet>("OreList"); x.Hidden = true; var x1 = X.GetCmp <FieldSet>("PreList"); x1.Title = "请假申请"; } return(View(preitem)); } else { return(View()); } }
public ActionResult VacationRemove(string id) { V_HR_VacationWithDepName va = entities.V_HR_VacationWithDepName.Find(id); if (va != null) { VacationApply vaa = new VacationApply(); vaa.ID = va.ID; vaa.StaffID = va.StaffID; vaa.Name = va.Name; vaa.Department = va.Department; vaa.VPType = va.VPType; vaa.StartTime = Convert.ToDateTime(va.StartTime); vaa.EndTime = Convert.ToDateTime(va.EndTime); vaa.StartTimeStr = vaa.StartTime.ToString("yyyy-MM-dd HH:mm"); vaa.EndTimeStr = vaa.EndTime.ToString("yyyy-MM-dd HH:mm"); vaa.TimeSpan = Convert.ToDecimal(va.TimeSpan); vaa.VPReason = va.VPReason; vaa.Valid = Convert.ToBoolean(va.Valid); vaa.Remark = va.Remark; vaa.CreaterName = va.CreaterName; vaa.CreateTime = Convert.ToDateTime(va.CreateTime); vaa.EditorName = va.EditorName; vaa.EditeTime = Convert.ToDateTime(va.EditeTime); vaa.OperationListID = va.OperationListID; //if (vaa.OperationListID != null) // vaa.CheckFlowId = vaa.GetCheckFlowId; vaa.LastID = va.LastID; vaa.VPEdit = Convert.ToBoolean(va.VPEdit); vaa.VPDelete = Convert.ToBoolean(va.VPDelete); vaa.EditOrDelete = va.EditOrDelete; return(View(vaa)); } else { return(HttpNotFound()); } }
public ActionResult Apply(VacationApply apply) { ArtDialogResponseResult result = new ArtDialogResponseResult(); apply.UserID = CurrUser.ID; apply.ApplyTime = DateTime.Now; apply.Status = EnumVacationApplyStatus.Apply; var msg = GetNextFlow(CurrUser, null); if (msg.IsComplete) { apply.FlowID = ((VacationAuditFlow)msg.Entity).ID; apply.Insert(); return(Json(ArtDialogResponseResult.SuccessResult)); } else { result.Message = msg.Message; return(Json(result)); } }
public ActionResult DeleteVacation(string id, string opid) { if (VacationApply.GetState(opid) == CheckState.Approved && GetPreState(id)) { Window win = new Window { ID = "windowVacation", Title = "销假", Height = 500, Width = 800, BodyPadding = 5, Modal = true, CloseAction = CloseAction.Destroy, Loader = new ComponentLoader { Url = Url.Action("VacationRemove", "Vacation", new { id = id }), DisableCaching = true, Mode = LoadMode.Frame }, Listeners = { Close = { Handler = "App.direct.person.VacationReload()", } } }; win.Render(RenderMode.Auto); } else { X.Msg.Alert("警告", "不可修改!").Show(); } return(this.Direct()); }
public ActionResult AddOrEditVacation(VacationApply vacation) { try { vacation.StartTime = Convert.ToDateTime(vacation.StartTimeStr);//计算TimeSpan vacation.EndTime = Convert.ToDateTime(vacation.EndTimeStr); } catch (FormatException fe) { X.Msg.Alert("警告", "日期不正确,请检查!").Show(); return(this.Direct()); } if (vacation.StartTime.Year == vacation.EndTime.Year && vacation.StartTime.Month == vacation.EndTime.Month && vacation.StartTime <= vacation.EndTime) { DirectResult r = new DirectResult(); T_HR_Vacation vacationupdate = entities.T_HR_Vacation.Find(vacation.ID); if (vacationupdate == null)//为空为添加 { vacation.ID = Guid.NewGuid().ToString(); vacation.OperationListID = Guid.NewGuid().ToString(); vacation.Valid = true; vacation.CreaterName = new LoginUser().EmployeeId; vacation.CreateTime = DateTime.Now; vacation.VPEdit = false; vacation.VPDelete = false; T_CH_Operation_list newList = new T_CH_Operation_list(); newList.ID = vacation.OperationListID; newList.State = (int)CheckState.Checking;//审核中 newList.Check_flowID = vacation.CheckFlowId; newList.Check_funcID = vacation.FuncId; newList.CreateTime = DateTime.Now; newList.Creator = new LoginUser().EmployeeId; newList.Url = Url.Action("CheckVacation", "Vacation", new { id = vacation.ID }); entities.T_HR_Vacation.Add(vacation.ToDB(1)); entities.T_CH_Operation_list.Add(newList); try { entities.SaveChanges(); r.Success = true; X.Msg.Alert("提示", "保存成功!", new JFunction { Fn = "closewindow" }).Show(); } catch (Exception e) { X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction { Fn = "closewindow" }).Show(); r.Success = false; } } else//否则为修改 { vacation.EditorName = new LoginUser().EmployeeId; vacation.EditeTime = DateTime.Now; vacationupdate.Valid = false; vacation.ID = Guid.NewGuid().ToString(); vacation.OperationListID = Guid.NewGuid().ToString(); vacation.Valid = true; vacation.VPEdit = false; vacation.VPDelete = false; T_CH_Operation_list newList = new T_CH_Operation_list(); newList.ID = vacation.OperationListID; newList.State = (int)CheckState.Checking;//审核中 newList.Check_flowID = vacation.CheckFlowId; newList.Check_funcID = vacation.FuncId; newList.CreateTime = DateTime.Now; newList.Creator = new LoginUser().EmployeeId; newList.Url = Url.Action("CheckVacation", "Vacation", new { id = vacation.ID }); entities.T_HR_Vacation.Add(vacation.ToDB(2)); entities.T_CH_Operation_list.Add(newList); try { entities.SaveChanges(); r.Success = true; X.Msg.Alert("提示", "修改成功!", new JFunction { Fn = "closewindow" }).Show(); } catch (Exception e) { X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction { Fn = "closewindow" }).Show(); r.Success = false; } } return(r); } else { X.Msg.Alert("警告", "请假不可跨月!").Show(); return(this.Direct()); } }
public JsonResult AuditPage(int pageIndex, int pageSize, int?typeID, int?deptID) { var sql = Sql.Builder.Where("status in (@0,@1)", EnumVacationApplyStatus.Apply, EnumVacationApplyStatus.Audited); if (typeID.HasValue) { sql.Where("vacation_type_id=@0", typeID.Value); } // 如果没有查看总站的权限时 if (!SysHelper.HasPower("vacation_apply_aduit_all")) { if (SysHelper.HasPower("vacation_apply_aduit_site")) { if (!deptID.HasValue) { deptID = BasicDataCache.listDepts.Single(d => d.ID == CurrUser.DeptID).ParentID; } } else { if (!deptID.HasValue) { deptID = CurrUser.DeptID; } } } if (deptID.HasValue) { sql.Where("user_id in (select id from sys_users where dept_id in (@0))", BasicDataCache.GetSubDepts(deptID.Value).Select(d => d.ID)); } // 找出需要审核的流程 var flows = BasicDataCache.listVacationAuditFlows.Where(flow => flow.AuditRoleIDs.ToIntList().Contains(CurrUser.RoleID)); if (flows.HasElements()) { // 判断范围 List <string> scopes = new List <string>(); foreach (var item in flows) { switch (item.DeptLevel) { case EnumDeptLevel.TheOrSub: { scopes.Add(string.Format("flow_id={0} and user_id in (select id from sys_users where dept_id in({1}))", item.ID, BasicDataCache.GetSubDepts(CurrUser.DeptID).Select(d => d.ID).Join())); } break; case EnumDeptLevel.TheSite: { scopes.Add(string.Format("flow_id={0} and user_id in (select id from sys_users where dept_id in({1}))", item.ID, BasicDataCache.GetSubDepts(BasicDataCache.GetSite(CurrUser.DeptID).ID).Select(d => d.ID).Join())); } break; case EnumDeptLevel.All: { scopes.Add(string.Format("flow_id={0}", item.ID)); } break; default: throw new NotImplementedException(); } } sql.Where(scopes.Join(" or ")); } else { return(Json(new ResponseData { Total = 0, Data = new List <VacationApplyModel>() })); } var page = VacationApply.Page(pageIndex, pageSize, sql); List <VacationApplyModel> result = CreateModel(page); return(Json(new ResponseData { Total = page.TotalItems, Data = result })); }