public void UpdateOne(Cours cours) { TPDataBaseEntities context = new TPDataBaseEntities(); Cours dbCours = context.Cours.Find(cours.Id); dbCours.Libelle = cours.Libelle; context.SaveChanges(); }
public void AddCours(Etudiants etudiant, Cours cour) { TPDataBaseEntities context = new TPDataBaseEntities(); EtudiantsCours etudiantcours = new EtudiantsCours(); etudiantcours.Cours = context.Cours.Find(cour.Id); etudiantcours.Etudiants = context.Etudiants.Find(etudiant.Id); context.EtudiantsCours.Add(etudiantcours); context.SaveChanges(); }
public async Task<string> makeOperationAsync(AllowedOperations op, Cours reqCours = null, int resID = -1) { if (ApplicationModel.Current.IsConnected) { if (!isExpired || (await getSessionCookieAsync())) { CallbackArgs args = null; switch (op) { case AllowedOperations.getSingleAnnounce: if (reqCours == null && resID < 0) { return ""; } args = new CallbackArgs() { cidReq = reqCours, resId = resID, operation = op }; break; case AllowedOperations.getCourseToolList: case AllowedOperations.getDocList: case AllowedOperations.getAnnounceList: if (reqCours == null) { return ""; } args = new CallbackArgs() { cidReq = reqCours, operation = op }; break; case AllowedOperations.getUserData: case AllowedOperations.getCourseList: case AllowedOperations.getUpdates: args = new CallbackArgs() { operation = op }; break; } HttpResponseMessage response = null; HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, ApplicationModel.Current.Domain + ApplicationModel.Current.WebServicePath); StringContent content = new StringContent(args.ToString()); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded"); message.Content = content; HttpClient request = getClient(); response = await request.SendAsync(message); String result = await response.Content.ReadAsStringAsync(); Debug.WriteLine("Fin de la méthode " + op.ToString() + " : " + result); return result; } } //TODO tell the user the network is unavailable return ""; }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cours cours = db.Courses.Find(id); if (cours == null) { return(HttpNotFound()); } return(View(cours)); }
public override bool Equals(object obj) { if (!(obj is Cours)) { return(false); } Cours cours = (Cours)obj; return(cours.NumeroCours == this.NumeroCours && cours.TitreCours == this.TitreCours && cours.CodeCours == this.CodeCours); }
public async Task <ActionResult> Delete(Cours c) { CourseBL courseBL = new CourseBL(); string userData = JsonConvert.SerializeObject(c.CourseID); string result = await courseBL.DeleteC(c.CourseID); if (result == "true") { string courses = await courseBL.GetCourses(); List <Cours> userList = JsonConvert.DeserializeObject <List <Cours> >(courses); return(View("Index", userList)); } return(View()); }
/// <summary> /// Update function /// Will simple update anything as long as the name stays the same. /// </summary> /// <param name="NomCours"></param> /// <returns></returns> public ActionResult Update(String NomCours) { Cours model = context.Cours.Where(x => x.Nom == NomCours).Select(x => new Cours() { Nom = x.Nom, Description = x.Description, Prerequis = x.Prerequis, NbModules = x.NbModules, Content = x.Content }).SingleOrDefault(); return(View(model)); }
// GET: Cours/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cours cours = await db.Courses.FindAsync(id); if (cours == null) { return(HttpNotFound()); } ViewBag.DoctorId = new SelectList(db.Doctors, "DoctorID", "DoctorName", cours.DoctorId); return(View(cours)); }
protected void AddButton_Click(object sender, EventArgs e) { Cours Cours = new Cours(); DBContext dB = new DBContext(); var elmId = dB.Professors.Where(b => b.Nom == Proff.SelectedValue).FirstOrDefault(); Cours.Nom = NomCours.Text; Cours.Module = NomModule.Text; Cours.Description = Descr.Text; Cours.IdProfessor = elmId.Id; dB.Cours.Add(Cours); dB.SaveChanges(); Response.Redirect("/Cours.aspx"); }
public static List<Cours> listeCours(Formation pF) { SqlConnection connexion = ConnexionSQL.CreationConnexion(); SqlCommand cmd = new SqlCommand(SELECT_COURS, connexion); List<Cours> listeCours = new List<Cours>(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Cours c = new Cours(); c.IdCours = reader.GetInt32(reader.GetOrdinal("IdCours")); c.LibelleCours = reader.GetString(reader.GetOrdinal("LibelleCours")); listeCours.Add(c); } connexion.Close(); return listeCours; }
public IHttpActionResult Post(CoursesRequestModel course) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } var dbCourse = new Cours { Name = course.Name, Description = course.Description, Materials = course.Materials }; this.courseRepository.InsertCourse(dbCourse); this.courseRepository.Save(); return this.Ok(course); }
public bool ExistCours(Etudiants etudiant, Cours cour) { TPDataBaseEntities context = new TPDataBaseEntities(); EtudiantsCours etudiantcours = new EtudiantsCours(); etudiantcours.Cours = context.Cours.Find(cour.Id); etudiantcours.Etudiants = context.Etudiants.Find(etudiant.Id); // Vérifie si l'association Etudiant/Cours existe déjà List<EtudiantsCours> listeetudiantcours = context.EtudiantsCours.Where(ec => (ec.FK_Cours == etudiantcours.Cours.Id) && (ec.FK_Etudiants == etudiantcours.Etudiants.Id) ).ToList(); return (listeetudiantcours != null && listeetudiantcours.Count > 0); // OU UTILISATION DU ANY AVEC LINQ => PLUS DIRECT //return context.EtudiantsCours.Any(ec => (ec.FK_Cours == etudiantcours.Cour.Id) // && (ec.FK_Etudiants == etudiantcours.Etudiant.Id) // ); }
public ActionResult Create(Cours NouvCours) { try { if (ModelState.IsValid) { if (NouvCours.DateDebut.CompareTo(NouvCours.DateFin) < 0) { DB.Cours.Add(NouvCours); DB.SaveChanges(); return RedirectToAction("Index"); } else { ViewBag.Matieres = (from m in DB.Matieres select m).ToList().Select(c => new SelectListItem { Value = c.MatiereId.ToString(), Text = c.Titre }); var teachers = (from e in DB.Enseignants select e).ToList().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Prenom + " " + c.Nom }); ViewBag.Teachers = teachers; ModelState.AddModelError("", GestionEcole.Resources.Views.Cours.Index.ErrorDate); return View(NouvCours); } } else { return View(); } } catch { return View(); } }
public ActionResult Create(Cours NouvCours) { try { if (ModelState.IsValid) { DB.Cours.Add(NouvCours); DB.SaveChanges(); return RedirectToAction("Index"); } else { return View(); } } catch { return View(); } }
public override void LoadCollectionsFromDatabase() { base.LoadCollectionsFromDatabase(); if (DesignerProperties.IsInDesignTool) { Cours c1 = new Cours() { title = "Design Cours 1", titular = "Design Titular 1", officialCode = "Design Code 1" }; allCours.Add(c1); allCours.Add(new Cours() { title = "Design Cours 2", titular = "Design Titular 2", officialCode = "Design Code 2" }); allCours.Add(new Cours() { title = "Design Cours 3", titular = "Design Titular 3", officialCode = "Design Code 3" }); allCours.Add(new Cours() { title = "Design Cours 4", titular = "Design Titular 4", officialCode = "Design Code 4" }); topNotifications.Add(new Notification() { resource = new ResourceModel() { title = "Design Resource 1", date = DateTime.Now }, date = DateTime.Now }); } else { allCours = new ObservableCollection<Cours>(from Cours c in ClarolineDB.Cours_Table select c); RaisePropertyChanged("topNotifications"); } }
public void ClearNotifsOfCours(Cours coursToClear) { foreach (CL_Notification currentNot in _notifByCours[coursToClear.sysCode]) { if (!currentNot.updated) DeleteNotification(currentNot); else currentNot.updated = false; } }
// NE PAS UTILISER LE CONTEXT EN STATIC CAR RISQUE D'ECRASEMENT MULTI-SESSIONS UTILISATEURS public void CreateOne(Cours cours) { TPDataBaseEntities context = new TPDataBaseEntities(); context.Cours.Add(cours); context.SaveChanges(); }
public CoursPageVM(ISettings settings, string sysCode) : base(settings) { if (IsInDesignMode) { currentCours = new Cours() { officialCode = "DESIGN", sysCode = "DESIGN", title = "Design test" }; ResourceList l1 = new ResourceList() { Cours = currentCours, name = "Resource L1", label = "CLANN", ressourceType = typeof(Annonce) }; ResourceList l2 = new ResourceList() { Cours = currentCours, name = "Resource L2", label = "CLDOC", ressourceType = typeof(Document) }; ResourceList l3 = new ResourceList() { Cours = currentCours, name = "Resource L3", label = "CLDSC", ressourceType = typeof(Description) }; ResourceList l4 = new ResourceList() { Cours = currentCours, name = "Resource L4", label = "CLCAL", ressourceType = typeof(Event) }; ResourceList l5 = new ResourceList() { Cours = currentCours, name = "Resource L5", label = "CLFRM", ressourceType = typeof(Forum) }; currentCours.Resources.Add(l5); _resources = new ObservableCollection<ResourceList>(); _resources.Add(l5); _resources.Add(PivotMenu); currentCours.Resources.Add(new ResourceList() { Cours = currentCours, name = "L4", label = "L4" }); l1.Resources.Add(new Annonce() { title = "Annonce 1", content = "Contenu 1 Contenu 1 v Contenu 1 Contenu 1 Contenu 1 v Contenu 1", date = DateTime.Now }); l1.Resources.Add(new Annonce() { title = "Annonce 2 Annonce 2 Annonce 2", content = "Contenu 2", date = DateTime.Now }); l1.Resources.Add(new Annonce() { title = "Annonce 3", content = "Contenu 3", date = DateTime.Now }); l1.Resources.Add(new Annonce() { title = "Annonce 4", content = "Contenu 4", date = DateTime.Now }); l3.Resources.Add(new Description() { title = "Annonce 1", content = "Contenu 1", date = DateTime.Now }); l4.Resources.Add(new Event() { title = "Event 1", content = "Contenu 1", date = DateTime.Now, speakers = "Mr Nobody, Someone else" }); l4.Resources.Add(new Event() { title = "Event 2", content = "Contenu 1", date = DateTime.Now, location = "This is a very very very very veyr vey long location" }); l4.Resources.Add(new Event() { title = "Event 3", content = "Contenu 1", date = DateTime.Now, location = "B543", speakers = "Mr Nobody, Someone else" }); l5.Resources.Add(new Forum() { title = "Forum 1", ForumDescription = "ForumDescription 1", CategoryId = 1, CategoryName = "Cat 1", CategoryRank = 1, Rank = 2 }); l5.Resources.Add(new Forum() { title = "Forum 2", ForumDescription = "ForumDescription 2", CategoryId = 1, CategoryName = "Cat 1", CategoryRank = 1, Rank = 1 }); l5.Resources.Add(new Forum() { title = "Forum 3", ForumDescription = "ForumDescription 3", CategoryId = 2, CategoryName = "Cat 2", CategoryRank = 2, Rank = 3 }); l5.Resources.Add(new Forum() { title = "Forum 4", ForumDescription = "ForumDescription 4", CategoryId = 2, CategoryName = "Cat 2", CategoryRank = 2, Rank = 0 }); } else { currentCours = (from Cours c in ClarolineDB.Cours_Table where c.sysCode.Equals(sysCode) select c).FirstOrDefault(); LoadCollectionsFromDatabase(); if (!currentCours.loadedToday() || currentCours.Resources.Count == 0) { PrepareCoursForOpeningAsync(currentCours); } } }
public void UpdateCourse(Cours course) { this.db.Entry(course).State = EntityState.Modified; }
public async Task<Cours> PrepareCoursForOpeningAsync(Cours coursToPrepare) { bool r = await GetResourcesListForThisCoursAsync(coursToPrepare); if (r) { foreach (ResourceList rl in (from ResourceList l in ClarolineDB.ResourceList_Table where l.Cours.Equals(coursToPrepare) select l)) { if (Enum.IsDefined(typeof(SupportedModules), rl.GetSupportedModule())) { await GetResourcesForThisListAsync(rl); } } ClearResOfCours(coursToPrepare); using (ClarolineDataContext cdc = new ClarolineDataContext(ClarolineDataContext.DBConnectionString)) { coursToPrepare = (from Cours c in cdc.Cours_Table where c.Equals(coursToPrepare) select c).Single(); coursToPrepare.loaded = DateTime.Now; int count = coursToPrepare.Resources.Count; cdc.SubmitChanges(); } } return coursToPrepare; }
public void ClearResOfCours(Cours coursToClear) { using (ClarolineDataContext cdc = new ClarolineDataContext(ClarolineDataContext.DBConnectionString)) { (from ResourceModel rm in cdc.Resources_Table where rm.ResourceList.Cours.Equals(coursToClear) select rm).ToList() .ForEach(rm => { if (rm.updated) { rm.updated = false; } else { DeleteResource(rm); } }); cdc.SubmitChanges(); } }
public void AddToCourses(Cours cours) { base.AddObject("Courses", cours); }
private void PushIntoDB(string[][] result, String type) { iCampusViewModel VM = App.ViewModel; Cours coursToUpdate; switch (type) { #region CASE COURS case "Cours": foreach (string[] array in result) { Cours toPushC = new Cours { sysCode = array[0], title = array[1], titular = array[3], notified = (array[4] == "hot") }; VM.AddCours(toPushC); } VM.ClearCoursList(); if (RefreshAll) { RefreshAll = false; Connect cx = new Connect(); foreach (Cours item in VM.AllCours) { //cx.Sync(item.url); } } break; #endregion #region CASE SECTION case "Section": coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][4] select _cours).First(); foreach (string[] array in result) { switch (array[0]) { case "Documents et liens": Connect cx = new Connect(); coursToUpdate.isDnL = true; coursToUpdate.dnlNotif = (array[4] == "hot"); cx.Sync(array[1].Replace("&","&")); break; case "Annonces": coursToUpdate.isAnn = true; coursToUpdate.annNotif = (array[4] == "hot"); (new Connect()).Sync(array[1].Replace("&", "&")); break; default: break; } } //VM.AddCours(coursToUpdate); break; #endregion #region CASE DOC case "Docs": coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][7] select _cours).First(); foreach (string[] array in result) { string[] name = array[0].Split('.'); Documents toPush = new Documents() { url = array[1], Description = array[5], notified = (array[6] == "hot"), Cours = coursToUpdate }; switch (array[2]) { case "document": //Dossier toPush.path = array[0].Trim(); toPush.IsFolder = true; toPush.date = DateTime.Today; (new Connect()).Sync(array[1].Replace("&", "&")); break; case "backends": //Fichier string[] date = array[4].Split('.'); string[] partialSize = array[3].Replace(" ", " ").Replace('.', ',').Split(' '); switch (partialSize[1]) { case "Ko": partialSize[1] = "E+3"; break; case "Mo": partialSize[1] = "E+6"; break; case "Go": partialSize[1] = "E+9"; break; default: partialSize[1] = ""; break; } if (name.Length > 2) { for (int i = 1; i < name.Length - 1; i++) { name[0] += " "+name[i]; } } toPush.path = name[0].Trim(); toPush.IsFolder = false; toPush.Extension = name.Last().Trim(); toPush.size = Double.Parse(partialSize[0] + partialSize[1]); toPush.date = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0])); break; default: break; } if (array[8] != null) { toPush.RootFolder = (from Documents _root in VM.AllFolders where _root.path == result[0][8] select _root).First(); toPush.IsRoot = false; } else { toPush.IsRoot = true; } //Debug.WriteLine("Adding Document" + toPush.Name + "\r" + toPush.IsRoot); VM.AddDocument(toPush); } //VM.AddCours(coursToUpdate); break; #endregion #region CASE ANNONCE case "Annonces": coursToUpdate = (from Cours _cours in VM.AllCours where _cours.sysCode == result[0][4] select _cours).First(); foreach (string[] array in result) { Annonce AnnToPush = new Annonce() { title = array[0], content = array[1], notified = (array[3] == "hot"), Cours = coursToUpdate, date = DateTime.Parse(array[2]) }; //Debug.WriteLine("Adding "+ AnnToPush.title +" to DB (depend of " + AnnToPush.Cours.sysCode); VM.AddAnnonce(AnnToPush); } VM.ClearAnnsOfCours(coursToUpdate); break; #endregion default: break; } }
public override void DeleteCours(Cours coursForDelete) { base.DeleteCours(coursForDelete); allCours.Remove(coursForDelete); RaisePropertyChanged("topNotifications"); }
public override void AddCours(Cours newCours) { base.AddCours(newCours); if (!allCours.Contains(newCours)) { allCours.Add(newCours); } RaisePropertyChanged("topNotifications"); }
public virtual void AddCours(Cours newCours) { ClarolineDataContext cdc = ClarolineDB; //using (ClarolineDataContext cdc = new ClarolineDataContext(ClarolineDataContext.DBConnectionString)) //{ var q = cdc.Cours_Table.Where(c => c.sysCode == newCours.sysCode); newCours.updated = true; newCours.loaded = DateTime.Now; if (!q.Any()) { cdc.Cours_Table.InsertOnSubmit(newCours); cdc.SubmitChanges(); cdc.Refresh(RefreshMode.OverwriteCurrentValues, newCours); } else { q.First().UpdateFrom(newCours); newCours.Id = q.First().Id; cdc.SubmitChanges(); } //} }
public virtual void DeleteCours(Cours coursForDelete) { ClarolineDB.Cours_Table.DeleteOnSubmit(coursForDelete); SaveChangesToDB(); }
private List<BlocHoraire> GetBlocsHoraire(Cours cours) { //Document XML contenant les infos sur les blocs d'heures des cours XmlDocument xml = new XmlDocument(); var path = System.IO.Directory.GetCurrentDirectory() + "\\cours.xml"; xml.Load(path); //xml.Load(@"C:\Users\mvezina\Documents\Visual Studio 2013\Projects\TacheApp\cours.xml"); XmlNodeList coursInfo = null; List<BlocHoraire> blocs = new List<BlocHoraire>(); if (cours.NoGroupe != null) { //On obtien le noeud correspondant au cours dans le fichiers XML des cours du programme coursInfo = xml.SelectNodes("/programme/cours[@numero='" + cours.Numero + "']"); string groupe = Regex.Match(cours.NoGroupe.Replace("0", ""), @"\d+").Value; if (coursInfo.Count > 0) { foreach (XmlNode xmlCours in coursInfo) { //On créer un noeud pour chaque bloc d'heures du cours foreach (XmlNode xmlBloc in xmlCours.ChildNodes) { blocs.Add(new BlocHoraire { NbHeures = int.Parse(xmlBloc.InnerText) }); } } } } return blocs; }
public void ClearNotifsOfCours(Cours coursToClear, int keeped) { (from Notification n in ClarolineDB.Notifications_Table where n.Cours.Equals(coursToClear) orderby n.date descending select n).Skip(keeped).ToList() .ForEach(n => DeleteNotification(n)); }
private void AfficherBlocHoraire(List<object> oTagInfo, String prof, Cours cours, BlocHoraire bloc) { Debug.Assert(bloc.EstAffecte); //On conserve seuelement les lettres majuscules pour identitfier le prof. prof = String.Concat(prof.Select(c => char.IsUpper(c) ? c.ToString() : String.Empty)); //On enlève les 0 et les lettres du numéro du groupe. string groupe = "Gr " + Regex.Match(cours.NoGroupe.Replace("0", ""), @"\d+").Value; //On conserve seulement une partie du numéro du cours String numero = cours.Numero.Remove(0, 4).Remove(3, 3); TableLayoutPanelCellPosition pos = CalculerPosition(bloc); // Affichage du Label System.Windows.Forms.Label lblCours = new System.Windows.Forms.Label(); lblCours.Text = numero + "\n" + prof + "\n" + groupe; lblCours.Anchor = AnchorStyles.Left; lblCours.Margin = new Padding(0); lblCours.AutoSize = false; lblCours.BackColor = GetCouleurFromNumCours(numero); lblCours.Width = tableLayoutPanel1.GetColumnWidths()[pos.Column]; lblCours.Height = tableLayoutPanel1.GetRowHeights()[pos.Row] * bloc.NbHeures; lblCours.ContextMenuStrip = this.contextMenuStrip1; lblCours.MouseDown += new System.Windows.Forms.MouseEventHandler(this.coursLabel_MouseDown); lblCours.AllowDrop = true; lblCours.Tag = oTagInfo; this.tableLayoutPanel1.Controls.Add(lblCours, pos.Column, pos.Row); this.tableLayoutPanel1.SetRowSpan(lblCours, bloc.NbHeures); }
public async Task<bool> GetResourcesListForThisCoursAsync(Cours cours) { IsLoading = false; _lastClientCall = DateTime.Now; String strContent = await ViewModelLocator.Client.MakeOperationAsync(SupportedModules.USER, SupportedMethods.GetToolList, cours.sysCode); if (strContent != "") { List<ResourceList> rl = JsonConvert.DeserializeObject<List<ResourceList>>(strContent); foreach (ResourceList item in rl) { switch (item.label) { case Annonce.Label: item.ressourceType = typeof(Annonce); break; case Document.Label: item.ressourceType = typeof(Document); break; case Description.Label: item.ressourceType = typeof(Description); break; case Event.Label: item.ressourceType = typeof(Event); break; case Forum.Label: item.ressourceType = typeof(Forum); break; default: item.ressourceType = typeof(ResourceModel); break; } AddResourceList(item, cours.Id); } IsLoading = false; return true; } IsLoading = false; return false; }
public ActionResult Edit(int id, Cours EditCours) { try { if (ModelState.IsValid) { Cours cours = (from c in DB.Cours where c.CoursId == id select c).First(); cours.DateDebut = EditCours.DateDebut; cours.DateFin = EditCours.DateFin; cours.Description = EditCours.Description; DB.SaveChanges(); return RedirectToAction("Index"); } else { return View(); } } catch { return View(); } }
public static Cours CreateCours(int ID, string title, byte[] rowVersion) { Cours cours = new Cours(); cours.Id = ID; cours.Title = title; cours.RowVersion = rowVersion; return cours; }
public void InsertCourse(Cours course) { this.db.Courses.Add(course); }
public Cours Create(Cours obj) { throw new NotImplementedException(); }
/// <summary> /// Méthode permettant l'importation du scénario de la tâche à partir du rapport HTML généré par Omnivox. /// </summary> private void ImporterScenario() { StringBuilder sb = new StringBuilder(); //Contient le texte sur l'état d'avancement du processus de création. var html = new HtmlAgilityPack.HtmlDocument(); //DOM du document HTML IEnumerable<HtmlNode> cells = null; // Contient les cellules d'une ligne d'un tableau HTML Cours cours = null; //Contient les infos sur un cours Tache tache = null; //Cpontient les infors sur une tâche d'un prof. this.textBox1.Text = ""; //On charche le DOM du document HTML fourni html.Load(@"" + this.txtHtml.Text); var root = html.DocumentNode; //On obtient tous les span contant l'attribut class="DesEnseignant". Cela nous permettera de se positionner //au bon endroit dans le DOM pour obtenir les tables contenant les informations d'une tâche d'un prof. var span = root.Descendants("span").Where(t => t.GetAttributeValue("class", "").Equals("DescEnseignant")); var nbSpan = span.Count(); scenario.Clear(); foreach (var s in span) { //On obtient la table principale contant les infos sur la tâche d'un prof. var tblMain = s.Ancestors("table").Where(t => t.GetAttributeValue("class", "").Equals("table")).First(); //On obtient toutes les tables contenant de l'information sur la tâche d'un profs. var tables = tblMain.Descendants("table"); if (tables.Count() > 1) { //On obtien la table contenant les informations sur le prof var tblProf = tables.ElementAt(0); //On obtien la collection de lignes var rows = tblProf.Descendants("tr"); //On obtien la collection de cellules de la première ligne cells = rows.ElementAt(0).Descendants("td"); //Instanciation et initialisation de la tâche d'un prof. tache = new Tache() { Prof = cells.ElementAt(1).InnerText }; //On obtien la table contenant les informations sur les cours. var tblTache = tables.ElementAt(2); //On va chercherles lignes de la table contenant aucune attribut class ou contenat l'attribut class="trContenu" //et ayant au moins une cellule. var rowsTache = tblTache.Descendants("tr").Where( x => (x.GetAttributeValue("class", "").Equals("trContenu") || x.GetAttributeValue("class", "").Equals("")) && x.Descendants("td").Count() > 1); foreach (var tr in rowsTache) { //On obtient la liste des cellules de la ligne. var cellsTache = tr.Descendants("td"); //int nbCells = tr.Descendants("td").Count(); //Le nombre de cellules dans la ligne influence la manière dont nous devons aller chercher l'information. switch (tr.Descendants("td").Count()) { case 4: //Session Automne /******************************************************/ //cours = new Cours(); //cours.Numero = cellsTache.ElementAt(0).InnerText; //if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") //{ // cours.CI = double.Parse(cellsTache.ElementAt(2).InnerText, System.Globalization.CultureInfo.InvariantCulture); //} //else //{ // cours.CI = double.Parse(cellsTache.ElementAt(1).InnerText, System.Globalization.CultureInfo.InvariantCulture); //} //tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ //if (cellsTache.ElementAt(3).InnerText != " " & tache.SessionHiver.Cours.Count() > 0) //{ cours = new Cours(); cours.Numero = cellsTache.ElementAt(1).InnerText; //if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") //{ // cours.CI = double.Parse(cellsTache.ElementAt(5).InnerText, System.Globalization.CultureInfo.InvariantCulture); //} //else //{ cours.CI = double.Parse(cellsTache.ElementAt(3).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); //} tache.SessionHiver.Cours.Add(cours); //} break; case 5: //Session Automne /******************************************************/ cours = new Cours(); cours.Numero = cellsTache.ElementAt(0).InnerText; if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") { cours.CI = double.Parse(cellsTache.ElementAt(2).InnerText, System.Globalization.CultureInfo.InvariantCulture); } else { cours.CI = double.Parse(cellsTache.ElementAt(1).InnerText, System.Globalization.CultureInfo.InvariantCulture); } cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ if (cellsTache.ElementAt(3).InnerText != " " & tache.SessionHiver.Cours.Count() > 0) { cours = new Cours(); cours.Numero = cellsTache.ElementAt(3).InnerText; if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") { cours.CI = double.Parse(cellsTache.ElementAt(5).InnerText, System.Globalization.CultureInfo.InvariantCulture); } else { cours.CI = double.Parse(cellsTache.ElementAt(4).InnerText, System.Globalization.CultureInfo.InvariantCulture); } cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); } break; case 7: //Session Automne /******************************************************/ cours = new Cours(); cours.Numero = cellsTache.ElementAt(0).InnerText; //if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") //{ cours.CI = double.Parse(cellsTache.ElementAt(2).InnerText, System.Globalization.CultureInfo.InvariantCulture); //} //else //{ // cours.CI = double.Parse(cellsTache.ElementAt(1).InnerText, System.Globalization.CultureInfo.InvariantCulture); //} cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ //if (cellsTache.ElementAt(3).InnerText != " " & tache.SessionHiver.Cours.Count() > 0) //{ cours = new Cours(); cours.Numero = cellsTache.ElementAt(4).InnerText; if (cellsTache.ElementAt(0).Attributes["colspan"].Value == "8") { cours.CI = double.Parse(cellsTache.ElementAt(6).InnerText, System.Globalization.CultureInfo.InvariantCulture); } else { cours.CI = double.Parse(cellsTache.ElementAt(4).InnerText, System.Globalization.CultureInfo.InvariantCulture); } cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); //} break; case 10: //if (cellsTache.ElementAt(0).GetAttributeValue("colspan", "").Equals("2")) //{ // //Session Automne // /******************************************************/ // cours = new Cours(); // //Numéro du cours // cours.Numero = tache.SessionAutomne.Cours.Last().Numero; // //Nb. groupes // cours.NoGroupe = cellsTache.ElementAt(1).InnerText; // //Nb. Heures // cours.NbHeures = int.Parse(cellsTache.ElementAt(5).InnerText); // //Nb. Etudiant // cours.NbEtudiants = int.Parse(cellsTache.ElementAt(7).InnerText); // tache.SessionAutomne.Cours.Add(cours); //} //else if (cellsTache.ElementAt(0).GetAttributeValue("colspan", "").Equals("11")) { //Session Hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = tache.SessionHiver.Cours.Last().Numero; //No. groupes cours.NoGroupe = cellsTache.ElementAt(2).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(6).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(8).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); } break; case 11: if (cellsTache.ElementAt(0).GetAttributeValue("colspan", "").Equals("2")) { //Session Automne /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = tache.SessionAutomne.Cours.Last().Numero; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(1).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(5).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(7).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); } else if (cellsTache.ElementAt(0).GetAttributeValue("colspan", "").Equals("11")) { //Session Hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = cellsTache.ElementAt(1).InnerText; //No. groupes cours.NoGroupe = cellsTache.ElementAt(3).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(7).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(9).InnerText); //CI cours.CI = double.Parse(cellsTache.ElementAt(10).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); } break; case 12: //Session Automne /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = cellsTache.ElementAt(0).InnerText; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(2).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(6).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(8).InnerText); //CI cours.CI = double.Parse(cellsTache.ElementAt(9).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); break; case 19: //Session Automne /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = tache.SessionAutomne.Cours.Last().Numero; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(1).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(5).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(7).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = tache.SessionHiver.Cours.Last().Numero; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(11).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(15).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(17).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); break; case 20: //Session Automne /******************************************************/ cours = new Cours(); if (cellsTache.ElementAt(0).GetAttributeValue("colspan", "").Equals("2")) { //Numéro du cours cours.Numero = tache.SessionAutomne.Cours.Last().Numero; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(1).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(5).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(7).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = cellsTache.ElementAt(10).InnerText; //No. groupes cours.NoGroupe = cellsTache.ElementAt(12).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(16).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(18).InnerText); //CI cours.CI = double.Parse(cellsTache.ElementAt(19).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); } else { //Numéro du cours cours.Numero = cellsTache.ElementAt(0).InnerText; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(2).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(6).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(8).InnerText); //CI cours.CI = double.Parse(cellsTache.ElementAt(9).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session d'hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = tache.SessionHiver.Cours.Last().Numero; //No. groupes cours.NoGroupe = cellsTache.ElementAt(12).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(16).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(18).InnerText); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); } break; case 21: //Session Automne /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = cellsTache.ElementAt(0).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(6).InnerText); //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(2).InnerText; //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(8).InnerText); //CI cours.CI = double.Parse(cellsTache.ElementAt(9).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionAutomne.Cours.Add(cours); //Session Hiver /******************************************************/ cours = new Cours(); //Numéro du cours cours.Numero = cellsTache.ElementAt(11).InnerText; //Nb. groupes cours.NoGroupe = cellsTache.ElementAt(13).InnerText; //Nb. Heures cours.NbHeures = int.Parse(cellsTache.ElementAt(17).InnerText); //Nb. Etudiant cours.NbEtudiants = int.Parse(cellsTache.ElementAt(19).InnerText); //CI cours.CI = cours.CI = double.Parse(cellsTache.ElementAt(20).InnerText, System.Globalization.CultureInfo.InvariantCulture); cours.BlocsHoraire = GetBlocsHoraire(cours); tache.SessionHiver.Cours.Add(cours); break; } } scenario.Add(tache); } } // Afficher l'horaire this.cmbSession.SelectedIndex = 0; AfficherHoraire(true); this.textBox1.AppendText("Les données ont été importées avec succès!" + System.Environment.NewLine); }