private void ButtonLogin_Click(object sender, EventArgs e)
 {
     if (!(textBoxEmail.Text == "Email") && !(textBoxPassword.Text == "Password"))
     {
         var controller           = new UserController();
         FacultyUserModel faculty = controller.ValidateLogin(textBoxEmail.Text, textBoxPassword.Text);
         if (faculty == null)
         {
             textBoxPassword.Clear();
             textBoxPassword.Focus();
         }
         else
         {
             //MessageBox.Show("Login successful.\nID: " + faculty.Id + "\nName: " + faculty.FullName + "\nEmail: " + faculty.Email);
             var dash = new FormDashboard(faculty);
             dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
             dash.Show();
             this.Hide();
         }
     }
     else
     {
         MessageBox.Show("Please insert your login credentials first");
     }
 }
        public AddClassPopupForm(FacultyUserModel gotFaculty, SectionModel gotSection)
        {
            InitializeComponent();
            faculty = gotFaculty;
            section = gotSection;

            datePicker.CalendarForeColor       = Color.FromArgb(217, 217, 217);
            datePicker.CalendarMonthBackground = Color.FromArgb(49, 49, 49);

            datePicker.MinDate = DateTime.Today;
            datePicker.MaxDate = DateTime.MaxValue;
            datePicker.Value   = DateTime.Today;

            List <ClassTimeModel> timeListStart       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart = new ClassTimeController();

            timeListStart = timeControllerStart.Get();

            comboBoxStartTime.DataSource    = timeListStart;
            comboBoxStartTime.DisplayMember = "ClassTimeText";
            comboBoxStartTime.ValueMember   = "Id";

            List <ClassTimeModel> timeListEnd       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd = new ClassTimeController();

            timeListEnd = timeControllerEnd.Get();

            comboBoxEndTime.DataSource    = timeListEnd;
            comboBoxEndTime.DisplayMember = "ClassTimeText";
            comboBoxEndTime.ValueMember   = "Id";

            comboBoxClassType.DataSource = Enum.GetValues(typeof(ClassTypes));
        }
 public List <SectionModel> GetByFaculty(FacultyUserModel faculty)
 {
     using (IDbConnection conn = SQLiteDBConnection.Get())
     {
         var query = $"SELECT * FROM Sections WHERE FacultyId = @Id";
         return(conn.Query <SectionModel>(query, faculty).ToList());
     }
 }
Beispiel #4
0
        public FormDashboard(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = "Welcome, " + gotFaculty.FullName;

            buttonYourSections.Focus();
        }
Beispiel #5
0
 public FacultyUserModel UpdateInfo(FacultyUserModel model)
 {
     using (IDbConnection conn = SQLiteDBConnection.Get())
     {
         var query = @"UPDATE Users SET FirstName = @FirstName, LastName = @LastName, Email = @Email WHERE Id = @Id";
         conn.Execute(query, model);
     }
     return(model);
 }
Beispiel #6
0
 public FacultyUserModel GetPasswordByUser(FacultyUserModel model)
 {
     using (IDbConnection conn = SQLiteDBConnection.Get())
     {
         var query      = @"SELECT Password FROM Users where Id = @Id;";
         var parameters = new DynamicParameters();
         parameters.Add("@Id", model.Id);
         return(conn.QuerySingle <FacultyUserModel>(query, parameters));
     }
 }
 public ProfileForm(FacultyUserModel gotFaculty)
 {
     InitializeComponent();
     faculty               = gotFaculty;
     labelWelcome.Text     = faculty.FullName;
     textBoxFirstName.Text = faculty.FirstName;
     textBoxLastName.Text  = faculty.LastName;
     textBoxEmail.Text     = faculty.Email;
     labelId.Text          = faculty.AcademicId;
     //faculty.
 }
        public AllClassesForm(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = faculty.FullName;

            try
            {
                ClassController   ccontroller    = new ClassController();
                List <ClassModel> allClassesList = ccontroller.GetByFacultyId(faculty.Id);
                //Console.WriteLine(allClassesList.Count + " improper classes");
                List <ProperClassModel> properClassList = new List <ProperClassModel>();
                foreach (ClassModel model in allClassesList)
                {
                    ProperClassModel properModel = new ProperClassModel();
                    properModel.ClassDate   = model.ClassDate;
                    properModel.ClassType   = model.ClassType;
                    properModel.EndTimeId   = model.EndTimeId;
                    properModel.Id          = model.Id;
                    properModel.RoomNo      = model.RoomNo;
                    properModel.SectionId   = model.SectionId;
                    properModel.StartTimeId = model.StartTimeId;

                    //Console.WriteLine("improper date: " + model.ClassDate + " | proper date: " + properModel.ClassDate);

                    SectionController scontroller = new SectionController();
                    properModel.SectionName = scontroller.Get(model.SectionId).SectionName;

                    ClassTimeController ctcontroller = new ClassTimeController();
                    properModel.Time = ctcontroller.Get(model.StartTimeId).ClassTimeText + " - " + ctcontroller.Get(model.EndTimeId).ClassTimeText;

                    properClassList.Add(properModel);
                }
                MySortableBindingList <ProperClassModel> bindingClassesList = new MySortableBindingList <ProperClassModel>(properClassList);
                //Console.WriteLine(bindingClassesList.Count + " classes found");
                dataGridViewClassList.AutoGenerateColumns = false;
                dataGridViewClassList.DataSource          = bindingClassesList;
                dataGridViewSerial.AutoGenerateColumns    = false;
                dataGridViewSerial.DataSource             = bindingClassesList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            dataGridViewSerial.DataBindingComplete += (o, e) =>
            {
                foreach (DataGridViewRow row in dataGridViewSerial.Rows)
                {
                    row.Cells["sln"].Value = (row.Index + 1).ToString();
                }
            };
        }
Beispiel #9
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            if (!(textBoxEmail.Text == "Email") && !(textBoxPassword.Text == "Password") && !(string.IsNullOrWhiteSpace(textBoxEmail.Text)) && !(string.IsNullOrWhiteSpace(textBoxPassword.Text)))
            {
                LoadingForm loadingForm = new LoadingForm();
                loadingForm.Show();

                loadingForm.Step(20);
                var           controller = new UserController();
                Argon2Hashing hashing    = new Argon2Hashing();
                try
                {
                    FacultyUserModel faculty = controller.GetByEmail(textBoxEmail.Text);
                    if (faculty == null)
                    {
                        textBoxPassword.Clear();
                        textBoxPassword.Focus();
                    }
                    else
                    {
                        //Console.WriteLine("Got hash: " + faculty.Password);
                        //Console.WriteLine("Got salt: " + faculty.salt);
                        //Console.WriteLine("Verification: " + hashing.VerifyHash(textBoxPassword.Text, Convert.FromBase64String(faculty.salt), Convert.FromBase64String(faculty.Password)));
                        loadingForm.Step(20);
                        if (hashing.VerifyHash(textBoxPassword.Text, Convert.FromBase64String(faculty.salt), Convert.FromBase64String(faculty.Password)))
                        {
                            loadingForm.Step(60);
                            loadingForm.Close();
                            var dash = new FormDashboard(faculty);
                            dash.FormClosed += new FormClosedEventHandler(dash_FormClosed);
                            dash.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Incorrect email or password. Please try again");
                        }
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                loadingForm.Close();
            }
            else
            {
                MessageBox.Show("Please insert your login credentials first");
            }
        }
        private void ButtonSignUp_Click(object sender, EventArgs e)
        {
            if (!(textBoxFirstNameSignUp.Text == "First Name") && !(textBoxLastNameSignUp.Text == "Last Name"))
            {
                if (textBoxPassSignUp.Text == textBoxConfirmPassSignUp.Text)
                {
                    //MessageBox.Show("Sign up pressed");
                    FacultyUserModel faculty = new FacultyUserModel();
                    faculty.AcademicId = textBoxAcademicIdSignUp.Text;
                    faculty.FirstName  = textBoxFirstNameSignUp.Text;
                    faculty.LastName   = textBoxLastNameSignUp.Text;
                    faculty.Email      = textBoxEmailSignup.Text;
                    faculty.Password   = textBoxPassSignUp.Text;
                    //faculty.CreatedAt =
                    //faculty.CreatedAt = DateTime.Now;

                    try
                    {
                        faculty.IsValid();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    MessageBox.Show("Data accepted");

                    try
                    {
                        var controller = new UserController();
                        controller.Create(faculty);
                        buttonCancel.PerformClick();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Passwords do not match");
                }
            }
            else
            {
                MessageBox.Show("Please fill up all fields");
            }
        }
Beispiel #11
0
        public EditClassPopupForm(FacultyUserModel gotFaculty, ClassModel gotClass)
        {
            InitializeComponent();
            faculty = gotFaculty;
            Class   = gotClass;

            SectionController scontroller = new SectionController();

            labelTitle.Text = "Edit class of " + scontroller.Get(Class.SectionId).SectionName + " on " + Class.ClassDate;

            datePicker.CalendarForeColor       = Color.FromArgb(217, 217, 217);
            datePicker.CalendarMonthBackground = Color.FromArgb(49, 49, 49);

            datePicker.MinDate = DateTime.Today;
            datePicker.MaxDate = DateTime.MaxValue;
            datePicker.Value   = DateTime.Parse(Class.ClassDate);

            List <ClassTimeModel> timeListStart       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart = new ClassTimeController();

            timeListStart = timeControllerStart.Get();

            comboBoxStartTime.DataSource    = timeListStart;
            comboBoxStartTime.DisplayMember = "ClassTimeText";
            comboBoxStartTime.ValueMember   = "Id";
            comboBoxStartTime.SelectedIndex = Class.StartTimeId - 1;

            List <ClassTimeModel> timeListEnd       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd = new ClassTimeController();

            timeListEnd = timeControllerEnd.Get();

            comboBoxEndTime.DataSource    = timeListEnd;
            comboBoxEndTime.DisplayMember = "ClassTimeText";
            comboBoxEndTime.ValueMember   = "Id";
            comboBoxEndTime.SelectedIndex = Class.EndTimeId - 1;

            comboBoxClassType.DataSource    = Enum.GetValues(typeof(ClassTypes));
            comboBoxClassType.SelectedIndex = Convert.ToInt32(Class.ClassType);

            textBoxRoomNo.Text = Class.RoomNo;
        }
Beispiel #12
0
        public FacultyUserModel GetByEmail(string email)
        {
            FacultyUserModel faculty = null;

            using (IDbConnection conn = SQLiteDBConnection.Get())
            {
                var query      = @"SELECT * FROM Users WHERE Email = @Email;";
                var parameters = new DynamicParameters();
                parameters.Add("@Email", email);
                try
                {
                    faculty = conn.QuerySingle <FacultyUserModel>(query, parameters);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Incorrect email or password. Please try again");
                }
                return(faculty);
            }
        }
Beispiel #13
0
        //public override List<BaseUserModel> Get()
        //{
        //    using (IDbConnection conn = SQLiteDBConnection.Get())
        //    {
        //        return conn.Query<dynamic, FacultyUserModel, StudentUserModel, BaseUserModel>
        //        ($"SELECT * FROM {TableName}", (baseUser, faculty, student) =>
        //        {
        //            if (baseUser.UserType == UserTypes.Faculty)
        //            {
        //                return new FacultyUserModel();
        //            }
        //            else if (baseUser.UserType == UserTypes.Student)
        //            {
        //                return new StudentUserModel();
        //            }
        //            return baseUser;
        //        });
        //    }
        //}

        public FacultyUserModel ValidateLogin(string email, string password)
        {
            FacultyUserModel faculty = null;

            using (IDbConnection conn = SQLiteDBConnection.Get())
            {
                var query      = @"SELECT * FROM Users where Email = @email AND Password = @password;";
                var parameters = new DynamicParameters();
                parameters.Add("@email", email);
                parameters.Add("@password", password);
                try
                {
                    faculty = conn.QuerySingle <FacultyUserModel>(query, parameters);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Wrong Login info. Please try again");
                }
            }
            return(faculty);
        }
        public FormYourSections(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = faculty.FullName;

            SectionController controller = new SectionController();

            try
            {
                List <SectionModel> sectionList = controller.GetByFaculty(faculty);
                //Console.WriteLine("Sections: ");
                foreach (SectionModel model in sectionList)
                {
                    //Console.WriteLine("Name: " + model.SectionName);
                    Panel sectionPanel = new Panel();
                    sectionPanel.Width       = 194;
                    sectionPanel.Height      = 102;
                    sectionPanel.BorderStyle = BorderStyle.None;
                    sectionPanel.Margin      = new Padding(0, 3, 7, 5);
                    sectionPanel.BackColor   = Color.FromArgb(38, 143, 164);
                    flowLayoutPanelSections.Controls.Add(sectionPanel);

                    Label labelSectionName = new Label();
                    labelSectionName.Text      = model.SectionName;
                    labelSectionName.Font      = new Font("Arial", 10, FontStyle.Regular);
                    labelSectionName.ForeColor = Color.FromArgb(217, 217, 217);
                    labelSectionName.Location  = new Point(8, 8);
                    labelSectionName.Size      = new Size(186, 100);

                    SectionTimeController   timeController = new SectionTimeController();
                    List <SectionTimeModel> sectionTimes   = timeController.GetBySection(model);

                    sectionPanel.Controls.Add(labelSectionName);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(textBoxFirstName.Text) && !string.IsNullOrWhiteSpace(textBoxLastName.Text) && !string.IsNullOrWhiteSpace(textBoxEmail.Text))
            {
                FacultyUserModel updatedModel = new FacultyUserModel();
                updatedModel.AcademicId = faculty.AcademicId;
                updatedModel.FirstName  = textBoxFirstName.Text.Trim();
                updatedModel.LastName   = textBoxLastName.Text.Trim();
                updatedModel.Email      = textBoxEmail.Text.ToLower().Trim();
                updatedModel.Id         = faculty.Id;
                updatedModel.Password   = faculty.Password;

                try
                {
                    updatedModel.IsValid();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                if (MessageBox.Show("Save changes?", "Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    try
                    {
                        var controller = new UserController();
                        faculty = controller.Update(updatedModel);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please fill up all fields");
            }
        }
Beispiel #16
0
        public YourSectionsForm(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = faculty.FullName;

            SectionController controller = new SectionController();

            try
            {
                List <SectionModel> sectionList = controller.GetByFaculty(faculty);
                if (sectionList.Count == 0)
                {
                    Label noSections = new Label();
                    noSections.Text      = "You have no sections added. To add a section,";
                    noSections.Font      = new Font("Arial", 12, FontStyle.Regular);
                    noSections.TextAlign = ContentAlignment.MiddleCenter;
                    noSections.ForeColor = Color.FromArgb(217, 217, 217);
                    noSections.AutoSize  = true;
                    noSections.Margin    = new Padding(3, 3, 0, 3);

                    flowLayoutPanelSections.Controls.Add(noSections);

                    Label clickHere = new Label();
                    clickHere.Text      = "click here";
                    clickHere.Font      = new Font("Arial", 12, FontStyle.Underline);
                    clickHere.ForeColor = Color.FromArgb(217, 217, 217);
                    clickHere.Margin    = new Padding(0, 3, 3, 3);
                    clickHere.Cursor    = Cursors.Hand;
                    clickHere.Click    += new System.EventHandler(this.ClickHere_Click);;

                    flowLayoutPanelSections.Controls.Add(clickHere);
                }
                int r = 28;
                int g = 124;
                int b = 143;
                int i = 1;
                foreach (SectionModel model in sectionList)
                {
                    //Console.WriteLine("Name: " + model.SectionName);
                    FlowLayoutPanel sectionPanel = new FlowLayoutPanel();
                    sectionPanel.Width                    = 188;
                    sectionPanel.Height                   = 110;
                    sectionPanel.BorderStyle              = BorderStyle.None;
                    sectionPanel.Margin                   = new Padding(0, 3, 7, 5);
                    sectionPanel.BackColor                = Color.FromArgb(r, g, b);
                    sectionPanel.FlowDirection            = FlowDirection.LeftToRight;
                    sectionPanel.WrapContents             = true;
                    sectionPanel.AutoScroll               = false;
                    sectionPanel.VerticalScroll.Visible   = false;
                    sectionPanel.HorizontalScroll.Enabled = false;
                    flowLayoutPanelSections.Controls.Add(sectionPanel);

                    Label labelSectionName = new Label();
                    labelSectionName.Text        = model.SectionName;
                    labelSectionName.Font        = new Font("Arial", 10, FontStyle.Regular);
                    labelSectionName.ForeColor   = Color.FromArgb(217, 217, 217);
                    labelSectionName.AutoSize    = false;
                    labelSectionName.Size        = new Size(sectionPanel.Width - 4, 32);
                    labelSectionName.Margin      = new Padding(5, 8, 0, 3);
                    labelSectionName.UseMnemonic = false;

                    sectionPanel.Controls.Add(labelSectionName);

                    SectionTimeController   timeController = new SectionTimeController();
                    List <SectionTimeModel> sectionTimes   = timeController.GetBySection(model);

                    foreach (SectionTimeModel timeModel in sectionTimes)
                    {
                        WeekDayController   dayCon   = new WeekDayController();
                        ClassTimeController classCon = new ClassTimeController();

                        Label sectionTimeText1 = new Label();
                        sectionTimeText1.Text = timeModel.ClassType + ": " + dayCon.Get(timeModel.WeekDayId).WeekDayText.Substring(0, 3) + " " + classCon.Get(timeModel.StartTimeId).ClassTimeText + " - " + classCon.Get(timeModel.EndTimeId).ClassTimeText + " [" + timeModel.RoomNo + "]";
                        if (sectionTimes.Count == 2)
                        {
                            sectionTimeText1.AutoSize = true;
                        }
                        else
                        {
                            sectionTimeText1.Size = new Size(sectionPanel.Width - 4, 32);
                        }
                        sectionTimeText1.Font      = new Font("Arial", 8, FontStyle.Italic);
                        sectionTimeText1.ForeColor = Color.FromArgb(217, 217, 217);

                        if (timeModel == sectionTimes[0])
                        {
                            sectionTimeText1.Margin = new Padding(4, 0, 0, 0);
                        }
                        else
                        {
                            sectionTimeText1.Margin = new Padding(4, 0, 0, 4);
                        }

                        sectionPanel.Controls.Add(sectionTimeText1);
                    }

                    Button studentsButton = new Button();
                    studentsButton.Text      = "Students";
                    studentsButton.BackColor = Color.FromArgb(38, 143, 164);
                    studentsButton.Cursor    = Cursors.Hand;
                    studentsButton.FlatAppearance.BorderSize = 0;
                    studentsButton.FlatStyle = FlatStyle.Flat;
                    studentsButton.Font      = new Font("Arial", 10F);
                    studentsButton.ForeColor = Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    studentsButton.AutoSize  = false;
                    studentsButton.Size      = new Size(75, 25);
                    studentsButton.Margin    = new Padding(12, 2, 6, 0);
                    studentsButton.Anchor    = AnchorStyles.Bottom | AnchorStyles.Left;
                    studentsButton.Dock      = DockStyle.Bottom | DockStyle.Left;
                    studentsButton.Click    += delegate(object sender, EventArgs e) { studentsButton_Click(sender, e, model); };


                    sectionPanel.Controls.Add(studentsButton);

                    Button editButton = new Button();
                    editButton.Text      = "Edit";
                    editButton.BackColor = Color.FromArgb(38, 143, 164);
                    editButton.Cursor    = Cursors.Hand;
                    editButton.FlatAppearance.BorderSize = 0;
                    editButton.FlatStyle = FlatStyle.Flat;
                    editButton.Font      = new Font("Arial", 10F);
                    editButton.ForeColor = Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    editButton.AutoSize  = false;
                    editButton.Size      = new Size(75, 25);
                    editButton.Margin    = new Padding(6, 2, 12, 0);
                    editButton.Anchor    = AnchorStyles.Bottom | AnchorStyles.Right;
                    editButton.Click    += delegate(object sender, EventArgs e) { editButton_Click(sender, e, model, sectionTimes); };

                    sectionPanel.Controls.Add(editButton);

                    if (i % 3 == 0)
                    {
                        r -= 5; g -= 5; b -= 5;
                    }
                    i++;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public EditSectionForm(FacultyUserModel gotFaculty, SectionModel gotSection, List <SectionTimeModel> gotSectionTimes)
        {
            InitializeComponent();
            faculty                 = gotFaculty;
            section                 = gotSection;
            sectionTimes            = gotSectionTimes;
            labelWelcome.Text       = faculty.FullName;
            labelEditSection.Text   = "Edit section: " + section.SectionName;
            textBoxSectionName.Text = section.SectionName;

            List <WeekDayModel> dayList1       = new List <WeekDayModel>();
            WeekDayController   dayController1 = new WeekDayController();

            dayList1 = dayController1.Get();

            comboBoxWeekDay1.DataSource    = dayList1;
            comboBoxWeekDay1.DisplayMember = "WeekDayText";
            comboBoxWeekDay1.ValueMember   = "Id";

            comboBoxWeekDay1.SelectedIndex = sectionTimes[0].WeekDayId - 1;

            List <WeekDayModel> dayList2       = new List <WeekDayModel>();
            WeekDayController   dayController2 = new WeekDayController();

            dayList2 = dayController2.Get();

            comboBoxWeekDay2.DataSource    = dayList2;
            comboBoxWeekDay2.DisplayMember = "WeekDayText";
            comboBoxWeekDay2.ValueMember   = "Id";

            if (!(sectionTimes.Count == 1))
            {
                comboBoxWeekDay2.SelectedIndex = sectionTimes[1].WeekDayId - 1;
            }

            List <ClassTimeModel> timeListStart1       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart1 = new ClassTimeController();

            timeListStart1 = timeControllerStart1.Get();

            comboBoxStartTime1.DataSource    = timeListStart1;
            comboBoxStartTime1.DisplayMember = "ClassTimeText";
            comboBoxStartTime1.ValueMember   = "Id";

            comboBoxStartTime1.SelectedIndex = sectionTimes[0].StartTimeId - 1;

            List <ClassTimeModel> timeListStart2       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart2 = new ClassTimeController();

            timeListStart2 = timeControllerStart2.Get();

            comboBoxStartTime2.DataSource    = timeListStart2;
            comboBoxStartTime2.DisplayMember = "ClassTimeText";
            comboBoxStartTime2.ValueMember   = "Id";
            if (!(sectionTimes.Count == 1))
            {
                comboBoxStartTime2.SelectedIndex = sectionTimes[1].StartTimeId - 1;
            }

            List <ClassTimeModel> timeListEnd1       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd1 = new ClassTimeController();

            timeListEnd1 = timeControllerEnd1.Get();

            comboBoxEndTime1.DataSource    = timeListEnd1;
            comboBoxEndTime1.DisplayMember = "ClassTimeText";
            comboBoxEndTime1.ValueMember   = "Id";

            comboBoxEndTime1.SelectedIndex = sectionTimes[0].EndTimeId - 1;

            List <ClassTimeModel> timeListEnd2       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd2 = new ClassTimeController();

            timeListEnd2 = timeControllerEnd2.Get();

            comboBoxEndTime2.DataSource    = timeListEnd2;
            comboBoxEndTime2.DisplayMember = "ClassTimeText";
            comboBoxEndTime2.ValueMember   = "Id";
            if (!(sectionTimes.Count == 1))
            {
                comboBoxEndTime2.SelectedIndex = sectionTimes[1].EndTimeId - 1;
            }

            comboBoxClassType1.DataSource = Enum.GetValues(typeof(ClassTypes));
            comboBoxClassType2.DataSource = Enum.GetValues(typeof(ClassTypes));

            comboBoxClassType1.SelectedItem = sectionTimes[0].ClassType;
            if (!(sectionTimes.Count == 1))
            {
                comboBoxClassType2.SelectedItem = sectionTimes[1].ClassType;
            }

            textBoxRoomNo1.Text = sectionTimes[0].RoomNo;
            if (!(sectionTimes.Count == 1))
            {
                textBoxRoomNo2.Text = sectionTimes[1].RoomNo;
            }
            //if (!(sectionTimes.Count == 1))
            //Console.WriteLine(sectionTimes[0].Id + " " + sectionTimes[1].Id);

            if ((sectionTimes.Count == 1))
            {
                checkBoxIgnore.Checked = true;
                panel3.Controls.Remove(comboBoxWeekDay2);
                panel3.Controls.Remove(labelTime2);
                panel3.Controls.Remove(labelFrom2);
                panel3.Controls.Remove(comboBoxStartTime2);
                panel3.Controls.Remove(labelTo2);
                panel3.Controls.Remove(comboBoxEndTime2);
                panel3.Controls.Remove(labelClassType2);
                panel3.Controls.Remove(comboBoxClassType2);
                panel3.Controls.Remove(labelRoomNo2);
                panel3.Controls.Remove(panelRoomNo2BG);
                panel3.Controls.Remove(textBoxRoomNo2);
                panel3.Controls.Remove(labelCheck);
                panel3.Controls.Remove(checkBoxIgnore);
            }
            else
            {
                panel3.Controls.Remove(labelCheck);
                panel3.Controls.Remove(checkBoxIgnore);
            }
        }
Beispiel #18
0
        public FormCreateManual(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = faculty.FullName;

            List <WeekDayModel> dayList1       = new List <WeekDayModel>();
            WeekDayController   dayController1 = new WeekDayController();

            dayList1 = dayController1.Get();

            comboBoxWeekDay1.DataSource    = dayList1;
            comboBoxWeekDay1.DisplayMember = "WeekDayText";
            comboBoxWeekDay1.ValueMember   = "Id";

            List <WeekDayModel> dayList2       = new List <WeekDayModel>();
            WeekDayController   dayController2 = new WeekDayController();

            dayList2 = dayController2.Get();

            comboBoxWeekDay2.DataSource    = dayList2;
            comboBoxWeekDay2.DisplayMember = "WeekDayText";
            comboBoxWeekDay2.ValueMember   = "Id";

            List <ClassTimeModel> timeListStart1       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart1 = new ClassTimeController();

            timeListStart1 = timeControllerStart1.Get();

            comboBoxStartTime1.DataSource    = timeListStart1;
            comboBoxStartTime1.DisplayMember = "ClassTimeText";
            comboBoxStartTime1.ValueMember   = "Id";

            List <ClassTimeModel> timeListStart2       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerStart2 = new ClassTimeController();

            timeListStart2 = timeControllerStart2.Get();


            comboBoxStartTime2.DataSource    = timeListStart2;
            comboBoxStartTime2.DisplayMember = "ClassTimeText";
            comboBoxStartTime2.ValueMember   = "Id";

            List <ClassTimeModel> timeListEnd1       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd1 = new ClassTimeController();

            timeListEnd1 = timeControllerEnd1.Get();

            comboBoxEndTime1.DataSource    = timeListEnd1;
            comboBoxEndTime1.DisplayMember = "ClassTimeText";
            comboBoxEndTime1.ValueMember   = "Id";

            List <ClassTimeModel> timeListEnd2       = new List <ClassTimeModel>();
            ClassTimeController   timeControllerEnd2 = new ClassTimeController();

            timeListEnd2 = timeControllerEnd2.Get();

            comboBoxEndTime2.DataSource    = timeListEnd2;
            comboBoxEndTime2.DisplayMember = "ClassTimeText";
            comboBoxEndTime2.ValueMember   = "Id";

            comboBoxClassType1.DataSource = Enum.GetValues(typeof(ClassTypes));
            comboBoxClassType2.DataSource = Enum.GetValues(typeof(ClassTypes));
        }
        public OpenSpreadSheetForm(FacultyUserModel gotFaculty)
        {
            InitializeComponent();

            faculty = gotFaculty;
        }
Beispiel #20
0
 public List <SectionModel> GetByFaculty(FacultyUserModel faculty)
 {
     return(DataAccess.GetByFaculty(faculty));
 }
        public YourClassesForm(FacultyUserModel gotFaculty)
        {
            InitializeComponent();
            faculty           = gotFaculty;
            labelWelcome.Text = faculty.FullName;

            Label labelToday = new Label();

            labelToday.Anchor    = System.Windows.Forms.AnchorStyles.Left;
            labelToday.AutoSize  = true;
            labelToday.Font      = new System.Drawing.Font("Arial", 12.5F);
            labelToday.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
            labelToday.Location  = new System.Drawing.Point(25, 151);
            labelToday.Margin    = new System.Windows.Forms.Padding(20, 10, 0, 10);
            labelToday.Name      = "labelToday";
            labelToday.Size      = new System.Drawing.Size(52, 19);
            labelToday.TabIndex  = 8;
            labelToday.Text      = "Today";
            labelToday.Margin    = new Padding(25, 13, 0, 0);

            flowLayoutPanelClasses.Controls.Add(labelToday);

            Panel panelTodayUL = new Panel();

            panelTodayUL.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
            panelTodayUL.Location  = new System.Drawing.Point(20, 178);
            panelTodayUL.Name      = "panelTodayUL";
            panelTodayUL.Size      = new System.Drawing.Size(576, 1);
            panelTodayUL.TabIndex  = 9;
            panelTodayUL.Margin    = new Padding(19, 8, 0, 0);

            flowLayoutPanelClasses.Controls.Add(panelTodayUL);

            flowLayoutPanelToday.AutoScroll    = false;
            flowLayoutPanelToday.AutoSize      = true;
            flowLayoutPanelToday.AutoSizeMode  = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            flowLayoutPanelToday.Location      = new System.Drawing.Point(20, 186);
            flowLayoutPanelToday.Name          = "flowLayoutPanelToday";
            flowLayoutPanelToday.Size          = new System.Drawing.Size(0, 0);
            flowLayoutPanelToday.TabIndex      = 10;
            flowLayoutPanelToday.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanelToday_ControlAdded);
            flowLayoutPanelToday.WrapContents  = true;
            flowLayoutPanelToday.FlowDirection = FlowDirection.LeftToRight;
            flowLayoutPanelToday.Margin        = new Padding(19, 5, 0, 0);

            ClassController   ccontroller   = new ClassController();
            List <ClassModel> todaysClasses = ccontroller.GetByDateAndFacultyId(DateTime.Today.ToString("yyyy-MM-dd"), faculty.Id);
            //todaysClasses.Sort();
            //Console.WriteLine("Found " + todaysClasses.Count + "classes");
            int r = 112;
            int g = 52;
            int b = 158;

            if (todaysClasses.Count != 0)
            {
                foreach (ClassModel model in todaysClasses)
                {
                    Panel classPanel = new Panel();
                    classPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(r)))), ((int)(((byte)(g)))), ((int)(((byte)(b)))));
                    classPanel.Size      = new System.Drawing.Size(285, 71);
                    classPanel.Margin    = new Padding(0, 0, 5, 5);

                    SectionController scontroller = new SectionController();
                    var   gotSection  = scontroller.Get(model.SectionId);
                    Label sectionName = new Label();
                    sectionName.Text      = gotSection.SectionName;
                    sectionName.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    sectionName.AutoSize  = false;
                    sectionName.Font      = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    sectionName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    sectionName.Location  = new System.Drawing.Point(10, 10);
                    sectionName.Margin    = new System.Windows.Forms.Padding(10, 10, 0, 0);
                    sectionName.Name      = "labelSectionName";
                    sectionName.Size      = new System.Drawing.Size(217, 32);

                    classPanel.Controls.Add(sectionName);

                    Label classType = new Label();
                    classType.Text      = model.ClassType.ToString();
                    classType.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    classType.AutoSize  = true;
                    classType.Font      = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Italic);
                    classType.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    classType.Location  = new System.Drawing.Point(10, 45);
                    classType.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    classType.Name      = "labelClassType";
                    classType.Size      = new System.Drawing.Size(53, 16);

                    classPanel.Controls.Add(classType);

                    ClassTimeController ctcontroller = new ClassTimeController();
                    Label classTime = new Label();
                    classTime.Text      = ctcontroller.Get(model.StartTimeId).ClassTimeText + " - " + ctcontroller.Get(model.EndTimeId).ClassTimeText;
                    classTime.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    classTime.AutoSize  = true;
                    classTime.Font      = new System.Drawing.Font("Arial", 10F);
                    classTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    classTime.Location  = new System.Drawing.Point(73, 45);
                    classTime.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    classTime.Name      = "labelClassTime";
                    classTime.Size      = new System.Drawing.Size(93, 16);

                    classPanel.Controls.Add(classTime);

                    Label roomNo = new Label();
                    roomNo.Text      = model.RoomNo;
                    roomNo.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    roomNo.AutoSize  = true;
                    roomNo.Font      = new System.Drawing.Font("Arial", 10F);
                    roomNo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    roomNo.Location  = new System.Drawing.Point(176, 45);
                    roomNo.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    roomNo.Name      = "labelRoomNo";
                    roomNo.Size      = new System.Drawing.Size(50, 16);

                    classPanel.Controls.Add(roomNo);

                    Button buttonEdit = new Button();
                    buttonEdit.BackgroundImage           = Properties.Resources.edit;
                    buttonEdit.Location                  = new System.Drawing.Point(250, 8);
                    buttonEdit.Size                      = new System.Drawing.Size(20, 20);
                    buttonEdit.FlatStyle                 = FlatStyle.Flat;
                    buttonEdit.FlatAppearance.BorderSize = 0;
                    buttonEdit.Cursor                    = Cursors.Hand;
                    buttonEdit.BackgroundImageLayout     = ImageLayout.Stretch;
                    buttonEdit.Click                    += (sender, EventArgs) => { ButtonEdit_Click(sender, EventArgs, model); };;

                    classPanel.Controls.Add(buttonEdit);

                    Button buttonDelete = new Button();
                    buttonDelete.BackgroundImage           = Properties.Resources.delete;
                    buttonDelete.Location                  = new System.Drawing.Point(250, 40);
                    buttonDelete.Size                      = new System.Drawing.Size(22, 22);
                    buttonDelete.FlatStyle                 = FlatStyle.Flat;
                    buttonDelete.FlatAppearance.BorderSize = 0;
                    buttonDelete.Cursor                    = Cursors.Hand;
                    buttonDelete.BackgroundImageLayout     = ImageLayout.Center;
                    buttonDelete.Click                    += (sender, EventArgs) => { ButtonDelete_Click(sender, EventArgs, model); };;

                    classPanel.Controls.Add(buttonDelete);

                    flowLayoutPanelToday.Controls.Add(classPanel);

                    r -= 5; g -= 5; b -= 5;
                }
            }
            else
            {
                Label labelNoClasses = new Label();
                labelNoClasses.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                labelNoClasses.AutoSize  = false;
                labelNoClasses.Font      = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Italic);
                labelNoClasses.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                labelNoClasses.Location  = new System.Drawing.Point(25, 151);
                labelNoClasses.Margin    = new System.Windows.Forms.Padding(20, 10, 0, 10);
                labelNoClasses.Name      = "labelToday";
                labelNoClasses.Size      = new System.Drawing.Size(500, 19);
                labelNoClasses.TabIndex  = 8;
                labelNoClasses.Text      = "No classes today";
                labelNoClasses.Margin    = new Padding(25, 13, 0, 0);

                flowLayoutPanelClasses.Controls.Add(labelNoClasses);
            }

            flowLayoutPanelClasses.Controls.Add(flowLayoutPanelToday);

            Label labelTomorrow = new Label();

            labelTomorrow.Anchor    = System.Windows.Forms.AnchorStyles.Left;
            labelTomorrow.AutoSize  = false;
            labelTomorrow.Font      = new System.Drawing.Font("Arial", 12.5F);
            labelTomorrow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
            labelTomorrow.Location  = new System.Drawing.Point(25, 151);
            labelTomorrow.Margin    = new System.Windows.Forms.Padding(20, 10, 0, 10);
            labelTomorrow.Name      = "labelTomorrow";
            labelTomorrow.Size      = new System.Drawing.Size(500, 19);
            labelTomorrow.TabIndex  = 8;
            labelTomorrow.Text      = "Tomorrow";
            labelTomorrow.Margin    = new Padding(25, 13, 0, 0);

            flowLayoutPanelClasses.Controls.Add(labelTomorrow);

            Panel panelTommorrowUL = new Panel();

            panelTommorrowUL.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
            panelTommorrowUL.Location  = new System.Drawing.Point(20, 178);
            panelTommorrowUL.Name      = "panelTomorrowUL";
            panelTommorrowUL.Size      = new System.Drawing.Size(576, 1);
            panelTommorrowUL.TabIndex  = 9;
            panelTommorrowUL.Margin    = new Padding(19, 8, 0, 0);

            flowLayoutPanelClasses.Controls.Add(panelTommorrowUL);

            flowLayoutPanelTomorrow.AutoScroll    = false;
            flowLayoutPanelTomorrow.AutoSize      = true;
            flowLayoutPanelTomorrow.AutoSizeMode  = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            flowLayoutPanelTomorrow.Location      = new System.Drawing.Point(20, 186);
            flowLayoutPanelTomorrow.Name          = "flowLayoutPanelToday";
            flowLayoutPanelTomorrow.Size          = new System.Drawing.Size(0, 0);
            flowLayoutPanelTomorrow.TabIndex      = 10;
            flowLayoutPanelTomorrow.ControlAdded += new System.Windows.Forms.ControlEventHandler(this.flowLayoutPanelToday_ControlAdded);
            flowLayoutPanelTomorrow.WrapContents  = true;
            flowLayoutPanelTomorrow.FlowDirection = FlowDirection.LeftToRight;
            flowLayoutPanelTomorrow.Margin        = new Padding(19, 5, 0, 0);

            List <ClassModel> tomorrowClasses = ccontroller.GetByDateAndFacultyId(DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"), faculty.Id);
            //Console.WriteLine("Found " + todaysClasses.Count + "classes");
            int r2 = 112;
            int g2 = 52;
            int b2 = 158;

            if (tomorrowClasses.Count != 0)
            {
                foreach (ClassModel model in tomorrowClasses)
                {
                    Panel classPanel = new Panel();
                    classPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(r2)))), ((int)(((byte)(g2)))), ((int)(((byte)(b2)))));
                    classPanel.Size      = new System.Drawing.Size(285, 71);
                    classPanel.Margin    = new Padding(0, 0, 5, 5);

                    SectionController scontroller = new SectionController();
                    var   gotSection  = scontroller.Get(model.SectionId);
                    Label sectionName = new Label();
                    sectionName.Text      = gotSection.SectionName;
                    sectionName.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    sectionName.AutoSize  = false;
                    sectionName.Font      = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    sectionName.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    sectionName.Location  = new System.Drawing.Point(10, 10);
                    sectionName.Margin    = new System.Windows.Forms.Padding(10, 10, 0, 0);
                    sectionName.Name      = "labelSectionName";
                    sectionName.Size      = new System.Drawing.Size(217, 32);

                    classPanel.Controls.Add(sectionName);

                    Label classType = new Label();
                    classType.Text      = model.ClassType.ToString();
                    classType.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    classType.AutoSize  = true;
                    classType.Font      = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Italic);
                    classType.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    classType.Location  = new System.Drawing.Point(10, 45);
                    classType.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    classType.Name      = "labelClassType";
                    classType.Size      = new System.Drawing.Size(53, 16);

                    classPanel.Controls.Add(classType);

                    ClassTimeController ctcontroller = new ClassTimeController();
                    Label classTime = new Label();
                    classTime.Text      = ctcontroller.Get(model.StartTimeId).ClassTimeText + " - " + ctcontroller.Get(model.EndTimeId).ClassTimeText;
                    classTime.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    classTime.AutoSize  = true;
                    classTime.Font      = new System.Drawing.Font("Arial", 10F);
                    classTime.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    classTime.Location  = new System.Drawing.Point(73, 45);
                    classTime.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    classTime.Name      = "labelClassTime";
                    classTime.Size      = new System.Drawing.Size(93, 16);

                    classPanel.Controls.Add(classTime);

                    Label roomNo = new Label();
                    roomNo.Text      = model.RoomNo;
                    roomNo.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                    roomNo.AutoSize  = true;
                    roomNo.Font      = new System.Drawing.Font("Arial", 10F);
                    roomNo.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                    roomNo.Location  = new System.Drawing.Point(176, 45);
                    roomNo.Margin    = new System.Windows.Forms.Padding(10, 3, 0, 0);
                    roomNo.Name      = "labelRoomNo";
                    roomNo.Size      = new System.Drawing.Size(50, 16);

                    classPanel.Controls.Add(roomNo);

                    Button buttonEdit = new Button();
                    buttonEdit.BackgroundImage           = Properties.Resources.edit;
                    buttonEdit.Location                  = new System.Drawing.Point(250, 8);
                    buttonEdit.Size                      = new System.Drawing.Size(20, 20);
                    buttonEdit.FlatStyle                 = FlatStyle.Flat;
                    buttonEdit.FlatAppearance.BorderSize = 0;
                    buttonEdit.Cursor                    = Cursors.Hand;
                    buttonEdit.BackgroundImageLayout     = ImageLayout.Stretch;
                    buttonEdit.Click                    += (sender, EventArgs) => { ButtonEdit_Click(sender, EventArgs, model); };;

                    classPanel.Controls.Add(buttonEdit);

                    Button buttonDelete = new Button();
                    buttonDelete.BackgroundImage           = Properties.Resources.delete;
                    buttonDelete.Location                  = new System.Drawing.Point(250, 40);
                    buttonDelete.Size                      = new System.Drawing.Size(22, 22);
                    buttonDelete.FlatStyle                 = FlatStyle.Flat;
                    buttonDelete.FlatAppearance.BorderSize = 0;
                    buttonDelete.Cursor                    = Cursors.Hand;
                    buttonDelete.BackgroundImageLayout     = ImageLayout.Center;
                    buttonDelete.Click                    += (sender, EventArgs) => { ButtonDelete_Click(sender, EventArgs, model); };;

                    classPanel.Controls.Add(buttonDelete);

                    flowLayoutPanelTomorrow.Controls.Add(classPanel);

                    r -= 5; g -= 5; b -= 5;
                }
            }
            else
            {
                Label labelNoClasses = new Label();
                labelNoClasses.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                labelNoClasses.AutoSize  = false;
                labelNoClasses.Font      = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Italic);
                labelNoClasses.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(217)))), ((int)(((byte)(217)))), ((int)(((byte)(217)))));
                labelNoClasses.Location  = new System.Drawing.Point(25, 151);
                labelNoClasses.Margin    = new System.Windows.Forms.Padding(20, 10, 0, 10);
                labelNoClasses.Name      = "labelToday";
                labelNoClasses.Size      = new System.Drawing.Size(500, 19);
                labelNoClasses.TabIndex  = 8;
                labelNoClasses.Text      = "No classes tomorrow";
                labelNoClasses.Margin    = new Padding(25, 13, 0, 0);

                flowLayoutPanelClasses.Controls.Add(labelNoClasses);
            }

            flowLayoutPanelClasses.Controls.Add(flowLayoutPanelTomorrow);
        }
Beispiel #22
0
 public FacultyUserModel Update(FacultyUserModel model)
 {
     return(DataAccess.UpdateInfo(model));
 }
        public FormStudentList(FacultyUserModel gotFaculty, SectionModel gotSection)
        {
            InitializeComponent();
            faculty = gotFaculty;
            section = gotSection;

            labelWelcome.Text  = faculty.FullName;
            labelStudents.Text = "Students of " + section.SectionName;

            //try
            //{
            UserController controller = new UserController();

            studentList = controller.GetBySection(section);
            ClassController ccontroller = new ClassController();

            classList = ccontroller.GetBySectionId(section.Id);
            AttendanceController acontroller = new AttendanceController();

            attendanceList = acontroller.GetAllBySection(section.Id);

            Console.WriteLine("Found student: " + studentList.Count);
            Console.WriteLine("Found classes: " + classList.Count);
            Console.WriteLine("Found attendances: " + attendanceList.Count);

            List <StudentView> mainList = new List <StudentView>();

            int i = 0;

            foreach (StudentUserModel student in studentList)
            {
                Console.WriteLine("doing student no. " + i);
                StudentView view = new StudentView();
                view.AcademicId = student.AcademicId;
                view.FullName   = student.FullName;
                int c = 0;
                foreach (ClassModel Class in classList)
                {
                    AttendanceModel att = attendanceList.Find(x => (x.ClassId == Class.Id) && (x.StudentId == student.Id));
                    Console.WriteLine("Found attendance id: " + att.Id + " for: " + student.Id + " on: " + Class.Id + " entry: " + att.Entry);
                    view.attendances.Add(att.Entry);

                    DataGridViewColumn col = new DataGridViewTextBoxColumn();
                    col.HeaderText = Class.ClassDate;
                    int colIndex = dataGridViewStudentList.Columns.Add(col);
                    //dataGridViewStudentList.Rows[i].Cells[c+2].Value = att.Entry.ToString();
                    c++;
                }
                mainList.Add(view);

                i++;
            }

            Console.WriteLine("Main list count: " + mainList.Count);
            MySortableBindingList <StudentView> mainListBinding = new MySortableBindingList <StudentView>(mainList);

            dataGridViewStudentList.AutoGenerateColumns = false;
            dataGridViewStudentList.DataSource          = mainListBinding;
            dataGridViewSerial.AutoGenerateColumns      = false;
            dataGridViewSerial.DataSource = mainListBinding;
            dataGridViewSerial.Columns[0].DefaultCellStyle.Padding = new Padding(3, 0, 0, 0);
            dataGridViewStudentList.DataBindingComplete           += (o, e) =>
            {
                foreach (DataGridViewRow row in dataGridViewSerial.Rows)
                {
                    row.Cells["sln"].Value = (row.Index + 1).ToString();
                }
                foreach (DataGridViewColumn column in dataGridViewStudentList.Columns)
                {
                    column.SortMode = DataGridViewColumnSortMode.Programmatic;
                }
            };

            foreach (DataGridViewColumn column in dataGridViewStudentList.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.Automatic;
            }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }
 public FormChangePassword(FacultyUserModel gotFaculty)
 {
     InitializeComponent();
 }
 public AddStudentForm(FacultyUserModel gotFaculty, SectionModel gotSection)
 {
     InitializeComponent();
     faculty = gotFaculty;
     section = gotSection;
 }
Beispiel #26
0
 public FacultyUserModel GetPasswordByUser(FacultyUserModel model)
 {
     return(DataAccess.GetPasswordByUser(model));
 }
Beispiel #27
0
 public FormAddSection(FacultyUserModel gotFaculty)
 {
     InitializeComponent();
     faculty           = gotFaculty;
     labelWelcome.Text = faculty.FullName;
 }
Beispiel #28
0
 //pass Faculty ID to constructor
 public FormDashboard(FacultyUserModel gotFaculty)
 {
     InitializeComponent();
     faculty           = gotFaculty;
     labelWelcome.Text = "Welcome, " + gotFaculty.FullName;
 }
Beispiel #29
0
 public SearchForm(FacultyUserModel gotFaculty)
 {
     InitializeComponent();
     faculty           = gotFaculty;
     labelWelcome.Text = faculty.FullName;
 }
Beispiel #30
0
        private void ButtonSignUp_Click(object sender, EventArgs e)
        {
            if (!(textBoxFirstNameSignUp.Text == "First Name") && !(textBoxLastNameSignUp.Text == "Last Name"))
            {
                if (textBoxPassSignUp.Text == textBoxConfirmPassSignUp.Text)
                {
                    LoadingForm loading = new LoadingForm();
                    loading.Show();
                    FacultyUserModel faculty = new FacultyUserModel();
                    faculty.AcademicId = textBoxAcademicIdSignUp.Text;
                    faculty.FirstName  = textBoxFirstNameSignUp.Text.Trim();
                    faculty.LastName   = textBoxLastNameSignUp.Text.Trim();
                    faculty.Email      = textBoxEmailSignup.Text.ToLower().Trim();
                    faculty.Password   = textBoxPassSignUp.Text;

                    try
                    {
                        faculty.IsValid();
                        loading.Step(20);
                        //hashing now
                        Argon2Hashing hashing = new Argon2Hashing();
                        faculty.salt     = Convert.ToBase64String(hashing.CreateSalt());
                        faculty.Password = Convert.ToBase64String(hashing.HashPassword(textBoxPassSignUp.Text, Convert.FromBase64String(faculty.salt)));
                        loading.Step(20);
                        //hashing done
                        //Console.WriteLine("Salt: " + faculty.salt);
                        //Console.WriteLine("Hashed password: "******"Verify hash: " + hashing.VerifyHash(textBoxPassSignUp.Text, Convert.FromBase64String(faculty.salt), Convert.FromBase64String(faculty.Password)));
                        loading.Step(20);
                        try
                        {
                            var controller = new UserController();
                            controller.Create(faculty);
                            loading.Step(20);
                            loading.Close();
                            MessageBox.Show("Account created. Please login with your email and password");
                            buttonCancel.PerformClick();
                        }
                        catch (SQLiteException ex)
                        {
                            loading.Close();
                            if (ex.ErrorCode == 19)
                            {
                                MessageBox.Show("An account is already registered with this email or ID");
                            }
                            else
                            {
                                MessageBox.Show(ex.Message + ex.ErrorCode);
                            }
                        }catch (Exception ex)
                        {
                            loading.Close();
                            MessageBox.Show(ex.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        loading.Close();
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    MessageBox.Show("Passwords do not match");
                }
            }
            else
            {
                MessageBox.Show("Please fill up all fields");
            }
        }