Exemple #1
0
        private void Delete_Click(object sender, EventArgs e)

        {
            var getID = (int)room_view_win.SelectedRows[0].Cells["id"].Value;
            var gotID = checkMeInDB.Bookings.FirstOrDefault(q => q.id == getID);

            DialogResult dr = MessageBox.Show("Are you sure you want to add this booking?", "update", MessageBoxButtons.YesNoCancel,
                                              MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                checkMeInDB.Bookings.Remove(gotID);

                checkMeInDB.SaveChanges();

                room_view_win.Refresh();
            }
        }
Exemple #2
0
        private void bookin_Click(object sender, EventArgs e)
        {
            string firstName    = F_Name.Text;
            string lastName     = L_Name.Text;
            var    checkInDate  = dateIn.Value;
            var    checkOutDate = dateOut.Value;
            var    room         = Select_room_CB.Text;
            string contact      = contact_tb.Text;
            string country      = countryTB.Text;
            string gender       = gendertb.Text;

            var newguest = new Guest();

            newguest.firstName    = firstName;
            newguest.lastName     = lastName;
            newguest.telephoneNum = contact;
            newguest.homeAddress  = country;
            newguest.gender       = gender;
            newguest.roomNum      = (int)Select_room_CB.SelectedValue;


            checkMeInDB.Guests.Add(newguest);
            checkMeInDB.SaveChanges();


            var savebooking = new Booking();

            savebooking.checkInDate  = checkInDate;
            savebooking.guest_FK     = newguest.id;
            savebooking.checkOutDate = checkOutDate;
            savebooking.rooms_FK     = newguest.roomNum;

            checkMeInDB.Bookings.Add(savebooking);
            checkMeInDB.SaveChanges();


            var isValid = true;

            if (String.IsNullOrEmpty(firstName))

            {
                isValid = false;
                MessageBox.Show("Please eneter a valid first name");
            }

            if (String.IsNullOrEmpty(lastName))
            {
                isValid = false;
                MessageBox.Show("Please eneter a valid last name");
            }

            if (checkInDate > checkOutDate)
            {
                isValid = false;
                MessageBox.Show("Please eneter a valid Date");
            }
            if (String.IsNullOrEmpty(gender))
            {
                isValid = false;
                MessageBox.Show("Please eneter your gender");
            }
            if (String.IsNullOrEmpty(country))
            {
                isValid = false;
                MessageBox.Show("Please eneter your country of origin");
            }
            if (String.IsNullOrEmpty(contact))
            {
                isValid = false;
                MessageBox.Show("Please eneter a contact number");
            }

            DialogResult dr = MessageBox.Show("Are you sure you want to add this booking?", "update", MessageBoxButtons.YesNoCancel,
                                              MessageBoxIcon.Warning);

            if (dr == DialogResult.Yes)
            {
                if (isValid == true)
                {
                    MessageBox.Show($" Congrats!! {firstName} {lastName}\n\r \n\r" +
                                    $"you have booked room {room}\n\r \n\r" +
                                    $"from {checkInDate}   to the   {checkOutDate}\n\r \n\r" +
                                    $"Thank you will see you there ");



                    this.Controls.Clear();
                }
            }
        }