Component Page /Topic.cs (C#)
1: using System;  
2: using Microsoft.ApplicationBlocks.Data;  
3: using System.Data.SqlClient;  
4: using System.Data;  
5:   
6: namespace QuizNetOnline.Logic  
7: {  
8:     [Serializable]  
9:     public class Topic  
10:     {  
11:         private static Topic _instance;  
12:   
13:         private string _topicCode;  
14:         private int _topicCount;  
15:   
16:         private string _topicDesc;  
17:   
18:         public static Topic Instance  
19:         {  
20:             get  
21:             {  
22:                 return _instance ?? (_instance = new Topic());  
23:             }  
24:         }  
25:   
26:         public string TopicCode  
27:         {  
28:             get { return _topicCode; }  
29:             set { _topicCode = value; }  
30:         }  
31:   
32:         public string TopicDesc  
33:         {  
34:             get { return _topicDesc; }  
35:             set { _topicDesc = value; }  
36:         }  
37:   
38:         public int TopicCount  
39:         {  
40:             get { return _topicCount; }  
41:             set { _topicCount = value; }  
42:         }  
43:   
44:         public Topic(string topicCode)  
45:         {  
46:             LoadTopic(topicCode, new SqlWrapper());  
47:         }  
48:   
49:         public Topic()  
50:         {  
51:         }  
52:   
53:         public static DataTable LoadTopics(string topicCode, bool includeMovie, ISqlWrapper isqlWrapper)  
54:         {  
55:             string connStr = isqlWrapper.GetConnectionString();  
56:   
57:             if (connStr == null)  
58:                 throw new NotImplementedException();  
59:   
60:             const string sproc = "GetTopic";  
61:             var parameters = new SqlParameter[2];  
62:             parameters[0] = new SqlParameter("TopicCode", topicCode);  
63:             parameters[1] = new SqlParameter("IncludeMovie", false);  
64:             try  
65:             {  
66:                 return isqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters).Tables[0];  
67:             }  
68:             catch (Exception ex)  
69:             {  
70:                 ErrorLog errorLog = new ErrorLog();  
71:                 errorLog.LogException("LoadTopic", ex, isqlWrapper);  
72:                 throw;  
73:             }  
74:         }  
75:   
76:         public virtual void LoadTopic(string topicCode, ISqlWrapper isqlWrapper)  
77:         {  
78:             string connStr = isqlWrapper.GetConnectionString();  
79:   
80:             if (connStr == null)  
81:                 throw new NotImplementedException();  
82:   
83:             const string sproc = "GetTopic";  
84:             var parameters = new SqlParameter[2];  
85:             parameters[0] = new SqlParameter("TopicCode", topicCode);  
86:             parameters[1] = new SqlParameter("IncludeMovie", true);  
87:             try  
88:             {  
89:                 DataTable tbl = isqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters).Tables[0];  
90:   
91:                 TopicCode = topicCode;  
92:                 TopicDesc = tbl.Rows[0]["TopicDesc"].ToString();  
93:                 TopicCount = Convert.ToInt32(tbl.Rows[0]["TopicCount"]);  
94:   
95:             }  
96:             catch (Exception ex)  
97:             {  
98:                 ErrorLog errorLog = new ErrorLog();  
99:                 errorLog.LogException("LoadTopic", ex, isqlWrapper);  
100:                 throw;  
101:             }  
102:         }  
103:     }  
104: }  

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