private void btnSave_Click(object sender, EventArgs e) { try { switch (btnSave.Text) { case "Enregistrer": if (fx.Question(1) == true) { ex.Id = fx.ValidateName(id); ex.Resultat = fx.ValidateName(symptome.Text); ex.IdAgent = fx.ValidateName(idagent.Text); ex.IdPatient = pro.IdCombo("Liste_patient", patient.Text, "Noms"); ex.Idtarif = fx.ValidateName(pro.IdCombo("Tarif", tarif.Text, "Designation")); ex.IdConsultation = fx.ValidateName(pro.IdCombo__("select Id from liste_consultation where id is not null and symptome ='" + symptome.Text + "' and patient='" + patient.Text + "'")); if (ex.Enregistrer() == true) { fx.Message(1); Actualiser(); } } break; case "Modifier": if (fx.Question(2) == true) { ex.Id = fx.ValidateName(id); ex.Resultat = fx.ValidateName(symptome.Text); ex.IdAgent = fx.ValidateName(idagent.Text); ex.IdPatient = pro.IdCombo("Liste_patient", patient.Text, "Noms"); ex.Idtarif = fx.ValidateName(pro.IdCombo("Tarif", tarif.Text, "Designation")); ex.IdConsultation = fx.ValidateName(pro.IdCombo__("select Id from liste_consultation where id is not null and symptome ='" + symptome.Text + "' and patient='" + patient.Text + "'")); if (ex.Enregistrer() == true) { fx.Message(2); Actualiser(); } } break; } } catch (InvalidOperationException ex) { MessageBox.Show("Error when loading datas, " + ex.Message, "Loading datas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (System.Data.SqlClient.SqlException ex) { MessageBox.Show("Error when loading datas, " + ex.Message, "Loading datas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (ImplementeConnexion.Instance.Conn != null) { if (ImplementeConnexion.Instance.Conn.State == System.Data.ConnectionState.Open) { ImplementeConnexion.Instance.Conn.Close(); } } } }