Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string   name     = txbName.Text;
            DateTime birthday = dtpBirthDay.Value;
            string   address  = txbAddress.Text;
            string   phone    = txbPhone.Text;
            string   email    = txbEmail.Text;
            string   topic    = txbTopic.Text;
            string   country  = txbCountry.Text;
            int      check;

            if (cbCheck.Checked == true)
            {
                check = 1;
            }
            else
            {
                check = 0;
            }
            GuestDAO _guest = new GuestDAO();

            if (_guest.CheckExist(name, phone))
            {
                MessageBox.Show("Người này đã tồn tại", "Thông Báo");
            }
            else
            {
                _guest.AddGuest(name, birthday, address, phone, topic, email, check, country);
                Register next = new Register();
                this.Hide();
                next.Show();
            }
        }
        public async Task <IActionResult> Create(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment, int Amount)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);
            int bookingid = BookingDAO.InsertBooking(new Booking()
            {
                RoomID       = RoomID,
                CheckInDate  = CheckInDate.AddHours(14),
                CheckOutDate = CheckOutDate.AddHours(12).AddMinutes(5),
                GuestID      = guestid,
                Amount       = (int)(CheckOutDate - CheckInDate).TotalDays * RoomsDAO.GetRoomModel(RoomID).RoomType.Price,
                PaymentID    = paymentid,
            });

            var    model = BookingDAO.GetBookingModel(bookingid);
            string body  = await Utlities.RenderViewToStringAsync <BookingModel>(this, "~/Areas/Guests/Views/Partial/_ConfirmEmail.cshtml", model);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**");
            mail.To.Add(guest.Email);
            mail.Subject    = "Congratulations on your successful booking";
            mail.Body       = body;
            mail.IsBodyHtml = true;

            Utlities.SendEmail(mail);

            return(View());
        }
 public ControllerClass(HotelContext db)
 {
     roomDAO       = new RoomDAO(db);
     guestDAO      = new GuestDAO(db);
     bookingDAO    = new BookingDAO(db);
     dictionaryDAO = new DictionaryDAO(db);
     this.view     = new ViewClass(dictionaryDAO.GetRoomTypes(), dictionaryDAO.GetGuestStatus());
 }
Example #4
0
        public IActionResult Index()
        {
            if (!Authentication.AuthenticateByCookie(HttpContext))
            {
                return(Redirect("/Receptionists/Authentication/Login?are=Receptionists&ctrl=Guests&act=Index"));
            }

            List <Guest> list = GuestDAO.GetAllGuests();

            return(View(list));
        }
Example #5
0
 public DataTable GetPersons(int id)
 {
     try
     {
         GuestDAO guestDAO = new GuestDAO();
         return(guestDAO.Read(id));
     }
     catch
     {
         throw;
     }
 }
 static void Main(string[] args)
 {
     using (HotelContext dB = new HotelContext())
     {
         RoomDAO         rd         = new RoomDAO(dB);
         GuestDAO        gd         = new GuestDAO(dB);
         BookingDAO      bd         = new BookingDAO(dB);
         DictionaryDAO   d          = new DictionaryDAO(dB);
         ControllerClass controller = new ControllerClass(dB);
         controller.Start();
     }
 }
Example #7
0
        public IActionResult Create(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment, int Amount)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);
            int bookingid = BookingDAO.InsertBooking(new Booking()
            {
                RoomID       = RoomID,
                CheckInDate  = CheckInDate.AddHours(14),
                CheckOutDate = CheckOutDate.AddHours(12).AddMinutes(5),
                GuestID      = guestid,
                Amount       = (int)(CheckOutDate - CheckInDate).TotalDays * RoomsDAO.GetRoomModel(RoomID).RoomType.Price,
                PaymentID    = paymentid,
            });

            return(View());
        }
        public IActionResult AddGuestOnCheckin(string FullName, string Gender, string IdCard, int bookingid)
        {
            if (!GuestDAO.CheckIsExistGuestByIdCard(IdCard))
            {
                var guestid = GuestDAO.InsertGuest(new Guest()
                {
                    FullName     = FullName,
                    Gender       = Gender,
                    IDCardNumber = IdCard
                });

                var stay = StayDAO.InsertStay(new Stay()
                {
                    GuestID   = guestid,
                    BookingID = bookingid,
                    FromDate  = DateTime.Now,
                    ToDate    = null
                });

                return(Json(stay));
            }
            else
            {
                var guestid = GuestDAO.GetGuestByIdCardNumber(IdCard).GuestID;
                if (!StayDAO.CheckGuestStaying(guestid))
                {
                    var stay = StayDAO.InsertStay(new Stay()
                    {
                        GuestID   = guestid,
                        BookingID = bookingid,
                        FromDate  = DateTime.Now,
                        ToDate    = null
                    });

                    return(Json(stay));
                }
                else
                {
                    return(Json(null));
                }
            }
        }
        public JsonResult CreateBooking(int RoomID, DateTime CheckInDate, DateTime CheckOutDate, Guest guest, Payment payment)
        {
            int guestid   = GuestDAO.InsertGuest(guest);
            int paymentid = PaymentDAO.InsertPayment(payment);

            Booking booking = new Booking();

            booking.RoomID       = RoomID;
            booking.GuestID      = guestid;
            booking.PaymentID    = paymentid;
            booking.CheckInDate  = CheckInDate;
            booking.CheckOutDate = CheckOutDate;

            int bookingid = BookingDAO.InsertBooking(booking);

            return(Json(new
            {
                data = booking
            }));
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int     index       = dgvData.CurrentCell.RowIndex;
            DataRow row         = (dgvData.Rows[index].DataBoundItem as DataRowView).Row;
            string  name        = row["Name"].ToString();
            string  phonenumber = row["PhoneNumber"].ToString();

            if (flag == 1)
            {
                InstructorDAO _instructorDAO = new InstructorDAO();
                _instructorDAO.DeleteData(name, phonenumber);
            }
            else if (flag == 2)
            {
                GuestDAO _guest = new GuestDAO();
                _guest.DeleteData(name, phonenumber);
            }
            else
            {
                AudienceDAO _audience = new AudienceDAO();
                _audience.DeleteData(name, phonenumber);
            }
            ShowData();
        }
Example #11
0
 public GuestBLL()
 {
     guestDAO = new GuestDAO();
     dt       = new DataTable();
 }
Example #12
0
 public IActionResult UpdateGuest(Guest guest)
 {
     GuestDAO.UpdateGuest(guest);
     return(Json(guest.GuestID));
 }