private void BtnPreview_Click(object sender, EventArgs e) { this.Hide(); Set_MidsemExam_Paper smp = new Set_MidsemExam_Paper(); smp.Show(); }
private void btnSetPaper_Click(object sender, EventArgs e) { if (cbExamName.SelectedIndex == -1) { MessageBox.Show("Plz !! Select Exam Name First ", "Error"); } else if (cbSelectSubject.SelectedIndex == -1) { MessageBox.Show("Plz !! Select Exam Subject ", "Error"); } else if (cbExamName.Items[cbExamName.SelectedIndex].ToString() == "Final Exam") { string subjectName = cbSelectSubject.SelectedValue.ToString(); Login_info.SelectedSubject = subjectName; Login_info.FinalExamDate = dtExamDate.Value.ToShortDateString(); Login_info.FinalExamMonth = dtExamDate.Value.ToString("MMMM"); Login_info.FinalExamYear = dtExamDate.Value.Year.ToString(); //subject credit decision goes here int credit, TotalMarks; try { DataTable dt = new DataTable(); command = new SqlCommand("select * from Paper_type where Paper_Name=@subjectName", con); con.Open(); command.Parameters.AddWithValue("@subjectName", subjectName); adpt = new SqlDataAdapter(command); DataSet ds = new DataSet(); adpt.Fill(ds); credit = Convert.ToInt32(ds.Tables[0].Rows[0]["Paper_Credit"]); con.Close(); } catch (Exception ex) { MessageBox.Show("Error::" + ex.ToString()); throw; } if (credit == 3) { Login_info.FinalExamStart = dtExamTime.Value.ToString("hh:mm tt"); Login_info.FinalExamEnd = (dtExamTime.Value.AddHours(3).ToString("hh:mm tt")); TotalMarks = 100; Login_info.Total_Marks = TotalMarks; } else { Login_info.FinalExamStart = dtExamTime.Value.ToString("hh:mm tt"); Login_info.FinalExamEnd = (dtExamTime.Value.AddHours(2).ToString("hh:mm tt")); TotalMarks = 50; Login_info.Total_Marks = TotalMarks; } this.Hide(); Set_FinalExam_Paper sf1 = new Set_FinalExam_Paper(); sf1.Show(); } else if (cbExamName.Items[cbExamName.SelectedIndex].ToString() == "Mid-sem Exam") { string subjectName = cbSelectSubject.SelectedValue.ToString(); Login_info.SelectedSubject = subjectName; Login_info.MidExamDate = dtExamDate.Value.ToShortDateString(); Login_info.MidExamMonth = dtExamDate.Value.ToString("MMMM"); Login_info.MidExamYear = dtExamDate.Value.Year.ToString(); string theDate = dtExamDate.Value.ToShortDateString(); string subDate = theDate.Substring(0, 2); Login_info.MidSemDateOnly = subDate; int credit, TotalMarks; try { DataTable dt = new DataTable(); command = new SqlCommand("select * from Paper_type where Paper_Name=@subjectName", con); con.Open(); command.Parameters.AddWithValue("@subjectName", subjectName); adpt = new SqlDataAdapter(command); DataSet ds = new DataSet(); adpt.Fill(ds); credit = Convert.ToInt32(ds.Tables[0].Rows[0]["Paper_Credit"]); con.Close(); } catch (Exception ex) { MessageBox.Show("Error::" + ex.ToString()); throw; } if (credit == 3) { Login_info.MidExamStart = dtExamTime.Value.ToString("hh:mm tt"); Login_info.MidExamEnd = dtExamTime.Value.AddHours(3).ToString("hh:mm tt"); TotalMarks = 50; Login_info.Total_Marks = TotalMarks; } else { Login_info.MidExamStart = dtExamTime.Value.ToString("hh:mm tt"); Login_info.MidExamEnd = dtExamTime.Value.AddHours(2).ToString("hh:mm tt"); TotalMarks = 30; Login_info.Total_Marks = TotalMarks; } this.Hide(); Set_MidsemExam_Paper sm1 = new Set_MidsemExam_Paper(); sm1.Show(); } }