Untitled
unknown
plain_text
a year ago
2.3 kB
5
Indexable
using System; using System.Windows.Forms; namespace Final_Exam_Carillo { public partial class Update : Form { private BookingManager bookingManager; private int bookingId; public Update(int bookingId, BookingManager bookingManager) { InitializeComponent(); this.bookingManager = bookingManager; this.bookingId = bookingId; LoadBookingDetails(); this.CenterToScreen(); } private void LoadBookingDetails() { Booking booking = bookingManager.GetBookingById(bookingId); if (booking != null) { txtCustomerName.Text = booking.CustomerName; txtPhoneNumber.Text = booking.PhoneNumber; txtEventName.Text = booking.EventName; dateTimePicker1.Value = booking.Date; dateTimePicker2.Value = DateTime.Today.Add(booking.Time); // TimeSpan to DateTime comboBoxStatus.Text = booking.Status; txtPreference.Text = booking.Preferences; } else { MessageBox.Show("Booking not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } private void btnSave_Click(object sender, EventArgs e) { Booking updatedBooking = new Booking { BookingID = bookingId, CustomerName = txtCustomerName.Text, PhoneNumber = txtPhoneNumber.Text, EventName = txtEventName.Text, Date = dateTimePicker1.Value, Time = dateTimePicker2.Value.TimeOfDay, Status = comboBoxStatus.Text, Preferences = txtPreference.Text }; bookingManager.UpdateBooking(bookingId, updatedBooking); MessageBox.Show("Booking updated successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }
Editor is loading...
Leave a Comment