Code Behind Page Page /Admin/Comments.aspx.cs (C#)
Used by Page /Admin/Comments.aspx (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Collections;  
5: using System.Web;  
6: using System.Web.Security;  
7: using System.Web.UI;  
8: using System.Web.UI.WebControls;  
9: using System.Web.UI.WebControls.WebParts;  
10: using System.Web.UI.HtmlControls;  
11: using System.Data.SqlClient;  
12: using QuizNetOnline.Logic;  
13: using QuiznetOnline.Data;  
14: using System.Text;  
15: using Microsoft.ApplicationBlocks.Data;  
16:   
17: public partial class Admin_Comments : System.Web.UI.Page  
18: {  
19:     protected void Page_Load(object sender, EventArgs e)  
20:     {  
21:         DataFunctions dataFunctions = DataFunctions.GetInstance();  
22:         SqlDataSource1.ConnectionString = dataFunctions.GetConnectionString();  
23:         if (Session["Validated"] == null || (bool)Session["Validated"] == false)  
24:             Response.Redirect("Default.aspx");  
25:   
26:         //this.SqlDataSource1.ConnectionString = ConnectionObj.GetConnection().ConnectionString;  
27:   
28:     }  
29:     protected void cmdSend_Click(object sender, EventArgs e)  
30:     {  
31:         QuizNetSystem quizNetSystem = new QuizNetSystem();  
32:         Button butt = (Button)sender;  
33:         GridViewRow grdRow = (GridViewRow)butt.Parent.Parent;  
34:         string strEmail = grdRow.Cells[5].Text;  
35:         string strUserComment = grdRow.Cells[4].Text;  
36:   
37:         int questionID = Convert.ToInt32(grdRow.Cells[3].Text);  
38:         Question question = new Question();  
39:         question.LoadQuestion(questionID, new SqlWrapper());  
40:   
41:         StringBuilder questionDesc=new StringBuilder(question.QuestionDesc);  
42:         questionDesc.Append(Environment.NewLine);  
43:         questionDesc.Append(Environment.NewLine);  
44:         questionDesc.Append("Possible answers:");  
45:         questionDesc.Append(Environment.NewLine);  
46:         foreach (Answer ans in question.Answers)  
47:         {  
48:             questionDesc.Append("\t" + ans.AnswerDesc);  
49:             questionDesc.Append(Environment.NewLine);  
50:         }  
51:         questionDesc.Append(Environment.NewLine);  
52:         questionDesc.Append("Correct answer:");  
53:         questionDesc.Append(Environment.NewLine);  
54:         questionDesc.Append("\t" + question.AnswerDesc);  
55:   
56:         questionDesc.Append(Environment.NewLine);  
57:         questionDesc.Append(Environment.NewLine);  
58:   
59:         if (!string.IsNullOrEmpty(question.Explaination))  
60:         {  
61:             questionDesc.Append("Explaination:");  
62:             questionDesc.Append(Environment.NewLine);  
63:             questionDesc.Append("\t" + question.Explaination);  
64:         }  
65:   
66:         string strResponse = ((TextBox)grdRow.FindControl("txtReply")).Text;  
67:   
68:         quizNetSystem.SendEmail(strEmail, "QuiznetOnline to question comments", string.Format(HttpContext.GetGlobalResourceObject("Email", "CommentsReply").ToString(), questionDesc,strUserComment, strResponse),true,false);  
69:         butt.Enabled = false;  
70:     }  
71: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.