Repository navigation
Expand file tree
/
Copy pathCourseService.cs
More file actions
170 lines (159 loc) · 5.94 KB
/
Copy pathCourseService.cs
File metadata and controls
170 lines (159 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using AHS.Core;
using AHS.Core.Framework;
using AHS.Core.Utility;
using System;
using System.Collections.Generic;
using System.Data;
namespace AHAL.StudentCourse.BO
{
#region Service Object
[Serializable]
internal sealed class CourseService : BaseService
{
#region Constructor
internal CourseService()
{
}
#endregion
#region Methods
internal void Save(Course item)
{
this.DatabaseManager.DatabaseProvider.BeginTransaction(true);
try
{
this.SourceObject = item;
if (item.IsNew)
{
item.ID = this.GenerateSequence();
//item.course_name
//item.Position = this.GenerateSequence("Position");
//item.EntryUserID = AHS.Security.Global.CurrentUser.ID;
//item.EntryDate = DateTime.Now;
this.AddData();
}
else
{
//item.UpdateUserID = AHS.Security.Global.CurrentUser.ID;
//item.UpdateDate = DateTime.Now;
this.ClearSearchColumns();
this.UpdateData();
}
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
}
internal void Delete(int id)
{
this.DatabaseManager.DatabaseProvider.BeginTransaction(true);
try
{
Course item = new Course();
item.ID = id;
this.SourceObject = item;
this.ClearSearchColumns(); //why? saimon bhai
this.RemoveData();
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
}
internal bool IsExists(List<ParamValue> searchItems)
{
bool isExists = false;
this.DatabaseManager.DatabaseProvider.BeginTransaction(false);
try
{
Course item = new Course();
this.SourceObject = item;
isExists = this.IsRecordExists(searchItems);
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
return isExists;
}
internal Course GetData(List<ParamValue> searchItems)
{
Course item = new Course();
this.DatabaseManager.DatabaseProvider.BeginTransaction(false);
try
{
this.SourceObject = item;
item = (Course)base.GetDataByParamValue(searchItems);
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
return item;
}
internal CourseCollection GetAllData(List<ParamValue> searchItems, List<ParamValue> orderByItems)
{
CourseCollection collection = new CourseCollection();
this.DatabaseManager.DatabaseProvider.BeginTransaction(false);
try
{
Course item = new Course();
this.SourceObject = item;
string sql = this.ObjectMap.SelectStatement;
sql += AHS.Core.Global.MakeSearchSQL(searchItems);
sql += AHS.Core.Global.MakeOrderBySQL(orderByItems);
IDataReader reader = this.DatabaseManager.DatabaseProvider.ExecuteRead(sql);
while (reader.Read())
{
Course singleItem = (Course)this.ObjectMap.LoadObject(reader);
collection.Add(singleItem);
}
reader.Close();
reader.Dispose();
reader = null;
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
return collection;
}
internal DataSet LoadAllData(List<ParamValue> searchItems, List<ParamValue> orderByItems)
{
DataSet dataSet = new DataSet();
this.DatabaseManager.DatabaseProvider.BeginTransaction(false);
try
{
string sql = "SELECT * FROM course";
sql += AHS.Core.Global.MakeSearchSQL(searchItems);
sql += AHS.Core.Global.MakeOrderBySQL(orderByItems);
this.DatabaseManager.DatabaseProvider.FillDataSet(sql, dataSet, "course");
this.DatabaseManager.DatabaseProvider.CommitTransaction();
}
catch (Exception exp)
{
this.DatabaseManager.DatabaseProvider.RollbackTransaction();
ExceptionLog.Write(exp);
throw new Exception(exp.Message, exp.InnerException);
}
return dataSet;
}
#endregion
}
#endregion
}