-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDonationHistory.aspx.cs
307 lines (254 loc) · 11.5 KB
/
DonationHistory.aspx.cs
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
using FoodPantry;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FoodPantry
{
public partial class DonationHistory : System.Web.UI.Page
{
static string connectionStr = ConfigurationManager.ConnectionStrings["appString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string GetDonationInfo()
{
try
{
string status = "Active";
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand objCommand = new SqlCommand();
ArrayList Donations = new ArrayList();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "GetDonationData"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@Status", status);
//Execute the stored procedure using the DBConnect object and the SQLCommand object
DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand);
int count = 0;
foreach (DataRow row in myDS.Tables[0].Rows)
{
count++;
}
for (int i = 0; i < count; i++)
{
DonationData donation = new DonationData();
donation.DonationID = Convert.ToInt32(objDB.GetField("DonationID", i));
donation.DonorID = Convert.ToInt32(objDB.GetField("DonorID", i));
donation.DonorOrgs = objDB.GetField("Organization", i).ToString();
donation.DonorLN = objDB.GetField("LastName", i).ToString();
donation.DonorFN = objDB.GetField("FirstName", i).ToString();
donation.DonorEmail = objDB.GetField("Email", i).ToString();
donation.DonorType = objDB.GetField("DonorType", i).ToString();
donation.DonationType = objDB.GetField("DonationType", i).ToString();
DateTime date = DateTime.Parse(objDB.GetField("DonationDate", i).ToString());
donation.DonationDate = date.ToShortDateString();
donation.DonationDetail = objDB.GetField("DonationDetail", i).ToString();
Donations.Add(donation);
}
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(Donations);
return json;
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string UpdateDonation(string DonationId, string DonationType, string DonationDate)
{
try
{
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand objCommand = new SqlCommand();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "UpdateDonation"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@DonationID", Convert.ToInt32(DonationId));
objCommand.Parameters.AddWithValue("@DonationType", DonationType);
objCommand.Parameters.AddWithValue("@DonationDate", DonationDate);
objCommand.Parameters.AddWithValue("@Last_Update_User", HttpContext.Current.Session["Access_Net"].ToString());
objCommand.Parameters.AddWithValue("@Last_Update_Date", DateTime.Now);
objDB.DoUpdateUsingCmdObj(objCommand);
return "true";
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string UpdateDonor(string DonorID, string DonorFN, string DonorLN, string DonorEmail, string DonorType, string DonorOrgs)
{
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "UpdateDonor"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@Donorid ", DonorID);
objCommand.Parameters.AddWithValue("@DonorFN ", DonorFN);
objCommand.Parameters.AddWithValue("@DonorLN", DonorLN);
objCommand.Parameters.AddWithValue("@DonorEmail", DonorEmail);
objCommand.Parameters.AddWithValue("@DonorType", DonorType);
objCommand.Parameters.AddWithValue("@DonorOrgs", DonorOrgs);
objCommand.Parameters.AddWithValue("@Last_Update_User", HttpContext.Current.Session["Access_Net"].ToString());
objCommand.Parameters.AddWithValue("@Last_Update_Date", DateTime.Now);
objDB.DoUpdateUsingCmdObj(objCommand);
return "true";
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string DeleteDonation(string DonationID)
{
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
string status = "Inactive";
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "DeleteDonation"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@donationID", DonationID);
objCommand.Parameters.AddWithValue("@Status", status);
objDB.DoUpdateUsingCmdObj(objCommand);
return "true";
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string DeleteDonor(string DonorID)
{
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
string status = "Inactive";
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "DeleteDonor"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@DonorID", DonorID);
objCommand.Parameters.AddWithValue("@Status", status);
objDB.DoUpdateUsingCmdObj(objCommand);
return "true";
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string GetDonationDetail(string DonationID)
{
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
ArrayList Ddetails = new ArrayList();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "GetDonationDetails"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@donationID", DonationID);
DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand);
int count = 0;
foreach (DataRow row in myDS.Tables[0].Rows)
{
count++;
}
for (int i = 0; i < count; i++)
{
DonationData donation = new DonationData();
donation.DonationDetail = objDB.GetField("DonationDetail", i).ToString();
Ddetails.Add(donation);
}
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(Ddetails);
return json;
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string UpdateDonationDetails(string DonationDetails, string DonationID)
{
try
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
ArrayList Donation = new ArrayList();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "UpdateDonationDetail"; // identify the name of the stored procedure to execute
objCommand.Parameters.AddWithValue("@DonationID", Convert.ToInt32(DonationID));
objCommand.Parameters.AddWithValue("@DonationDetails", DonationDetails);
objCommand.Parameters.AddWithValue("@Last_Update_User", HttpContext.Current.Session["Access_Net"].ToString());
objCommand.Parameters.AddWithValue("@Last_Update_Date", DateTime.Now);
objDB.DoUpdateUsingCmdObj(objCommand);
return "true";
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string GetDonorType()
{
try
{
ArrayList DonorType = new ArrayList();
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetDonorType";
DataSet ds = objDB.GetDataSetUsingCmdObj(cmd);
foreach (DataRow dr in ds.Tables[0].Rows)
{
DonorType.Add(dr["DonorType"].ToString());
}
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
return javaScriptSerializer.Serialize(DonorType);
}
catch (Exception ex)
{
return ex.Message;
}
}
[WebMethod]
public static string GetDonationType()
{
try
{
ArrayList DonaType = new ArrayList();
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetDonationType";
DataSet ds = objDB.GetDataSetUsingCmdObj(cmd);
foreach (DataRow dr in ds.Tables[0].Rows)
{
DonaType.Add(dr["DonationType"].ToString());
}
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
return javaScriptSerializer.Serialize(DonaType);
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}