public ActionResult print(int information_id) { HttpCookie CategoryCookie = null; if (Request.Cookies["information_id"] != null) { CategoryCookie = Request.Cookies["information_id"]; } else { CategoryCookie = new HttpCookie("information_id"); } CategoryCookie.Value = information_id.ToString(); Response.Cookies.Add(CategoryCookie); borrowInformationContext infortionsContext = new borrowInformationContext(); HttpCookie CurrCookie = Request.Cookies["information_id"]; int NUM = Convert.ToInt32(CurrCookie.Value); List <borrowInformation> borrowInformations = (from item in infortionsContext.borrowInformations.ToList() where item.information_id == NUM select item).ToList(); return(View(borrowInformations)); }
[HttpPost] //这里没问题 public ActionResult SaveInformation() { HttpCookie CurrCookie = Request.Cookies["user_id"]; int NUM = Convert.ToInt32(CurrCookie.Value); borrowInformation borrowInformations = new borrowInformation(); borrowInformations.单位名称 = Request["单位名称"]; borrowInformations.借用机房 = Request["借用机房"]; borrowInformations.借用人 = Request["借用人"]; borrowInformations.借用人身份 = Request["借用人身份"]; borrowInformations.具体内容描述 = Request["具体内容描述"]; borrowInformations.联系电话 = Request["联系电话"]; borrowInformations.其它 = Request["其它"]; borrowInformations.所在班级 = Request["所在班级"]; borrowInformations.提交时间 = DateTime.Now; borrowInformations.批准时间 = DateTime.Now; borrowInformations.学号 = Request["学号"]; borrowInformations.用途 = Request["用途"]; borrowInformations.借用具体时间始 = Request["借用具体时间始"]; borrowInformations.借用具体时间终 = Request["借用具体时间终"]; borrowInformations.user_id = NUM; borrowInformationContext iContext = new borrowInformationContext(); iContext.borrowInformations.Add(borrowInformations); iContext.SaveChanges(); return(RedirectToAction("checking", "borrowInformation")); }
public ActionResult requestCondition(int informationCategory = 2, int pages = 1) { int type_id = 0; type_id = informationCategory; HttpCookie type_idCookie = null; if (Request.Cookies["type_id"] != null) { type_idCookie = Request.Cookies["type_id"]; } else { type_idCookie = new HttpCookie("type_id"); } type_idCookie.Value = type_id.ToString(); Response.Cookies.Add(type_idCookie); IEnumerable <borrowInformation> borrowInformations = null; borrowInformationContext infortionsContext = new borrowInformationContext(); HttpCookie CurrCookie = Request.Cookies["user_id"]; int NUM = Convert.ToInt32(CurrCookie.Value); if (informationCategory == 2) { borrowInformations = from items in infortionsContext.borrowInformations where items.user_id == NUM orderby items.提交时间 descending select items; } else { borrowInformations = from items in infortionsContext.borrowInformations where items.informationCategory == informationCategory && items.user_id == NUM orderby items.提交时间 descending select items; } Paging paging = new Paging(borrowInformations, 6, 3, pages); return(View(paging)); }
public ActionResult inforCheck(int informationCategory = 0, int pages = 1) { int type_id = 0; type_id = informationCategory; HttpCookie type_id_checkCookie = null; if (Request.Cookies["type_id_check"] != null) { type_id_checkCookie = Request.Cookies["type_id_check"]; } else { type_id_checkCookie = new HttpCookie("type_id_check"); } type_id_checkCookie.Value = type_id.ToString(); Response.Cookies.Add(type_id_checkCookie); borrowInformationContext infortionsContext = new borrowInformationContext(); IEnumerable <borrowInformation> borrowInformations = null; if (informationCategory == 2) { borrowInformations = from items in infortionsContext.borrowInformations orderby items.提交时间 descending select items; } else { borrowInformations = from items in infortionsContext.borrowInformations where items.informationCategory == informationCategory orderby items.提交时间 descending select items; } Paging paging = new Paging(borrowInformations, 11, 3, pages); return(View(paging)); }
public JsonResult CheckSchedule() { setWeekContext set_weekContext = new setWeekContext(); setWeek set_week = (from item in set_weekContext.set_week where item.id == 1 select item).FirstOrDefault(); string datetime = ""; if (Request["借用日期"] == null) { datetime = DateTime.Now.ToLongDateString(); } else { datetime = Request["借用日期"]; } string weekstr = Convert.ToDateTime(datetime).DayOfWeek.ToString(); DateTime dt1 = set_week.start_date; //这里你要显示几个信息? 那你在哪里计算? DateTime dt2 = Convert.ToDateTime(datetime); //为什么两个 dt, 基准应该是8月 那是第一周 TimeSpan ts = dt2 - dt1; int a = Convert.ToInt32(ts.TotalDays); int weekCount = a / 7 + 1; DateTime dt = DateTime.Now; //Request.Cookies["weekIndex"].Expires = dt.Second.ToString() + "7"; String[] weekDay = new String[7] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; string index = (weekDay.ToList().IndexOf(weekstr) + 1).ToString(); lookScheduleContext lookSchedulesContext = new lookScheduleContext(); lookSchedule lookSchedules = (from item in lookSchedulesContext.lookSchedules.ToList() where ("计" + item.实验室名) == Request["借用机房"] && item.weekDay == index select item).FirstOrDefault(); borrowInformationContext borrowInformationsContext = new borrowInformationContext(); List <borrowInformation> borrowInformation = (from item in borrowInformationsContext.borrowInformations.ToList() where item.借用机房 == Request["借用机房"] && item.借用具体时间始 == Request["借用日期"] select item).ToList(); int count = borrowInformation.Count(); string[] str2 = new string[] { "", lookSchedules.第一节, lookSchedules.第二节, lookSchedules.第三节, lookSchedules.第四节, lookSchedules.第五节, lookSchedules.第六节, lookSchedules.第七节, lookSchedules.第八节 }; string str = weekCount.ToString(); for (int i = 1; i < 9; i++) { if (str2[i] != null) { if (!str2[i].Contains(str)) { if (count == 0) { str2[i] = null; } else { for (int j = 0; j < count; j++) { if (borrowInformation[j].借用具体时间终.Contains(i.ToString())) { str2[i] = "已借用"; } else { str2[i] = null; } } } } else { str2[i] = "有课"; } } else { for (int j = 0; j < count; j++) { if (borrowInformation[j].借用具体时间终.Contains(i.ToString())) { str2[i] = "已借用"; } } } } return(Json(new { weekindex = str, cindex1 = str2[1], cindex2 = str2[2], cindex3 = str2[3], cindex4 = str2[4], cindex5 = str2[5], cindex6 = str2[6], cindex7 = str2[7], cindex8 = str2[8] })); }