private void New1() { mvtSysteme = new clsmouvementsysteme(); bln1 = false; bindingcls1(); if (cboTypeSystem.Items.Count > 0) { cboTypeSystem.SelectedIndex = 0; } txtIdCPN.Text = clsDoTraitement.IdConsultationPreNatal.ToString(); }
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(); }
private void btnDelete1_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("Voulez - vous vraiment supprimer cet enregistrement ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (bsrc.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().delete(s); MessageBox.Show("Suppression éffectuée", "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Information); this.New1(); refresh1(); } } } catch (Exception ex) { MessageBox.Show("Echec de la suppression " + ex.Message, "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }