Пример #1
0
        public string UpdateSessionSemester(SessionSemester sem)
        {
            using (var context = new BASContext())
            {
                var oldSem = context.SessionSemesters.SingleOrDefault(a => a.Id == sem.Id && !a.IsDeleted);
                if (oldSem == null)
                {
                    return("Session Semester not found");
                }

                if (context.SessionSemesters.Any(a => a.Session == sem.Session && a.Semester == sem.Semester && !a.IsDeleted && a.Id != sem.Id))
                {
                    return("Session Semester already exist");
                }

                oldSem.Session  = sem.Session;
                oldSem.Semester = sem.Semester;
                oldSem.IsActive = sem.IsActive;

                if (sem.IsActive)
                {
                    var allsems = context.SessionSemesters.Where(a => !a.IsDeleted);
                    foreach (var item in allsems)
                    {
                        item.IsActive = false;
                    }
                }

                if (context.SaveChanges() > 0)
                {
                    return("Session Semester details updated successfully");
                }
                return("Session Semester details could not be updated");
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (PassedValidation())
                {
                    var model = new SessionSemester()
                    {
                        Session  = txtSession.Text.ToTitleCase(),
                        Semester = txtSemester.Text.ToTitleCase(),
                        IsActive = chkIsActive.Checked
                    };

                    if (model.IsActive)
                    {
                        DialogResult result1 = MessageBox.Show(
                            "Are you sure you want to make this the active session/semester?",
                            "Confirm Active",
                            MessageBoxButtons.YesNo);
                        if (result1 == DialogResult.Yes)
                        {
                            PerformSave(model);
                        }
                    }
                    else
                    {
                        PerformSave(model);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public string AddSessionSemester(SessionSemester newSem)
        {
            try
            {
                using (var context = new BASContext())
                {
                    if (context.SessionSemesters.Any(a => a.Session == newSem.Session && a.Semester == newSem.Semester && !a.IsDeleted))
                    {
                        return("Session and Semester already exist");
                    }

                    if (newSem.IsActive)
                    {
                        var allsems = context.SessionSemesters.Where(a => !a.IsDeleted);
                        foreach (var item in allsems)
                        {
                            item.IsActive = false;
                        }
                    }

                    context.SessionSemesters.Add(newSem);
                    if (context.SaveChanges() > 0)
                    {
                        return("Session Semester added successfully");
                    }
                    return("Session Semester could not be added");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!LoggedInUser.IsAdmin)
            {
                Base.ShowError("Access Denied", "You do not have the required permission");
                return;
            }

            var item = new SessionSemester()
            {
                Id       = _id,
                Session  = txtSession.Text.ToTitleCase(),
                Semester = txtSemester.Text.ToTitleCase(),
                IsActive = checkActive.Checked
            };

            var validate = ValidateForm();

            if (validate == string.Empty)
            {
                AddOrUpdate(item);
            }
            else
            {
                Base.ShowInfo("Validation Failed", validate);
            }
        }
        private void FrmAttendance_Load(object sender, EventArgs e)
        {
            try
            {
                activeSemester = _semesterRepo.GetActiveSessionSemester();
                if (activeSemester == null)
                {
                    MessageBox.Show("You cannot mark attendance because there is no active semester", "Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                lblSession.Text = activeSemester.Session + " - " + activeSemester.Semester;
                Cursor          = Cursors.WaitCursor;
                // set culture
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB", false);

                Capturer = new DPFP.Capture.Capture();               // Create a capture operation.
                try
                {
                    if ((Capturer != null))
                    {
                        Capturer.StartCapture();
                        Capturer.EventHandler = this;
                    }
                    // Subscribe for capturing events.
                    else
                    {
                        throw new Exception("Can't initiate capture operation! Please exit and relaunch the application");
                    }
                }
                catch (Exception ex)
                {
                    logger.WriteLog(ex);
                    MessageBox.Show("Can't initiate capture operation! Please exit and relaunch the application", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Enroller    = new DPFP.Processing.Enrollment();
                Verificator = new DPFP.Verification.Verification();
                Application.DoEvents();

                Capturer.StartCapture();
                SetPrompt("Using the fingerprint reader, scan your fingerprint.");
            }
            catch (Exception ex)
            {
                logger.WriteLog(ex);
                //MsgBox(ex.Message, MsgBoxStyle.Exclamation, Application.ProductName);
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            getTodayAttendance();
        }
Пример #6
0
 public SessionSemesterForm(SessionSemester data = null)
 {
     InitializeComponent();
     _semesterRepo = new SessionSemesterRepo();
     if (data != null)
     {
         lblId.Text          = data.Id.ToString();
         txtSession.Text     = data.Session;
         txtSemester.Text    = data.Semester;
         chkIsActive.Checked = data.IsActive;
         lblTitle.Text       = "Update Session/Semester";
     }
 }
Пример #7
0
        public string AddSessionSemester(SessionSemester newSem)
        {
            try
            {
                if (_context.SessionSemesters.Any(a => a.Session == newSem.Session && a.Semester == newSem.Semester && !a.IsDeleted))
                {
                    return("Session and Semester already exist");
                }

                if (newSem.IsActive)
                {
                    var allsems = _context.SessionSemesters.Where(a => !a.IsDeleted).ToList();
                    foreach (var item in allsems)
                    {
                        item.IsActive = false;
                    }
                }

                newSem.Id = Guid.NewGuid().ToString();
                _context.SessionSemesters.Add(newSem);


                if (_context.SaveChanges() > 0)
                {
                    if (newSem.IsActive)  //change the active semester on local sqlite
                    {
                        LoggedInUser.ActiveSession = newSem;
                        var localSems = _localContext.SessionSemesters.Where(a => !a.IsDeleted).ToList();
                        foreach (var item in localSems)
                        {
                            item.IsActive = false;
                        }

                        _localContext.SaveChanges();
                    }

                    return("");
                }
                else
                {
                    return("Session/Semester could not be added");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #8
0
        public string UpdateSessionSemester(SessionSemester sem)
        {
            var oldSem = _context.SessionSemesters.SingleOrDefault(a => a.Id == sem.Id && !a.IsDeleted);

            if (oldSem == null)
            {
                return("Session Semester not found");
            }

            if (_context.SessionSemesters.Any(a => a.Session == sem.Session && a.Semester == sem.Semester && !a.IsDeleted && a.Id != sem.Id))
            {
                return("Session Semester already exist");
            }

            oldSem.Session  = sem.Session;
            oldSem.Semester = sem.Semester;
            oldSem.IsActive = sem.IsActive;

            if (sem.IsActive)
            {
                var allsems = _context.SessionSemesters.Where(a => !a.IsDeleted && a.Id != oldSem.Id).ToList();
                foreach (var item in allsems)
                {
                    item.IsActive = false;
                }
            }

            if (_context.SaveChanges() > 0)
            {
                if (sem.IsActive)  //change the active semester on local sqlite
                {
                    LoggedInUser.ActiveSession = sem;
                    var localSems = _localContext.SessionSemesters.Where(a => !a.IsDeleted && a.Id != oldSem.Id).ToList();
                    foreach (var item in localSems)
                    {
                        item.IsActive = false;
                    }

                    _localContext.SaveChanges();
                }

                return("");
            }
            else
            {
                return("Session/Semester could not be updated");
            }
        }
Пример #9
0
        private void AddOrUpdate(SessionSemester item)
        {
            var saveItem = _id == ""
                ? _repo.AddSessionSemester(item)
                : _repo.UpdateSessionSemester(item);

            if (saveItem == string.Empty)
            {
                Base.ShowSuccess("Success", "Session/Semester saved successfully");
                this.Close();
            }
            else
            {
                Base.ShowError("Failed", saveItem);
            }
        }
Пример #10
0
        private void PerformSave(SessionSemester model)
        {
            string response;

            if (lblId.Text == string.Empty) //add
            {
                response = _semesterRepo.AddSessionSemester(model);
                if (response == string.Empty)
                {
                    MessageBox.Show(this, "Session/Semester added successfully", "Success",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    ClearControls();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show(this, response, "Failed", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
            else //update
            {
                model.Id = int.Parse(lblId.Text);
                response = _semesterRepo.UpdateSessionSemester(model);
                if (response == string.Empty)
                {
                    MessageBox.Show(this, "Session/Semester updated successfully", "Success",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    ClearControls();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show(this, response, "Failed", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
            }
        }