public JsonResult CreatePhong(string tenphongid, string maphongid, string sochongoiid, string motaid) { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var result = new JsonResultBO(true); try { var modelPhong = new QL_PHONGHOP(); //Kiểm tra Input null không if (tenphongid == null || maphongid == null || sochongoiid == null || motaid == null) { result.Status = false; result.Message = "Không cập nhật được"; } modelPhong.TENPHONG = tenphongid; modelPhong.MAPHONG = maphongid; modelPhong.SOCHONGOI = int.Parse(sochongoiid); modelPhong.MOTA = motaid; modelPhong.DEPID = currentUser.DeptParentID; QL_PHONGHOPBusiness.Save(modelPhong); } catch { result.Status = false; result.Message = "Không thêm mới được"; } return(Json(result)); }
public JsonResult EditPhong(int id, string TenPhongIdEdit, string MaPhongIdEdit, string SoChoNgoiIdEdit, string MoTaIdEdit) { QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var result = new JsonResultBO(true); try { var myobj = QL_PHONGHOPBusiness.Find(id); if (TenPhongIdEdit == null || MaPhongIdEdit == null || MoTaIdEdit == null || SoChoNgoiIdEdit == null) { result.Status = false; result.Message = "Không cập nhật được"; } myobj.TENPHONG = TenPhongIdEdit; myobj.MAPHONG = MaPhongIdEdit; myobj.MOTA = MoTaIdEdit; myobj.SOCHONGOI = int.Parse(SoChoNgoiIdEdit); QL_PHONGHOPBusiness.Save(myobj); } catch { result.Status = false; result.Message = "Không cập nhật được"; } return(Json(result)); }
public PartialViewResult Create() { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var model = new CreateVM(); model.Object = QL_PHONGHOPBusiness.GetPhong(currentUser.DeptParentID); return(PartialView("_Create", model)); }
public JsonResult Delete(long id) { var result = new JsonResultBO(true); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); QL_PHONGHOPBusiness.repository.Delete(id); QL_PHONGHOPBusiness.Save(); return(Json(result)); }
public ActionResult Index() { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var data = QL_PHONGHOPBusiness.GetDaTaByPage(currentUser.DeptParentID, null); SessionManager.SetValue("TimKiemPhong", null); return(View(data)); }
public PartialViewResult Edit(long id) { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var myModel = new EditVM(); myModel.Object = QL_PHONGHOPBusiness.repository.Find(id); myModel.LstPhong = QL_PHONGHOPBusiness.GetPhong(currentUser.DeptParentID); return(PartialView("_EditPartial", myModel)); }
public PartialViewResult BookingRoom(long id) { AssignUserInfo(); QUANLY_PHONGHOPBusiness = Get <QUANLY_PHONGHOPBusiness>(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); DetailVM viewModel = new DetailVM(); viewModel.roomEntity = QUANLY_PHONGHOPBusiness.GetDetail(id); viewModel.groupOfRooms = QL_PHONGHOPBusiness.context.QL_PHONGHOP .Where(x => x.DEPID == currentUser.DeptParentID) .ToList().Select(x => new SelectListItem() { Value = x.ID.ToString(), Text = string.Format("{0} - {1}", x.TENPHONG, x.MAPHONG), }).ToList(); return(PartialView("_BookingRoom", viewModel)); }
public JsonResult searchData(FormCollection form) { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var searchModel = SessionManager.GetValue("TimKiemPhong") as QLPHONGHOP_SEARCHBO; if (searchModel == null) { searchModel = new QLPHONGHOP_SEARCHBO(); searchModel.pageSize = 20; } searchModel.TenPhong = form["sea_TenPhong"]; searchModel.MaPhong = form["sea_MaPhong"];; SessionManager.SetValue("TimKiemPhong", searchModel); var data = QL_PHONGHOPBusiness.GetDaTaByPage(currentUser.DeptParentID, searchModel, searchModel.pageSize, 1); return(Json(data)); }
public JsonResult getData(int indexPage, string sortQuery, int pageSize) { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); var searchModel = SessionManager.GetValue("TimKiemPhong") as QLPHONGHOP_SEARCHBO; if (!string.IsNullOrEmpty(sortQuery)) { if (searchModel == null) { searchModel = new QLPHONGHOP_SEARCHBO(); } searchModel.sortQuery = sortQuery; if (pageSize > 0) { searchModel.pageSize = pageSize; } SessionManager.SetValue("TimKiemPhong", searchModel); } var data = QL_PHONGHOPBusiness.GetDaTaByPage(currentUser.DeptParentID, searchModel, pageSize, indexPage); return(Json(data)); }
public JsonResult SaveBooking(FormCollection col) { AssignUserInfo(); JsonResultBO result = new JsonResultBO(true); QUANLY_PHONGHOPBusiness = Get <QUANLY_PHONGHOPBusiness>(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); SYS_TINNHANBusiness = Get <SYS_TINNHANBusiness>(); List <long> notifyUsers = new List <long>(); string title = string.Empty; string content = string.Empty; string url = string.Empty; string bookDate = string.Empty; string startTime = string.Empty; string endTime = string.Empty; string roomName = string.Empty; QUANLY_PHONGHOP bookEntity = QUANLY_PHONGHOPBusiness.Find(col["ID"].ToIntOrZero()); if (bookEntity != null && bookEntity.IS_DELETE != true) { bookEntity.PHONG_ID = col["PHONG_ID"].ToIntOrZero(); QUANLY_PHONGHOPBusiness.Save(bookEntity); //hủy lịch các phòng khác string duplicateIds = col["DUPLICATE"]; if (!string.IsNullOrEmpty(duplicateIds)) { List <int> ids = duplicateIds.ToListInt(','); foreach (var id in ids) { QUANLY_PHONGHOP cancelCalendar = QUANLY_PHONGHOPBusiness.Find(id); if (cancelCalendar != null) { cancelCalendar.IS_DELETE = true; QUANLY_PHONGHOPBusiness.Save(cancelCalendar); //gửi thông báo hủy lịch đến người đặt lịch bookDate = cancelCalendar.NGAYDAT != null?cancelCalendar.NGAYDAT.Value.ToVietnameseDateFormat() : string.Empty; startTime = string.Format("{0}h{1}", cancelCalendar.GIOBATDAU.Value.ToString("D2"), cancelCalendar.PHUTBATDAU.Value.ToString("D2")); endTime = string.Format("{0}h{1}", cancelCalendar.GIOKETTHUC.Value.ToString("D2"), cancelCalendar.PHUTKETTHUC.Value.ToString("D2")); title = "THÔNG BÁO HỦY LỊCH"; content = string.Format("Cuộc họp về \"{0}\" trong ngày {1} ({2} - {3}) đã bị hủy", cancelCalendar.MUCDICH, bookDate, startTime, endTime); SYS_TINNHANBusiness.sendMessageMultipleUsers(new List <long> { cancelCalendar.CREATED_BY.GetValueOrDefault() }, currentUser, title, content, url, string.Empty, false, cancelCalendar.ID, 0); } } } result.Message = "Đặt phòng thành công"; //lấy thông tin phòng, người đặt lịch và thời gian đặt lịch QL_PHONGHOP room = QL_PHONGHOPBusiness.Find(bookEntity.PHONG_ID) ?? new QL_PHONGHOP(); roomName = room.TENPHONG; notifyUsers.Add(bookEntity.CREATED_BY.GetValueOrDefault()); bookDate = bookEntity != null?bookEntity.NGAYDAT.Value.ToVietnameseDateFormat() : string.Empty; startTime = string.Format("{0}h{1}", bookEntity.GIOBATDAU.Value.ToString("D2"), bookEntity.PHUTBATDAU.Value.ToString("D2")); endTime = string.Format("{0}h{1}", bookEntity.GIOKETTHUC.Value.ToString("D2"), bookEntity.PHUTKETTHUC.Value.ToString("D2")); } else { result.Status = false; result.Message = "Yêu cầu đặt lịch không tồn tại"; } title = "THÔNG BÁO ĐẶT PHÒNG"; content = string.Format("Cuộc họp về \"{0}\" trong ngày {1} ({2} - {3}) được đặt tại {4}", bookEntity.MUCDICH, bookDate, startTime, endTime, roomName); SYS_TINNHANBusiness.sendMessageMultipleUsers(notifyUsers, currentUser, title, content, url, string.Empty, false, bookEntity.ID, 0); return(Json(result)); }
public PartialViewResult SearchPhongHop(QLPHONGHOP_SEARCH searchModel) { AssignUserInfo(); QL_PHONGHOPBusiness = Get <QL_PHONGHOPBusiness>(); QUANLY_PHONGHOPBusiness = Get <QUANLY_PHONGHOPBusiness>(); DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>(); if (searchModel.calendarDay == null) { searchModel.calendarDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); } else { searchModel.calendarDay = new DateTime(searchModel.calendarDay.Value.Year, searchModel.calendarDay.Value.Month, searchModel.calendarDay.Value.Day); } DateTime today = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); DateTime currentDay = searchModel.calendarDay.Value; PhongHopViewModel viewModel = new PhongHopViewModel(); var startOfWeek = currentDay.GetStartDayOfWeek(); var endOfWeek = currentDay.GetEndDayOfWeek(); //gán vào search model searchModel.queryStartDate = startOfWeek; searchModel.queryEndDate = endOfWeek; searchModel.queryDeptParentID = currentUser.DeptParentID.GetValueOrDefault(); //lấy các ngày trong tuần viewModel.groupOfDates = new List <DateTime>(); for (DateTime day = startOfWeek; day <= endOfWeek; day = day.AddDays(1)) { viewModel.groupOfDates.Add(day); } viewModel.title = currentDay.GetNameOfWeek() + " (" + startOfWeek.GetNameOfDay() + ", " + startOfWeek.ToVietnameseDateFormat() + " - " + endOfWeek.GetNameOfDay() + ", " + endOfWeek.ToVietnameseDateFormat() + ")"; viewModel.groupOfYears = QUANLY_PHONGHOPBusiness.GetListYears(currentDay); viewModel.groupOfWeeks = Enumerable.Range(1, 52).Select(w => new SelectListItem() { Value = w.ToString(), Text = "Tuần " + w, Selected = (currentDay.GetWeekNumber() == w) }).ToList(); //lấy danh sách các lịch đặt phòng List <QLPHONGHOP_BO> calendars = QUANLY_PHONGHOPBusiness.GetData(searchModel); //lấy danh sách các phòng List <QL_PHONGHOP> rooms = QL_PHONGHOPBusiness.context.QL_PHONGHOP.Where(x => x.DEPID == currentUser.DeptParentID).ToList(); viewModel.groupOfCalendars = new List <LichCongTacEntityViewModel>(); for (DateTime day = startOfWeek; day <= endOfWeek; day = day.AddDays(1)) { LichCongTacEntityViewModel dayEntity = new LichCongTacEntityViewModel(); dayEntity.title = string.Format("{0} ({1})", day.GetNameOfDay(), day.ToVietnameseDateFormat()); dayEntity.isToday = day.Equals(today); dayEntity.groupOfCalendars = calendars.Where(x => x.NGAYDAT == day && x.PHONG_ID == 0) .OrderBy(x => x.GIOBATDAU).ThenBy(x => x.PHUTBATDAU) .ThenBy(x => x.USER_ID) .ToList(); viewModel.groupOfCalendars.Add(dayEntity); } viewModel.groupOfRooms = new List <PhongHopEntity>(); foreach (var room in rooms) { PhongHopEntity roomEntity = new PhongHopEntity(); roomEntity.name = room.TENPHONG; roomEntity.groupOfCalendars = new List <LichCongTacEntityViewModel>(); for (DateTime day = startOfWeek; day <= endOfWeek; day = day.AddDays(1)) { LichCongTacEntityViewModel dayEntity = new LichCongTacEntityViewModel(); dayEntity.groupMorningItems = calendars .Where(x => x.NGAYDAT == day && x.PHONG_ID == room.ID) .Where(x => x.GIOBATDAU <= 12) .OrderBy(x => x.GIOBATDAU) .ThenBy(x => x.PHUTBATDAU) .ToList(); dayEntity.groupAfternoonItems = calendars .Where(x => x.NGAYDAT == day && x.PHONG_ID == room.ID) .Where(x => x.GIOBATDAU > 13) .OrderBy(x => x.GIOBATDAU) .ThenBy(x => x.PHUTBATDAU) .ToList(); roomEntity.groupOfCalendars.Add(dayEntity); } viewModel.groupOfRooms.Add(roomEntity); } return(PartialView("_ListPhongHop", viewModel)); }