// //On form load: Displays the employee name and his result // private void Result_Load(object sender, EventArgs e) { employeeNameLabel.Text = emp.first_Name + " " + emp.last_Name; Results re = new Results(); re.Employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; re = r.getResult(re); ResultStatus rs = new ResultStatus(); rs.employee_ID = emp.employee_Id; rs.exam_Type = ed.exam_Type; ResultStatusBS rsb = new ResultStatusBS(); rs = rsb.getResultStatus(rs); Exam_Types m = new Exam_Types(); m.exam_Type = ed.exam_Type; Exam_TypeBS exd = new Exam_TypeBS(); m = exd.getExamType(m); examLabel.Text = "Exam ID: " + ed.exam_ID + " Exam Type: " + ed.exam_Type + " Subject: " + m.subject + " Level: " + m.level_Number + " Attempt No: " + rs.attempt_No; if (rs.status == "Passed") congratulationsLabel.Text = "Congratulations ! You have passed! Your score is"+re.score+". Percentage: "+re.percentage+"%"; else { if (rs.attempt_No == m.no_Of_Attempts) { congratulationsLabel.Text = "Sorry, You have Failed in this Examination . Your score is" + re.score + ". Percentage: " + re.percentage + "%. You have no more attempts left for this exam"; } congratulationsLabel.Text = "Sorry , You have Failed in this Examination . Your score is"+re.score+". Percentage: "+re.percentage+"%. You have got " +(m.no_Of_Attempts-rs.attempt_No) + " attempts left for this exam"; } }
protected void Page_Load(object sender, EventArgs e) { ed.employee_ID = (String)Session["employee_ID"]; employeeIDText.Text = ed.employee_ID; int count = p.getResultCountForEmployee(ed); DataTable dt = new DataTable(); dt.Columns.Add("Employee_ID", Type.GetType("System.String")); dt.Columns.Add("Exam_ID", Type.GetType("System.String")); dt.Columns.Add("Score", Type.GetType("System.Int32")); dt.Columns.Add("Percentage", Type.GetType("System.Double")); if (count > 0) { Results[] arr = new Results[count]; arr = p.viewResultForEmployee(ed, count); for (int i = 0; i < count; i++) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Employee_ID"] = arr[i].employee_ID; dt.Rows[dt.Rows.Count - 1]["Exam_ID"] = arr[i].exam_ID; dt.Rows[dt.Rows.Count - 1]["Score"] = arr[i].score; dt.Rows[dt.Rows.Count - 1]["Percentage"] = arr[i].percentage; } GridView1.DataSource = dt; GridView1.Enabled = false; GridView1.DataBind(); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Results present in the database.')</SCRIPT>"); //MessageBox.Show("No Results present in the database.", "Error"); }
// //On Form Load: Displays Result in Grid // private void CheckEmployeeResult_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 = checkEmpResultLegend.Width / 2; groupStartPosition = centerForm - centerGroup; checkEmpResultLegend.Left = groupStartPosition; employeeIDText.Text = ed.employee_ID; int count = p.getResultCountForEmployee(ed); if (count > 0) { Results[] arr = new Results[count]; arr = p.viewResultForEmployee(ed,count); resultDataGrid.DataSource = arr; resultDataGrid.Enabled = false; } else MessageBox.Show("No Results present in the database.", "Error"); }
// //On Form Load: Displays Welcome Message, displays today's schedule, if any // private void EmpHome_Load(object sender, EventArgs e) { emp = b.getEmployee(emp); welcomeLabel.Text = "Welcome " + emp.first_Name + " " + emp.last_Name; ResultsBS r = new ResultsBS(); int count = r.getExamCountForEmployee(emp); Exam_Details[] er = new Exam_Details[count]; er = r.getExamIDsForEmployee(emp, count); er = eb.getSchedule(er); int[] index = eb.checkTodaysSchedule(er); Results[] res = new Results[index.Length]; for (int i = 0; i < index.Length; i++) { res[i] = new Results(); res[i].employee_ID = emp.employee_Id; res[i].exam_ID = er[index[i]].exam_ID; } //bool[] feed = new bool[index.Length]; res = r.checkIfAppeared(res); int total = 0; for (int i = res.Length - 1; i >= 0; i--) { if (res[i].score == -1) { total++; ed.exam_ID = res[i].exam_ID; } } if (total == 0) { examIDLabel.Text = "Sorry."; examTypeLabel.Text = "You dont have any test scheduled today."; dateLabel.Text = ""; durationLabel.Text = ""; noteLabel.Text = ""; skipTutorial.Enabled = false; takeTutorial.Enabled = false; } else { ed = eb.getExamDetails(ed); Exam_Types et1 = new Exam_Types(); et1.exam_Type = ed.exam_Type; et1 = et.getExamType(et1); examIDLabel.Text += ed.exam_ID; examTypeLabel.Text +=" " +et1.exam_Type + " (" + et1.subject + " Level " + et1.level_Number+")"; dateLabel.Text += ed.datetime.Date.ToShortDateString(); ; durationLabel.Text += +ed.duration; total--; if (total >= 1) noteLabel.Text += "You have " + total + " more exams scheduled today."; else noteLabel.Text = ""; } }
protected void Page_Load(object sender, EventArgs e) { r = (Results)Session["exam_ID"]; examIDTextBox.Text = r.exam_ID; int count = re.getResultCountForDetailedReport(r); DataTable dt = new DataTable(); dt.Columns.Add("Employee_ID", Type.GetType("System.String")); dt.Columns.Add("Exam_ID", Type.GetType("System.String")); dt.Columns.Add("Section", Type.GetType("System.String")); dt.Columns.Add("Percentage", Type.GetType("System.Double")); if (count > 0) { DetailedReports[] arr = new DetailedReports[count]; arr = re.getDetailedReports(r, count); for (int i = 0; i < count; i++) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Employee_ID"] = arr[i].employee_ID; dt.Rows[dt.Rows.Count - 1]["Exam_ID"] = arr[i].exam_ID; dt.Rows[dt.Rows.Count - 1]["Section"] = arr[i].section; dt.Rows[dt.Rows.Count - 1]["Percentage"] = arr[i].percentage; } GridView1.DataSource = dt; GridView1.Enabled = false; GridView1.DataBind(); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Results present in the database.')</SCRIPT>"); //MessageBox.Show("No Results present in the database.", "Error"); }
// //Returns the number of Results for a Detailed Report for a particular Exam // public int getResultCountForDetailedReport(Results p) { conn.Open(); cmd = new SqlCommand("select count(Employee_ID) from Detailed_Reports where Exam_ID ='" + p.exam_ID + "'", conn); int count = Convert.ToInt32(cmd.ExecuteScalar()); conn.Close(); return count; }
// //On click of Check button // protected void check_Click(object sender, EventArgs e) { if (examIDCombo.SelectedIndex != -1) { Results ro = new Results(); ro.exam_ID = examIDCombo.SelectedItem.ToString(); Session["exam_ID"] = ro.employee_ID; Response.Redirect("~/CheckEmployeeResult.aspx"); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Please select a valid Exam ID.')</SCRIPT>"); }
protected void Page_Load(object sender, EventArgs e) { ed.exam_ID = (String)Session["exam_ID"]; Exam_Details feed = p.calculateResultFull(ed); if (feed.exam_ID == "ED00") { System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Exam was conducted today. So please checlk the result tomorrow. Thank You!')</SCRIPT>"); //MessageBox.Show("Exam was conducted today. So please checlk the result tomorrow. Thank You!"); } else if (feed.exam_ID == "ED000") { System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Sorry some error occured! Please try later!')</SCRIPT>"); //MessageBox.Show("Sorry some error occured! Please try later!"); } else { highestlabel.Text = "Highest:" + feed.highest; lowestlabel.Text = "Lowest: " + feed.lowest; averagelabel.Text = "Average: " + feed.average; examIDText.Text = ed.exam_ID; int count = p.getResultCountForExam(ed); DataTable dt = new DataTable(); dt.Columns.Add("Employee_ID", Type.GetType("System.String")); dt.Columns.Add("Exam_ID", Type.GetType("System.String")); dt.Columns.Add("Score", Type.GetType("System.Int32")); dt.Columns.Add("Percentage", Type.GetType("System.Double")); if (count > 0) { Results[] arr = new Results[count]; arr = p.viewResult(ed); for (int i = 0; i < count; i++) { dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1]["Employee_ID"] = arr[i].employee_ID; dt.Rows[dt.Rows.Count - 1]["Exam_ID"] = arr[i].exam_ID; dt.Rows[dt.Rows.Count - 1]["Score"] = arr[i].score; dt.Rows[dt.Rows.Count - 1]["Percentage"] = arr[i].percentage; } GridView1.DataSource = dt; GridView1.Enabled = false; GridView1.DataBind(); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Results present in the database.')</SCRIPT>"); //MessageBox.Show("No Results present in the database.", "Error"); } }
// //On click of Check: Navigates to Detaile Report Form // protected void check_Click(object sender, EventArgs e) { if (examIDCombo.SelectedIndex != -1) { Results r = new Results(); r.exam_ID = examIDCombo.SelectedItem.ToString(); Session["exam_ID"] = r; Response.Redirect("~/DetailedReport.aspx"); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Please select a valid Exam ID.')</SCRIPT>"); //MessageBox.Show("Please select a valid Exam ID.", "Error", MessageBoxButtons.OK); }
protected void Page_Load(object sender, EventArgs e) { int count = r.getConductedExamsCount(); if (count > 0) { Results[] rs = new Results[count]; rs = r.loadConductedExamID(rs); for (int i = 0; i < count; i++) { examIDCombo.Items.Add(rs[i].exam_ID); } } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Exams in the database')</SCRIPT>"); }
// //On click of Check button // private void check_Click(object sender, EventArgs e) { if (examIDCombo.SelectedIndex != -1) { Results ro = new Results(); ro.exam_ID = examIDCombo.SelectedItem.ToString(); SeeResult f28 = new SeeResult(ro); f28.MdiParent = this.MdiParent; f28.Dock = DockStyle.Fill; this.Close(); f28.Show(); } else MessageBox.Show("Please select a valid Exam ID.", "Error"); }
// //On click of Check: Navigates to Detaile Report Form // private void check_Click(object sender, EventArgs e) { if (examIDCombo.SelectedIndex != -1) { Results r = new Results(); r.exam_ID = examIDCombo.SelectedItem.ToString(); DetailedReport dr = new DetailedReport(r); dr.MdiParent = this.MdiParent; dr.Dock = DockStyle.Fill; this.Close(); dr.Show(); } else MessageBox.Show("Please select a valid Exam ID.", "Error",MessageBoxButtons.OK); }
// //On click on Check button: Validates selection & Naviagtes to Check Employee Result Form // private void check_Click(object sender, EventArgs e) { if (employeeIDCombo.SelectedIndex != -1) { string temp; Results ro = new Results(); temp = employeeIDCombo.SelectedItem.ToString(); ro.employee_ID = temp.Substring(0, 4); CheckEmployeeResult f28 = new CheckEmployeeResult(ro); this.Close(); f28.Show(); } else MessageBox.Show("Please select a valid Employee ID.", "Error"); }
// //On form Load: Loads the conducted exam IDs // private void CheckDetailed_Load(object sender, EventArgs e) { ResultsBS r = new ResultsBS(); int count = r.getConductedExamsCount(); if (count > 0) { Results[] rs = new Results[count]; rs = r.loadConductedExamID(rs); for (int j = 0; j < count; j++) { examIDCombo.Items.Add(rs[j].exam_ID); } } else MessageBox.Show("No Exams yet conducted","Error",MessageBoxButtons.OK); }
// //Adds applicant and returns success or Error Message // public string addApplicant(Results e) { try { conn.Open(); cmd = new SqlCommand("Insert into Results(Employee_ID,Exam_ID, Score) values('"+e.employee_ID+"','"+e.exam_ID+"',-1"+")", conn); int i = cmd.ExecuteNonQuery(); conn.Close(); if(i==1) return "Employee " + e.employee_ID + " was successfully added for Exam " + e.exam_ID + "."; else return "Error"; } catch (Exception ex) { conn.Close(); return "Error"; } }
//Calculate Detailed Result public bool calculateResult(Answers[] a, Questions[] q, Results r, Employee emp) { bool flag = true; int count = q.Length; int total = 0; string[] abc; ResultsDAL d = new ResultsDAL(); int i = d.getSectionCount(r); DetailedReports[] re = new DetailedReports[i]; abc = new string[i]; int[] section = new int[i]; abc = d.loadSection(r, i); int[] totalQuestions = d.totalSectionQuestions(abc, r); for (int j = 0; j < count; j++) { //total = total + q[j].marks; if (a[j].answer.Equals(q[j].solution)) { string click = q[j].section; for (int k = 0; k < i; k++) { if (click == abc[k]) section[k]++; } } } for (int k = 0; k < i; k++) { re[k] = new DetailedReports(); re[k].employee_ID = emp.employee_Id; re[k].exam_ID = r.exam_ID; re[k].section = abc[k]; re[k].percentage = (section[k] * 100) / totalQuestions[k]; flag = d.addDetailedResult(re[k]); } return flag; }
// //Returns detailed results for a particular Exam // public DetailedReports[] getDetailedReports(Results s, int count) { DetailedReports[] arr = new DetailedReports[count]; conn.Open(); cmd = new SqlCommand("select Employee_ID, Exam_ID, Section,Percentage from Detailed_Reports where Exam_ID ='" + s.exam_ID + "'", conn); dread = cmd.ExecuteReader(); for (int i = 0; i < count; i++) { if (dread.Read()) { arr[i] = new DetailedReports(); arr[i].employee_ID = dread[0].ToString(); arr[i].exam_ID = dread[1].ToString(); arr[i].section = dread[2].ToString(); arr[i].percentage = Convert.ToSingle(dread[3].ToString()); } } dread.Close(); conn.Close(); return arr; }
//Calculate Highest, Lowest, Average public Exam_Details calculateResultFull(Results re) { Results[] r = cs.viewResult(re); Exam_Details ed = new Exam_Details(); Exam_Details ed1 = new Exam_Details(); ed.exam_ID = re.exam_ID; int highest = 0, lowest = 999, sum = 0; ed1 = cs.CheckResult(re); if (ed1.exam_ID != "ED000") { if (ed1.datetime.Date == DateTime.Today.Date) { ed.exam_ID = "ED00"; } else { for (int i = 0; i < r.Length; i++) { if (highest < r[i].score) highest = r[i].score; if (lowest > r[i].score) lowest = r[i].score; sum += r[i].score; } ed.highest = highest; ed.lowest = lowest; ed.average = sum / r.Length; bool feed = cs.addResult(ed); } } else if (cs.CheckResult(re).exam_ID == "ED000") { ed.exam_ID = "ED000"; } else ed = cs.getExamDetails(ed); return ed; }
// //On Form Load // private void SelectResult_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 = selectExamLegend.Width / 2; groupStartPosition = centerForm - centerGroup; selectExamLegend.Left = groupStartPosition; ResultsBS r = new ResultsBS(); int count = r.getConductedExamsCount(); if (count > 0) { Results[] rs = new Results[count]; rs = r.loadConductedExamID(rs); for (int i = 0; i < count; i++) { examIDCombo.Items.Add(rs[i].exam_ID); } } else MessageBox.Show("No Exams yet conducted"); }
// //Calculates marks for each question and the total, stores them in Answers array, DAL call to store the answers in the Answers table, and final results in the Result table // public bool submit(Answers[] a, Questions[] q, Employee emp, Exam_Details ed) { //Calculates marks for each question (stores them in Answers array), total and percentage int score = 0; int outOf = 0; float per = 0; for (int i = 0; i < q.Length; i++) { if (a[i].answer.Equals(q[i].solution)) a[i].marks = q[i].marks; else a[i].marks = 0; score += a[i].marks; outOf += q[i].marks; } per = (score *100) / outOf; //DAL call to store the answers in the Answers table bool feed = d.submitAnswers(a); //DAL call to store final result in the Result table if (feed) { Results re = new Results(); re.employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; re.score = score; re.percentage = per; ResultsDAL rb = new ResultsDAL(); bool feed1 = rb.addScore(re); if (feed1) { ResultStatusDAL rsd = new ResultStatusDAL(); ResultStatus rs = new ResultStatus(); rs.employee_ID = emp.employee_Id; rs.exam_Type = ed.exam_Type; if (re.percentage >= 50.0) rs.status = "Passed"; else rs.status = "Failed"; bool feed2 = rsd.updateStatus(rs); if (feed2) return true; else return false; } else return false; } else return false; }
// //Returns results for a particular Employee // public Results[] viewResultForEmployee(Results s, int count) { Results[] arr = new Results[count]; conn.Open(); cmd = new SqlCommand("select Employee_ID, Exam_ID, Score,Percentage from Results where Employee_ID ='" + s.employee_ID + "'", conn); dread = cmd.ExecuteReader(); for (int i = 0; i < count; i++) { dread.Read(); arr[i] = new Results(); arr[i].employee_ID = dread[0].ToString(); arr[i].exam_ID = dread[1].ToString(); arr[i].score = Convert.ToInt32(dread[2].ToString()); arr[i].percentage = Convert.ToSingle(dread[3].ToString()); ; } dread.Close(); conn.Close(); return arr; }
//Get Total Questions for a particular Exam for a particular Section public int[] totalSectionQuestions(string[] section, Results r) { SqlConnection cnNorth; string constr = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\BE Project\Final Backup\WindowsFormsApplication10\Data1\Database2.mdf;Integrated Security=True";//@"Server=NIKKHIL-HP\sqlexpress;Integrated Security=true; database=OnlineExamination"; cnNorth = new SqlConnection(constr); int[] total = new int[section.Length]; try { cnNorth.Open(); for (int i = 0; i < section.Length; i++) { SqlCommand cmd = new SqlCommand(); cmd.Connection = cnNorth; //SqlCommand cmd = new SqlCommand("Insert into Employee(Employee_ID) values('" + e.employee_Id + "','" + e.last_Name + "','" + e.first_Name + "','" + e.birthdate + "','" + e.hire_Date + "' ,'" + e.address + "','" + e.city + "','" + e.region + "'," + e.postalCode + ",'" + e.country + "','" + e.mobile_Number + "')",cnNorth); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select No_Of_Questions from SetPaper where Exam_ID='" + r.exam_ID + "' and Section='" + section[i] + "'"; dread = cmd.ExecuteReader(); if (dread.Read()) { total[i] = total[i] + dread.GetInt32(0); while (dread.Read()) { total[i] = total[i] + dread.GetInt32(0); } } dread.Dispose(); } } catch (Exception ex) { //return false; } cnNorth.Close(); return total; }
protected void timer1_tick(object sender, EventArgs e) { if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString()))) { timerLabel.Text = string.Format("Time Left: 00:{0}:{1}", ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString(), ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).Seconds).ToString()); } else { //If the user runs out of time, stops the timer, shows a MessageBox //Timer.Stop(); timerLabel.Text = "Time's up!"; //MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK); System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('You have run out of time! You didn't finish in time. Sorry.')</SCRIPT>"); //Stores the selected ans string ans = ""; if (option1RadioButton.Checked) ans = "1"; else if (option2RadioButton.Checked) ans = "2"; else if (option3RadioButton.Checked) ans = "3"; else if (option4RadioButon.Checked) ans = "4"; a[index].answer = ans; //a = ab.storeAnswer(a, index, ans); //Calculates score, stores answers and result in database bool feed = ab.submit(a, q, emp, ed); if (feed == true) { //Add Detailed Result Results re = new Results(); DetailedReports dr = new DetailedReports(); re.employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; //re.score = score; ResultsBS rb = new ResultsBS(); bool flag = rb.calculateResult(a, q, re, emp); /*Navigates to Results Form Result rs = new Result(emp, ed, q, a); rs.MdiParent = this.MdiParent; rs.Dock = DockStyle.Fill; this.Close(); rs.Show();*/ } } }
public SeeResult(Results e) { InitializeComponent(); ed = e; }
// //Stores the result, returns true if successfully, else false // public bool addScore(Results e) { try { conn.Open(); cmd = new SqlCommand("Update Results SET Score= " + e.score + ", Percentage = " + e.percentage + " Where Employee_ID = '" + e.employee_ID + "' AND Exam_ID = '" + e.exam_ID + "'", conn); int i = cmd.ExecuteNonQuery(); conn.Close(); if (i == 1) return true; else return false; } catch (Exception ex) { conn.Close(); return false; } }
// //On click on Submit button: Stores the selected answer, Confirms choice to submit, submits and navigates to Result Form // private void submit_Click(object sender, EventArgs e) { //Stores the selected answer ans = (string)orderTextBox.Text; ab.storeAnswer(a, index, ans); //Confirms choice to submit DialogResult r = MessageBox.Show("Are you sure you want to submit?", "Submit Test", MessageBoxButtons.YesNo); if (r == DialogResult.Yes) { //Calculates score, stores answers, and result bool feed = ab.submit(a, q, emp, ed); if (feed == true) { //Add Detailed Result Results re = new Results(); DetailedReports dr = new DetailedReports(); re.employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; //re.score = score; ResultsBS rb = new ResultsBS(); bool flag = rb.calculateResult(a, q, re, emp); //Navigates to Results Form Result rs = new Result(emp, ed, q, a); rs.MdiParent = this.MdiParent; rs.Dock = DockStyle.Fill; this.Close(); rs.Show(); } else MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error"); } }
// //Updates & displays time. On time up, submits the paper // private void Timer_Tick(object sender, EventArgs e) { if (timeLeft > 0) { // Updates & Display the new time left timeLeft = timeLeft - 1; min = timeLeft / 60; sec = timeLeft - 60 * min; timerLabel.Text = min + " minutes: " + sec + " seconds"; } else { //If the user runs out of time, stops the timer, shows a MessageBox Timer.Stop(); timerLabel.Text = "Time's up!"; MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK); //Stores the answer ans = (string)orderTextBox.Text; ab.storeAnswer(a, index, ans); //Calculates score, stores answers and result in database bool feed = ab.submit(a, q, emp, ed); if (feed == true) { //Add Detailed Result Results re = new Results(); DetailedReports dr = new DetailedReports(); re.employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; //re.score = score; ResultsBS rb = new ResultsBS(); bool flag = rb.calculateResult(a, q, re, emp); //Navigates to Results Form Result rs = new Result(emp, ed, q, a); rs.MdiParent = this.MdiParent; rs.Dock = DockStyle.Fill; this.Close(); rs.Show(); } else MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error"); } }
// //Returns results for a particular Exam // public Results[] viewResult(Results s) { int count = this.getResultCountForExam(s); Results[] arr = new Results[count]; conn.Open(); string query = string.Format("select Employee_ID, Exam_ID, Score,Percentage from Results where Exam_ID ='{0}'", s.exam_ID); cmd = new SqlCommand(query, conn); dread = cmd.ExecuteReader(); for (int i = 0; i < count; i++) { dread.Read(); arr[i] = new Results(); arr[i].employee_ID = dread[0].ToString(); arr[i].exam_ID = dread[1].ToString(); arr[i].score = Convert.ToInt32(dread[2].ToString()); arr[i].percentage = Convert.ToSingle(dread[3].ToString()); } dread.Close(); conn.Close(); return arr; }
// //On Form Load: Displays Result in Grid // private void SeeResult_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 = seeResultLegend.Width / 2; groupStartPosition = centerForm - centerGroup; seeResultLegend.Left = groupStartPosition; Exam_Details feed = p.calculateResultFull(ed); if (feed.exam_ID == "ED00") { MessageBox.Show("Exam was conducted today. So please checlk the result tomorrow. Thank You!"); } else if (feed.exam_ID == "ED000") { MessageBox.Show("Sorry some error occured! Please try later!"); } else { highestlabel.Text = "Highest:" + feed.highest; lowestlabel.Text = "Lowest: " + feed.lowest; averagelabel.Text = "Average: " + feed.average; examIDText.Text = ed.exam_ID; int count = p.getResultCountForExam(ed); if (count > 0) { Results[] arr = new Results[count]; arr = p.viewResult(ed); resultDataGrid.DataSource = arr; resultDataGrid.Enabled = false; } else MessageBox.Show("No Results present in the database.", "Error"); } }
protected void submit_Click(object sender, EventArgs e) { //Stores the selected ans string ans = ""; //Response.Write(option1RadioButton.Checked.ToString()); if (option1RadioButton.Checked) //Response.Write("Hello 1"); //(Session["answeres"] as Answers[])[index].answer = "1"; a[index].answer = "1"; else if (option2RadioButton.Checked) a[index].answer = "2"; else if (option3RadioButton.Checked) a[index].answer = "3"; else if (option4RadioButon.Checked) a[index].answer = "4"; //a = ab.storeAnswer(a, index, ans); //answ.Text = a[index].answer; //Response.Write("Hello" + answ.Text + " " + a[index].answer); Session.Remove("answers"); Session["answers"] = a; string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { Session["questions"] = q; Session["answers"] = a; Session["employee"] = emp; Session["exam"] = ed; bool feed = ab.submit(a, q, emp, ed); if (feed == true) { //Add Detailed Result Results re = new Results(); DetailedReports dr = new DetailedReports(); re.employee_ID = emp.employee_Id; re.exam_ID = ed.exam_ID; //re.score = score; ResultsBS rb = new ResultsBS(); bool flag = rb.calculateResult(a, q, re, emp); /*Navigates to Results Form Result rs = new Result(emp, ed, q, a); rs.MdiParent = this.MdiParent; rs.Dock = DockStyle.Fill; this.Close(); rs.Show();*/ Response.Redirect("~/Result.aspx"); } else System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Some error occured. Sorry for the inconvenience.')</SCRIPT>"); //MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error"); } }