private void buttonGetReady_Click(object sender, EventArgs e) { UserInformation.setOnlineOrOffline("Online"); InformationAnalysis.makeMyQuestionNoTempNull(); string[] myQuestion = new string[int.Parse(TotalQuestionNo)]; int j = 0; for (int i = 2; i <= int.Parse(TotalQuestionNo) + 1; i++, j++) { myQuestion[j] = datalines[i]; } directoryDelete(); this.Hide(); UserInformation.setQuizNo(onlineQuizSerialNo); InformationAnalysis ia = new InformationAnalysis(); ia.makeValue(myQuestion); }
public TestForm() { InitializeComponent(); result = InformationAnalysis.getResult(); labelResult.Text = result.ToString(); Application.DoEvents(); }
public void searchQuestionFromDatabase() { int QuestionSNo = 1; if (selectQuestionNoSystem == "Online") { QuestionSNo = InformationAnalysis.getQuestionNo(); } else if (selectQuestionNoSystem == "Offline") { QuestionSNo = offlineInformationAnalysis.getQuestionNo(); } // step 1: Create a connection var result = Path.GetFullPath("InformationDatabase.mdf"); string strConnection = "Data Source=.\\sqlexpress;AttachDbFilename=" + result + ";User Instance=true;Integrated Security=True;Pooling=False"; SqlConnection objConnection = new SqlConnection(strConnection); objConnection.Open(); try { // step 2: fire a command string strCommand = "select PicURL from Question where QSN=" + QuestionSNo + ""; SqlCommand objCommand = new SqlCommand(strCommand, objConnection); // step 3: bind the result data with user interface SqlDataReader reader = objCommand.ExecuteReader(); reader.Read(); byte[] img = (byte[])(reader[0]); MemoryStream ms = new MemoryStream(img); pictureBoxPic.Image = Image.FromStream(ms); objConnection.Close(); } catch (Exception ex) { if (objConnection.State == ConnectionState.Open) { objConnection.Close(); } } }
private void buttonBack_Click(object sender, EventArgs e) { if (selectQuestionNoSystem == "Online") { this.Hide(); InformationAnalysis ia = new InformationAnalysis(); ia.previousForm(); } else if (selectQuestionNoSystem == "Offline") { this.Hide(); offlineInformationAnalysis oia = new offlineInformationAnalysis(); oia.previousForm(); } }
private void buttonSubmit_Click(object sender, EventArgs e) { if (selectQuestionNoSystem == "Online") { if (radioButtonOptionA.Checked) { user_Answer = OptionA.ToLower().Replace(" ", ""); } else if (radioButtonOptionB.Checked) { user_Answer = OptionB.ToLower().Replace(" ", ""); } else if (radioButtonOptionC.Checked) { user_Answer = OptionC.ToLower().Replace(" ", ""); } else if (radioButtonOptionD.Checked) { user_Answer = OptionD.ToLower().Replace(" ", ""); } else { user_Answer = ""; } //user_Answer = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer = right_Answer.ToLower().Replace(" ", ""); if (user_Answer == right_Answer) { point = 5; UserInformation.setQuestionNO(QSN); makeSolve.makeSolveStatus(); } else if (user_Answer == "") { point = 0; } else if (user_Answer != right_Answer) { point = -2; } this.Hide(); InformationAnalysis ia = new InformationAnalysis(); ia.removeForm(point); } else if (selectQuestionNoSystem == "Offline") { if (radioButtonOptionA.Checked) { user_Answer = OptionA.ToLower().Replace(" ", ""); } else if (radioButtonOptionB.Checked) { user_Answer = OptionB.ToLower().Replace(" ", ""); } else if (radioButtonOptionC.Checked) { user_Answer = OptionC.ToLower().Replace(" ", ""); } else if (radioButtonOptionD.Checked) { user_Answer = OptionD.ToLower().Replace(" ", ""); } else { user_Answer = ""; } //user_Answer = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer = right_Answer.ToLower().Replace(" ", ""); if (user_Answer == right_Answer) { UserInformation.setQuestionNO(QSN); makeSolve.makeSolveStatus(); MessageBox.Show("Right Answer!"); this.Hide(); offlineInformationAnalysis oia = new offlineInformationAnalysis(); oia.removeForm(); } else if (user_Answer == "") { MessageBox.Show("Answer is blank!"); } else if (user_Answer != right_Answer) { MessageBox.Show("Wrong Answer!!"); } } }
private void buttonNext_Click(object sender, EventArgs e) { if (selectQuestionNoSystem == "Online") { this.Hide(); InformationAnalysis ia = new InformationAnalysis(); ia.nextForm(); } else if (selectQuestionNoSystem == "Offline") { this.Hide(); offlineInformationAnalysis oia = new offlineInformationAnalysis(); oia.nextForm(); } }
public void searchQuestionFromDatabase() { int QuestionSNo = 1; if (selectQuestionNoSystem == "Online") { QuestionSNo = InformationAnalysis.getQuestionNo(); } else if (selectQuestionNoSystem == "Offline") { QuestionSNo = offlineInformationAnalysis.getQuestionNo(); } QSN = QuestionSNo; // step 1: Create a connection var result = Path.GetFullPath("InformationDatabase.mdf"); string strConnection = "Data Source=.\\sqlexpress;AttachDbFilename=" + result + ";User Instance=true;Integrated Security=True;Pooling=False"; SqlConnection objConnection = new SqlConnection(strConnection); objConnection.Open(); try { // step 2: fire a command string strCommand = "select * from Question where QSN=" + QuestionSNo + ""; SqlCommand objCommand = new SqlCommand(strCommand, objConnection); // step 3: bind the result data with user interface SqlDataReader reader = objCommand.ExecuteReader(); reader.Read(); labelQSN.Text = reader[0].ToString(); if (reader[2].ToString() == "NA") { labelUpperText.Text = ""; } else { labelUpperText.Text = reader[2].ToString(); } if (reader[6].ToString() == "NA") { richTextBoxDescription.Text = ""; } else { richTextBoxDescription.Text = reader[6].ToString(); } labelQuestion1.Text = reader[13].ToString(); labelQuestion2.Text = reader[15].ToString(); labelOptionA.Text = reader[16].ToString(); labelOptionB.Text = reader[17].ToString(); labelOptionC.Text = reader[18].ToString(); labelOptionD.Text = reader[19].ToString(); OptionA = reader[16].ToString(); OptionB = reader[17].ToString(); OptionC = reader[18].ToString(); OptionD = reader[19].ToString(); right_Answer1 = reader[14].ToString(); right_Answer2 = reader[20].ToString(); objConnection.Close(); } catch (Exception ex) { if (objConnection.State == ConnectionState.Open) { objConnection.Close(); } // MessageBox.Show(ex.Message); } }
private void buttonSubmit_Click(object sender, EventArgs e) { if (selectQuestionNoSystem == "Online") { user_Answer1 = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer1 = right_Answer1.ToLower().Replace(" ", ""); if (user_Answer1 == right_Answer1) { point = 3; } else if (user_Answer1 == "") { point = 0; } else if (user_Answer1 != right_Answer1) { point = -1; } if (radioButtonOptionA.Checked) { user_Answer2 = OptionA.ToLower().Replace(" ", ""); } else if (radioButtonOptionB.Checked) { user_Answer2 = OptionB.ToLower().Replace(" ", ""); } else if (radioButtonOptionC.Checked) { user_Answer2 = OptionC.ToLower().Replace(" ", ""); } else if (radioButtonOptionD.Checked) { user_Answer2 = OptionD.ToLower().Replace(" ", ""); } else { user_Answer2 = ""; } //user_Answer = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer2 = right_Answer2.ToLower().Replace(" ", ""); if (user_Answer2 == right_Answer2) { point = point + 2; } else if (user_Answer2 == "") { point = point + 0; } else if (user_Answer2 != right_Answer2) { point = point - 1; } if (user_Answer1 == right_Answer1 && user_Answer2 == right_Answer2) { UserInformation.setQuestionNO(QSN); makeSolve.makeSolveStatus(); } this.Hide(); InformationAnalysis ia = new InformationAnalysis(); ia.removeForm(point); } else if (selectQuestionNoSystem == "Offline") { user_Answer1 = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer1 = right_Answer1.ToLower().Replace(" ", ""); if (radioButtonOptionA.Checked) { user_Answer2 = OptionA.ToLower().Replace(" ", ""); } else if (radioButtonOptionB.Checked) { user_Answer2 = OptionB.ToLower().Replace(" ", ""); } else if (radioButtonOptionC.Checked) { user_Answer2 = OptionC.ToLower().Replace(" ", ""); } else if (radioButtonOptionD.Checked) { user_Answer2 = OptionD.ToLower().Replace(" ", ""); } else { user_Answer2 = ""; } //user_Answer = textBoxAnswer.Text.ToLower().Replace(" ", ""); right_Answer2 = right_Answer2.ToLower().Replace(" ", ""); if (user_Answer1 == right_Answer1 && user_Answer2 == right_Answer2) { UserInformation.setQuestionNO(QSN); makeSolve.makeSolveStatus(); MessageBox.Show("Right Answer!"); this.Hide(); offlineInformationAnalysis oia = new offlineInformationAnalysis(); oia.removeForm(); } else if (user_Answer1 != right_Answer1 && user_Answer2 != right_Answer2) { MessageBox.Show("Both Wrong Answer!!"); } else if (user_Answer1 != right_Answer1) { MessageBox.Show("Question One's Answer is Wrong!"); } else if (user_Answer2 != right_Answer2) { MessageBox.Show("Question Twos's Answer is Wrong!"); } } }