private void btnSave1_Click(object sender, EventArgs e) { try { if (!bln1) { mvtSysteme.inserts(); MessageBox.Show("Enregistrement éffectué", "Enregistrement", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (bsrc1.DataSource != null) { clsmouvementsysteme s = new clsmouvementsysteme(); Object[] obj = ((DataRowView)bsrc.Current).Row.ItemArray; int i = 0; foreach (DataColumn dtc in ((DataRowView)bsrc.Current).Row.Table.Columns) { if (dtc.ToString().Equals("commentaire")) { s.Commentaire = ((string)obj[i]); } else if (dtc.ToString().Equals("id_consultationPrenatal")) { s.Id_consultationprenatal = ((int)obj[i]); } else if (dtc.ToString().Equals("id_typeSysteme")) { s.Id_typesysteme = ((int)obj[i]); } else if (dtc.ToString().Equals("id")) { s.Id = ((int)obj[i]); } i++; } new clsmouvementsysteme().update(s); MessageBox.Show("Modification effectuée!", "Modification", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("Echec de la mise à jour" + ex.Message, "Mise à jour", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.New1(); refresh1(); }