public void Hide_Eval_And_Insert_Marks_And_Update_Marks_Code() { Eval_1_Label.Hide(); Eval_1_txtbox.Hide(); Eval_2_Label.Hide(); Eval_2_txtbox.Hide(); Eval_3_Label.Hide(); Eval_3_txtbox.Hide(); Insert_eval_mode.Hide(); Enter_Eval_Modes_Label.Hide(); Enter_Student_Marks_Label.Hide(); Eval_1_Marks_Label.Hide(); Eval_1_Marks_txtbox.Hide(); Eval_2_Marks_Label.Hide(); Eval_2_Marks_txtbox.Hide(); Eval_3_Marks_Label.Hide(); Eval_3_Marks_txtbox.Hide(); Insert_Eval_Marks_Button.Hide(); Marks_Info_Label.Hide(); Total_Score_label.Hide(); Marks_Outof_50.Hide(); Update_Eval_Marks_Button.Hide(); }
// Method for displaying the marks of students already entered in the database. public void Display_And_Update_Student_Marks(string stud_name) { Eval_1_Marks_Label.Show(); Eval_1_Marks_txtbox.Show(); Eval_2_Marks_Label.Show(); Eval_2_Marks_txtbox.Show(); Eval_3_Marks_Label.Show(); Eval_3_Marks_txtbox.Show(); Marks_Info_Label.Show(); Enter_Eval_Modes_Label.Hide(); Enter_Student_Marks_Label.Show(); Update_Eval_Marks_Button.Show(); Insert_Eval_Marks_Button.Hide(); Total_Score_label.Show(); Marks_Outof_50.Show(); Enter_Student_Marks_Label.Text = "Update marks of : " + stud_name; Get_Evaluation_Modes_For_Labels(); string commandText1 = "SELECT eval_1_marks, eval_2_marks, eval_3_marks, final_marks from Evaluation_Marks where student_id = (SELECT student_id from Student where student_name = @stud_name) and subject_id = (SELECT subject_id from Subject where subject_name = @subj_name)"; try { using (SqlCommand cmd = new SqlCommand(commandText1, sqlConnection1)) { cmd.Parameters.AddWithValue("@stud_name", stud_name); cmd.Parameters.AddWithValue("@subj_name", SubjectComboBox.SelectedItem); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Eval_1_Marks_txtbox.Text = reader.GetInt32(0).ToString(); Eval_2_Marks_txtbox.Text = reader.GetInt32(1).ToString(); Eval_3_Marks_txtbox.Text = reader.GetInt32(2).ToString(); Marks_Outof_50.Text = reader.GetInt32(3).ToString() + " / 50"; } reader.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Function to insert Evaluation modes for a subject public void Enter_Modes_Of_Evaluation() { Enter_Eval_Modes_Label.Show(); Enter_Eval_Modes_Label.Text = "Enter 3 modes of evaluation for this Subject"; Eval_1_Label.Show(); Eval_1_txtbox.Show(); Eval_2_Label.Show(); Eval_2_txtbox.Show(); Eval_3_Label.Show(); Eval_3_txtbox.Show(); Insert_eval_mode.Show(); Insert_Eval_Marks_Button.Hide(); }
private void StudentComboBox_SelectedValueChanged(object sender, EventArgs e) { Enter_Eval_Modes_Label.Show(); Total_Score_label.Hide(); Marks_Outof_50.Hide(); Insert_Eval_Marks_Button.Show(); Update_Eval_Marks_Button.Hide(); string commandText1 = "SELECT eval_mode_1,eval_mode_2,eval_mode_3 FROM Evaluation WHERE subject_id = (SELECT subject_id FROM Subject where subject_name = @s1_name)"; try { //sqlConnection1.Open(); using (SqlCommand cmd = new SqlCommand(commandText1, sqlConnection1)) { cmd.Parameters.AddWithValue("@s1_name", SubjectComboBox.Text); SqlDataReader reader = cmd.ExecuteReader(); // If the evaluation modes already are entered in the database. if (reader.HasRows) { reader.Close(); if (Check_If_Marks_Already_Exist()) { Display_And_Update_Student_Marks(StudentComboBox.SelectedItem.ToString()); } else { // Displaying Textboxes and Labels for inserting Student marks and Labels Display_Textboxes_And_Labels_For_Inserting_Marks(); } } // If the evaluation modes are not yet entered in the database. // Creation of Evaluation modes. else { reader.Close(); Enter_Modes_Of_Evaluation(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Method for displaying Textboxes and Labels for inserting marks of student. // Called from private void StudentComboBox_SelectedValueChange() , private void Insert_eval_mode_Click() and , Display_And_Update_Student_Marks(). public void Display_Textboxes_And_Labels_For_Inserting_Marks() { Eval_1_Marks_Label.Show(); Eval_1_Marks_txtbox.Show(); Eval_2_Marks_Label.Show(); Eval_2_Marks_txtbox.Show(); Eval_3_Marks_Label.Show(); Eval_3_Marks_txtbox.Show(); Insert_eval_mode.Hide(); Insert_Eval_Marks_Button.Show(); Marks_Info_Label.Show(); Enter_Eval_Modes_Label.Hide(); Enter_Student_Marks_Label.Show(); Enter_Student_Marks_Label.Text = "Enter Marks of : " + StudentComboBox.SelectedItem; Get_Evaluation_Modes_For_Labels(); }