public ActionResult MachineroomRes(Reservation res) { //这里传入的预约信息中的ComputerinfoID,其实是机房的id,并不是电脑id string resultstr = "err"; Machineroom mr = machineroomService.GetEntities(u => u.ID == res.ComputerinfoID).FirstOrDefault() as Machineroom; //先查询该机房是否有隐藏的电脑信息 List <Computerinfo> cilist = computerinfoService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.MachineroomID == mr.ID && u.Col == 0 && u.Row == 0).ToList(); if (cilist.Count == 0) { //一台隐藏的没有,那就添加一台 Computerinfo ciadd = new Computerinfo(); ciadd.MachineroomID = mr.ID; ciadd.Number = mr.Number + "-ALL"; ciadd.Money = 0; ciadd.Memory = mr.Name + "(所有电脑)"; ciadd.IP = "机房网关:" + mr.IPinfo; ciadd.MAC = mr.Address; ciadd.Model = mr.Name + "(所有电脑)"; ciadd.System = mr.Name + "(所有电脑)"; ciadd.RN = mr.Name + "(所有电脑)"; ciadd.Row = 0; ciadd.Col = 0; ciadd.Brand = mr.Name + "(所有电脑)"; ciadd.CPU = mr.Name + "(所有电脑)"; ciadd.Delflag = (int)DelflagEnum.Normal; ciadd.Status = (int)StatusEnum.Over; ciadd.Hard = mr.Name + "(所有电脑)"; ciadd.Facturedate = DateTime.Now; computerinfoService.Add(ciadd); } else if (cilist.Count > 1) { //隐藏电脑只能有一台,如果有多台,全部删除,返回err return(Json(resultstr)); } //先查询是否已经有预约信息(查询整个机房,只要有一台被预约了,就不行),如果没有被预约,再插入 List <Reservation> temp = reservationService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.Computerinfo.MachineroomID == mr.ID && u.Sdate == res.Sdate && u.DateFlag == res.DateFlag).ToList(); if (temp.Count() == 0) { Computerinfo ci = computerinfoService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.MachineroomID == mr.ID && u.Col == 0 && u.Row == 0).FirstOrDefault(); res.ComputerinfoID = ci.ID; res.Rdate = DateTime.Now; res.Edate = res.Sdate; res.Status = (int)StatusEnum.Normal; res.Delflag = (int)DelflagEnum.Normal; //从缓存里面拿到userLoginId信息 string userLoginId = Request.Cookies["userLoginId"].Value.ToString(); Userinfo userInfo = CacheHelper.GetCache(userLoginId) as Userinfo; res.UserinfoID = userInfo.ID; reservationService.Add(res); resultstr = "ok"; } return(Json(resultstr)); }
public ActionResult Edit(Machineroom mr) { if (ModelState.IsValid) { mr.Delflag = (int)DelflagEnum.Normal; machineroomService.Update(mr); return(Json("ok")); } return(View(mr)); }
public ActionResult Details(int id = 0) { Machineroom machineroom = machineroomService.GetEntities(u => (u.Delflag == (int)DelflagEnum.Normal && u.ID == id)).First(); if (machineroom == null) { return(HttpNotFound()); } return(View(machineroom)); }
public ActionResult ShowLayout(PagingInfo pi, string MachineroomID = null) { int midint = Convert.ToInt32(MachineroomID); pi.PageIndex = pi.PageIndex == 0 ? 1 : pi.PageIndex; pi.PageSize = pi.PageSize == 0 ? 3 : pi.PageSize; List <Computerinfo> computerlist = new List <Computerinfo>(); computerlist = computerinfoService.GetEntities(u => (u.Delflag == (int)DelflagEnum.Normal && u.MachineroomID == midint)).ToList(); if (computerlist.Count() > 0) { Machineroom mroom = computerlist.First().Machineroom; pi.TotalItems = mroom.Ccol; List <Computerinfo> showcomputerlist = new List <Computerinfo>(); int starti = (pi.PageIndex - 1) * pi.PageSize + 1; int endi = starti + pi.PageSize - 1; if (starti > mroom.Ccol) { starti = 1; endi = 3; } endi = endi > mroom.Ccol ? mroom.Ccol : endi; for (int i = starti; i <= endi; i++) { for (int j = 1; j <= mroom.Crow; j++) { var temp = computerlist.Where(u => u.Row == i && u.Col == j); if (temp.Count() > 0) { showcomputerlist.Add(temp.First()); } else { Computerinfo citemp = new Computerinfo(); citemp.ID = 0; citemp.Number = "此位空置"; citemp.Row = i; citemp.Col = j; showcomputerlist.Add(citemp); } } } return(Json(Tuple.Create(mroom, pi, showcomputerlist))); } else { return(Json("null")); } }
public ActionResult Edit(string id = null) { int idint = Convert.ToInt32(id); Machineroom machineroom = machineroomService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.ID == idint).First() as Machineroom; if (machineroom == null) { return(HttpNotFound()); } return(View(machineroom)); }
public ActionResult Create(Machineroom mr) { if (ModelState.IsValid) { mr.Delflag = (int)DelflagEnum.Normal; mr.Status = (int)StatusEnum.Normal; machineroomService.Add(mr); return(Json("ok")); } return(View()); }
public ActionResult Edit(Machineroom mr) { if (ModelState.IsValid) { //从缓存里面拿到userLoginId信息 string userLoginId = Request.Cookies["userLoginId"].Value.ToString(); Userinfo userInfo = CacheHelper.GetCache(userLoginId) as Userinfo; mr.UserinfoID = userInfo.ID; mr.Delflag = (int)DelflagEnum.Normal; machineroomService.Update(mr); return(Json("ok")); } return(View(mr)); }
public bool RCExist(int row, int col, int id) { IMachineroomService machineroomService = new MachineroomService(); Machineroom mr = machineroomService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.ID == id).First(); if (mr.Crow < row || mr.Ccol < col) { return(false); } if (GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.Row == row && u.Col == col && u.MachineroomID == mr.ID).Count() > 0) { return(false); } return(true); }
public ActionResult Delete(string id) { int idint = Convert.ToInt32(id); Machineroom machineroom = machineroomService.GetEntities(u => u.ID == idint && u.Delflag == (int)DelflagEnum.Normal).First() as Machineroom; if (machineroom != null) { machineroomService.Delete(machineroom); return(Json("ok")); } else { return(Json("err")); } }
public ActionResult Index(PagingInfo pi, Machineroom mr) { pi.PageIndex = pi.PageIndex == 0 ? 1 : pi.PageIndex; pi.PageSize = pi.PageSize == 0 ? 5 : pi.PageSize; string uname = Request["uname"]; //mr.Userinfo.Uname = String.IsNullOrWhiteSpace(mr.Userinfo.Uname) ? "" : mr.Userinfo.Uname; mr.Number = String.IsNullOrWhiteSpace(mr.Number) ? "" : mr.Number; mr.Name = String.IsNullOrWhiteSpace(mr.Name) ? "" : mr.Name; Expression <Func <Machineroom, bool> > wherelambda = u => (u.Delflag == (int)DelflagEnum.Normal && u.Name != null && u.Number != null && u.Userinfo.Uname != null && u.Number.Contains(mr.Number) && u.Name.Contains(mr.Name) && u.Userinfo.Uname.Contains(uname)); int count = 0; var Machinelist = machineroomService.GetPageEntities <int>(pi.PageSize, pi.PageIndex, out count, wherelambda, u => u.Count, true).ToList(); pi.TotalItems = count; return(Json(Tuple.Create(Machinelist, pi))); }
/// <summary> /// 机房预约界面 /// </summary> /// <returns></returns> public ActionResult MachineRes(int id = 0) { Machineroom machineroominfo = machineroomService.GetEntities(u => u.ID == id && u.Delflag == (int)DelflagEnum.Normal).First() as Machineroom; return(View(machineroominfo)); }