public JsonResult GetStudentCourse(int?id) { //获取具体上课时间的考生列表。 BaseJsonData json = new BaseJsonData(); return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult AddRollCall(IList <RollCallModel> modelList) { //补录点名信息 BaseJsonData json = new BaseJsonData(); return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteConfirmed(int id) { BaseJsonData json = new BaseJsonData(); Course_Info courseModel = db.Course_Infos.Find(id); //权限校验 //有在上课的课程不能删 if (db.Course_vs_Times.Where(x => x.cvt_course_id == id && (x.cvt_state == 2 || x.cvt_state == 3)).Count() > 0) { json.msg_text = "课程已经进行中,无当删除。"; return(Json(json)); } db.Course_Infos.Remove(courseModel); int res = db.SaveChanges(); if (res > 0) { var cvt = db.Course_vs_Times.Where(x => x.cvt_course_id == id); if (cvt.Count() > 0) { db.Course_vs_Times.RemoveRange(cvt); db.SaveChanges(); } json.state = 1; } else { json.msg_text = "删除失败。"; } RemoveCache(courseModel.c_sub_id); return(Json(json)); }
public JsonResult GetCourseTime(int?id) { //获取课程下的上具体上课时间 BaseJsonData json = new BaseJsonData(); return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult CheckStudent(string student) { student = PageValidate.InputText(student, 20); List <Cache_Student> list; object obj = DataCache.GetCache(cache_student); if (obj == null) { list = (from stu in db.Student_Infos select new Cache_Student { id = stu.stu_id, name = stu.stu_name }).ToList(); DataCache.SetCache(cache_student, list); } else { list = (List <Cache_Student>)obj; } var s = from stu in list where stu.id == student || stu.name == student select stu.id; BaseJsonData json = new BaseJsonData(); if (s.Count() > 0) { json.state = 1; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult ContrlModule(EditModules models) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (ModelState.IsValid) { string ctrl_name; foreach (ModuleInfo info in models.modules) { ctrl_name = info.name; var no1 = db.Role_vs_Controller.Where(x => x.rvc_role_id != 1 && x.rvc_controller == ctrl_name); if (no1.Count() > 0) { db.Role_vs_Controller.RemoveRange(no1); db.SaveChanges(); } if (info.roles != null && info.roles.Length > 0) { foreach (RoleInfo rinfo in info.roles) { Role_vs_Controller rvc = new Role_vs_Controller(); rvc.rvc_role_id = rinfo.id; rvc.rvc_controller = ctrl_name; if (db.Role_vs_Controller.Find(rvc.rvc_role_id, rvc.rvc_controller) == null) { db.Role_vs_Controller.Add(rvc); } } } } db.SaveChanges(); SysLog.WriteLog(user, "修改系统模块", IpHelper.GetIP(), "", 5, "", db); json.state = 1; json.msg_code = "success"; json.msg_text = "数据更新成功。"; DBCaches2.ClearCache("dic-module"); } else { json.msg_code = "error"; json.msg_text = "数据接收错误。"; } next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult SetRoleAuth(List <ViewRoleAuthority> auths) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (auths == null || auths.Count() == 0) { json.msg_text = "没有接收任何数据。"; json.msg_code = "NoReceive"; goto next; } bool firstIn = true; foreach (ViewRoleAuthority item in auths) { if (firstIn) { db.Role_vs_Authority.RemoveRange(db.Role_vs_Authority.Where(x => x.rva_role_id == item.roleId)); firstIn = false; } Role_vs_Authority rva = new Role_vs_Authority() { rva_auth_id = item.authId, rva_role_id = item.roleId }; db.Role_vs_Authority.Add(rva); } try { db.SaveChanges(); json.state = 1; json.msg_text = "角色的权限修改成功。"; json.msg_code = "success"; } catch (Exception ex) { json.msg_text = "角色权限修改出错。"; json.msg_code = "error"; Common.ErrorUnit.WriteErrorLog(ex.ToString(), this.GetType().ToString()); } SysLog.WriteLog(user, "重置角色的权限", IpHelper.GetIP(), "", 5, "", db); //重设置角色权限后,必需清除缓存 DataCache.RemoveCacheBySearch("user_vs_roles"); next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteContent(int id) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } Reimbursement_Content content = db.Reimbursement_Content.Find(id); if (content == null) { json.msg_code = "nodate"; json.msg_text = "报销内容不存在或被删除。"; goto next; } Reimbursement bill = db.Reimbursement.Find(content.c_reimbursement_code); if (bill != null) { int user = Common.PageValidate.FilterParam(User.Identity.Name); if (user != bill.r_add_user_id) { json.msg_code = "forbidden"; json.msg_text = "没有权限操作他人申请的报销单。"; goto next; } if (bill.r_bill_state == 1) { json.msg_code = "forbidden"; json.msg_text = "已批复同意的报销单不允许删除。"; goto next; } } var details = db.Reimbursement_Detail.Where(x => x.detail_content_id == content.content_id); foreach (var detail in details) { db.Reimbursement_Detail.Remove(detail); } db.Reimbursement_Content.Remove(content); try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().Name); json.msg_code = "error"; json.msg_text = "报销单删除失败。"; goto next; } json.state = 1; json.msg_code = "success"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateRole(Dic_Role model) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (model.role_id == 0) { json.msg_text = "获取角色的ID出错。"; json.msg_code = "IDError"; goto next; } if (model.role_id == 1) { json.msg_text = "该角色不允许修改。"; json.msg_code = "CanNotUpdate"; goto next; } var same = db.Dic_Role.Where(x => x.role_name == model.role_name && x.role_id != model.role_id); if (same.Count() > 0) { json.msg_text = "该名称已存在。"; json.msg_code = "NameExists"; goto next; } db.Entry(model).State = EntityState.Modified; try { db.SaveChanges(); DBCaches <Dic_Role> .ClearCache("cache_role"); } catch { json.msg_text = "更新,请重新操作。"; json.msg_code = "UpdateErr"; goto next; } json.state = 1; json.msg_code = "success"; json.msg_text = "更新成功!"; SysLog.WriteLog(user, string.Format("更新角色[{0}]名称", model.role_name), IpHelper.GetIP(), "", 5, "", db); next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult GetDeptChild(string id) { BaseJsonData json = new BaseJsonData(); List <SelectOption> options = DropDownList.getDepartment(PageValidate.FilterParam(id)); json.data = options; json.state = 1; return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteAttachment(int id) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } Reimbursement_Attachment atta = db.Reimbursement_Attachment.Find(id); if (atta == null) { json.msg_code = "nodate"; json.msg_text = "附件不存在或被删除。"; goto next; } Reimbursement bill = db.Reimbursement.Find(atta.atta_reimbursement_code); if (bill != null) { int user = Common.PageValidate.FilterParam(User.Identity.Name); if (user != bill.r_add_user_id && !RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_code = "forbidden"; json.msg_text = "没有权限操作他人申请的报销单。"; goto next; } if (bill.r_bill_state == 1) { json.msg_code = "forbidden"; json.msg_text = "已批复同意的报销单不允许删除任何信息。"; goto next; } } db.Reimbursement_Attachment.Remove(atta); try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().Name); json.msg_code = "error"; json.msg_text = "附件删除失败。"; goto next; } json.state = 1; json.msg_code = "success"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteRole(string rid) { int id = PageValidate.FilterParam(rid); BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (id == 1) { json.msg_text = "该角色不允许删除。"; json.msg_code = "CanNotDel"; goto next; } Dic_Role model = db.Dic_Role.Find(id); if (model == null) { json.msg_text = "没有找到该角色,该角色可能已被删除。"; json.msg_code = "noThis"; goto next; } db.Dic_Role.Remove(model); try { db.SaveChanges(); DBCaches <Dic_Role> .ClearCache("cache_role"); } catch { json.msg_text = "删除失败,请重新操作。"; json.msg_code = "recyErr"; goto next; } json.state = 1; json.msg_code = "success"; json.msg_text = "删除成功!"; SysLog.WriteLog(user, string.Format("删除角色[{0}]", model.role_name), IpHelper.GetIP(), "", 5, "", db); next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteDept(string pid) { int id = PageValidate.FilterParam(pid); BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } Dic_Department model = db.Dic_Department.Find(id); if (model == null) { json.msg_text = "没有找到该部门/科室,该部门/科室可能已被删除。"; json.msg_code = "noThis"; goto next; } db.Dic_Department.Remove(model); try { db.SaveChanges(); DBCaches2.ClearCache("cache_depts"); } catch { json.msg_text = "删除失败,请重新操作。"; json.msg_code = "recyErr"; goto next; } SysLog.WriteLog(user, string.Format("删除部门[{0}]", model.dept_name), IpHelper.GetIP(), "", 5, "", db); json.state = 1; json.msg_code = "success"; json.msg_text = "删除成功!"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult GetRoleAuth(int roleId) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (roleId == 0) { json.msg_text = "获取角色出错。"; json.msg_code = "IDError"; goto next; } var rvas = from rva in db.Role_vs_Authority where rva.rva_role_id == roleId select new ViewRoleAuthority { authId = rva.rva_auth_id, roleId = rva.rva_role_id }; if (rvas.Count() == 0) { json.state = 0; json.msg_code = "noData"; json.msg_text = "没有数据。"; } else { json.state = 1; json.data = rvas.ToList(); } next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult GetRespondResult(string id) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } int user = Common.PageValidate.FilterParam(User.Identity.Name); Bills dal = new Bills(db); var bill = dal.GetReimbursement(id, 0).FirstOrDefault(); if (bill == null) { json.msg_text = "没有找到该报销单。"; json.msg_code = "noData"; goto next; } if (bill.state != 1) { json.msg_text = "不能打印未批复报销单。"; json.msg_code = "noData"; goto next; } if (user != bill.userId) { json.msg_text = "不能操作他人报销单。"; json.msg_code = "noData"; goto next; } bill.userName = AESEncrypt.Decrypt(bill.userName); bill.contents = dal.getContents(bill.reimbursementCode, 0).ToList(); bill.attachmentsCount = dal.getAttachments(bill.reimbursementCode, 0).Count(); bill.detailsCount = (from content in db.Reimbursement_Content join detail in db.Reimbursement_Detail on content.content_id equals detail.detail_content_id where content.c_reimbursement_code == bill.reimbursementCode select content.content_id).Count(); json.state = 1; json.msg_code = "success"; json.data = bill; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult GetCourseCost(string course) { int id = PageValidate.FilterParam(course); BaseJsonData json = new BaseJsonData(); var list = getCourseLite(); var c = list.Where(x => x.id == id).FirstOrDefault(); if (c == null) { json.data = "该未查到该课程价格或该课程已被删除。"; } else { json.data = c.cost; } json.state = 1; return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteAllCache() { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; return(Json(json, JsonRequestBehavior.AllowGet)); } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; return(Json(json, JsonRequestBehavior.AllowGet)); } DataCache.RemoveAllCache(); return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllDetail(string id) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } if (id == null) { json.msg_code = "errorNumber"; json.msg_text = "报销单号获取失败。"; goto next; } //ViewDetailContent var query = (from content in db.Reimbursement_Content join detail in db.Reimbursement_Detail on content.content_id equals detail.detail_content_id join dic in db.Dic_Reimbursement_Content on content.c_dic_id equals dic.content_id where content.c_reimbursement_code == id orderby detail.detail_content_id select new ViewDetailContent { contentTitle = dic.content_title, detailInfo = detail.detail_info, amount = detail.detail_amount, detailDate = detail.detail_date } ).ToList(); json.data = query; json.state = 1; json.msg_code = "success"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteCourseTime() { BaseJsonData json = new BaseJsonData(); int _id = PageValidate.FilterParam(Request.Form["id"]); int _group = PageValidate.FilterParam(Request.Form["group"]); var cvt = db.Course_vs_Times.Where(x => x.cvt_course_id == _id && x.cvt_group == _group); if (cvt.Count() == 0) { json.state = 0; json.msg_text = "删除失败,所选时间不存在或已被删除。"; return(Json(json, JsonRequestBehavior.AllowGet)); } var groups = db.Course_vs_Times.Where(x => x.cvt_course_id == _id).GroupBy(x => new { x.cvt_course_id, x.cvt_group }).Count(); if (groups == 1) { json.state = 0; json.msg_text = "删除失败,当前课程仅有一个时间段,无法删除。"; return(Json(json, JsonRequestBehavior.AllowGet)); } db.Course_vs_Times.RemoveRange(cvt); int res = db.SaveChanges(); if (res > 0) { json.state = 1; } else { json.state = 0; json.msg_text = "删除失败,请刷新当前页面后重新操作。"; return(Json(json, JsonRequestBehavior.AllowGet)); } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult LogReceive(string id, decimal amount) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } int user = Common.PageValidate.FilterParam(User.Identity.Name); var bill = db.Reimbursement.Find(id); if (bill == null) { json.msg_text = "没有找到该报销单。"; json.msg_code = "noData"; goto next; } if (bill.r_bill_state != 1) { json.msg_text = "不能操作未批复报销单。"; json.msg_code = "noData"; goto next; } bool isManager = RoleCheck.CheckHasAuthority(user, db, "系统管理"); if (!isManager && bill.c_has_log) { json.msg_text = "已操作录入实际信用金额。"; json.msg_code = "noData"; goto next; } if (user != bill.r_add_user_id && !isManager) { json.msg_text = "不能操作他人报销单。"; json.msg_code = "noData"; goto next; } bill.r_fact_amount = amount; bill.c_has_log = true; db.Entry(bill).State = EntityState.Modified; Funds funds = db.Funds.Find(bill.r_funds_id); if (funds != null) { decimal m = bill.r_bill_amount - bill.r_fact_amount; funds.f_balance = funds.f_balance + m; db.Entry(funds).State = EntityState.Modified; } try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("录入报销单[{0}]实领金额{1}元", bill.reimbursement_code, amount), IpHelper.GetIP(), bill.reimbursement_code, 4, "", db); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().Name); json.msg_code = "error"; json.msg_text = "录入失败。"; goto next; } json.state = 1; json.msg_code = "success"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult AddFromExcel(string file) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; return(Json(json, JsonRequestBehavior.AllowGet)); } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "添加经费", "经费管理")) { json.msg_text = "没有权限。"; json.msg_code = "noPower"; return(Json(json, JsonRequestBehavior.AllowGet)); } string attachmentTempPath = MyConfiguration.GetAttachmentTempPath();//上传附件的暂存地址 string filePath = attachmentTempPath + file; if (!io.File.Exists(filePath)) { json.msg_text = "没有找到上传的文件。"; json.msg_code = "noFile"; return(Json(json, JsonRequestBehavior.AllowGet)); } OpenXMLHelper excel = new OpenXMLHelper(); DataTable dtExcel = null; try { dtExcel = excel.ExcelToDataTable("Sheet1", filePath); }catch (Exception ee) { json.msg_text = string.Format("excel[{0}]读取出错。", file); json.msg_code = "noThis"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (dtExcel == null || dtExcel.Rows.Count == 0) { json.msg_text = "表格里没有行。"; json.msg_code = "noThis"; return(Json(json, JsonRequestBehavior.AllowGet)); } string code, name, manager; decimal amount, balance; int i = 1, mid; StringBuilder sbMsg = new StringBuilder(); List <SelectOption> managers = DropDownList.UserSelect(1); foreach (DataRow dr in dtExcel.Rows) { code = dr["项目编号"].ToString().Trim(); if (string.IsNullOrEmpty(code)) { sbMsg.Append("行").Append(i).Append("没有项目编号。\r\n"); continue; } if (db.Funds.Where(x => x.f_code == code).Count() > 0) { sbMsg.Append("行").Append(i).Append("经费").Append(code).Append("经费已存在,勿重复录入。\r\n"); continue; } name = dr["项目名称"].ToString().Trim(); manager = dr["负责人"].ToString().Trim(); if (string.IsNullOrEmpty(manager)) { sbMsg.Append("行").Append(i).Append("经费").Append(code).Append("没有项目负责人。\r\n"); continue; } try { mid = int.Parse( (from m in managers where m.text == manager select m.id).FirstOrDefault()); } catch { sbMsg.Append("行").Append(i).Append("经费").Append(code).Append("项目负责人未录入。\r\n"); continue; } try { balance = decimal.Parse(dr["本年余额"].ToString().Trim().Replace(",", "")); } catch { sbMsg.Append("行").Append(i).Append("经费").Append(code).Append("经费余额读取失败。\r\n"); continue; } try { amount = decimal.Parse(dr["年初数"].ToString().Trim().Replace(",", "")); } catch { amount = balance; } Funds funds = new Funds { f_add_Time = DateTime.Now, f_amount = amount, f_balance = balance, f_code = code, f_info = name, f_manager = mid, f_name = name, f_source = name, f_state = 1 }; db.Funds.Add(funds); } try { db.SaveChanges(); SysLog.WriteLog(user, "经费批量录入[{0}]", IpHelper.GetIP(), "", 6, "", db); } catch (Exception) { json.msg_text = "添加失败,请检查excel后重新操作。"; json.msg_code = "delErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } DataCache.RemoveCacheBySearch("cache_user"); DataCache.RemoveCacheBySearch("cache_response_user"); DataCache.RemoveCacheBySearch("cache_funds"); json.msg_text = sbMsg.ToString(); json.msg_code = "success"; json.state = 1; return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(string fid) { int id = PageValidate.FilterParam(fid); BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; return(Json(json, JsonRequestBehavior.AllowGet)); } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "添加经费", "经费管理")) { json.msg_text = "没有权限。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (id == 0) { json.msg_text = "参数传递失败,请重试。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } Funds funds = db.Funds.Find(id); if (funds == null) { json.msg_text = "没有找到该经费,该经费可能已被删除。"; json.msg_code = "noThis"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (user != funds.f_manager && !RoleCheck.CheckHasAuthority(user, db, "经费管理")) { json.msg_text = "非经费管理员不能操作他们经费。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } var used = (from bill in db.Reimbursement where bill.r_funds_id == funds.f_id && bill.r_bill_state == 1 select 1).Count(); if (used > 0) { json.msg_text = "该经费已在使用中,无法删除。"; json.msg_code = "inUsed"; return(Json(json, JsonRequestBehavior.AllowGet)); } db.Funds.Remove(funds); try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("经费删除[{0}]", funds.f_code), IpHelper.GetIP(), funds.f_id.ToString(), 6, "", db); } catch (Exception) { json.msg_text = "删除失败,请重新操作。"; json.msg_code = "delErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } json.msg_text = "删除成功。"; json.msg_code = "success"; json.state = 1; return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Edit(CourseModel courseModel) { BaseJsonData json = new BaseJsonData(); if (ModelState.IsValid) { Course_Info cmodel = db.Course_Infos.Find(courseModel.id); if (cmodel == null) { json.msg_text = "更新失败,该课程不存在或已删除。"; return(Json(json, JsonRequestBehavior.AllowGet)); } string time_info = ""; cmodel.course_cost = courseModel.cost; cmodel.course_introduce = courseModel.introduce; cmodel.course_max_num = courseModel.max; cmodel.course_name = courseModel.name; cmodel.c_assistant_id = courseModel.assistant; cmodel.c_cs_id = courseModel.season; cmodel.c_sub_id = courseModel.subject; cmodel.c_room = courseModel.room; cmodel.c_teacher_id = courseModel.teacher; cmodel.c_room = courseModel.room; cmodel.c_type_id = courseModel.type; foreach (ListTime lTiem in courseModel.ListTimes) { if (lTiem.count > 1) { time_info += "每"; } time_info += string.Format("{0}{1} ", WeeK.GetCHNDay(lTiem.day), lTiem.lessonTime); if (lTiem.times != null && lTiem.times.Count > 0) { //删除在页面删除的时间点 if (lTiem.cgroup > 0) { var t_list = from cvt2 in lTiem.times select cvt2.id; var delete_cvt = from cvt in db.Course_vs_Times where cvt.cvt_id != 0 && cvt.cvt_course_id == courseModel.id && cvt.cvt_group == lTiem.cgroup && !t_list.Contains(cvt.cvt_id) select cvt; if (delete_cvt.Count() > 0) { db.Course_vs_Times.RemoveRange(delete_cvt); db.SaveChanges(); } } else { var list = db.Course_vs_Times.Where(x => x.cvt_course_id == courseModel.id); if (list.Count() > 0) { lTiem.cgroup = list.Max(x => x.cvt_group).Value + 1; } else { lTiem.cgroup = 1; } } foreach (ListDetailTime time in lTiem.times) { Course_vs_Time cvt = db.Course_vs_Times.Find(time.id); if (cvt == null) { cvt = new Course_vs_Time(); cvt.cvt_course_id = courseModel.id; cvt.cvt_dayofweek = lTiem.day; cvt.cvt_duration = lTiem.lastlong; cvt.cvt_info = time.info; cvt.cvt_is_extra = time.isextra; cvt.cvt_state = time.state == 0?1: time.state; cvt.cvt_time = time.time; if (time.room == 0) { cvt.cvt_room_id = courseModel.room; } else { cvt.cvt_room_id = time.room; } cvt.cvt_group = lTiem.cgroup; db.Course_vs_Times.Add(cvt); db.SaveChanges(); } else { cvt.cvt_course_id = courseModel.id; cvt.cvt_dayofweek = lTiem.day; cvt.cvt_duration = lTiem.lastlong; cvt.cvt_info = time.info; cvt.cvt_is_extra = time.isextra; cvt.cvt_state = time.state == 0 ? 1 : time.state; cvt.cvt_time = time.time; if (time.room == 0) { cvt.cvt_room_id = courseModel.room; } else { cvt.cvt_room_id = time.room; } cvt.cvt_group = lTiem.cgroup; db.Entry(cvt).State = EntityState.Modified; db.SaveChanges(); } } } else { Course_vs_Time cvtModel; int group; var list = db.Course_vs_Times.Where(x => x.cvt_course_id == courseModel.id); if (list.Count() > 0) { group = list.Max(x => x.cvt_group).Value + 1; } else { group = 1; } List <DateTime> ListTime = CreateTimeDetail(courseModel.SuspendDays, courseModel.beginDate, lTiem.lessonTime, lTiem.day, lTiem.count); List <Course_vs_Time> cvtList = new List <Course_vs_Time>(); foreach (DateTime dtLesson in ListTime) { cvtModel = new Course_vs_Time(); cvtModel.cvt_course_id = courseModel.id; cvtModel.cvt_dayofweek = lTiem.day; cvtModel.cvt_is_extra = false; cvtModel.cvt_state = 1; cvtModel.cvt_time = dtLesson; cvtModel.cvt_duration = lTiem.lastlong; cvtModel.cvt_room_id = courseModel.room; cvtModel.cvt_group = group; cvtList.Add(cvtModel); } try { db.Course_vs_Times.AddRange(cvtList); db.SaveChanges(); } catch (Exception e) { json.msg_text = "课程时间编排出错,请重新操作。"; return(Json(json, JsonRequestBehavior.AllowGet)); } } } cmodel.c_time_info = time_info; db.Entry(cmodel).State = EntityState.Modified; //录入停课日期 if (courseModel.SuspendDays != null && courseModel.SuspendDays.Count() > 0) { foreach (DateTime dt in courseModel.SuspendDays) { if (db.Course_SuspendTimes.Where(x => x.cst_course_id == courseModel.id && x.cst_suspend_time.Year == dt.Year && x.cst_suspend_time.Month == dt.Month && x.cst_suspend_time.Day == dt.Day).Count() == 0) { db.Course_SuspendTimes.Add(new Course_SuspendTime { cst_course_id = courseModel.id, cst_suspend_time = dt }); } } } db.SaveChanges(); json.state = 1; json.msg_text = "更新完成。"; RemoveCache(courseModel.subject); } else { var errors = ModelState.Where(x => x.Value.Errors.Count() > 0); StringBuilder sbMsg = new StringBuilder(); foreach (var modelstate in errors) { if (modelstate.Value.Errors.Count() > 0) { foreach (ModelError err in modelstate.Value.Errors) { sbMsg.Append(modelstate.Key).Append(" ").Append(err.ErrorMessage).Append("<br />"); } } } //foreach (ModelError err in errors) //{ // sbMsg.Append(err.ErrorMessage).Append("<br />"); //} json.state = 0; json.msg_text = sbMsg.ToString(); } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Edit(ApplyListModel viewBill) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } int user = Common.PageValidate.FilterParam(User.Identity.Name); SetSelect(0); if (ModelState.IsValid) { Reimbursement bill = db.Reimbursement.Find(viewBill.reimbursementCode); if (bill == null) { json.msg_code = "error"; json.msg_text = "没有主申请单,更新失败。"; goto next; } if (viewBill.next == 0) { json.msg_code = "error"; json.msg_text = "必需选择审核用户。"; goto next; } StringBuilder sbmsg = new StringBuilder(); if (bill.r_bill_state == 1) { json.msg_code = "error"; json.msg_text = "该报销单已经批复完成,不允许修改。"; goto next; } else { bill.r_bill_amount = viewBill.amount; bill.r_fact_amount = viewBill.amount; bill.r_bill_state = 0; bill.r_add_date = DateTime.Now; bill.reimbursement_info = viewBill.info; db.Entry(bill).State = EntityState.Modified; //录入报销事由 Reimbursement_Content content = null; foreach (ViewContentModel citem in viewBill.contents) { if (citem.contentId != null && citem.contentId != 0) { content = db.Reimbursement_Content.Find(citem.contentId); if (content != null) { content.c_amount = citem.amount; db.Entry(content).State = EntityState.Modified; } } else { content = new Reimbursement_Content(); content.c_reimbursement_code = bill.reimbursement_code; content.c_dic_id = citem.selectId; content.c_amount = citem.amount; db.Reimbursement_Content.Add(content); } try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); sbmsg.Append("报销内容录入失败<br />"); continue; } //录入明细 if (citem.details != null && citem.details.Count() > 0) { Reimbursement_Detail detail = null; foreach (ViewDetailContent item in citem.details) { if (item.detailId != null && item.detailId != 0) { detail = db.Reimbursement_Detail.Find(item.detailId); } else { detail = new Reimbursement_Detail(); detail.detail_content_id = content.content_id; } detail.detail_amount = item.amount; detail.detail_date = DateTime.Parse(item.strDate + " 00:00"); detail.detail_info = item.detailInfo; detail.detail_content_id = content.content_id; if (item.detailId != null && item.detailId != 0) { db.Entry(detail).State = EntityState.Modified; } else { db.Reimbursement_Detail.Add(detail); } } } //录入附件 if (citem.attachments != null && citem.attachments.Count() > 0) { string attachment_path = string.Format("{0}\\{1}\\{2}\\", MyConfiguration.GetAttachmentPath(), bill.reimbursement_code, DateTime.Now.ToString("yyyyMMdd")); string attachment_temp_path = MyConfiguration.GetAttachmentTempPath();; if (!Directory.Exists(attachment_path)) { Directory.CreateDirectory(attachment_path); } string filePath, tempFile, saveFileName = "", storeFileName; foreach (ViewAttachment item in citem.attachments) { if (item.id > 0) { continue; } try { saveFileName = Path.GetFileName(item.fileName); storeFileName = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), saveFileName); tempFile = attachment_temp_path + item.fileName; filePath = string.Format("{0}{1}", attachment_path, saveFileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } System.IO.File.Move(tempFile, filePath); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); sbmsg.Append("文件【").Append(item.fileName).Append("】保存失败,请重新上传"); continue; } Reimbursement_Attachment attachment = new Reimbursement_Attachment { attachment_path = storeFileName, atta_detail_id = (int)citem.contentId, atta_reimbursement_code = bill.reimbursement_code }; db.Reimbursement_Attachment.Add(attachment); } } try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); sbmsg.Append("报销明细录入失败<br />"); continue; } } //录入附件 if (viewBill.attachments != null && viewBill.attachments.Count() > 0) { string attachment_path = string.Format("{0}\\{1}\\{2}\\", MyConfiguration.GetAttachmentPath(), bill.reimbursement_code, DateTime.Now.ToString("yyyyMMdd")); string attachment_temp_path = MyConfiguration.GetAttachmentTempPath();; if (!Directory.Exists(attachment_path)) { Directory.CreateDirectory(attachment_path); } string filePath, tempFile, saveFileName = "", storeFileName; foreach (ViewAttachment item in viewBill.attachments) { if (item.id > 0) { continue; } try { saveFileName = Path.GetFileName(item.fileName); storeFileName = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), saveFileName); tempFile = attachment_temp_path + item.fileName; filePath = string.Format("{0}{1}", attachment_path, saveFileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } System.IO.File.Move(tempFile, filePath); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); sbmsg.Append("文件【").Append(item.fileName).Append("】保存失败,请重新上传"); continue; } Reimbursement_Attachment attachment = new Reimbursement_Attachment { attachment_path = storeFileName, atta_detail_id = 0, atta_reimbursement_code = bill.reimbursement_code }; db.Reimbursement_Attachment.Add(attachment); } try { //干脆都先提交得了 db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单附件提交失败。"; goto next; } } //录入批复流程 db.Process_Respond.RemoveRange(db.Process_Respond.Where(x => x.pr_reimbursement_code == bill.reimbursement_code)); //添加批复人 Process_Respond pr = new Process_Respond(); pr.pr_reimbursement_code = bill.reimbursement_code; pr.pr_user_id = viewBill.next; pr.pr_number = 1; db.Process_Respond.Add(pr); try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("修改报帐单[{0}]", bill.reimbursement_code), IpHelper.GetIP(), bill.reimbursement_code, 4, "", db); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } } json.state = 1; json.msg_code = bill.reimbursement_code; json.msg_text = sbmsg.ToString(); } next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateDept(DepartMentModel dept) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; goto next; } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "系统管理")) { json.msg_text = "没有权限。"; json.msg_code = "NoPower"; goto next; } if (dept.deptId == null || dept.deptId == 0) { json.msg_text = "获取部门/科室的ID出错。"; json.msg_code = "IDError"; goto next; } int id = (int)dept.deptId; Dic_Department model = db.Dic_Department.Find(id); if (model == null) { json.msg_text = "没有找到该部门/科室,该部门/科室可能已被删除。"; json.msg_code = "noThis"; goto next; } var same = db.Dic_Department.Where(x => x.dept_name == dept.deptName && x.dept_id != dept.deptId); if (same.Count() > 0) { json.msg_text = "该名称已存在。"; json.msg_code = "NameExists"; goto next; } model.dept_name = dept.deptName; model.dept_parent_id = dept.parentId; db.Entry(model).State = EntityState.Modified; try { db.SaveChanges(); DBCaches2.ClearCache("cache_depts"); } catch { json.msg_text = "更新,请重新操作。"; json.msg_code = "UpdateErr"; goto next; } SysLog.WriteLog(user, string.Format("更新部门[{0}]", model.dept_name), IpHelper.GetIP(), "", 5, "", db); json.state = 1; json.msg_code = "success"; json.msg_text = "更新成功!"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
// GET: ApplyManager/Delete/5 public JsonResult Delete(string number) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } if (number == null) { json.msg_code = "errorNumber"; json.msg_text = "报销单号获取失败。"; goto next; } //查询订单状态,如果已批复,不能撤销。如果没有,删除流程。 Reimbursement bill = db.Reimbursement.Find(number); if (bill == null) { json.msg_code = "nodate"; json.msg_text = "报销单不存在或被删除。"; goto next; } int user = Common.PageValidate.FilterParam(User.Identity.Name); if (user != bill.r_add_user_id) { json.msg_code = "forbidden"; json.msg_text = "没有权限操作他人申请的报销单。"; goto next; } if (bill.r_bill_state == 1) { json.msg_code = "forbidden"; json.msg_text = "已批复同意的报销单不允许删除。"; goto next; } var cs = db.Reimbursement_Content.Where(x => x.c_reimbursement_code == bill.reimbursement_code); //删除报销内容 if (cs.Count() > 0) { foreach (Reimbursement_Content citem in cs) { //删除报销细节 db.Reimbursement_Detail.RemoveRange(db.Reimbursement_Detail.Where(x => x.detail_content_id == citem.content_id)); db.Reimbursement_Content.Remove(citem); } } //删除附件 db.Reimbursement_Attachment.RemoveRange(db.Reimbursement_Attachment.Where(x => x.atta_reimbursement_code == bill.reimbursement_code)); //删除批复 db.Process_Respond.RemoveRange(db.Process_Respond.Where(x => x.pr_reimbursement_code == bill.reimbursement_code)); //删除总单 db.Reimbursement.Remove(bill); try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("删除报帐单[{0}]", bill.reimbursement_code), IpHelper.GetIP(), bill.reimbursement_code, 4, "", db); } catch (DbEntityValidationException ex) { StringBuilder errors = new StringBuilder(); IEnumerable <DbEntityValidationResult> validationResult = ex.EntityValidationErrors; foreach (DbEntityValidationResult result in validationResult) { ICollection <DbValidationError> validationError = result.ValidationErrors; foreach (DbValidationError err in validationError) { errors.Append(err.PropertyName + ":" + err.ErrorMessage + "\r\n"); } } ErrorUnit.WriteErrorLog(errors.ToString(), this.GetType().Name); json.msg_code = "error"; json.msg_text = "报销单删除失败。"; goto next; } json.state = 1; json.msg_code = "success"; next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Create(ApplyListModel _sbill) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_code = "nologin"; goto next; } int user = Common.PageValidate.FilterParam(User.Identity.Name); SetSelect(0); if (ModelState.IsValid) { Reimbursement bill = new Reimbursement(); bill.r_bill_amount = _sbill.amount; bill.r_bill_state = 0; bill.r_add_date = DateTime.Now; bill.r_add_user_id = user; bill.reimbursement_info = _sbill.info; var maxfa = db.Reimbursement.OrderByDescending(x => x.reimbursement_code).FirstOrDefault(); //apply_number:年份+10001自增 if (maxfa == null) { bill.reimbursement_code = DateTime.Now.Year.ToString() + "10001"; } else { bill.reimbursement_code = DateTime.Now.Year.ToString() + (int.Parse(maxfa.reimbursement_code.Substring(4)) + 1); } db.Reimbursement.Add(bill); try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } StringBuilder sbErr = new StringBuilder(); //添加报销内容 foreach (ViewContentModel citem in _sbill.contents) { Reimbursement_Content content = new Reimbursement_Content(); content.c_reimbursement_code = bill.reimbursement_code; content.c_amount = citem.amount; content.c_dic_id = citem.selectId; db.Reimbursement_Content.Add(content); try { //必需先提交更改,因为下面添加明细需要用到自动生成的ID。 db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } //添加明细 if (citem.details != null && citem.details.Count() > 0) { foreach (ViewDetailContent viewDetail in citem.details) { Reimbursement_Detail detail = new Reimbursement_Detail() { detail_amount = viewDetail.amount, detail_content_id = content.content_id, detail_date = DateTime.Parse(viewDetail.strDate + " 00:00"), detail_info = viewDetail.detailInfo }; db.Reimbursement_Detail.Add(detail); } } //添加附件 if (citem.attachments != null && citem.attachments.Count() > 0) { string attachment_path = string.Format("{0}\\{1}\\{2}\\", MyConfiguration.GetAttachmentPath(), bill.reimbursement_code, DateTime.Now.ToString("yyyyMMdd")); string attachment_temp_path = MyConfiguration.GetAttachmentTempPath();; if (!Directory.Exists(attachment_path)) { Directory.CreateDirectory(attachment_path); } string filePath, tempFile, saveFileName = "", storeFileName; foreach (ViewAttachment item in citem.attachments) { try { saveFileName = Path.GetFileName(item.fileName); storeFileName = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), saveFileName); tempFile = attachment_temp_path + item.fileName; filePath = string.Format("{0}{1}", attachment_path, saveFileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } System.IO.File.Move(tempFile, filePath); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), GetType().ToString()); sbErr.Append("文件【").Append(saveFileName).Append("】保存失败,请重新上传。\r\n"); continue; } Reimbursement_Attachment attachment = new Reimbursement_Attachment { attachment_path = storeFileName, atta_detail_id = content.content_id, atta_reimbursement_code = bill.reimbursement_code }; db.Reimbursement_Attachment.Add(attachment); } } try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } } //添加其他附件 if (_sbill.attachments != null && _sbill.attachments.Count() > 0) { string attachment_path = string.Format("{0}\\{1}\\{2}\\", MyConfiguration.GetAttachmentPath(), bill.reimbursement_code, DateTime.Now.ToString("yyyyMMdd")); string attachment_temp_path = MyConfiguration.GetAttachmentTempPath();; if (!Directory.Exists(attachment_path)) { Directory.CreateDirectory(attachment_path); } string filePath, tempFile, saveFileName = "", storeFileName; foreach (ViewAttachment item in _sbill.attachments) { try { saveFileName = Path.GetFileName(item.fileName); storeFileName = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMMdd"), saveFileName); tempFile = attachment_temp_path + item.fileName; filePath = string.Format("{0}{1}", attachment_path, saveFileName); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } System.IO.File.Move(tempFile, filePath); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), GetType().ToString()); sbErr.Append("文件【").Append(saveFileName).Append("】保存失败,请重新上传。\r\n"); continue; } Reimbursement_Attachment attachment = new Reimbursement_Attachment { attachment_path = storeFileName, atta_detail_id = 0, atta_reimbursement_code = bill.reimbursement_code }; db.Reimbursement_Attachment.Add(attachment); } try { db.SaveChanges(); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } } //添加批复人 Process_Respond pr = new Process_Respond(); pr.pr_reimbursement_code = bill.reimbursement_code; pr.pr_user_id = _sbill.next; pr.pr_number = 1; db.Process_Respond.Add(pr); try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("添加报帐单[{0}]", bill.reimbursement_code), IpHelper.GetIP(), bill.reimbursement_code, 4, "", db); } catch (Exception e) { ErrorUnit.WriteErrorLog(e.ToString(), this.GetType().ToString()); Delete(bill.reimbursement_code); json.msg_code = "error"; json.msg_text = "报销单提交失败。"; goto next; } json.state = 1; json.msg_code = bill.reimbursement_code; json.msg_text = sbErr.ToString(); } next: return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult SetAgree(Respond respond) { BaseJsonData json = new BaseJsonData(); if (!User.Identity.IsAuthenticated) { json.msg_text = "没有登陆或登陆失效,请重新登陆后操作。"; json.msg_code = "notLogin"; return(Json(json, JsonRequestBehavior.AllowGet)); } int user = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(user, db, "批复管理", "批复")) { json.msg_text = "没有权限。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (respond.id == null || respond.id == 0) { json.msg_text = "参数传递失败,请重试。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } Process_Respond model = db.Process_Respond.Find(respond.id); if (model == null) { json.msg_text = "没找到该流程,可能已经撤销,请重试。"; json.msg_code = "None"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (user != model.pr_user_id) { json.msg_text = "非该流程的当前批复人。"; json.msg_code = "paramErr"; return(Json(json, JsonRequestBehavior.AllowGet)); } var exists = db.Process_Respond.Where(x => x.pr_reimbursement_code == model.pr_reimbursement_code && x.pr_user_id == respond.next); if (exists.Count() > 0) { json.msg_text = "该审核人已存在审批列表中。"; json.msg_code = "Exists"; return(Json(json, JsonRequestBehavior.AllowGet)); } //批复当前流程 int state = respond.state; model.pr_state = state; model.pr_time = DateTime.Now; model.pr_content = PageValidate.InputText(Server.UrlDecode(respond.reason), 2000); db.Entry(model).State = System.Data.Entity.EntityState.Modified; //是否为批复不通过 Reimbursement bill = db.Reimbursement.Find(model.pr_reimbursement_code); if (bill == null) { json.msg_text = "操作失败,该报销单已被删除。"; json.msg_code = "Error"; return(Json(json, JsonRequestBehavior.AllowGet)); } if (state == 1) { Funds fmodel = db.Funds.Find(bill.r_funds_id); if (fmodel == null) { json.msg_text = "所申请的经费已不存在,无法继续。"; json.msg_code = "applyError"; json.state = 0; return(Json(json, JsonRequestBehavior.AllowGet)); } //是否有next if (respond.next != null && respond.next != 0) { Process_Respond pr = new Process_Respond(); pr.pr_reimbursement_code = model.pr_reimbursement_code; pr.pr_user_id = (int)respond.next; pr.pr_number = model.pr_number + 1; db.Process_Respond.Add(pr); model.next = pr.pr_id; db.Entry(model).State = System.Data.Entity.EntityState.Modified; } else { if (fmodel.f_balance < bill.r_bill_amount) { //经费不足,回退批复 json.msg_text = "当前经费余额不足,无法继续。"; json.msg_code = "applyError"; json.state = 0; return(Json(json, JsonRequestBehavior.AllowGet)); } else { fmodel.f_balance = fmodel.f_balance - bill.r_bill_amount; db.Entry(fmodel).State = System.Data.Entity.EntityState.Modified; bill.r_bill_state = state; bill.r_fact_amount = bill.r_bill_amount; db.Entry(bill).State = System.Data.Entity.EntityState.Modified; } } } else { bill.r_bill_state = state; db.Entry(bill).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); SysLog.WriteLog(user, string.Format("批复报帐单[{0}],结果为[{1}]", bill.reimbursement_code, state), IpHelper.GetIP(), bill.reimbursement_code, 3, "", db); } catch (DbEntityValidationException et) { StringBuilder errors = new StringBuilder(); IEnumerable <DbEntityValidationResult> validationResult = et.EntityValidationErrors; foreach (DbEntityValidationResult result in validationResult) { ICollection <DbValidationError> validationError = result.ValidationErrors; foreach (DbValidationError err in validationError) { errors.Append(err.PropertyName + ":" + err.ErrorMessage + "\r\n"); } } ErrorUnit.WriteErrorLog(errors.ToString(), this.GetType().Name); json.msg_text = "审核失败。"; json.msg_code = "respondError"; json.state = 0; return(Json(json, JsonRequestBehavior.AllowGet)); } json.msg_text = "操作成功。"; json.msg_code = "success"; json.state = 1; return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(int?id) { BaseJsonData json = new BaseJsonData(); int uid = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理")) { json.state = 0; json.msg_text = "没有权限。"; goto next; } if (id == 1) { goto next; } if (!User.Identity.IsAuthenticated) { goto next; } if (id == null) { goto next; } if (id == 1) { json.state = 1; json.msg_text = "该帐号不允许删除。"; goto next; } User_Info user_Info = db.User_Info.Find(id); if (user_Info == null) { json.state = 1; json.msg_text = "所选用户不存在或已被删除。"; goto next; } User_Extend extend = db.User_Extend.Find(id); db.User_Info.Remove(user_Info); if (extend != null) { db.User_Extend.Remove(extend); } try { db.SaveChanges(); json.state = 1; json.msg_code = "success"; json.msg_text = "删除成功。"; SysLog.WriteLog(uid, string.Format("删除用户[{0}]信息", Common.DEncrypt.AESEncrypt.Decrypt(user_Info.real_name)), IpHelper.GetIP(), id.ToString(), 2, "", db); } catch (Exception ex) { ErrorUnit.WriteErrorLog(ex.ToString(), this.GetType().Name); json.state = 1; json.msg_text = "删除可能没有成功,请刷新页面查看。"; } next: return(Json(json, JsonRequestBehavior.AllowGet)); }