public void delete_staff(string idstaff) { DialogResult result = MessageBox.Show("Seguro que desea eliminar este registro?", "Eliminar registro", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { try { AddPatient frm = new AddPatient(); string comando = "DELETE FROM staff WHERE idstaff = '" + idstaff + "'"; SqlCommand insertion = new SqlCommand(comando, cnx); if (insertion.ExecuteNonQuery() > 0) { MessageBox.Show("Se ha Borrado correctamente", "Hecho"); frm.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } } else if (result == DialogResult.No) { } }
public void update_patient(String idpatient, String namepatient, String bdaypatient, String sexpatient, String idperson, String addresspatient, String telpatient, String celpatient, String tworkpatient, String insurancepatient, String affiliatepatient) { try { DialogResult result = MessageBox.Show("Seguro que desea Actualizar?", "Actualizar datos del Paciente", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { AddPatient frm = new AddPatient(); string comando = "UPDATE patient set name = '" + namepatient + "', sex = '" + sexpatient + "', bday = '" + bdaypatient + "', idperson = '" + idperson + "', address = '" + addresspatient + "', tel = '" + telpatient + "', cel = '" + celpatient + "', telwork = '" + tworkpatient + "', insurance = '" + insurancepatient + "', affiliate = '" + affiliatepatient + "' WHERE idpatient = '" + idpatient + "'"; SqlCommand insertion = new SqlCommand(comando, cnx); if (insertion.ExecuteNonQuery() > 0) { MessageBox.Show("Se ha actualizado correctamente", "Hecho"); frm.Close(); } } else if (result == DialogResult.No) { } } catch (Exception ex) { MessageBox.Show("No se llego a actualizar. Causa: " + ex.Message); } }