public static void UpdateGroupStudent(int number, int secID, bool state) { using (BDIIDataContext dc = new BDIIDataContext()) { if (state == false) { Students_Groups res = (from el in dc.Students_Groups where (el.StudentAlbumNr == number.ToString() && el.GroupID == secID) select el).SingleOrDefault(); if (res != null) { res.Active = state; dc.SubmitChanges(); } } } }
public static void UpdateMark(int userID, double mark) { using (BDIIDataContext dc = new BDIIDataContext()) { Students res = (from el in dc.Users join ol in dc.Students on el.ID equals ol.UserID where ol.UserID == userID select ol).SingleOrDefault(); Students_Groups res2 = (from il in dc.Students_Groups join ul in dc.Students on il.StudentAlbumNr equals ul.AlbumNr where il.StudentAlbumNr == res.AlbumNr select il).SingleOrDefault(); res2.Mark = mark; dc.SubmitChanges(); } }
public static void SetStudentSection(int album, Sections sec) { int nr = 0; int oldnr = 0; using (BDIIDataContext dc = new BDIIDataContext()) { var res = dc.Students_Groups.Where(x => Convert.ToInt32(x.StudentAlbumNr) == album).Select(x => x).SingleOrDefault(); if (res == null) { Students_Groups stg = new Students_Groups { ID = -1, Active = true, StudentAlbumNr = album.ToString(), GroupID = DependencyFacade.GetSection(sec).ID }; dc.Students_Groups.InsertOnSubmit(stg); dc.SubmitChanges(); } else { res.ID = res.ID; res.StudentAlbumNr = res.StudentAlbumNr; oldnr = res.GroupID; if (sec.ID != 0) { if (sec.ID == res.GroupID) { res.Active = !res.Active; } else { res.GroupID = DependencyFacade.GetSection(sec).ID; if (res.Active == false) { res.Active = true; } } } else { if (res.Active == true) { res.Active = false; } else { res.Active = true; } } nr = res.GroupID; dc.SubmitChanges(); } } Sections oldgrp = new Sections(); Sections newgrp = new Sections(); Topics topic = new Topics(); oldgrp.ID = oldnr; newgrp.ID = nr; oldgrp = (Sections)DependencyFacade.GetSection(oldgrp); newgrp = (Sections)DependencyFacade.GetSection(newgrp); if (newgrp.GroupSize == DependencyFacade.GetStudentNumber(newgrp.ID)) { newgrp.Status = "cls"; DependencyFacade.UpdateSection(newgrp); } if (oldgrp.GroupSize != DependencyFacade.GetStudentNumber(oldgrp.ID)) { oldgrp.Status = "opn"; DependencyFacade.UpdateSection(oldgrp); } }