Code Behind Page Page /Admin/Video.aspx.cs (C#)
Used by Page /Admin/Video.aspx (C#)
1: using System;  
2: using System.Data;  
3: using System.Configuration;  
4: using System.Collections.Generic;  
5: using System.Collections.ObjectModel;  
6: using System.Web;  
7: using System.Web.Security;  
8: using System.Web.UI;  
9: using System.Web.UI.WebControls;  
10: using System.Web.UI.WebControls.WebParts;  
11: using System.Web.UI.HtmlControls;  
12: using System.Data.SqlClient;  
13: using QuiznetOnline.Data;  
14: using QuizNetOnline.Logic;  
15: using Microsoft.ApplicationBlocks.Data;  
16: using AjaxControlToolkit;  
17:   
18: public partial class AdminVideo : System.Web.UI.Page  
19: {  
20:     protected int NewListOrderNumber;  
21:     protected List<Video> ListDataItems;  
22:   
23:     protected void Page_Load(object sender, EventArgs e)  
24:     {  
25:         ReorderList1.ItemReorder += new EventHandler<ReorderListItemReorderEventArgs>(ReorderList1_ItemReorder);  
26:   
27:         // Event handler for deleting items from the list  
28:         ReorderList1.ItemCommand += new EventHandler<ReorderListCommandEventArgs>(ReorderList1_ItemCommand);  
29:   
30:         DataFunctions dataFunctions = DataFunctions.GetInstance();  
31:         if (Session["Validated"] == null || (bool)Session["Validated"] == false)  
32:             Response.Redirect("Default.aspx");  
33:   
34:   
35:         if (!Page.IsPostBack)  
36:         {  
37:             PopulateTopics();  
38:         }  
39:   
40:         GetListData();  
41:   
42:         if (!Page.IsPostBack)  
43:         {  
44:             BindData();  
45:         }  
46:   
47:   
48:     }  
49:   
50:   
51:     /// <summary>  
52:     /// Reorder list items in the database when a reorder event occurs  
53:     /// </summary>  
54:     protected void ReorderList1_ItemReorder(object sender, ReorderListItemReorderEventArgs e)  
55:     {  
56:         var NewOrder = e.NewIndex + 1;  
57:         var OldOrder = e.OldIndex + 1;  
58:   
59:         var ReorderListItemID = Convert.ToInt32(((Label)(e.Item.FindControl("lblVideoID"))).Text);  
60:   
61:         var ListItemCount = 1;  
62:   
63:         Video video = new Video();  
64:   
65:         var ListData = video.Get(new Topic(cmbTopic.SelectedItem.Value));  
66:         foreach (var ListDataItem in ListData)  
67:         {  
68:             // Move forward items in this range  
69:             if (OldOrder > NewOrder  
70:                 && ListItemCount >= NewOrder  
71:                 && ListItemCount <= OldOrder  
72:                 )  
73:                 ListDataItem.VideoPosition = ListItemCount + 1;  
74:             // Move backward items in this range  
75:             else if  
76:                 (OldOrder < NewOrder  
77:                 && ListItemCount <= NewOrder  
78:                 && ListItemCount >= OldOrder  
79:                 )  
80:                 ListDataItem.VideoPosition = ListItemCount - 1;  
81:   
82:             ListItemCount++;  
83:   
84:             // Set the changed item into the newly numerical gap  
85:             if (ListDataItem.VideoID == ReorderListItemID)  
86:                 ListDataItem.VideoPosition = NewOrder;  
87:         }  
88:   
89:         foreach (var ListDataItem in ListData)  
90:         {  
91:             ListDataItem.Save();  
92:         }  
93:   
94:   
95:         GetListData();  
96:         BindData();  
97:     }  
98:   
99:     private void PopulateTopics()  
100:     {  
101:         ISqlWrapper sqlWrapper = new SqlWrapper();  
102:         Topics topics = new Topics();  
103:         topics.LoadTopics(sqlWrapper);  
104:   
105:         cmbTopic.DataSource = topics.Topiclist;  
106:         cmbTopic.DataTextField = "TopicCode";  
107:         cmbTopic.DataValueField = "TopicCode";  
108:         cmbTopic.DataBind();  
109:     }  
110:   
111:     protected void cmbTopic_SelectedIndexChanged(object sender, EventArgs e)  
112:     {  
113:         GetListData();  
114:         BindData();  
115:     }  
116:   
117:     private void SaveVideo(bool isUpdate)  
118:     {  
119:         Video video = new Video();  
120:         video.Topic = new Topic(cmbTopic.SelectedItem.Value);  
121:         video.VideoCode = txtVideoCode.Text;  
122:         video.VideoDesc = txtVideoDesc.Text;  
123:   
124:         if (!isUpdate)  
125:         {  
126:             video.Add();  
127:         }  
128:         else  
129:         {  
130:             video.VideoID = Convert.ToInt32(txtVideoID.Text);  
131:             video.Save();  
132:         }  
133:   
134:         ClearFields();  
135:     }  
136:   
137:     private void ClearFields()  
138:     {  
139:         txtVideoID.Text = string.Empty;  
140:         txtVideoCode.Text = string.Empty;  
141:         txtVideoDesc.Text = string.Empty;  
142:   
143:         GetListData();  
144:         BindData();  
145:     }  
146:   
147:     protected void cmdInsert_Click(object sender, EventArgs e)  
148:     {  
149:         SaveVideo(false);  
150:     }  
151: There is a limit of 150 source code lines in the evaluation version
152: There is a limit of 150 source code lines in the evaluation version
153: There is a limit of 150 source code lines in the evaluation version
154: There is a limit of 150 source code lines in the evaluation version
155: There is a limit of 150 source code lines in the evaluation version
156: There is a limit of 150 source code lines in the evaluation version
157: There is a limit of 150 source code lines in the evaluation version
158: There is a limit of 150 source code lines in the evaluation version
159: There is a limit of 150 source code lines in the evaluation version
160: There is a limit of 150 source code lines in the evaluation version
161: There is a limit of 150 source code lines in the evaluation version
162: There is a limit of 150 source code lines in the evaluation version
163: There is a limit of 150 source code lines in the evaluation version
164: There is a limit of 150 source code lines in the evaluation version
165: There is a limit of 150 source code lines in the evaluation version
166: There is a limit of 150 source code lines in the evaluation version
167: There is a limit of 150 source code lines in the evaluation version
168: There is a limit of 150 source code lines in the evaluation version
169: There is a limit of 150 source code lines in the evaluation version
170: There is a limit of 150 source code lines in the evaluation version
171: There is a limit of 150 source code lines in the evaluation version
172: There is a limit of 150 source code lines in the evaluation version
173: There is a limit of 150 source code lines in the evaluation version
174: There is a limit of 150 source code lines in the evaluation version
175: There is a limit of 150 source code lines in the evaluation version
176: There is a limit of 150 source code lines in the evaluation version
177: There is a limit of 150 source code lines in the evaluation version
178: There is a limit of 150 source code lines in the evaluation version
179: There is a limit of 150 source code lines in the evaluation version
180: There is a limit of 150 source code lines in the evaluation version
181: There is a limit of 150 source code lines in the evaluation version
182: There is a limit of 150 source code lines in the evaluation version
183: There is a limit of 150 source code lines in the evaluation version
184: There is a limit of 150 source code lines in the evaluation version
185: There is a limit of 150 source code lines in the evaluation version
186: There is a limit of 150 source code lines in the evaluation version
187: There is a limit of 150 source code lines in the evaluation version
188: There is a limit of 150 source code lines in the evaluation version
189: There is a limit of 150 source code lines in the evaluation version
190: There is a limit of 150 source code lines in the evaluation version
191: There is a limit of 150 source code lines in the evaluation version
192: There is a limit of 150 source code lines in the evaluation version
193: There is a limit of 150 source code lines in the evaluation version
194: There is a limit of 150 source code lines in the evaluation version
195: There is a limit of 150 source code lines in the evaluation version
196: There is a limit of 150 source code lines in the evaluation version
197: There is a limit of 150 source code lines in the evaluation version
198: There is a limit of 150 source code lines in the evaluation version
199: There is a limit of 150 source code lines in the evaluation version
200: There is a limit of 150 source code lines in the evaluation version
201: There is a limit of 150 source code lines in the evaluation version
202: There is a limit of 150 source code lines in the evaluation version
203: There is a limit of 150 source code lines in the evaluation version
204: There is a limit of 150 source code lines in the evaluation version
205: There is a limit of 150 source code lines in the evaluation version
206: There is a limit of 150 source code lines in the evaluation version
207: There is a limit of 150 source code lines in the evaluation version
208: There is a limit of 150 source code lines in the evaluation version
209: There is a limit of 150 source code lines in the evaluation version
210: There is a limit of 150 source code lines in the evaluation version
211: There is a limit of 150 source code lines in the evaluation version
212: There is a limit of 150 source code lines in the evaluation version
213: There is a limit of 150 source code lines in the evaluation version
214: There is a limit of 150 source code lines in the evaluation version
215: There is a limit of 150 source code lines in the evaluation version
216: There is a limit of 150 source code lines in the evaluation version
217: There is a limit of 150 source code lines in the evaluation version
218: There is a limit of 150 source code lines in the evaluation version
219: There is a limit of 150 source code lines in the evaluation version
220: There is a limit of 150 source code lines in the evaluation version
221: There is a limit of 150 source code lines in the evaluation version
222: There is a limit of 150 source code lines in the evaluation version
223: There is a limit of 150 source code lines in the evaluation version

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