public Puzzle(string Title, string Image) { InitializeComponent(); strTitle = Title; strImage = Image; objQuestion = new QuestionVO(); ImagesDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images"); }
private void Form1_Load(object sender, EventArgs e) { tooltip = new ToolTip(); LocalPictureBox = new PictureBox(); objQuestion = new QuestionVO(); ImagesDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images"); //SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename='c:\users\arif\documents\visual studio 2010\Projects\Medical Training Center\Medical Training Center\MedicalDB.mdf';Integrated Security=True;User Instance=True"); string DBPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) + @"\MedicalDB.mdf"; SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + DBPath + ";Integrated Security=True;User Instance=True"); con.Open(); SqlCommand cmd = new SqlCommand("Select * from QuestionTB", con); ds = new System.Data.DataSet(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = cmd; cmd.ExecuteNonQuery(); adapter.Fill(ds); GlobalData.dtQuestionData = ds.Tables[0]; objQuestion.QuestionID = Convert.ToInt32(ds.Tables[0].Rows[0][0]); CurrentQuestionID = objQuestion.QuestionID; objQuestion.QuestionType = Convert.ToString(ds.Tables[0].Rows[CurrentQuestionID][1]); objQuestion.QuestionTitle = Convert.ToString(ds.Tables[0].Rows[CurrentQuestionID][2]); objQuestion.QuestionName = Convert.ToString(ds.Tables[0].Rows[CurrentQuestionID][3]).Split('~'); string strOptions = Convert.ToString(ds.Tables[0].Rows[CurrentQuestionID][4]); objQuestion.QuestionOptions = strOptions.Split('~'); objQuestion.QuestionAnswer = Convert.ToString(ds.Tables[0].Rows[CurrentQuestionID][5]).Split('~'); lblQuestionTitle.Text = objQuestion.QuestionTitle; pictureBox1.Image = Image.FromFile(ImagesDirectory + @"\" + objQuestion.QuestionName[0] + ".jpg"); pictureBoxOption1.Image = Image.FromFile(ImagesDirectory + @"\" + objQuestion.QuestionOptions[0] + ".jpg"); pictureBox3.Image = Image.FromFile(ImagesDirectory + @"\" + objQuestion.QuestionOptions[1] + ".jpg"); pictureBox4.Image = Image.FromFile(ImagesDirectory + @"\" + objQuestion.QuestionOptions[2] + ".jpg"); pictureBox5.Image = Image.FromFile(ImagesDirectory + @"\" + objQuestion.QuestionOptions[3] + ".jpg"); // setting tool tip tooltip.SetToolTip(this.pictureBoxOption1, "Click to select option"); tooltip.SetToolTip(this.pictureBox3, "Click to select option"); tooltip.SetToolTip(this.pictureBox4, "Click to select option"); tooltip.SetToolTip(this.pictureBox5, "Click to select option"); con.Close(); }