private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { try { if (lvwAppoints.SelectedItems != null && lvwAppoints.SelectedItems.Count != 0) { if (!IsList) { if (objUIRights.DeleteRight) { DialogResult dr = new DialogResult(); dr = MessageBox.Show("Do You Really Want to Delete Record ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dr == DialogResult.Yes) { Appointment objAppoint = new Appointment(); objAppoint = AppointmentManager.GetItem(Convert.ToInt32(lvwAppoints.SelectedItems[0].Name)); AppointmentManager.Delete(objAppoint); lvwAppoints.Items.Remove(lvwAppoints.SelectedItems[0]); } } else { throw new Exception("Not Authorised."); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public async Task <IActionResult> Delete(Guid id, bool rollback = false) { try { return(Ok(await AppointmentManager.Delete(id, rollback))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public void DeleteTest() { var task = AppointmentManager.Load(); List <Appointment> appointments = task.Result; task.Wait(); Appointment appointment = appointments.FirstOrDefault(); var task2 = AppointmentManager.Delete(appointment.Id, true); int result = task2.Result; task2.Wait(); Assert.IsTrue(result > 0); }
public void DeleteAppointment() { if (dataGridViewAppointments.SelectedRows.Count > 0) { var ids = new List <int>(); foreach (DataGridViewRow row in dataGridViewAppointments.SelectedRows) { ids.Add(Convert.ToInt32(row.Cells[0].Value)); } var messageBoxResult = MessageBox.Show("Are you sure you want to delete?", "Confirm Delete.", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (messageBoxResult == DialogResult.Yes) { if (appointmentManager.Delete(ids.ToArray())) { MessageBox.Show("Deleted Succesfully"); FillDataGridViewAppointments(); } } } }