Exemplo n.º 1
0
        public stdMainpage(string username, userDatabase usrDB, courseDatabase crsDB)
        {
            // Store attributes
            InitializeComponent();
            this.crsDB = crsDB;
            this.usrDB = usrDB;
            std        = usrDB.getStudent(username);

            // Change texts
            welcome.Text += std.fname + " " + std.lname;
            gpa.Text     += " " + std.GPA;
            credits.Text += " " + std.totalCredits;

            // Create all the tables
            createCrsLst();
            createGradeHist();
            createStdSch();

            // Clear selections on tables
            gradeHist.ClearSelection();
            stdSch.ClearSelection();

            // Auto completion source
            foreach (course crs in crsDB.getCourseList())
            {
                crsIDBox.AutoCompleteCustomSource.Add(crs.crsID);
            }
        }
Exemplo n.º 2
0
        // Construct the database and update it
        public courseDatabase(ref userDatabase userDB)
        {
            this.crsLst = new List <course>();
            string line;

            System.IO.StreamReader input = new System.IO.StreamReader(@"..\..\courseDB.in");
            while ((line = input.ReadLine()) != null)
            {
                string        code            = line.Substring(0, 10).Trim();
                string        title           = line.Substring(11, 15).Trim();
                string        instructor      = line.Substring(27, 10).Trim().ToLower();
                string        credit          = line.Substring(38, 4).Trim();
                int           seats           = Convert.ToInt32(line.Substring(43, 3).Trim());
                int           num_time_blocks = int.Parse(line.Substring(47, 1).Trim());
                int           index           = 49;
                List <string> BlockLst        = new List <string>();
                for (int i = 0; i < num_time_blocks; i++)
                {
                    string time_block = line.Substring(index, 5);
                    BlockLst.Add(time_block);
                    index += 6;
                }
                course crs = new course(code, title, instructor, credit, seats, num_time_blocks, BlockLst);
                crsLst.Add(crs);
                faculty courseFac = userDB.getFaculty(instructor.Trim());
                courseFac.nextSemesterCourses.Add(crs);
            }
            input.Close();
        }
Exemplo n.º 3
0
        public facMainpage(string username, userDatabase usrDB, courseDatabase crsDB)
        {
            InitializeComponent();
            this.usrDB = usrDB;
            this.crsDB = crsDB;
            fac        = usrDB.getFaculty(username);

            // Change texts
            welcome.Text += fac.fname + " " + fac.lname;

            // Create all the tables
            createCrsLst();
            createFacSch();
            createAdviseeLst();

            // Auto complete
            foreach (course crs in crsDB.getCourseList())
            {
                crsIDBox.AutoCompleteCustomSource.Add(crs.crsID);
            }

            // Clear selection of tables
            facSch.ClearSelection();
            adviseeLst.ClearSelection();
        }
Exemplo n.º 4
0
        public admChangeAdvisor(userDatabase usrDB, string advisor)
        {
            InitializeComponent();
            foreach (faculty fac in usrDB.getFacultyList())
            {
                facDropDown.Items.Add(fac.username);
                facDropDown.AutoCompleteCustomSource.Add(fac.username);
            }

            currentAdvisor.Text += advisor;
        }
Exemplo n.º 5
0
        bool flag = false;  // Flag to check if at least one mainpage was open

        public LoginForm()
        {
            InitializeComponent();
            usrDB = new userDatabase(@"..\..\userDB.in");

            // Make the close button transparent
            Bitmap bmp = ((Bitmap)close.BackgroundImage);

            bmp.MakeTransparent();
            bmp = ((Bitmap)pictureBox2.BackgroundImage);
            bmp.MakeTransparent();
        }
Exemplo n.º 6
0
        public admCreateUser(userDatabase usrDB)
        {
            InitializeComponent();
            this.usrDB = usrDB;
            confirm.FlatAppearance.CheckedBackColor = Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(49)))), ((int)(((byte)(63)))));

            foreach (faculty fac in usrDB.getFacultyList())
            {
                advisor.Items.Add(fac.fname + " " + fac.lname);
                advisor.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname);
            }
        }
Exemplo n.º 7
0
        public admCreateCrs(courseDatabase crsDB, userDatabase usrDB)
        {
            InitializeComponent();
            this.crsDB = crsDB;
            this.usrDB = usrDB;


            foreach (course crs in crsDB.getCourseList())
            {
                crsIDBox.AutoCompleteCustomSource.Add(crs.crsID);
            }

            foreach (faculty fac in usrDB.getFacultyList())
            {
                facDropDown.Items.Add(fac.fname + " " + fac.lname);
                facDropDown.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname);
            }
        }
Exemplo n.º 8
0
        public admChangeCrs(course crs, userDatabase usrDB)
        {
            InitializeComponent();

            // Create the schedule table
            DataTable table = new DataTable();

            table.Columns.Add("Schedule");
            table.Columns.Add("Code");
            foreach (string crsBlock in crs.timeBlocks)
            {
                table.Rows.Add(course.Decode(crsBlock), crsBlock);
            }

            crsSch.DataSource = table;

            DataGridViewCheckBoxColumn btn = new DataGridViewCheckBoxColumn();

            btn.ValueType = typeof(bool);
            crsSch.Columns.Insert(0, btn);
            crsSch.Columns[0].HeaderText = "Remove";
            crsSch.Columns[0].Name       = "Remove";

            foreach (DataGridViewColumn col in crsSch.Columns)
            {
                col.ReadOnly = true;
            }
            crsSch.Columns[0].ReadOnly     = false;
            crsSch.Columns["Code"].Visible = false;

            foreach (faculty fac in usrDB.getFacultyList())
            {
                facDropDown.Items.Add(fac.fname + " " + fac.lname);
                facDropDown.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname);
            }
            this.crs   = crs;
            this.usrDB = usrDB;
        }
Exemplo n.º 9
0
        // Change the database
        public void removeCrs(string crsID, string filepath, ref userDatabase usrDB)
        {
            // Remove the course from the offering
            course removedCrs = getCourse(crsID);

            crsLst.Remove(removedCrs);

            // Remove the course from students' schedule
            List <student> enrolledStdLst = removedCrs.getStudents();

            foreach (student std in enrolledStdLst)
            {
                std.dropCrsFromNext(removedCrs);
            }

            // Remove the course from faculties' schedule
            faculty fac = usrDB.getFaculty(removedCrs.instructor);

            fac.removeCrsFromNext(removedCrs);

            ////Updates the coursedb.in file to remove the removed course from it
            //string[] courseLines = File.ReadAllLines(filepath);
            //string[] newCourseLinesArr;
            //List<string> newCourseLines = new List<string>();
            //foreach (string courseString in courseLines)
            //{
            //    string courseID = courseString.Substring(0, 10).Trim();
            //    //string courseID = courseString.Substring(4, 10);
            //    if (courseID == removedCrs.crsID.Trim())
            //        continue;   // Skip the iteration if the course is being deleted
            //    else
            //        newCourseLines.Add(courseString);

            //    newCourseLinesArr = newCourseLines.ToArray();
            //    File.WriteAllLines(filepath, newCourseLinesArr);
            //}
        }
Exemplo n.º 10
0
        private void loginClick(object sender, EventArgs e)
        {
            uname = username.Text.Trim().ToLower();
            utype = "student";
            string password = this.password.Text.Trim();

            if (usrDB.isValidUser(uname, password, ref utype))
            {
                Hide();
                if (utype == "admin" || utype == "manager")
                {
                    if (!flag)
                    {
                        var form = new admMainpage(usrDB, @"..\..\historyDB.in", utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                        usrDB.updateDatabase();
                    }
                    else
                    {
                        var form = new admMainpage(usrDB, crsDB, utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                    }
                }
                else
                {
                    if (utype == "faculty")
                    {
                        if (!flag)
                        {
                            var form = new facMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new facMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                    else
                    {
                        if (!flag)
                        {
                            var form = new stdMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new stdMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                }
                username.Text              = "Username";
                username.ForeColor         = Color.Silver;
                this.password.Text         = "Password";
                this.password.PasswordChar = '\0';
                this.password.ForeColor    = Color.Silver;

                flag = true;
                Show();
            }
            else
            {
                MessageBox.Show("Your username or password is incorrect.",
                                "Invalid Credential",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Question);
                this.password.Text         = "";
                this.password.PasswordChar = '*';
                this.password.ForeColor    = Color.White;
            }
        }