//
        //Of Loading of Form, loads Exam IDs and Employee IDs
        //
        private void AddApplicant_Load(object sender, EventArgs e)
        {
            // to allign the Legend(Group Box) to
            // the center of form
            int centerForm;
            int centerGroup;
            int groupStartPosition;

            centerForm = this.Width / 2;
            centerGroup = addApplicantLegend.Width / 2;
            groupStartPosition = centerForm - centerGroup;
            addApplicantLegend.Left = groupStartPosition;

            //Exam IDs
            Exam_DetailsBS em = new Exam_DetailsBS();
            int i = em.getCount();
            if(i>0)
            {
                string[] abc = new string[i];
                abc = em.loadExamDetail(i);
                for (int m = 0; m < i; m++)
                {
                    examIDCombo.Items.Add(abc[m]);
                }
                examIDCombo.SelectedIndex = 0;
            }
            else
                MessageBox.Show("No Exams present in the databse.", "Error");

            //Employee IDs
            EmployeeBS emp = new EmployeeBS();
            int j = emp.getCount();
            if(j>0)
            {
                string[] abcd = new string[j];
                abcd = emp.loadEmployee(j);
                for (int k = 0; k < j; k++)
                {
                    employeeIDCombo.Items.Add(abcd[k]);
                }
                employeeIDCombo.SelectedIndex = 0;
            }
            else
                MessageBox.Show("No Employees present in the databse.", "Error");
        }
        //
        //On changing the Exam ID
        //
        private void examIDcombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Resets the other controls on change of ExamID, also disables then in case of an invalid selection
            examTypeCombo.ResetText();
            examTypeCombo.Items.Clear();
            examTypeCombo.Enabled = false;
            datePicker.Enabled = false;
            update.Enabled = false;

            if (examIDCombo.SelectedIndex != -1)
            {
                //Gets the details of the selected Exam ID
                Exam_Details et = new Exam_Details();
                Exam_DetailsBS cs = new Exam_DetailsBS();
                et.exam_ID = examIDCombo.SelectedItem.ToString();
                et = cs.getExamDetails(et);

                //Enables the other controls
                examTypeCombo.Enabled = true;
                datePicker.Enabled = true;
                update.Enabled = true;

                //Loads the Exam Types
                Exam_TypeBS em = new Exam_TypeBS();
                int i = em.getCount();
                if (i > 0)
                {
                    string[] abc = new string[i];
                    abc = em.loadExamType(i);
                    for (int j = 0; j < i; j++)
                    {
                        examTypeCombo.Items.Add(abc[j]);
                    }
                }
                else
                    MessageBox.Show("No Data");

                //Loads the Exam Details
                examTypeCombo.SelectedItem = et.exam_Type;
                datePicker.Value = et.datetime;
            }
            else
                MessageBox.Show("Please select a valid Exam ID.");
        }
示例#3
0
 //
 //On click of Proceed: Navigates to Feedback form
 //
 private void proceed_Click(object sender, EventArgs e)
 {
     //Gets the exam configuration
     Exam_DetailsBS edb = new Exam_DetailsBS();
     ed = edb.getExamDetails(ed);
     if (ed.answer_Config == "Yes")
     {
         //Navigates to Check Solution Form
         CheckSolution f = new CheckSolution(q, a, emp, ed);
         f.MdiParent = this.MdiParent;
         f.Dock = DockStyle.Fill;
         this.Close();
         f.Show();
     }
     else if (ed.answer_Config == "No")
     {
         //Navigates to Feedback Form
         FeedbackForm fm8 = new FeedbackForm(emp, ed);
         fm8.MdiParent = this.MdiParent;
         fm8.Dock = DockStyle.Fill;
         this.Close();
         fm8.Show();
     }
 }
        //
        //On Form Load
        //
        private void UpdateExamDetail_Load(object sender, EventArgs e)
        {
            // to allign the Legend(Group Box) to
            // the center of form
            int centerForm;
            int centerGroup;
            int groupStartPosition;

            centerForm = this.Width / 2;
            centerGroup = updateExamLegend.Width / 2;
            groupStartPosition = centerForm - centerGroup;
            updateExamLegend.Left = groupStartPosition;

            // Filling the ExamID ComboBox
            Exam_DetailsBS ed = new Exam_DetailsBS();
            int i = ed.getCount();
            if (i > 0)
            {
                string[] abc = new string[i];
                abc = ed.loadExamDetail(i);
                for (int j = 0; j < i; j++)
                {
                    examIDCombo.Items.Add(abc[j]);
                }
            }
            //Disabling the other controls
            examTypeCombo.Enabled = false;
            datePicker.Enabled = false;
            update.Enabled = false;
        }
        //
        //On click of Update button
        //
        private void update_Click(object sender, EventArgs e)
        {
            if (examIDCombo.SelectedIndex == -1 || examTypeCombo.SelectedIndex == -1)
                MessageBox.Show("Please select a valid entry", "Error");
            else
            {
                string config = "";
                if (yesConfigRadio.Checked)
                    config = "Yes";
                else if (noConfigRadio.Checked)
                    config = "No";

                Exam_DetailsBS js = new Exam_DetailsBS();
                Exam_Details em = new Exam_Details();
                em.exam_ID = examIDCombo.SelectedItem.ToString();
                em.exam_Type = (string)examTypeCombo.SelectedItem;
                em.datetime = datePicker.Value;

                if (durationTextBox.TextLength == 0)
                    em.duration = 0;
                else
                    em.duration = Convert.ToInt32(durationTextBox.Text);

                //Business logic call, forwarded to DAL
                string feedback = js.updateExamDetail(em,config);
                MessageBox.Show(feedback, "Update Exam");

                examIDCombo.SelectedIndex = 0;
                examTypeCombo.SelectedIndex = 0;
                datePicker.Value = DateTime.Today;
                yesConfigRadio.Checked = false;
                noConfigRadio.Checked = false;
            }
        }
        //
        //On click of Add button, validates, adds Exam & displays assigned Exam ID
        //
        private void add_Click(object sender, EventArgs e)
        {
            bool a = false;
            bool b = false;
            if (yesConfigRadio.Checked == false && noConfigRadio.Checked == false)
            {
                MessageBox.Show("Kindly select an option to allow employee to see the answers after exam or not to");
            }

            else a = true;

            if (examTypeCombo.SelectedIndex != -1)
            {
                b = true;
            }
            else
                MessageBox.Show("Please select a valid Exam ID.", "Error");
            string config = "";
            if (yesConfigRadio.Checked)
                config = "Yes";
            else if (noConfigRadio.Checked)
                config = "No";

            if (a == true && b == true)
            {
                Exam_Details em = new Exam_Details();
                Exam_DetailsBS js = new Exam_DetailsBS();
                em.exam_Type = examTypeCombo.SelectedItem.ToString();
                em.datetime = datePicker.Value;
                if (durationTextBox.TextLength == 0)
                    em.duration = 0;
                else
                    em.duration = Convert.ToInt32(durationTextBox.Text);

                //Call to BLL to validate and add Exam
                string feed = js.addExamDetail(em,config);
                MessageBox.Show(feed, "Add Exam");

                examTypeCombo.SelectedIndex = 0;
                datePicker.Value = DateTime.Today;
                durationTextBox.Text = "";
                yesConfigRadio.Checked = false;
                noConfigRadio.Checked = false;
            }
            else
                MessageBox.Show("Please select a valid Exam Type.");
        }
        //
        //Deletes the selected Exam & pops up a Success or Error message
        //
        private void delete_Click(object sender, EventArgs e)
        {
            if(empIDexamIDcombo.SelectedIndex != -1)
            {
                DialogResult result = MessageBox.Show("Are you sure you want delete " + empIDexamIDcombo.SelectedItem.ToString()+ "?", "Delete Applciant", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    //Results Object
                    Results r = new Results();
                    string temp = empIDexamIDcombo.SelectedItem.ToString();
                    int pos = temp.IndexOf(":");
                    r.employee_ID = temp.Substring(0, pos);
                    r.exam_ID = temp.Substring(pos+1);

                    //Gets Exam type
                    Exam_Details ed = new Exam_Details();
                    ed.exam_ID = r.exam_ID;
                    Exam_DetailsBS edb = new Exam_DetailsBS();
                    ed = edb.getExamDetails(ed);

                    //ResultStatus object
                    ResultStatus rs = new ResultStatus();
                    rs.employee_ID = r.employee_ID;
                    rs.exam_Type = ed.exam_Type;

                    //Gets Attempt No
                    ResultStatusBS rsb = new ResultStatusBS();
                    rs= rsb.getResultStatus(rs);

                    if (rs.attempt_No == 1)
                    {
                        //First Timer
                        string feedback = em.deleteResults(r);
                        if(feedback !="Error")
                        {
                            rsb.deleteResultStatus(rs);
                            MessageBox.Show("Succesfully deleted.", "Delete Applicant", MessageBoxButtons.OK);
                        }
                        else
                            MessageBox.Show("Unsuccessful attempt. Sorry for the inconvenience.", "Error", MessageBoxButtons.OK);
                    }
                    else
                    {
                        //Repeater
                        rs.attempt_No--;
                        string feedback = em.deleteResults(r);
                        if (feedback != "Error")
                        {
                            rsb.updateResultStatus(rs);
                            MessageBox.Show("Succesfully deleted.", "Delete Applicant",MessageBoxButtons.OK);
                        }
                        else
                            MessageBox.Show("Unsuccessful attempt. Sorry for the inconvenience.","Error",MessageBoxButtons.OK);
                    }
                }
            }
            else
                MessageBox.Show("Please select a valid entry.", "Error");
            this.DeleteApplicant_Load(sender, e);
        }
        //
        //Deletes the selected Exam & pops up a Success or Error message
        //
        protected void delete_Click(object sender, EventArgs e)
        {
            if (empIDexamIDcombo.SelectedIndex != -1)
            {
                //DialogResult result = MessageBox.Show("Are you sure you want delete " + empIDexamIDcombo.SelectedItem.ToString() + "?", "Delete Applciant", MessageBoxButtons.YesNo);

                    //Results Object
                    Results r = new Results();
                    string temp = empIDexamIDcombo.SelectedItem.ToString();
                    int pos = temp.IndexOf(":");
                    r.employee_ID = temp.Substring(0, pos);
                    r.exam_ID = temp.Substring(pos + 1);

                    //Gets Exam type
                    Exam_Details ed = new Exam_Details();
                    ed.exam_ID = r.exam_ID;
                    Exam_DetailsBS edb = new Exam_DetailsBS();
                    ed = edb.getExamDetails(ed);

                    //ResultStatus object
                    ResultStatus rs = new ResultStatus();
                    rs.employee_ID = r.employee_ID;
                    rs.exam_Type = ed.exam_Type;

                    //Gets Attempt No
                    ResultStatusBS rsb = new ResultStatusBS();
                    rs = rsb.getResultStatus(rs);

                    if (rs.attempt_No == 1)
                    {
                        //First Timer
                        string feedback = em.deleteResults(r);
                        if (feedback != "Error")
                        {
                            rsb.deleteResultStatus(rs);
                            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Succesfully deleted.')</SCRIPT>");
                            //essageBox.Show("Succesfully deleted.", "Delete Applicant", MessageBoxButtons.OK);
                        }
                        else
                            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Unsuccessful attempt. Sorry for the inconvenience')</SCRIPT>");
                            //MessageBox.Show("Unsuccessful attempt. Sorry for the inconvenience.", "Error", MessageBoxButtons.OK);
                    }
                    else
                    {
                        //Repeater
                        rs.attempt_No--;
                        string feedback = em.deleteResults(r);
                        if (feedback != "Error")
                        {
                            rsb.updateResultStatus(rs);
                            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Succesfully deleted.')</SCRIPT>");
                            //MessageBox.Show("Succesfully deleted.", "Delete Applicant", MessageBoxButtons.OK);
                        }
                        else
                            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Unsuccessful attempt. Sorry for the inconvenience')</SCRIPT>");
                            //MessageBox.Show("Unsuccessful attempt. Sorry for the inconvenience.", "Error", MessageBoxButtons.OK);
                    }
            }
            else
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Please select a valid entry')</SCRIPT>");
                //MessageBox.Show("Please select a valid entry.", "Error");
            this.Page_Load(sender, e);
        }