Component Page /Topics.cs (C#)
1: using System;  
2: using System.Collections.Generic;  
3: using System.Linq;  
4: using Microsoft.ApplicationBlocks.Data;  
5: using System.Data.SqlClient;  
6: using System.Data;  
7:   
8: namespace QuizNetOnline.Logic  
9: {  
10:     [Serializable]  
11:     public sealed class Topics  
12:     {  
13:         public List<Topic> Topiclist { get; set; }  
14:   
15:   
16:         public void LoadTopics(ISqlWrapper isqlwrapper)  
17:         {  
18:             var topics = new List<Topic>();  
19:   
20:             ISqlWrapper isqlWrapper = new SqlWrapper();  
21:             string connStr = isqlWrapper.GetConnectionString();  
22:   
23:             if (connStr == null)  
24:                 throw new NotImplementedException();  
25:   
26:             const string sproc = "GetTopic";  
27:             var parameters = new SqlParameter[2];  
28:             parameters[0] = new SqlParameter("TopicCode", null);  
29:             parameters[1] = new SqlParameter("IncludeMovie", true);  
30:             try  
31:             {  
32:                 DataTable tbl = isqlwrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters).Tables[0];  
33:   
34:                 topics.AddRange(from DataRow row in tbl.Rows select new Topic(row["TopicCode"].ToString()));  
35:   
36:                 Topiclist = topics;  
37:             }  
38:             catch (Exception ex)  
39:             {  
40:                 ErrorLog errorLog = new ErrorLog();  
41:                 errorLog.LogException("LoadTopic", ex, isqlwrapper);  
42:                 throw;  
43:             }  
44:         }  
45:     }  
46: }  

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