예제 #1
0
        public ActionResult GetDateFlag(int id, DateTime date)
        {
            //查询该机房是否有预约信息
            Computerinfo ci    = computerinfoService.GetEntities(u => u.ID == id).FirstOrDefault();
            Computerinfo ciall = computerinfoService.GetEntities(u => u.MachineroomID == ci.MachineroomID && u.Col == 0 && u.Row == 0 && u.Status == (int)StatusEnum.Over).FirstOrDefault();

            if (ciall == null)
            {
                ciall = new Computerinfo();
            }
            List <Reservation> reslist = reservationService.GetEntities(u => (u.Delflag == (int)DelflagEnum.Normal && (u.ComputerinfoID == id || u.ComputerinfoID == ciall.ID) && u.Sdate == date && u.Status != (int)StatusEnum.Block)).ToList();
            List <string>      reslut  = new List <string>();

            if (reslist.Where(u => u.DateFlag == (int)DateFlagEnum.Morning).Count() == 0)
            {
                reslut.Add(((int)DateFlagEnum.Morning).ToString() + ",上午第1、2节课");
            }
            if (reslist.Where(u => u.DateFlag == (int)DateFlagEnum.Forenoon).Count() == 0)
            {
                reslut.Add(((int)DateFlagEnum.Forenoon).ToString() + ",上午第3、4节课");
            }
            if (reslist.Where(u => u.DateFlag == (int)DateFlagEnum.Afternoon).Count() == 0)
            {
                reslut.Add(((int)DateFlagEnum.Afternoon).ToString() + ",下午课程时段");
            }
            if (reslist.Where(u => u.DateFlag == (int)DateFlagEnum.Night).Count() == 0)
            {
                reslut.Add(((int)DateFlagEnum.Night).ToString() + ",晚自习时段");
            }
            if (reslut.Count() == 0)
            {
                return(Json("null"));
            }
            return(Json(reslut));
        }
예제 #2
0
        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));
        }
예제 #3
0
 public ActionResult Edit(Computerinfo ci)
 {
     if (ModelState.IsValid)
     {
         ci.Delflag = (int)DelflagEnum.Normal;
         computerinfoService.Update(ci);
         return(Json("ok"));
     }
     return(View(ci));
 }
        public ActionResult StudentDetails(int id = 0)
        {
            Computerinfo computerinfo = computerinfoService.GetEntities(u => (u.Delflag == (int)DelflagEnum.Normal && u.ID == id)).First();

            if (computerinfo == null)
            {
                return(HttpNotFound());
            }
            return(View(computerinfo));
        }
예제 #5
0
 public ActionResult Create(Computerinfo ci)
 {
     if (ModelState.IsValid)
     {
         ci.Delflag = (int)DelflagEnum.Normal;
         ci.Status  = (int)StatusEnum.Normal;
         computerinfoService.Add(ci);
         return(Json("ok"));
     }
     return(View());
 }
예제 #6
0
        public ActionResult Edit(string id = null)
        {
            int          idint        = Convert.ToInt32(id);
            Computerinfo computerinfo = computerinfoService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.ID == idint).First() as Computerinfo;

            if (computerinfo == null)
            {
                return(HttpNotFound());
            }
            return(View(computerinfo));
        }
        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 Create(Computerinfo ci)
 {
     if (ModelState.IsValid)
     {
         if (computerinfoService.RCExist(ci.Row, ci.Col, ci.MachineroomID))
         {
             ci.Delflag = (int)DelflagEnum.Normal;
             ci.Status  = (int)StatusEnum.Normal;
             computerinfoService.Add(ci);
         }
         return(Json("ok"));
     }
     return(View());
 }
        public ActionResult Delete(string id)
        {
            int idint = Convert.ToInt32(id);

            Computerinfo computerinfo = computerinfoService.GetEntities(u => u.ID == idint && u.Delflag == (int)DelflagEnum.Normal).First() as Computerinfo;

            if (computerinfo != null)
            {
                computerinfoService.Delete(computerinfo);
                return(Json("ok"));
            }
            else
            {
                return(Json("err"));
            }
        }
 public ActionResult Edit(Computerinfo ci)
 {
     if (ModelState.IsValid)
     {
         Computerinfo computerinfo = computerinfoService.GetEntities(u => u.Delflag == (int)DelflagEnum.Normal && u.Status == (int)StatusEnum.Normal && u.ID == ci.ID).First() as Computerinfo;
         if (ci.Row != computerinfo.Row || ci.Col != computerinfo.Col)
         {
             if (!computerinfoService.RCExist(ci.Row, ci.Col, ci.MachineroomID))
             {
                 return(Json("err"));
             }
         }
         ci.Delflag = (int)DelflagEnum.Normal;
         computerinfoService.Update(ci);
         return(Json("ok"));
     }
     return(View(ci));
 }
        public ActionResult Index(PagingInfo pi, Computerinfo ci)
        {
            pi.PageIndex = pi.PageIndex == 0 ? 1 : pi.PageIndex;
            pi.PageSize  = pi.PageSize == 0 ? 5 : pi.PageSize;
            string roomnumber = Request["MNumber"];

            ci.Number = String.IsNullOrWhiteSpace(ci.Number) ? "" : ci.Number;
            ci.Model  = String.IsNullOrWhiteSpace(ci.Model) ? "" : ci.Model;

            Expression <Func <Computerinfo, bool> > wherelambda = u => (u.Delflag == (int)DelflagEnum.Normal && u.Status == (int)StatusEnum.Normal && u.Number != null && u.Model != null && u.Machineroom.Number != null && u.Model.Contains(ci.Model) && u.Number.Contains(ci.Number) && u.Machineroom.Number.Contains(roomnumber));

            int count        = 0;
            var computerlist = computerinfoService.GetPageEntities <int>(pi.PageSize, pi.PageIndex, out count, wherelambda, u => u.ID, true).ToList();

            pi.TotalItems = count;

            return(Json(Tuple.Create(computerlist, pi)));
        }
예제 #12
0
        public ActionResult Index(PagingInfo pi, Computerinfo ci)
        {
            pi.PageIndex = pi.PageIndex == 0 ? 1 : pi.PageIndex;
            pi.PageSize  = pi.PageSize == 0 ? 5 : pi.PageSize;
            string roomnumber = Request["MNumber"];

            ci.Number = String.IsNullOrWhiteSpace(ci.Number) ? "" : ci.Number;
            ci.Model  = String.IsNullOrWhiteSpace(ci.Model) ? "" : ci.Model;
            ci.IP     = String.IsNullOrWhiteSpace(ci.IP) ? "" : ci.IP;

            //从缓存里面拿到userLoginId信息
            string   userLoginId = Request.Cookies["userLoginId"].Value.ToString();
            Userinfo userInfo    = CacheHelper.GetCache(userLoginId) as Userinfo;

            Expression <Func <Computerinfo, bool> > wherelambda = u => (u.Delflag == (int)DelflagEnum.Normal && u.Machineroom.UserinfoID == userInfo.ID && u.Number != null && u.Model != null && u.IP != null && u.Machineroom.Number != null && u.Model.Contains(ci.Model) && u.IP.Contains(ci.IP) && u.Number.Contains(ci.Number) && u.Machineroom.Number.Contains(roomnumber));

            int count        = 0;
            var computerlist = computerinfoService.GetPageEntities <int>(pi.PageSize, pi.PageIndex, out count, wherelambda, u => u.ID, true).ToList();

            pi.TotalItems = count;

            return(Json(Tuple.Create(computerlist, pi)));
        }
        /// <summary>
        /// 根据id显示电脑信息,电脑预约界面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult StudentRes(int id = 0)
        {
            Computerinfo computerinfo = computerinfoService.GetEntities(u => u.ID == id && u.Delflag == (int)DelflagEnum.Normal).First() as Computerinfo;

            return(View(computerinfo));
        }