Ejemplo n.º 1
0
        public static void InsertPresenceDate(int sectionID)
        {
            var datetime = DateTime.Now;
            var date     = datetime.Date;

            Users[] users = UserFacade.GetSectionSquad(sectionID);
            for (int i = 0; i < users.Length; i++)
            {
                using (BDIIDataContext dc = new BDIIDataContext())
                {
                    Presence prs = new Presence();
                    prs.Present = false;
                    Students_Groups[] stdgrp = UserFacade.GetGroupStudentID(users[i].ID);
                    for (int j = 0; j < stdgrp.Length; j++)
                    {
                        if (stdgrp[j].Active == true)
                        {
                            prs.Group_StudentID = stdgrp[j].ID;
                        }
                    }
                    prs.ID   = -1;
                    prs.Date = date;

                    dc.Presence.InsertOnSubmit(prs);
                    dc.SubmitChanges();
                }
            }
        }
Ejemplo n.º 2
0
        public static int SetTopic(int topicID, int sectionID)
        {
            using (BDIIDataContext dc = new BDIIDataContext())
            {
                var res2 = (from ol in dc.Topics
                            where ol.ID == topicID
                            select ol).SingleOrDefault();
                if (res2 != null)
                {
                    var res = (from el in dc.Sections
                               where el.ID == sectionID
                               select el).SingleOrDefault();
                    if (res == null)
                    {
                        return(0);
                    }
                    res.ID      = sectionID;
                    res.TopicID = topicID;
                    dc.SubmitChanges();
                }
                else
                {
                    return(0);
                }

                return(1);
            }
        }
Ejemplo n.º 3
0
 public static void InsertSem(Sems sm)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         Sems sem = new Sems();
         sem.ID         = -1;
         sem.StudyField = sm.StudyField;
         sem.Year       = sm.Year;
         sem.Sem        = sm.Sem;
         dc.Sems.InsertOnSubmit(sem);
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 4
0
        public static void InsertTeacher(Users user, string degree)
        {
            var teacher = InsertUser(user);

            using (BDIIDataContext dc = new BDIIDataContext())
            {
                Teachers tch = new Teachers();
                tch.AcademicDegree = degree;
                tch.UserID         = teacher.ID;
                tch.ID             = -1;
                dc.Teachers.InsertOnSubmit(tch);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 5
0
 public static void InsertSection(Sections section)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         Sections grp = new Sections
         {
             GroupSize = section.GroupSize,
             ID        = -1,
             SemID     = 1,
             Status    = "opn"
         };
         dc.Sections.InsertOnSubmit(grp);
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 6
0
 public static void InsertTopic(Topics topic)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         Topics tpc = new Topics
         {
             ID          = -1,
             Title       = topic.Title,
             Description = topic.Description,
             Status      = "opn",
             TeacherID   = topic.TeacherID
         };
         dc.Topics.InsertOnSubmit(tpc);
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 7
0
        public static void InsertFile(byte[] file, int ID, string comment, string extension)
        {
            var datetime = DateTime.Now;
            var date     = datetime.Date;

            using (BDIIDataContext dc = new BDIIDataContext())
            {
                Files fls = new Files();
                fls.SectionID = ID;
                fls.File      = file;
                fls.Date      = date;
                fls.Details   = comment;
                fls.Ext       = extension;
                dc.Files.InsertOnSubmit(fls);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 8
0
 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();
             }
         }
     }
 }
Ejemplo n.º 9
0
 public static Users InsertUser(Users user)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         var res = new Users();
         res.ID         = -1;
         res.Login      = user.Login;
         res.Name       = user.Name;
         res.Surname    = user.Surname;
         res.Hash       = user.Hash;
         res.Salt       = user.Salt;
         res.TypeOfUser = user.TypeOfUser;
         dc.Users.InsertOnSubmit(res);
         dc.SubmitChanges();
         return(res);
     }
 }
Ejemplo n.º 10
0
 public static void UpdateSection(Sections grp)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         var res = (from el in dc.Sections
                    where el.ID == grp.ID
                    select el).SingleOrDefault();
         if (res == null)
         {
             return;
         }
         res.ID        = grp.ID;
         res.GroupSize = grp.GroupSize;
         res.TopicID   = grp.TopicID;
         res.Status    = grp.Status;
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 11
0
        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();
            }
        }
Ejemplo n.º 12
0
 public static void UpdateUsers(Users user)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         var res = (from el in dc.Users
                    where el.ID == user.ID
                    select el).SingleOrDefault();
         if (res == null)
         {
             return;
         }
         res.Login      = user.Login;
         res.Name       = user.Name;
         res.Surname    = user.Surname;
         res.TypeOfUser = user.TypeOfUser;
         res.Hash       = user.Hash;
         res.Salt       = user.Salt;
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 13
0
 public static void UpdatePresences(DateTime column, int ID, string value)
 {
     using (BDIIDataContext dc = new BDIIDataContext())
     {
         var res = (from el in dc.Presence
                    where ((el.Group_StudentID == ID) && (el.Date == column))
                    select el).SingleOrDefault();
         if (res == null)
         {
             return;
         }
         if (value.Equals("0"))
         {
             res.Present = false;
         }
         else
         {
             res.Present = true;
         }
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 14
0
        public static void InsertStudent(Users user, int album_nr, int semID)
        {
            var         student = InsertUser(user);
            Students    std     = new Students();
            Sem_Student sms     = new Sem_Student();

            using (BDIIDataContext dc = new BDIIDataContext())
            {
                std.UserID  = student.ID;
                std.AlbumNr = (album_nr + 1).ToString();
                dc.Students.InsertOnSubmit(std);
                dc.SubmitChanges();
            }

            using (BDIIDataContext dc = new BDIIDataContext())
            {
                sms.StudentAlbumNr = std.AlbumNr;
                sms.SemID          = semID;
                dc.Sem_Student.InsertOnSubmit(sms);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 15
0
        public static void UpdateTopics(Topics topic)
        {
            using (BDIIDataContext dc = new BDIIDataContext())
            {
                var res = (from el in dc.Topics
                           where el.ID == topic.ID
                           select el).SingleOrDefault();
                if (res == null)
                {
                    return;
                }
                res.ID     = topic.ID;
                res.Status = topic.Status;

                if (topic.Title != null)
                {
                    res.Title       = topic.Title;
                    res.Description = topic.Description;
                    res.TeacherID   = topic.TeacherID;
                }
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 16
0
        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);
            }
        }