ASP.NET Page /Admin/QuestionRatingAuthor.aspx.cs (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 Microsoft.ApplicationBlocks.Data;  
13: using QuizNetOnline.Logic;  
14: using QuiznetOnline.Data;  
15:   
16: public partial class QuestionRatingAuthor : System.Web.UI.Page  
17: {  
18:     protected void Page_Load(object sender, EventArgs e)  
19:     {  
20:         DataFunctions dataFunctions = DataFunctions.GetInstance();  
21:         if (Session["Validated"] == null || (bool)Session["Validated"] == false)  
22:             Response.Redirect("Default.aspx");  
23:   
24:         if(!Page.IsPostBack)  
25:         {  
26:             cmbTopics.DataSource = Topic.LoadTopics(null, false,new SqlWrapper());  
27:             cmbTopics.DataTextField = "TopicDesc";  
28:             cmbTopics.DataValueField = "TopicCode";  
29:             cmbTopics.DataBind();  
30:   
31:   
32:         }  
33:   
34:     }  
35:   
36:     protected void repeatQuestion_ItemDataBound(object sender, RepeaterItemEventArgs e)  
37:     {  
38:         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)  
39:         {  
40:             int i = 1;  
41:             foreach (var answer in ((Question)e.Item.DataItem).Answers)  
42:             {  
43:                 Label lblAnswer = ((Label)e.Item.FindControl("lblAnswer" + i));  
44:                 lblAnswer.Text = answer.AnswerDesc;  
45:                 i++;  
46:             }  
47:   
48:             TextBox lblRating = ((TextBox)e.Item.FindControl("lblRating"));  
49:             lblRating.TabIndex = 1;  
50:             TextBox txtComments = ((TextBox)e.Item.FindControl("txtComments"));  
51:             txtComments.TabIndex = 9999;  
52:               
53:   
54:             QuestionRating _questionRating=new QuestionRating();  
55:             _questionRating.GetAuthorRating(((Question)e.Item.DataItem).QuestionId, "?????????????");  
56:             lblRating.Text = _questionRating.Rating.ToString();  
57:   
58:             if (e.Item.ItemType == ListItemType.AlternatingItem)  
59:             {  
60:                 Table tbl = ((Table)e.Item.FindControl("tbl"));  
61:                 tbl.BackColor = System.Drawing.Color.LightCyan;  
62:             }  
63:         }  
64:     }  
65:   
66:     protected void butChooseTopic_Click(object sender, EventArgs e)  
67:     {  
68:         QuizNetSystem quizNetSystem = new QuizNetSystem();  
69:   
70:         repeatQuestion.DataSource = quizNetSystem.LoadQuestions(cmbTopics.SelectedItem.Value, new SqlWrapper());  
71:         repeatQuestion.DataBind();  
72:     }  
73:   
74:     protected void butSaveComments_Click(object sender, EventArgs e)  
75:     {  
76:           
77:         foreach(RepeaterItem item in repeatQuestion.Items)  
78:         {  
79:             TextBox txtComments = ((TextBox)item.FindControl("txtComments"));  
80:             TextBox lblRating = ((TextBox)item.FindControl("lblRating"));  
81:             if (!string.IsNullOrEmpty(lblRating.Text) && lblRating.Text != "0")  
82:             {  
83:                 QuestionRating _questionRating = new QuestionRating();  
84:                 _questionRating.QuestionID = Convert.ToInt32(((HiddenField)item.FindControl("hiddenQuestionID")).Value);  
85:                   
86:                 _questionRating.Rating=Convert.ToInt32(lblRating.Text);  
87:                 _questionRating.UserName = "????????????????";  
88:   
89:                 _questionRating.SaveAuthorRating();  
90:             }  
91:   
92:             if (!string.IsNullOrEmpty(txtComments.Text))  
93:             {  
94:                 Comments comments=new Comments();  
95:                 comments.Comment = txtComments.Text;  
96:                 comments.QuestionId = Convert.ToInt32(((HiddenField)item.FindControl("hiddenQuestionID")).Value);  
97:                 comments.UserName = "?????????????????????";  
98:                 comments.Save(new SqlWrapper());  
99:             }  
100:         }  
101:     }  
102: }  

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