private void DeleteAppointment(int id) { string[] message = { "Are you sure want to delete appointment " + id + " from the database?", "¿Estás seguro que quieres borrar la cita " + id + " del database?" }; string[] title = { "Warning", "Aviso" }; if (MessageBox.Show(message[Global.Language], title[Global.Language], MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { Appointments.Remove(Appointments.GetAppointmentBy(a => a.ID == id)); ResponseLabel.Text = _responsesArray[Convert.ToInt32(Responses.DELETE_APPOINTMENT), Global.Language] + Convert.ToString(id); ToggleDashboard(); } else { ToggleDashboard(); } }
private void AppointmentInspector_Load(object sender, EventArgs e) { if (_isUpdate) { Appointment appointment = Appointments.GetAppointmentBy(a => a.ID == _appointmentID); AppointmentIDField.Text = Convert.ToString(appointment.ID); CustomerDropList.DataSource = Customers.AllCustomersList; CustomerDropList.ValueMember = "ID"; CustomerDropList.DisplayMember = "Name"; CustomerDropList.SelectedItem = appointment.Customer; UserDropList.DataSource = Users.AllUserLists; UserDropList.ValueMember = "ID"; UserDropList.DisplayMember = "Name"; UserDropList.SelectedItem = appointment.User; TitleField.Text = appointment.Title; DescriptionField.Text = appointment.Description; URLField.Text = appointment.URL; ContactField.Text = appointment.Contact; TypeDropList.DataSource = Appointments.TypeArray; TypeDropList.SelectedIndex = Array.IndexOf(Appointments.TypeArray, appointment.Type); LocationDropList.DataSource = Appointments.LocationArray; LocationDropList.SelectedIndex = Array.IndexOf(Appointments.LocationArray, appointment.Location); StartDatePicker.Value = appointment.StartDate; StartTimePicker.Value = appointment.StartDate; EndDatePicker.Value = appointment.EndDate; EndTimePicker.Value = appointment.EndDate; DateCreatedField.Text = appointment.CreateDate.Date.ToString("MM/dd/yyyy");; CreatedByField.Text = appointment.CreateBy.Name; DateUpdatedField.Text = appointment.UpdateTimestamp.ToString("MM/dd/yyyy HH:mm:ss"); UpdatedByField.Text = appointment.UpdateBy.Name; } else { CustomerDropList.DataSource = Customers.AllCustomersList; CustomerDropList.ValueMember = "ID"; CustomerDropList.DisplayMember = "Name"; CustomerDropList.SelectedIndex = 0; UserDropList.DataSource = Users.AllUserLists; UserDropList.ValueMember = "ID"; UserDropList.DisplayMember = "Name"; UserDropList.SelectedItem = Users.CurrentUser; ContactField.Text = Customers.GetCustomerBy(c => c.ID == Convert.ToInt32(CustomerDropList.SelectedValue)).Address.Phone; TypeDropList.DataSource = Appointments.TypeArray; TypeDropList.SelectedIndex = 0; LocationDropList.DataSource = Appointments.LocationArray; LocationDropList.SelectedIndex = 0; StartDatePicker.Value = ToNext30(DateTime.Now); StartTimePicker.Value = ToNext30(DateTime.Now); DateCreatedField.Visible = false; DateCreatedLabel.Visible = false; CreatedByField.Visible = false; CreatedByLabel.Visible = false; DateUpdatedField.Visible = false; DateUpdatedLabel.Visible = false; UpdatedByField.Visible = false; UpdatedByLabel.Visible = false; } CustomerDropList.SelectedIndexChanged += CustomerDropList_SelectedIndexChanged; ToggleOkButton(); }