public static List <Surveillances> ConvertDatatableToListSurveillance(DataTable CurrentDataTable) { List <Surveillances> ListSurv = new List <Surveillances>(); Dal_Surveillance MyDalSurv = new Dal_Surveillance(); foreach (DataRow Row in CurrentDataTable.Rows) { ListSurv.Add(MyDalSurv.ConvertRowToSurveillances(Row)); } return(ListSurv); }
private void Btn_Enregistrer_Click(object sender, EventArgs e) { if (CurrentListSurv != null && CurrentListSurv.Count > 0) { //MessageBox.Show("A=Count " + CurrentListSurv.Count + " id : " + CurrentEns.PropId); Dal_Surveillance MyDal = new Dal_Surveillance(); MyDal.DeleteSurveillances(CurrentEns.PropId); foreach (Surveillances Row in CurrentListSurv) { if (Row != null) { MyDal.AddSurveillances(Row); } } if (CurrentEns != null) { CurrentEns.PropStatut = CbEtat.SelectedItem.ToString().ToLower().Trim(); new Dal_Enseignant().UpdateEnseignant(CurrentEns.PropEmail, CurrentEns); CurrentDataTableEnseignantInit = null; HasLoad = false; Surveillance_Load(null, null); } MessageBox.Show("Programme mis à jour !"); } else if (CurrentListSurvInit != null && CurrentListSurvInit.Count > 0) { Dal_Surveillance MyDal = new Dal_Surveillance(); MyDal.DeleteSurveillances(CurrentEns.PropId); if (CurrentEns != null) { CurrentEns.PropStatut = CbEtat.SelectedItem.ToString().ToLower().Trim(); new Dal_Enseignant().UpdateEnseignant(CurrentEns.PropEmail, CurrentEns); CurrentDataTableEnseignantInit = null; CurrentListSurvInit = null; Surveillance_Load(null, null); } MessageBox.Show("Programme mis à jour !"); } else { MessageBox.Show("Ajouter des programmes"); } IsUpdated = false; }