Component Page /QuestionLog.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 class QuestionLog  
12:     {  
13:         private int _questionId;  
14:         public int QuestionId  
15:         {  
16:             get { return _questionId; }  
17:             set { _questionId = value; }  
18:         }  
19:   
20:         private string _question;  
21:         public string Question  
22:         {  
23:             get { return _question; }  
24:             set { _question = value; }  
25:         }  
26:   
27:         private bool _isCorrect;  
28:         public bool IsCorrect  
29:         {  
30:             get { return _isCorrect; }  
31:             set { _isCorrect = value; }  
32:         }  
33:   
34:         private string _answer;  
35:         public string Answer  
36:         {  
37:             get { return _answer; }  
38:             set { _answer = value; }  
39:         }  
40:   
41:         private DateTime _questionDateTime;  
42:         public DateTime QuestionDateTime  
43:         {  
44:             get { return _questionDateTime; }  
45:             set { _questionDateTime = value; }  
46:         }  
47:   
48:         private string _location;  
49:         public string Location  
50:         {  
51:             get { return _location; }  
52:             set { _location = value; }  
53:         }  
54:   
55:         public float Latitude  
56:         {  
57:             get;  
58:             set;  
59:         }  
60:   
61:         public float Longitude  
62:         {  
63:             get;  
64:             set;  
65:         }  
66:   
67:         private string _ipaddress;  
68:         public string IpAddress  
69:         {  
70:             get { return _ipaddress; }  
71:             set { _ipaddress = value; }  
72:         }  
73:   
74:         private bool _isUserGuest;  
75:         public bool IsUserGuest  
76:         {  
77:             get { return _isUserGuest; }  
78:             set { _isUserGuest = value; }  
79:         }  
80:   
81:         private int _questionNumber;  
82:         public int QuestionNumber  
83:         {  
84:             get { return _questionNumber; }  
85:             set { _questionNumber = value; }  
86:         }  
87:   
88:   
89:         public string Link { get; set; }  
90:   
91:         public int Save(ISqlWrapper isqlWrapper)  
92:         {  
93:             string connStr = isqlWrapper.GetConnectionString();  
94:   
95:             const string sproc = "CreateQuestionLog";  
96:             var parameters = new SqlParameter[9];  
97:   
98:             parameters[0]=new SqlParameter("@IsCorrect", IsCorrect);  
99:             parameters[1]=new SqlParameter("@QuestionID", QuestionId);  
100:             parameters[2]=new SqlParameter("@IpAddress", IpAddress);  
101:             parameters[3]=new SqlParameter("@CountryCode", string.Empty);  
102:             parameters[4]=new SqlParameter("@Location", Location);  
103:             parameters[5]=new SqlParameter("@IsUserGuest", IsUserGuest);  
104:             parameters[6]=new SqlParameter("@QuestionNumber", QuestionNumber);  
105:             parameters[7]=new SqlParameter("@Latitude", Latitude);  
106:             parameters[8]=new SqlParameter("@Longitude", Longitude);  
107:   
108:             try  
109:             {  
110:                 return isqlWrapper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, sproc, parameters);  
111:             }  
112:             catch (Exception ex)  
113:             {  
114:                 ErrorLog errorLog = new ErrorLog();  
115:                 errorLog.LogException("QuestionLog.Save", ex, isqlWrapper);  
116:                 throw;  
117:             }  
118:         }  
119:   
120:         public List<QuestionLog> Load(int numberOfRecords, ISqlWrapper isqlWrapper)  
121:         {  
122:             var questionLogs = new List<QuestionLog>();  
123:             string connStr = isqlWrapper.GetConnectionString();  
124:             const string sproc = "GetQuestionLogs";  
125:   
126:             var parameters = new SqlParameter[1];  
127:   
128:             parameters[0] = new SqlParameter("@NumberOfRecords", numberOfRecords);  
129:   
130:             try  
131:             {  
132:                 DataSet ds = isqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters);  
133:                 questionLogs.AddRange(from DataRow row in ds.Tables[0].Rows  
134:                                       select new QuestionLog  
135:                                       {  
136:                                           Answer = row["Answer"].ToString(),  
137:                                           IsCorrect = Convert.ToBoolean(row["IsCorrect"]),  
138:                                           QuestionId = Convert.ToInt32(row["QuestionID"]),  
139:                                           Question = row["Question"].ToString(),  
140:                                           QuestionDateTime = Convert.ToDateTime(row["QuestionDateTime"].ToString()),  
141:                                           Location = row["Location"].ToString(),  
142:                                           Link = row["Link"].ToString(),  
143:                                           IsUserGuest = Convert.ToBoolean(row["IsUserGuest"].ToString()),  
144:                                           QuestionNumber = Convert.ToInt32(row["QuestionNumber"].ToString()),  
145:                                           Longitude = string.IsNullOrEmpty(row["Longitude"].ToString()) ? 0 : float.Parse(row["Longitude"].ToString()),  
146:                                           Latitude = string.IsNullOrEmpty(row["Latitude"].ToString()) ? 0 : float.Parse(row["Latitude"].ToString()),  
147:                                       });  
148:   
149:                 return questionLogs;  
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

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