-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDonation.aspx.cs
220 lines (183 loc) · 9.45 KB
/
Donation.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Serialization;
using System.Collections;
using System.Web.Services;
namespace FoodPantry
{
public partial class Donation : System.Web.UI.Page
{
static string connectionStr = ConfigurationManager.ConnectionStrings["appString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Session["Authenticated"].ToString() == "False")
{
Response.Redirect("Default.aspx");
}
}
catch (Exception ex)
{
Response.Redirect("Default.aspx");
}
//txtTodaysDate.Text = DateTime.Now.ToShortDateString();
}
[WebMethod]
public static string GetReturningDonors()
{
try
{
ArrayList donors = new ArrayList();
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "_donation-GetDonorList";
DataSet ds = objDB.GetDataSetUsingCmdObj(cmd);
foreach (DataRow dr in ds.Tables[0].Rows)
{
Donor newDonor = new Donor();
newDonor.DonorID = Convert.ToInt32(dr["DonorID"]);
newDonor.DonorType = dr["DonorType"].ToString();
newDonor.FirstName = dr["FirstName"].ToString();
newDonor.LastName = dr["LastName"].ToString();
newDonor.Affiliation = dr["TempleAffiliation"].ToString();
newDonor.Organization = dr["Organization"].ToString();
newDonor.TuId = dr["TUID"].ToString();
newDonor.Email = dr["Email"].ToString();
newDonor.Status = dr["Status"].ToString();
newDonor.SavedDonor = dr["SavedDonor"].ToString();
donors.Add(newDonor);
}
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
return javaScriptSerializer.Serialize(donors);
}
catch (Exception ex)
{
return "false";
}
}
[WebMethod]
public static string RemoveSavedDonor(string savedDonor)
{
try
{
DBConnect objDB = new DBConnect(connectionStr);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "removeSavedDonor";
cmd.Parameters.AddWithValue("@savedDonor", savedDonor);
int ret = objDB.DoUpdateUsingCmdObj(cmd);
return "true";
}
catch (Exception ex)
{
return "false";
}
}
[WebMethod]
public static string SubmitDonor(string firstName, string lastName, string donorType, string donationType, string email, string organization, string templeAffiliation, string tuID, string donationDetail, string savedDonor, string existingDonor)
{
try
{
if (existingDonor == "-1")
{
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
DateTime lastUpdateDate = DateTime.Now;
string LastUpdateUser = HttpContext.Current.Session["Access_Net"].ToString();
string status = "Active";
string personID = HttpContext.Current.Session["PersonID"].ToString();
if (savedDonor != "" && savedDonor != null)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "_donation-CheckSavedName";
cmd.Parameters.AddWithValue("@name", savedDonor);
DataSet ds2 = objDB.GetDataSetUsingCmdObj(cmd);
if (ds2.Tables[0].Rows.Count > 0)
{
//ClientScript.RegisterStartupScript(this.GetType(), "confirmation", "alertconfirmationError('Saved Donor Name already exists.')", true);
return "Donor Name Exists";
}
}
else
{
savedDonor = "";
}
SqlCommand objCommand = new SqlCommand();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "AddDonor";
objCommand.Parameters.AddWithValue("@DonorID", SqlDbType.Int).Direction = ParameterDirection.Output;
objCommand.Parameters.AddWithValue("@DonorType", donorType);
objCommand.Parameters.AddWithValue("@FirstName", firstName);
objCommand.Parameters.AddWithValue("@LastName", lastName);
objCommand.Parameters.AddWithValue("@TempleAffiliation", templeAffiliation);
objCommand.Parameters.AddWithValue("@Organization", organization);
objCommand.Parameters.AddWithValue("@TUID", tuID);
objCommand.Parameters.AddWithValue("@Email", email);
objCommand.Parameters.AddWithValue("@LastUpdateDate", lastUpdateDate);
objCommand.Parameters.AddWithValue("@LastUpdateUser", LastUpdateUser);
objCommand.Parameters.AddWithValue("@Status", status);
objCommand.Parameters.AddWithValue("@SavedDonor", savedDonor);
objDB.DoUpdateUsingCmdObj(objCommand);
string donorID = objCommand.Parameters["@DonorID"].Value.ToString();
objCommand.Parameters.Clear();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "AddDonation";
objCommand.Parameters.AddWithValue("@DonationID", SqlDbType.Int).Direction = ParameterDirection.Output;
objCommand.Parameters.AddWithValue("@PersonID", personID);
objCommand.Parameters.AddWithValue("@DonorID", donorID);
objCommand.Parameters.AddWithValue("@DonationType", donationType);
objCommand.Parameters.AddWithValue("@DonationDate", lastUpdateDate);
objCommand.Parameters.AddWithValue("@DonationDetail", donationDetail);
objCommand.Parameters.AddWithValue("@LastUpdateDate", lastUpdateDate);
objCommand.Parameters.AddWithValue("@LastUpdateUser", LastUpdateUser);
objCommand.Parameters.AddWithValue("@Status", status);
int ret = objDB.DoUpdateUsingCmdObj(objCommand);
//ClientScript.RegisterStartupScript(this.GetType(), "confirmation", "alertconfirmation()", true);
return "true";
}
else
{
string theDonorID = existingDonor;
DateTime lastUpdateDate = DateTime.Now;
string LastUpdateUser = HttpContext.Current.Session["Access_Net"].ToString();
string personID = HttpContext.Current.Session["PersonID"].ToString();
string status = "Active";
DBConnect objDB = new DBConnect(ConfigurationManager.ConnectionStrings["appString"].ConnectionString);
SqlCommand objCommand = new SqlCommand();
objCommand.Parameters.Clear();
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.CommandText = "AddDonation";
objCommand.Parameters.AddWithValue("@DonationID", SqlDbType.Int).Direction = ParameterDirection.Output;
objCommand.Parameters.AddWithValue("@PersonID", personID);
objCommand.Parameters.AddWithValue("@DonorID", theDonorID);
objCommand.Parameters.AddWithValue("@DonationType", donationType);
objCommand.Parameters.AddWithValue("@DonationDate", lastUpdateDate);
objCommand.Parameters.AddWithValue("@DonationDetail", donationDetail);
objCommand.Parameters.AddWithValue("@LastUpdateDate", lastUpdateDate);
objCommand.Parameters.AddWithValue("@LastUpdateUser", LastUpdateUser);
objCommand.Parameters.AddWithValue("@Status", status);
DataSet ds = objDB.GetDataSetUsingCmdObj(objCommand);
return "true";
//ClientScript.RegisterStartupScript(this.GetType(), "confirmation", "alertconfirmation()", true);
}
}
catch (Exception ex)
{
return "error";
//ClientScript.RegisterStartupScript(this.GetType(), "confirmation", "alertconfirmationError()", true);
}
}
protected void btnSubmitDonor_Click(object sender, EventArgs e)
{
}
}
}