private void button_submit_Click(object sender, EventArgs e) { QuestionNumber = QuestionNumber + 1; string marks; try { marks = Int32.Parse(textBox_given_marks.Text).ToString(); } catch (FormatException) { MessageBox.Show("Please put integer value", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_given_marks.Text = ""; return; } if (Int32.Parse(marks) > CurrentMark) { MessageBox.Show("You can't give more marks", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_given_marks.Text = ""; return; } TotalMarks += (Int32.Parse(marks)); if (QuestionNumber > TotalQuestions) { DBAccess sqlcon = new DBAccess(); string query = "Update Student_Master SET Marks= '" + TotalMarks.ToString() + "' where Student_Id = '" + ExamTeacherInfo.StudentId + "' AND Teacher_Id= '" + ExamTeacherInfo.ExamTeacherId + "' AND Course_Code= '" + ExamTeacherInfo.ExamCourseCode + "'"; SqlCommand updateCommand = new SqlCommand(query); int row = sqlcon.executeQuery(updateCommand); if (row > 0) { MessageBox.Show("Data added successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Unsuccefull to add data", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox_given_marks.Text = ""; } sqlcon.closeConn(); ParticipantInfo back = new ParticipantInfo(); back.Show(); this.Hide(); } else { ShowQuestionAndAnswer(); } }
private void AnswerSheetUi_Load(object sender, EventArgs e) { TotalMarks = 0; IndexQuestion = 0; QuestionNumber = QuestionNumber + 1; if (!File.Exists(GetFilePathAnswer())) { MessageBox.Show("Answer file not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ParticipantInfo participantPage = new ParticipantInfo(); participantPage.Show(); this.Hide(); } else { using (StreamReader read = new StreamReader(GetFilePathAnswer())) { string line; while ((line = read.ReadLine()) != null) { Answers.Add(line); } } } if (!File.Exists(GetFilePathQuestion())) { MessageBox.Show("Question file not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); TeacherPanelUi teacherPanel = new TeacherPanelUi(); teacherPanel.Show(); this.Hide(); } else { using (StreamReader read = new StreamReader(GetFilePathQuestion())) { string line; while ((line = read.ReadLine()) != null) { if (line != "★★★") { Questions.Add(line); } } } } TotalQuestions = (Questions.Count) / 2; ShowQuestionAndAnswer(); }
// Enter Exam work is pending ... private void button_enter_exam_Click(object sender, EventArgs e) { if (listView_teacher_current_exam.SelectedItems.Count > 0) { ListViewItem item = listView_teacher_current_exam.SelectedItems[0]; string courseCode = item.SubItems[0].Text; string teacherId = GetTeacherId(); ExamTeacherInfo.ExamTeacherId = teacherId; ExamTeacherInfo.ExamCourseCode = courseCode; ParticipantInfo participateInfo = new ParticipantInfo(); participateInfo.Show(); this.Hide(); } else { MessageBox.Show("Please Select a data to delete", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }