private void btnDeleteVeterinarian_Click(object sender, EventArgs e) { DataRow deleteVeterinarianRow = DM.dtVeterinarian.Rows[currencyManager.Position]; DataRow[] VisitRow = DM.dtVisit.Select("VeterinarianID = " + lblVeterinarianID.Text); if (VisitRow.Length != 0) { MessageBox.Show("You may only delete Veterinarians who do not have visits", "Error"); } else { if (MessageBox.Show("Are you sure you want to delete this record?", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK) { deleteVeterinarianRow.Delete(); DM.UpdateVeterinarian(); } } return; }
private void btnAddVeterinarian_Click(object sender, EventArgs e) { //Create a new row that the variables will be added into DataRow newVeterinarianRow = DM.dtVeterinarian.NewRow(); //If any of the text areas are empty then do not write data and return if ((txtLastName.Text == "") || (txtFirstName.Text == "") || (txtRate.Text) == "") { MessageBox.Show("You must enter a value for each of the text fields", "Error"); } else { newVeterinarianRow["LastName"] = txtLastName.Text; newVeterinarianRow["FirstName"] = txtFirstName.Text; newVeterinarianRow["Rate"] = Convert.ToDouble(txtRate.Text); //Add the new row to the Table DM.dtVeterinarian.Rows.Add(newVeterinarianRow); DM.UpdateVeterinarian(); //Give the user a success message MessageBox.Show("Veterinarian added succesfully", "Success"); } }