コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }