Ejemplo n.º 1
0
        private void createReservationBtn_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime startDate    = checkInDate.Value;
                DateTime endDate      = checkOutDate.Value;
                string   firstName    = firstNameBox.Text;
                string   lastName     = lastNameBox.Text;
                string   emailAddress = emailBox.Text;
                string   creditCard   = customerCCBox.Text;
                string   reservationID;

                decimal payment = DatabaseManager.addReservation(startDate, endDate, firstName, lastName, emailAddress, creditCard, out reservationID);

                if (payment > 0)
                {
                    makePaymentForm paymentForm = new makePaymentForm(reservationID, payment);
                    paymentForm.ShowDialog();
                }
                MessageBox.Show("Reservation Created Successfully");

                firstNameBox.Text  = "";
                lastNameBox.Text   = "";
                checkInDate.Text   = "";
                checkOutDate.Text  = "";
                emailBox.Text      = "";
                customerCCBox.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void updateReservationBtn_Click(object sender, EventArgs e)
        {
            if (reservationDataGrid.SelectedRows.Count <= 0)
            {
                return;
            }

            int       row = (int)reservationDataGrid.SelectedRows[0].Index;
            DataTable tbl = (DataTable)reservationDataGrid.DataSource;

            if (row < 0 || row >= tbl.Rows.Count)
            {
                return;
            }

            string reservationId = tbl.Rows[row].ItemArray[0].ToString();

            try
            {
                DateTime startDate = changeCheckIn.Value;
                DateTime endDate   = changeCheckOut.Value;
                string   firstName = changeFirstBox.Text;
                string   lastName  = changeLastBox.Text;
                string   email     = changeEmailBox.Text;

                decimal payment = DatabaseManager.changeReservation(reservationId, startDate, endDate, firstName, lastName, email);

                if (payment > 0)
                {
                    makePaymentForm make = new makePaymentForm(reservationId, payment);
                    make.ShowDialog();
                }

                MessageBox.Show("Change Reservation Successful");


                string   guestName      = guestNameBox.Text;
                DateTime initialDateVal = filterStartDateBtn.Value;
                DateTime endDateVal     = filterEndDateBtn.Value;
                reservationDataGrid.DataSource = DatabaseManager.findReservation(guestName, initialDateVal, endDateVal);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }