Exemplo n.º 1
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var _class   = cBoxClass.Text;
                var _subject = cBoxSubject.Text;
                var _term    = cBoxTerm.Text;
                var _session = cBoxSession.Text;

                try
                {
                    var subList = _unitOfWork.SubjectsRepository.FindAll().Where(
                        s => s._class == _class &&
                        s.subjects == _subject &&
                        s.term == _term &&
                        s.session == _session).ToList();

                    if (subList.Any())
                    {
                        dGridStudents.DataSource = subList;
                    }
                    else
                    {
                        MessageBox.Show("No information to display");
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }
            }
        }
Exemplo n.º 2
0
        private async void btnSave_ClickEventAsync(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckTextboxes(this, errorProvider1) &&
                ValidateFomControls.CheckPassword(_txtPassword.Text, _txtConfirmPassword.Text) &&
                ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                try
                {
                    var teacher = CreateTeacher();

                    if (teacher != null)
                    {
                        _unitOfWork = new UnitOfWork(new Model1());
                        _unitOfWork.TeacherRepository.Add(teacher);
                        await _unitOfWork.Save();

                        _unitOfWork.Dispose();
                        MessageBox.Show("Teacher added");
                    }
                    else
                    {
                        ArgumentNullException ex = new ArgumentNullException("Teacher object", "Teacher object is null");
                        Utils.LogException(ex);
                        MessageBox.Show("Error occured. Contact support");
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("An error occured. Please contact support");
                }
            }
        }
Exemplo n.º 3
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var subj = new sss()
                {
                    sss_subjects = cBoxSubject.Text,
                    upload_date  = DateTime.Now.ToString("d"),
                    upload_time  = DateTime.Now
                };
                try
                {
                    using (var db = new Model1())
                    {
                        var isExist = db.ssses.Any(x => x.sss_subjects == subj.sss_subjects);
                        if (!isExist)
                        {
                            db.ssses.Add(subj);
                            db.SaveChanges();

                            dGridSubjecs.DataSource = db.ssses.ToList();
                        }
                        else
                        {
                            MessageBox.Show("Subject already exists");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }
            }
        }
Exemplo n.º 4
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var tc = CreateTeacherClass();

                try
                {
                    var _unitOfWork = new UnitOfWork(new Model1());

                    _unitOfWork.Teachers_ClassesRepository.Add(tc);
                    _unitOfWork.Save();
                    _unitOfWork.Dispose();
                    MessageBox.Show("Added");

                    using (var db = new Model1())
                    {
                        TnCs = db.teachers_classes.ToList();
                        dGridTeachers_Class.DataSource = TnCs;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }
            }
        }
Exemplo n.º 5
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var class_   = cBoxClass.Text;
                var term_    = cBoxTerm.Text;
                var session_ = cBoxSession.Text;


                try
                {
                    using (var db = new Model1())
                    {
                        dGridBehaviour.Cursor = Cursors.WaitCursor;
                        var bhv = db.behaviorals.Where(x => x._class == class_ && x.term == term_ && x.session == session_).ToList();

                        if (bhv != null)
                        {
                            dGridBehaviour.DataSource = bhv;

                            dGridBehaviour.Cursor = Cursors.Arrow;
                        }
                        else
                        {
                            MessageBox.Show("No records found.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("No records found.");
                }
            }
        }
Exemplo n.º 6
0
        private void btnShow_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                Cursor = Cursors.WaitCursor;
                try
                {
                    using (var db = new Model1())
                    {
                        List <student_attendance> attendances = db.student_attendance.Where(x => x.session == cBoxSession.Text &&
                                                                                            x.term == cBoxTerm.Text && x._class == cBoxClass.Text).ToList();

                        dGridAttendance.DataSource = attendances;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }


                Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 7
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            try
            {
                if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
                {
                    var _class   = cBoxClass.Text;
                    var _session = cBoxSession.Text;
                    var _term    = cBoxTerm.Text;

                    using (var db = new Model1())
                    {
                        var positions = db.positions.Where(x => x._class == _class && x.session == _session && x.term == _term).ToList();

                        if (positions == null)
                        {
                            MessageBox.Show("No Found.");
                            return;
                        }

                        dgridPResults.DataSource = positions;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.LogException(ex);
                MessageBox.Show("An Error Occured. Please, Contact Support.");
            }
        }
Exemplo n.º 8
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                try
                {
                    var _class   = cBoxClass.Text;
                    var _session = cBoxSession.Text;
                    var _term    = cBoxTerm.Text;
                    var _subj    = cBoxSubject.Text;

                    Cursor = Cursors.WaitCursor;

                    using (var db = new Model1())
                    {
                        results = db.results1.Where(x => x._class == _class && x.session == _session && x.term == _term && x.subjects == _subj).ToList();

                        dGridStudents.DataSource = results;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("An error has occured. Please contact support");
                }
            }
        }
Exemplo n.º 9
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                students = _unitOfWork.StudentRepository.FindAll().Where(x => x._class == cBoxClass.Text).ToList();

                dgridStudents.DataSource = students;
            }
        }
Exemplo n.º 10
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    using (var db = new Model1())
                    {
                        List <student> students = db.students.Where(x => x._class == cBoxClass.Text).ToList();
                        behaviorals = new List <behavioral>();

                        foreach (var s in students)
                        {
                            behaviorals.Add(new behavioral()
                            {
                                name             = s.Fullname,
                                reg_number       = s.reg_number,
                                term             = cBoxTerm.Text,
                                session          = cBoxSession.Text,
                                _class           = cBoxClass.Text,
                                attentiveness    = "1",
                                attitude_to_work = "1",
                                hand_writting    = "1",
                                health           = "1",
                                musical_skills   = "1",
                                politeness       = "1",
                                sports           = "1",
                            });
                        }
                        dGridStudentsBehaviour.DataSource = behaviorals;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }


                Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 11
0
        private void btnSaveJss_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                try
                {
                    using (var db = new Model1())
                    {
                        var jssnum = db.jss_subject_number.FirstOrDefault();

                        if (jssnum != null)
                        {
                            jssnum.number_of_subject = Convert.ToInt32(cBoxNum.Text);
                            db.SaveChanges();
                            lblJSSNum.Text = string.Format("JSS Students must offer {0} subjects", cBoxNum.Text);
                            MessageBox.Show("Jss Subject Number updated");
                            cBoxNum.SelectedIndex = -1;
                        }
                        else
                        {
                            var _jnum = new jss_subject_number()
                            {
                                declared_date     = DateTime.Now.ToString("d"),
                                declared_time     = DateTime.Now,
                                number_of_subject = Convert.ToInt32(cBoxNum.Text)
                            };


                            db.jss_subject_number.Add(_jnum);
                            db.SaveChanges();
                            lblJSSNum.Text = string.Format("JSS Students must offer {0} subjects", cBoxNum.Text);
                            MessageBox.Show("Jss Subject Number added");
                            cBoxNum.SelectedIndex = -1;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }
            }
        }
Exemplo n.º 12
0
 private void btnSearch_ClickEvent(object sender, EventArgs e)
 {
     if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
     {
         try
         {
             using (var db = new Model1())
             {
                 var cls = cBoxClass.Text;
                 dGridStudents.DataSource = db.students.Where(x => x._class == cls).ToList();
             }
         }
         catch (Exception ex)
         {
             Utils.LogException(ex);
             MessageBox.Show("Error occured. Please contact support.");
         }
     }
 }
Exemplo n.º 13
0
        private void btnSearch_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                try
                {
                    Cursor = Cursors.WaitCursor;

                    using (var db = new Model1())
                    {
                        var Students = db.students.Where(x => x._class == cBoxClass.Text);
                        var Reg      = new List <subject>();

                        foreach (var s in Students)
                        {
                            var stuReg = new subject()
                            {
                                name       = s.Fullname,
                                reg_number = s.reg_number,
                                session    = cBoxSession.Text,
                                subjects   = cBoxSubject.Text,
                                term       = cBoxTerm.Text,
                                _class     = cBoxClass.Text,
                            };

                            Reg.Add(stuReg);
                        }

                        dGridStudReg.DataSource = Reg;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }
                finally
                {
                    Cursor = Cursors.Arrow;
                }
            }
        }
Exemplo n.º 14
0
        private void btnDelete_ClickEvent(object sender, EventArgs e)
        {
            try
            {
                if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
                {
                    var rtn = MessageBox.Show("Are you sure you want to delete these data?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (rtn != DialogResult.Yes)
                    {
                        return;
                    }

                    var _class   = cBoxClass.Text;
                    var _session = cBoxSession.Text;
                    var _term    = cBoxTerm.Text;

                    using (var db = new Model1())
                    {
                        var positions = db.positions.Where(x => x._class == _class && x.session == _session && x.term == _term);

                        if (positions == null)
                        {
                            MessageBox.Show("No Found.");
                            return;
                        }
                        else
                        {
                            db.positions.RemoveRange(positions);
                            db.SaveChanges();
                        }

                        dgridPResults.DataSource = new position();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.LogException(ex);
                MessageBox.Show("An Error Occured. Please, Contact Support.");
            }
        }
Exemplo n.º 15
0
        private void btnDelete_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var class_   = cBoxClass.Text;
                var term_    = cBoxTerm.Text;
                var session_ = cBoxSession.Text;


                try
                {
                    using (var db = new Model1())
                    {
                        dGridBehaviour.Cursor = Cursors.WaitCursor;
                        var bhv = db.behaviorals.Where(x => x._class == class_ && x.term == term_ && x.session == session_);

                        if (bhv != null)
                        {
                            db.behaviorals.RemoveRange(bhv);
                            db.SaveChanges();

                            dGridBehaviour.Cursor = Cursors.Arrow;
                            MessageBox.Show("Records deleted");
                            dGridBehaviour.DataSource = new List <behavioral>();
                        }
                        else
                        {
                            MessageBox.Show("No records to delete.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("An error ocurred. Please contact support");
                }
            }
        }
Exemplo n.º 16
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    using (var db = new Model1())
                    {
                        var students = db.students.Where(x => x._class == cboxFrom.Text);
                        if (students.Count() < 1)
                        {
                            MessageBox.Show("No student in this class.");
                        }
                        else
                        {
                            foreach (var s in students)
                            {
                                s._class = cboxToClass.Text;
                            }
                            db.SaveChanges();

                            MessageBox.Show("Students promoted successfully.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }


                Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 17
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckTextboxes(this, errorProvider1) && ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                if (btnFind.Enabled)
                {
                    MessageBox.Show("Click Find to make sure the reg number exists first.");
                    return;
                }
                var rtn = MessageBox.Show($"Are you sure you want to move this student from {_txtCurClass.Text} to {cboxToClass.Text}?", "", MessageBoxButtons.YesNo);
                if (rtn == DialogResult.Yes)
                {
                    try
                    {
                        using (var db = new Model1())
                        {
                            var stu = db.students.FirstOrDefault(x => x.reg_number == _txtRegNumber.Text);

                            if (stu == null)
                            {
                                MessageBox.Show("No student was found with this reg number.");
                            }
                            else
                            {
                                stu._class = cboxToClass.Text;
                                db.SaveChanges();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.LogException(ex);
                        MessageBox.Show("Error occured. Please contact support.");
                    }
                }
            }
        }
Exemplo n.º 18
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                var term = cBoxTerm.Text;
                var sess = cBoxSession.Text;

                try
                {
                    using (var db = new Model1())
                    {
                        var seas = db.current_season.FirstOrDefault();

                        if (seas != null)
                        {
                            seas.current_session = sess;
                            seas.current_term    = term;
                            seas.date_declared   = DateTime.Now.ToString("d");
                            seas.time_declared   = DateTime.Today;

                            db.SaveChanges();

                            MessageBox.Show("Term And Session Updated");
                        }
                        else
                        {
                            MessageBox.Show("Term And Session not yet set");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error has occured. Please contact support");
                }
            }
        }
Exemplo n.º 19
0
        private void btnExport_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1))
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    using (var db = new Model1())
                    {
                        List <student> students = db.students.Where(x => x._class == cBoxClass.Text).ToList();
                        if (students.Count < 1)
                        {
                            MessageBox.Show("No student in the selected class, Try again.");
                            Cursor = Cursors.Arrow;
                            return;
                        }

                        using (ExcelPackage excel = new ExcelPackage())
                        {
                            excel.Workbook.Worksheets.Add("Worksheet1");

                            var headerRow = new List <string[]>()
                            {
                                new string[] { "S/N", "Reg No", "Name", "Class", "Term", "Session", "Hand Writing",
                                               "Musical Skills", "Sports", "Attentiveness", "Attitude to work", "Health", "Politeness" }
                            };

                            var bodyRow = new List <string[]>();

                            for (int i = 0; i < students.Count; i++)
                            {
                                var s = students[i];

                                bodyRow.Add(new string[]
                                {
                                    (i + 1).ToString(), s.reg_number, s.Fullname, cBoxClass.Text, cBoxTerm.Text, cBoxSession.Text,
                                    "", "", "", "", "", "", ""
                                });
                            }

                            string headerRange = "A1:" + char.ConvertFromUtf32(headerRow[0].Length + 64) + "1";
                            string bodyRange   = "A2:" + char.ConvertFromUtf32(headerRow[0].Length + 64) + (bodyRow.Count + 1).ToString();

                            var workSheet = excel.Workbook.Worksheets["Worksheet1"];
                            workSheet.Cells[headerRange].LoadFromArrays(headerRow);
                            workSheet.Cells[bodyRange].LoadFromArrays(bodyRow);

                            workSheet.Cells[headerRange].Style.Font.Bold = true;

                            var      fPath     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), cBoxClass.Text + "Behaviour.xlsx");
                            FileInfo excelFile = new FileInfo(fPath);
                            excel.SaveAs(excelFile);

                            MessageBox.Show("Excel file saved at : \n" + fPath);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Please contact support.");
                }


                Cursor = Cursors.Arrow;
            }
        }
Exemplo n.º 20
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckComboBoxes(this, errorProvider1) && ValidateFomControls.CheckTextboxes(this, errorProvider1))
            {
                if (cboxType.Text == "Student")
                {
                    try
                    {
                        using (var db = new Model1())
                        {
                            var stud = db.students.FirstOrDefault(x => x.reg_number == _txtUsername.Text);
                            if (stud != null)
                            {
                                stud.gen_password = _txtPassword.Text;
                                db.SaveChanges();
                                MessageBox.Show("Password changed");
                            }
                            else
                            {
                                MessageBox.Show("No user found");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.LogException(ex);
                        MessageBox.Show("An error occured. Please contact admin");
                    }
                }
                else if (cboxType.Text == "Teacher")
                {
                    try
                    {
                        using (var db = new Model1())
                        {
                            var tech = db.teachers.FirstOrDefault(x => x.username == _txtUsername.Text);

                            if (tech != null)
                            {
                                tech.password = _txtPassword.Text;
                                db.SaveChanges();
                                MessageBox.Show("Password changed");
                            }
                            else
                            {
                                MessageBox.Show("No user found");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.LogException(ex);
                        MessageBox.Show("An error occured. Please contact admin");
                    }
                }
                else if (cboxType.Text == "Principal")
                {
                    try
                    {
                        using (var db = new Model1())
                        {
                            var prp = db.principals.FirstOrDefault(x => x.username == _txtUsername.Text);
                            if (prp != null)
                            {
                                prp.password = _txtPassword.Text;
                                db.SaveChanges();
                                MessageBox.Show("Password changed");
                            }
                            else
                            {
                                MessageBox.Show("No user found");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.LogException(ex);
                        MessageBox.Show("An error occured. Please contact admin");
                    }
                }
                else if (cboxType.Text == "Admin")
                {
                    try
                    {
                        using (var db = new Model1())
                        {
                            var ad = db.users.FirstOrDefault(x => x.email == _txtUsername.Text);
                            if (ad != null)
                            {
                                ad.password = _txtPassword.Text;
                                db.SaveChanges();
                                MessageBox.Show("Password changed");
                            }
                            else
                            {
                                MessageBox.Show("User not found");
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.LogException(ex);
                        MessageBox.Show("An error occured. Please contact admin");
                    }
                }
            }
        }