public void GetBookingEdit() { // Arrange BookingController controller = new BookingController(); // Act ViewResult result = controller.Edit(1) as ViewResult; // Assert Assert.IsNotNull(result); }
private void SubmitButton_Click(object sender, EventArgs e) { DialogResult result = default(DialogResult); switch (myState) { case "add": currentBooking = PopulateBooking(); double newAmount = accountDB.newAmount(currentBooking.Date, currentBooking.EndDate); int index = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index].AmountDue += newAmount; bookingController.Add(currentBooking); bookingController.makeBooking(currentBooking.Date, currentBooking.EndDate, currentBooking.Room); setUpBookingListView(); guests = guestController.AllGuests; messageTextBox.Text = ""; FormDisplay("view"); break; case "edit": currentBooking = PopulateBooking(); int index1 = currentBooking.BookingRef; double oldAmt = accountDB.oldAmt(index1); int index2 = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index2].AmountDue -= oldAmt; if (accountDB.AllAccounts[index2].AmountDue < 0) { accountDB.AllAccounts[index2].AmountDue = 0; } newAmount = accountDB.newAmount(currentBooking.Date, currentBooking.EndDate); index = accountDB.FindIndex(currentBooking.Guest.GuestID); accountDB.AllAccounts[index].AmountDue += newAmount; bookingController.Edit(currentBooking); bookingController.makeBooking(currentBooking.Date, currentBooking.EndDate, currentBooking.Room); setUpBookingListView(); messageTextBox.Text = ""; FormDisplay("view"); break; } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Please Enter Your Credit Card Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (textBox1.TextLength < 16) { MessageBox.Show("Credit card number must contain 16 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (textBox1.TextLength > 16) { MessageBox.Show("Credit card number must contain 16 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } else if (testForNonNumeric.IsMatch(textBox1.Text)) { MessageBox.Show("Credit card number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); return; } if (comboBox1.SelectedIndex == -1) //Nothing selected { MessageBox.Show("Please enter credit card expiry date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } if (comboBox2.SelectedIndex == -1) //Nothing selected { MessageBox.Show("Please enter credit card expiry date", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox2.Focus(); return; } if (Convert.ToInt32(comboBox1.SelectedItem) < 10 && Convert.ToInt32(comboBox2.SelectedItem) == 15) { MessageBox.Show("Credit Card is expired", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); comboBox1.Focus(); return; } else if (textBox3.Text == "") { MessageBox.Show("Please Enter Your CVV Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (textBox3.TextLength < 3) { MessageBox.Show("CVV number must contain 3 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (textBox3.TextLength > 3) { MessageBox.Show("CVV number must contain 3 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else if (testForNonNumeric.IsMatch(textBox3.Text)) { MessageBox.Show("CVV number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox3.Focus(); return; } else { payment = PopulateObject(aBooking); aBooking.DepositPaid = "true"; bookingController.Edit(aBooking); paymentController.ADD(payment); MessageBox.Show("Your payment has been verified", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); ConfirmationForm cf = new ConfirmationForm(aGuest, aBooking); cf.StartPosition = FormStartPosition.CenterParent; cf.Show(); this.Hide(); } }
private void button3_Click(object sender, EventArgs e) { Booking b = new Booking(); b.BookingID = textBox2.Text; b.GuestID = textBox3.Text; b.RoomNumber = textBox4.Text; b.ReservationDate = textBox5.Text; b.StartDate = textBox6.Text; b.EndDate = textBox7.Text; b.NoOfGuests = textBox8.Text; b.Price = Convert.ToDecimal(textBox9.Text); b.DepositAmount = Convert.ToDecimal(textBox10.Text); b.DepositPaid = textBox11.Text; if (myState == thisFormState.Delete) { DialogResult result = MessageBox.Show("Are you sure you want to delete booking", "Delete guest", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); //populate the text boxes if (result == DialogResult.Yes) { //we must delete the guest tell them guest has been successfully deleted bookingController.Delete(b); MessageBox.Show("Booking has been succesfully deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } else { //reset the controls ShowTextFieldsAndLabels(false); ResetTextBoxes(); button3.Visible = false; ToggleSearchFunctionality(true); } } if (myState == thisFormState.Edit) { //validate that start date less than end date if (dateTimePicker1.Value.Date > dateTimePicker2.Value.Date) { MessageBox.Show("Start date value cannot be greater than end date value", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Collection <Room> avail = bookingController.CheckAvailability(dateTimePicker1.Value, dateTimePicker2.Value, roomController.AllRooms, b); //ensure that the booking is actually available if (avail.Count == 0) { MessageBox.Show("New Dates are unvailable", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { //set the room Number b.RoomNumber = avail[0].RoomNumber; //set the start date b.StartDate = dateTimePicker1.Value.ToShortDateString(); //set the end date b.EndDate = dateTimePicker2.Value.ToShortDateString(); //set the price b.Price = bookingController.CalculateBookingPrice(dateTimePicker1.Value, dateTimePicker2.Value, roomRateController.AllRoomRates); //set the deposit b.DepositAmount = (b.Price / 10); //set the deposit paid to false b.DepositPaid = "false"; //set number of guests b.NoOfGuests = comboBox1.Text; bookingController.Edit(b); MessageBox.Show("Your booking has been successfully changed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); return; } } }