private void btnEduNew_Click(object sender, EventArgs e)
        {
            string institution = txtInstitution.Text;
            string degree      = txtDegree.Text;
            string emphasis    = txtEmphasis.Text;
            int?   year        = null;

            try
            {
                year = int.Parse(txtYear.Text);
            }
            catch
            {
                MessageBox.Show("Error: Year field is not in an integer format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                return;
            }

            isEditingEducation = false;

            if (ManagerId != null)
            {
                ManagerEducation.Insert((Guid)ManagerId, frmMain_Parent.CurrentUser.UserId, institution, degree, emphasis, year);
            }

            PopulateManagerEducationList();

            txtInstitution.Text = null;
            txtDegree.Text      = null;
            txtEmphasis.Text    = null;
            txtYear.Text        = null;
        }
        private void lstEducation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (isEditingEducation == true)
            {
                DialogResult result = MessageBox.Show("You have unsaved changes for this current education record. Are you sure you wish to continue without saving?", "Attention", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    isEditingEducation = false;
                }
                else
                {
                    return;
                }
            }

            if (lstEducation.SelectedIndex == -1 || lstEducation.SelectedItem == null)
            {
                txtInstitution.Text = null;
                txtDegree.Text      = null;
                txtEmphasis.Text    = null;
                txtYear.Text        = null;
                return;
            }

            ManagerEducation _managerEducation = (ManagerEducation)((ListItem)lstEducation.SelectedItem).HiddenObject;

            txtInstitution.Text = _managerEducation.Institution;
            txtDegree.Text      = _managerEducation.DegreeType;
            txtEmphasis.Text    = _managerEducation.Emphasis;
            txtYear.Text        = _managerEducation.Year.ToString();
        }
        private void btnEduDelete_Click(object sender, EventArgs e)
        {
            if (lstEducation.SelectedIndex == -1 || lstEducation.SelectedItem == null)
            {
                MessageBox.Show("Error: No education record is selected for deletion. Please correct and try again.", "Error", MessageBoxButtons.OK);
                return;
            }

            isEditingEducation = false;

            Guid             _managerEducationId = ((ManagerEducation)((ListItem)lstEducation.SelectedItem).HiddenObject).ManagerEducationId;
            ManagerEducation _managerEducation   = new ManagerEducation(_managerEducationId);

            _managerEducation.DeleteFromDatabase();

            PopulateManagerEducationList();

            txtInstitution.Text = null;
            txtDegree.Text      = null;
            txtEmphasis.Text    = null;
            txtYear.Text        = null;
        }
        private void btnEduSave_Click(object sender, EventArgs e)
        {
            if (lstEducation.SelectedIndex == -1 || lstEducation.SelectedItem == null)
            {
                MessageBox.Show("Error: No education record is selected for deletion. Please correct and try again.", "Error", MessageBoxButtons.OK);
                return;
            }

            ManagerEducation _managerEducation = (ManagerEducation)((ListItem)lstEducation.SelectedItem).HiddenObject;

            Guid   managerEducationId = _managerEducation.ManagerEducationId;
            string institution        = txtInstitution.Text;
            string degree             = txtDegree.Text;
            string emphasis           = txtEmphasis.Text;
            int?   year = null;

            try
            {
                year = int.Parse(txtYear.Text);
            }
            catch
            {
                MessageBox.Show("Error: Year field is not in an integer format. Please correct and try again.", "Error!", MessageBoxButtons.OK);
                return;
            }

            isEditingEducation = false;

            ManagerEducation.Update(managerEducationId, frmMain_Parent.CurrentUser.UserId, institution, degree, emphasis, year);

            PopulateManagerEducationList();

            txtInstitution.Text = null;
            txtDegree.Text      = null;
            txtEmphasis.Text    = null;
            txtYear.Text        = null;
        }
        public void PopulateManagerEducationList()
        {
            lstEducation.Items.Clear();

            if (ManagerId != null)
            {
                ManagerEducation.AssociateDetails(Manager);

                foreach (ManagerEducation _managerEducation in Manager.Education)
                {
                    lstEducation.Items.Add(new ListItem(_managerEducation.Institution, _managerEducation));
                }

                lstEducation.Enabled   = true;
                lstEducation.BackColor = System.Drawing.Color.White;
                txtInstitution.Enabled = true;
                txtYear.Enabled        = true;
                txtEmphasis.Enabled    = true;
                txtDegree.Enabled      = true;
                btnEduDelete.Enabled   = true;
                btnEduNew.Enabled      = true;
                btnEduSave.Enabled     = true;
            }
            else
            {
                lstEducation.Enabled   = false;
                lstEducation.BackColor = System.Drawing.SystemColors.Control;
                lstEducation.Items.Add("The manager record must exist before associating education records to it. Please save the record to complete this action.");
                txtInstitution.Enabled = false;
                txtYear.Enabled        = false;
                txtEmphasis.Enabled    = false;
                txtDegree.Enabled      = false;
                btnEduDelete.Enabled   = false;
                btnEduNew.Enabled      = false;
                btnEduSave.Enabled     = false;
            }
        }