Ejemplo n.º 1
0
        // On Login Click
        private void metroButton1_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                string user = username.Text.ToString().Trim().ToLower();
                string pass = password.Text.ToString().Trim().ToLower();

                // Check if Admin
                if (user == "admin" && pass == "admin")
                {
                    Hide();
                    new Ntecc().ShowDialog();
                    Show();
                }
                else
                {
                    // Check  if user exist and is teacher
                    AspireDB db = new AspireDB();
                    User     u  = db.Users.SingleOrDefault(x => x.Email == user && x.Password == pass);
                    if (u != null)
                    {
                        Teacher t = db.Teachers.SingleOrDefault(x => x.Email == u.Email);
                        Hide();
                        new TeacherHome(t).ShowDialog();
                        Show();
                    }
                    else
                    {
                        new MsgBox("User Does not Exsist");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public TeacherHome(Teacher tea)
 {
     // Initialize Teacher view from Teacher object
     InitializeComponent();
     db = new AspireDB();
     teacher_name.Text    = tea.Name.ToString();
     teacher_contact.Text = tea.Contact.ToString();
     teacher_email.Text   = tea.Email.ToString();
     user           = db.Users.SingleOrDefault(x => x.Email == tea.Email);
     mon_f.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[0].ToString()));
     mon_s.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[1].ToString()));
     tues_f.Checked = Convert.ToBoolean(int.Parse(tea.Availability_Time[2].ToString()));
     tues_s.Checked = Convert.ToBoolean(int.Parse(tea.Availability_Time[3].ToString()));
     wed_f.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[4].ToString()));
     wed_s.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[5].ToString()));
     thur_f.Checked = Convert.ToBoolean(int.Parse(tea.Availability_Time[6].ToString()));
     thur_s.Checked = Convert.ToBoolean(int.Parse(tea.Availability_Time[7].ToString()));
     fri_f.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[8].ToString()));
     fri_s.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[9].ToString()));
     sat_f.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[10].ToString()));
     sat_s.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[11].ToString()));
     sun_f.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[12].ToString()));
     sun_s.Checked  = Convert.ToBoolean(int.Parse(tea.Availability_Time[13].ToString()));
     teacher        = db.Teachers.SingleOrDefault(Teacher => Teacher.TeacherID == tea.TeacherID);
 }
Ejemplo n.º 3
0
        // Add Course Module
        private void Addcoursebtn_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                AspireDB db = new AspireDB();

                Course cs   = new Course();
                byte[] hash = HelpMe.Md5toBinary(course_name.Text.ToString());
                Course got  = db.Courses.SingleOrDefault(Course => Course.CourseID == hash);
                if (got != null)
                {
                    new MsgBox("Duplicate entry");
                    return;
                }
                cs.Name     = course_name.Text.ToString();
                cs.CourseID = hash;
                cs.Level    = course_level.Text;
                cs.Nos      = Convert.ToInt32(course_strength.Text);
                db.Courses.Add(cs);
                db.SaveChanges();

                message.Text         = "Done";
                course_strength.Text = "";
                course_name.Text     = "";
                course_level.Text    = "";
                CourseControl.Instance.CreateList();
                CourseControl.Instance.FooterMessage("Course Added");
            }
        }
Ejemplo n.º 4
0
        public void CreateList()
        {
            string lvl = LevelChoser.GetItemText(LevelChoser.SelectedItem);

            if (lvl.Equals("All"))
            {
                if (courses_layout.Controls.Count > 0)
                {
                    courses_layout.Controls.Clear();
                }
                AspireDB      db    = new AspireDB();
                List <Course> clist = db.Courses.ToList();
                foreach (Course c in clist)
                {
                    CoursesView cv = new CoursesView(c);
                    courses_layout.Controls.Add(cv);
                }
                db.Database.Connection.Close();
            }
            else
            {
                if (courses_layout.Controls.Count > 0)
                {
                    courses_layout.Controls.Clear();
                }
                AspireDB      db    = new AspireDB();
                List <Course> clist = db.Courses.Where(x => x.Level == lvl).ToList();
                foreach (Course c in clist)
                {
                    CoursesView cv = new CoursesView(c);
                    courses_layout.Controls.Add(cv);
                }
                db.Database.Connection.Close();
            }
        }
Ejemplo n.º 5
0
        private void filter_combo_SelectedIndexChanged(object sender, EventArgs e)
        {
            string item = filter_combo.Text;

            if (!item.Trim().Equals(""))
            {
                if (item.Trim().ToLower().Equals("all"))
                {
                    CreateList();
                }
                else
                {
                    string[] parsed = item.Split('-');
                    string   name   = parsed[0];
                    string   level  = HelpMe.GetFullForm(parsed[1]);
                    AspireDB db     = new AspireDB();
                    Course   c      = db.Courses.SingleOrDefault(Course => Course.Name == name && Course.Level == level);
                    CreateList(c);
                }
            }
            else
            {
                CreateList();
            }
        }
Ejemplo n.º 6
0
        // Add Teacher and user for login later
        private void Addbtn_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                db = new AspireDB();
                Teacher teacher = new Teacher();
                teacher.Name    = teacher_name.Text;
                teacher.Email   = teacher_email.Text;
                teacher.Contact = teacher_contact.Text;

                User u = new User();
                u.Email    = teacher.Email;
                u.Password = "******";
                u.Role     = "T";

                teacher.Availability_Time = AvailabilityTime();

                db.Teachers.Add(teacher);
                db.Users.Add(u);
                db.SaveChanges();

                teacher_contact.Text = "";
                teacher_name.Text    = "";
                teacher_email.Text   = "";
                TeachersControl.Instance.CreateList();
                TeachersControl.Instance.FooterMessage("Teacher Added");
            }
        }
Ejemplo n.º 7
0
        public EditSubject(Subject s)
        {
            InitializeComponent();
            db = new AspireDB();
            subject_credits.Text = s.Credit.ToString();
            subject_hours.Text   = s.Hour;
            subject_name.Text    = s.Name;
            sub = db.Subjects.SingleOrDefault(Subject => Subject.SubjectID == s.SubjectID && Subject.Name == s.Name);


            //1 Populating Combo box
            //2 then selecting the already chosen course
            List <Course> css = db.Courses.ToList();
            int           count = 0, si = 0;

            foreach (Course c in css)
            {
                course_combo.Items.Add(c.Name + "-" + c.Level);
                if (s.CourseID == c.CourseID)
                {
                    si = count;
                }
                count++;
            }
            course_combo.SelectedIndex = si;
        }
Ejemplo n.º 8
0
 public EditRoom(Room rm)
 {
     InitializeComponent();
     db            = new AspireDB();
     name.Text     = rm.Name.ToString();
     capacity.Text = rm.Capacity.ToString();
     room          = db.Rooms.SingleOrDefault(Room => Room.RoomID == rm.RoomID);
 }
Ejemplo n.º 9
0
 private void saveimgbtn_Click(object sender, EventArgs e)
 {
     AspireDB db = new AspireDB();
     db.Configuration.ProxyCreationEnabled = false;
     List<Course> cour = db.Courses.ToList<Course>();
     String str = HelpMe.GetJson(cour);
     Console.Write(str);
     HelpMe.SaveFileNow(str, "courses");
 }
Ejemplo n.º 10
0
 public EditCourse(Course cs)
 {
     InitializeComponent();
     db = new AspireDB();
     c  = db.Courses.SingleOrDefault(Course => Course.CourseID == cs.CourseID && Course.Name == cs.Name && Course.Level == cs.Level);
     course_level.Text    = c.Level;
     course_name.Text     = c.Name;
     course_strength.Text = c.Nos.ToString();
 }
Ejemplo n.º 11
0
        public AddCourse()
        {
            InitializeComponent();
            AspireDB db = new AspireDB();

            foreach (Level l in db.Levels.ToList())
            {
                course_level.Items.Add(l.LevelName);
            }
        }
Ejemplo n.º 12
0
        private void deletebtn_Click(object sender, EventArgs e)
        {
            db = new AspireDB();
            Room x = db.Rooms.SingleOrDefault(Room => Room.RoomID == _rm.RoomID);

            db.Rooms.Remove(x);
            db.SaveChanges();
            RoomsControl.Instance.FooterMessage("Room Deleted");
            RoomsControl.Instance.CreateList();
        }
Ejemplo n.º 13
0
        public AddSubject()
        {
            InitializeComponent();
            db = new AspireDB();
            List <Course> css = db.Courses.ToList();

            foreach (Course c in css)
            {
                course_combo.Items.Add(c.Name + "-" + c.Level);
            }
        }
Ejemplo n.º 14
0
        public void FilterBoxUpdate()
        {
            AspireDB      db = new AspireDB();
            List <Course> cs = db.Courses.ToList <Course>();

            filter_combo.Items.Add("All");
            foreach (Course c in cs)
            {
                filter_combo.Items.Add(c.Name + "-" + HelpMe.GetInitials(c.Level, ""));
            }
        }
Ejemplo n.º 15
0
        public AddStudent()
        {
            InitializeComponent();
            db = new AspireDB();
            List <Course> cs = db.Courses.ToList <Course>();

            foreach (Course c in cs)
            {
                course_combo.Items.Add(c.Name + "-" + HelpMe.GetInitials(c.Level, ""));
            }
        }
Ejemplo n.º 16
0
 public EditCourse(Course cs)
 {
     InitializeComponent();
     db = new AspireDB();
     foreach (Level l in db.Levels.ToList())
     {
         course_level.Items.Add(l.LevelName);
     }
     c = db.Courses.SingleOrDefault(Course => Course.CourseID == cs.CourseID && Course.Name == cs.Name && Course.Level == cs.Level);
     course_level.Text    = c.Level;
     course_name.Text     = c.Name;
     course_strength.Text = c.Nos.ToString();
 }
Ejemplo n.º 17
0
        private void saveimgbtn_Click(object sender, EventArgs e)
        {
            AspireDB db = new AspireDB();

            db.Configuration.ProxyCreationEnabled = false;
            List <Subject> sub = db.Subjects.ToList <Subject>();

            // Create JSON String
            String str = HelpMe.GetJson(sub);

            // Save in file with extension
            HelpMe.SaveFileNow(str, "subject");
        }
Ejemplo n.º 18
0
 public void CreateList()
 {
     if(courses_layout.Controls.Count>0)
     {
         courses_layout.Controls.Clear();
     }
     AspireDB db = new AspireDB();
     List<Course> clist = db.Courses.ToList();
     foreach (Course c in clist)
     {
         CoursesView cv = new CoursesView(c);
         courses_layout.Controls.Add(cv);
     }
     db.Database.Connection.Close();
 }
Ejemplo n.º 19
0
        public CourseControl()
        {
            InitializeComponent();

            LevelChoser.Items.Add("All");
            AspireDB db = new AspireDB();

            foreach (Level l in db.Levels.ToList())
            {
                LevelChoser.Items.Add(l.LevelName);
            }
            LevelChoser.SelectedIndex = 0;

            CreateList();
        }
Ejemplo n.º 20
0
        public void CreateList(Course c)
        {
            if (subject_layout.Controls.Count > 0)
            {
                subject_layout.Controls.Clear();
            }
            AspireDB       db    = new AspireDB();
            List <Subject> slist = db.Subjects.Where(Subject => Subject.CourseID == c.CourseID).ToList <Subject>();

            foreach (Subject s in slist)
            {
                SubjectsView cv = new SubjectsView(s);
                subject_layout.Controls.Add(cv);
            }
            db.Database.Connection.Close();
        }
Ejemplo n.º 21
0
        public void CreateList()
        {
            if (subject_layout.Controls.Count > 0)
            {
                subject_layout.Controls.Clear();
            }
            AspireDB       db    = new AspireDB();
            List <Subject> slist = db.Subjects.ToList();

            foreach (Subject c in slist)
            {
                SubjectsView cv = new SubjectsView(c);
                subject_layout.Controls.Add(cv);
            }
            db.Database.Connection.Close();
        }
Ejemplo n.º 22
0
        public void CreateList()
        {
            if (teacher_layout.Controls.Count > 0)
            {
                teacher_layout.Controls.Clear();
            }
            AspireDB       db    = new AspireDB();
            List <Teacher> tlist = db.Teachers.ToList();

            foreach (Teacher t in tlist)
            {
                TeacherView tv = new TeacherView(t);
                teacher_layout.Controls.Add(tv);
            }
            db.Database.Connection.Close();
        }
Ejemplo n.º 23
0
        public void CreateList()
        {
            if (rooms_layout.Controls.Count > 0)
            {
                rooms_layout.Controls.Clear();
            }
            AspireDB    db    = new AspireDB();
            List <Room> tlist = db.Rooms.ToList();

            foreach (Room r in tlist)
            {
                RoomView tv = new RoomView(r);
                rooms_layout.Controls.Add(tv);
            }
            db.Database.Connection.Close();
        }
Ejemplo n.º 24
0
        private void deletebtn_Click(object sender, EventArgs e)
        {
            db = new AspireDB();
            Teacher x = db.Teachers.SingleOrDefault(Teacher => Teacher.TeacherID == _ts.TeacherID);
            User    u = db.Users.SingleOrDefault(p => p.Email == x.Email);

            if (u != null)
            {
                db.Users.Remove(u);
            }

            db.Teachers.Remove(x);
            db.SaveChanges();
            TeachersControl.Instance.FooterMessage("Teacher Deleted");
            TeachersControl.Instance.CreateList();
        }
Ejemplo n.º 25
0
        public void CreateList()
        {
            if (student_layout.Controls.Count > 0)
            {
                student_layout.Controls.Clear();
            }
            AspireDB       db      = new AspireDB();
            List <Student> stulist = db.Students.ToList();

            foreach (Student s in stulist)
            {
                StudentsView sv = new StudentsView(s);
                student_layout.Controls.Add(sv);
            }
            db.Database.Connection.Close();
        }
Ejemplo n.º 26
0
        public BatchAddStudent()
        {
            InitializeComponent();
            db = new AspireDB();
            course_name.Items.Clear();
            List <Course> css = db.Courses.ToList();

            foreach (Course s in css)
            {
                course_name.Items.Add(s.Name);
            }

            course_level.Items.Clear();
            foreach (string s in HelpMe.levels)
            {
                course_level.Items.Add(s);
            }
            LoadClipboard();
        }
Ejemplo n.º 27
0
        private void loadimgbtn_Click(object sender, EventArgs e)
        {
            // Opens File and match extension -> If Extension do not match it shows msg
            string json = HelpMe.OpenFileNow("courses");

            // Load Data from Json File Opened
            List <Course> css = HelpMe.GetDataFromJson <Course>(json);

            AspireDB db = new AspireDB();

            db.Courses.SqlQuery(" DBCC CHECKIDENT('Course', RESEED, 0)");
            int count = 0;

            foreach (Course s in css)
            {
                // Check for Exsisting Subjects
                if (db.Courses.Count(Course => Course.Name == s.Name && Course.Level == s.Level) <= 0)
                {
                    db.Courses.Add(s);
                    count++;
                }
            }

            string msg;

            try
            {
                db.SaveChanges();
                msg = "File Loaded ( " + count + " Rows Added )";
            }
            catch (Exception ee)
            {
                count = 0;
                msg   = "File Not Loaded";
                new MsgBox("Invalid File");
                MessageBox.Show(ee.Message);
            }
            //Update list and Show Footer Message
            CourseControl.Instance.CreateList();
            CourseControl.Instance.FooterMessage(msg);
        }
Ejemplo n.º 28
0
        public EditStudent(Student s)
        {
            InitializeComponent();
            db   = new AspireDB();
            stud = db.Students.SingleOrDefault(Student => Student.ID == s.ID);
            student_name.Text      = s.Name;
            student_studentID.Text = s.StudentID;
            student_email.Text     = s.Email;
            List <Course> courses_list = db.Courses.ToList <Course>();
            int           count = 0, si = 0;

            foreach (Course c in courses_list)
            {
                course_combo.Items.Add(c.Name);
                if (c.Name.Equals(s.Course.Name))
                {
                    si = count;
                }
                count++;
            }
            course_combo.SelectedIndex = si;
        }
Ejemplo n.º 29
0
        private void loadimgbtn_Click(object sender, EventArgs e)
        {
            // Opens File and match extension -> If Extension do not match it shows msg
            string json = HelpMe.OpenFileNow("subject");

            // Load Data from Json File Opened
            List <Subject> sub = HelpMe.GetDataFromJson <Subject>(json);

            AspireDB db = new AspireDB();

            int count = 0;

            foreach (Subject s in sub)
            {
                // Check for Exsisting Subjects
                if (db.Subjects.Count(Subject => Subject.Name == s.Name && Subject.CourseID == s.CourseID) <= 0)
                {
                    db.Subjects.Add(s);
                    count++;
                }
            }

            string msg;

            try {
                db.SaveChanges();
                msg = "File Loaded ( " + count + " Rows Added )";
            }
            catch
            {
                count = 0;
                msg   = "File Not Loaded, Please Make Sure Courses Exsists";
                new MsgBox("Invalid File or Courses Missing!");
            }
            //Update list and Show Footer Message
            SubjectControl.Instance.CreateList();
            SubjectControl.Instance.FooterMessage(msg);
        }
Ejemplo n.º 30
0
        // Add Room method
        private void Addcoursebtn_Click(object sender, EventArgs e)
        {
            if (ValidateChildren())
            {
                db = new AspireDB();
                Room x  = new Room();
                Room rm = db.Rooms.SingleOrDefault(Room => Room.Name == name.Text.ToString() && Room.Capacity == capacity.Text.ToString());
                if (rm != null)
                {
                    new MsgBox("Duplicate Room Entry");
                    return;
                }
                x.Capacity = capacity.Text;;
                x.Name     = name.Text;

                db.Rooms.Add(x);
                db.SaveChanges();
                RoomsControl.Instance.CreateList();
                RoomsControl.Instance.FooterMessage("Room Added");
                name.Text     = "";
                capacity.Text = "";
                message.Text  = "Done";
            }
        }