private void checkExam() { try { string query = "select event from Exam_process where Candidate_ID=@Candidate_ID and Exam_ID=@Exam_ID"; SqlCommand cmd = new SqlCommand(); cmd = new SqlCommand(query, sqlconnect.connect()); cmd.Parameters.AddWithValue("@Exam_ID", exam_ID); cmd.Parameters.AddWithValue("@Candidate_ID", frmCandidateLogin.candidatID); SqlDataReader rd = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(rd); if (dt.Rows.Count != 0) { int Event = Int32.Parse(Convert.ToString(dt.Rows[0]["Event"])); if (Event == 1) { MessageBox.Show("İmtahan artıq keçirilib!"); frmCandidateLogin login = new frmCandidateLogin(); login.Show(); this.Hide(); } } sqlconnect.close(); } catch (Exception) { MessageBox.Show("Sistemdə xəta baş verdi, təkrar cəhd edin"); } }
private void getExamID() { try { string query = @"select id, topic_id, test_count,min_point,period from exam where group_id in (select group_id from group_candidate where candidate_id=@candidate_id) and begin_date=@login_date and (@login_time between begin_time and @end_time)"; SqlCommand cmd = new SqlCommand(); cmd = new SqlCommand(query, sqlconnect.connect()); cmd.Parameters.AddWithValue("@Candidate_ID", frmCandidateLogin.candidatID); cmd.Parameters.AddWithValue("@Login_date", DateTime.Now.ToString()); cmd.Parameters.AddWithValue("@Login_time", DateTime.Now.ToString("hh:mm tt")); cmd.Parameters.AddWithValue("@End_time", DateTime.Now.AddMinutes(50).ToString("hh:mm tt")); SqlDataReader rd = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(rd); if (dt.Rows.Count != 0) { exam_ID = Int32.Parse(Convert.ToString(dt.Rows[0]["ID"])); topic_ID = Int32.Parse(Convert.ToString(dt.Rows[0]["Topic_ID"])); test_Count = Int32.Parse(Convert.ToString(dt.Rows[0]["Test_Count"])); Min_Point = Int32.Parse(Convert.ToString(dt.Rows[0]["Min_point"])); Period = dt.Rows[0]["Period"].ToString(); sqlconnect.close(); checkExam(); setExamProcess(); getExamProcessID(); getTestIDCount(); getRandomNumbers(lstTest_ID.Count, test_Count, ref randomArray); fillExamTests(ref randomArray); createRadioButton(); getSetExamTests(); rdbtn[0].Checked = true; timerExam.Enabled = true; setTime(); } else { MessageBox.Show("İmtahan aktiv deyil"); frmCandidateLogin login = new frmCandidateLogin(); login.Show(); this.Hide(); } } catch (Exception) { MessageBox.Show("Sistemdə xəta baş verdi, təkrar cəhd edin"); } }