public string Edit(RetailSystem sys) { if (sys.SysName != sys.OldSysName) { // 若系统名称改变,则判断新改的系统名称是否有重复,如有重复不允许新增 RetailSystem rs = GetSysList().Find(a => a.SysName == sys.SysName); if (rs != null) { return("<p class='alert alert-danger'>出错了: " + sys.SysName + "已存在,不允许更新!" + "</p>"); } } try { dbContext.Entry(sys).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); // 更新内存 Update(2); return(Constants.AJAX_EDIT_SUCCESS_RETURN); } catch (Exception e1) { return("<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"); } }
// // GET: /SysManage/Edit/5 public ActionResult Edit(int id) { RetailSystem sys = GetSysList().Find(a => a.SysID == id); if (sys == null) { return(View()); } sys.OldSysName = sys.SysName; // 需求受理用户列表 var ls1 = GetUserList().Where(p => p.UserType == 1).ToList(); SelectList sl = new SelectList(ls1, "UID", "Realname", sys.ReqPersonID); // 选中当前值 ViewBag.ReqPersonList = sl; // 需求编辑用户列表 var ls2 = GetUserList().Where(p => p.UserType == 2).ToList(); ls2.Insert(0, new User() { UID = 0, Realname = "暂无" }); SelectList s2 = new SelectList(ls2, "UID", "Realname", sys.ReqEditPersonID); // 选中当前值 ViewBag.ReqEditPersonList = s2; return(View(sys)); }
public static void setup() { try { Server.Load(); Web.Load(); RetailSystem.LoadRetails(); Log.WriteLine("Configs successfully loaded"); } catch (Exception ex) { Log.WriteError("Couldn't setup configs (" + ex.Message + ") @ " + ex.StackTrace); } }
public string Delete(int id) { try { RetailSystem sys = GetSysList().Find(a => a.SysID == id); dbContext.Entry(sys).State = System.Data.Entity.EntityState.Deleted; dbContext.SaveChanges(); // 更新内存 Update(2); return("删除成功"); } catch (Exception e1) { return("出错了: " + e1.Message); } }
public string Create(RetailSystem sys) { // 判断是否有重复的系统名称,如有重复不允许新增 RetailSystem rs = GetSysList().Find(a => a.SysName == sys.SysName); if (rs != null) { return("<p class='alert alert-danger'>出错了: " + sys.SysName + "已存在,不允许重复添加!" + "</p>"); } try { dbContext.RetailSystems.Add(sys); dbContext.SaveChanges(); // 更新内存 Update(2); return(Constants.AJAX_CREATE_SUCCESS_RETURN); } catch (Exception e1) { return("<p class='alert alert-danger'>出错了: " + e1.Message + "</p>"); } }
/* * 【2】查询 */ // 默认页为查询页 // 按照查询条件查询结果:为使用分页功能,GET模式查询 public ActionResult Index(ReqQuery query, int pageNum = 1, bool isQuery = false, bool isExcel = false) { /*if (this.GetSessionCurrentUser() == null) * { * return RedirectToAction("Login", "User", new { ReturnUrl = "/ReqManage" }); * }*/ if (isQuery) { var ls = from a in dbContext.Reqs select a; if (query.SysId != 0) { ls = ls.Where(p => p.SysId == query.SysId); } if (!string.IsNullOrEmpty(query.AcptYear)) { ls = ls.Where(p => p.AcptDate.Year.ToString() == query.AcptYear); } if (!string.IsNullOrEmpty(query.AcptMonth)) { ls = ls.Where(p => p.AcptDate.Month.ToString() == query.AcptMonth); } if (!string.IsNullOrEmpty(query.ReqNo)) { ls = ls.Where(p => p.ReqNo == query.ReqNo.Trim()); } if (!string.IsNullOrEmpty(query.ReqDetailNo)) { ls = ls.Where(p => p.ReqDetailNo == query.ReqDetailNo.Trim()); } if (!string.IsNullOrEmpty(query.AnyRlsNo)) { ls = ls.Where(p => p.RlsNo == query.AnyRlsNo || p.SecondRlsNo == query.AnyRlsNo); } if (query.ReqStat != "全部") { // 分『等于』和『不等于』2种情况 if (query.NotEqual) { ls = ls.Where(p => p.ReqStat != query.ReqStat); } else { ls = ls.Where(p => p.ReqStat == query.ReqStat); } } if (query.ReqAcptPerson != 0) { ls = ls.Where(p => p.ReqAcptPerson == query.ReqAcptPerson); } // 特殊查询:0-无 1-超过3个月未出池 2-超过8天未入池 if (query.SpecialQuery == 1) { DateTime time = DateTime.Now.AddMonths(-3); ls = ls.Where(p => p.AcptDate.CompareTo(time) <= 0); } else if (query.SpecialQuery == 2) { DateTime time = DateTime.Now.AddDays(-8); ls = ls.Where(p => p.AcptDate.CompareTo(time) <= 0); } // 统一按照受理日期倒序 ls = ls.OrderByDescending(p => p.AcptDate); // 若isExcel为true,导出Excel if (isExcel) { RetailSystem s = new RetailSystem(); string targetFileName = ""; if (query.SysId != 0) { s = dbContext.RetailSystems.ToList().Find(a => a.SysID == query.SysId); targetFileName = "维护需求查询_" + s.SysName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss"); } else { targetFileName = "维护需求查询_所有系统_" + DateTime.Now.ToString("yyyyMMddHHmmss"); } // 需要对list修改以适应Excel模板 List <ReqExcel> excelList = this.GetExcelList(ls); return(this.MakeExcel <ReqExcel>("ReqReportT", targetFileName, excelList)); } else { var list = ls.ToList(); // 分页 query.ResultList = list.ToPagedList(pageNumber: pageNum, pageSize: Constants.PAGE_SIZE);; } } else { query = new ReqQuery(); } // 为了保证查询部分正常显示,对下拉列表处理 // 系统列表下拉 List <RetailSystem> sysList = this.GetSysList(); // 仅查询时可以选择所有系统 // 加上“全部” sysList.Insert(0, new RetailSystem() { SysID = 0, SysName = "全部" }); ViewBag.SysList = new SelectList(sysList, "SysID", "SysName", query.SysId); // 需求受理人下拉 List <User> userList = this.GetUserList(); // 加上“全部” userList.Insert(0, new User() { UID = 0, Realname = "全部" }); ViewBag.ReqAcptPerson = new SelectList(userList, "UID", "Realname", query.ReqAcptPerson); // 需求状态下拉 ViewBag.ReqStatList = MyTools.GetSelectList(Constants.ReqStatList, true, true, query.ReqStat); return(View(query)); }