/
ConfirmPayment.aspx.cs
332 lines (245 loc) · 11.7 KB
/
ConfirmPayment.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class ConfirmPayment : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null) // customer request
{
String[] paymentMethod = (String[])Session["payMethodDetails"];
String payAmt = paymentMethod[2];
lblPaidAmt.Text = payAmt;
lblRemainAmt.Text = "0.00"; // paying amt also same here
lblPaidDate.Text = DateTime.Today.Date.ToString();
lblRemDateName.Visible = false;
lblRemainDate.Visible = false;
}
else if (Session["user"].ToString() == "Admin") // admin request ------
{
String[] paymentMethod = (String[])Session["payMethodDetails"];
String payAmt = paymentMethod[2];
String remAmt = paymentMethod[3];
lblPaidAmt.Text = payAmt; // paid amt
lblRemainAmt.Text = remAmt; // rem amt
lblPaidDate.Text = DateTime.Today.Date.ToString(); // paid date
String remdate = paymentMethod[4];
if (remdate == "null") // no remain date
{
lblRemDateName.Visible = false;
lblRemainDate.Visible = false;
}
else
{
lblRemainDate.Text = remdate;
}
}
else if (Session["user"].ToString() == "Reseption") // Reseption request ------
{
String[] paymentMethod = (String[])Session["payMethodDetails"];
String payAmt = paymentMethod[2];
String remAmt = paymentMethod[3];
lblPaidAmt.Text = payAmt;
lblRemainAmt.Text = remAmt;
String remdate = paymentMethod[4];
if (remdate == "null") // no remain date
{
lblRemDateName.Visible = false;
lblRemainDate.Visible = false;
}
else
{
lblRemainDate.Text = remdate;
}
}
else if (Session["user"].ToString() == "Agent") // agent request ------
{
String[] paymentMethod = (String[])Session["payMethodDetails"];
String payAmt = paymentMethod[2];
String remAmt = paymentMethod[3];
lblPaidAmt.Text = payAmt;
lblRemainAmt.Text = remAmt;
String remdate = paymentMethod[4];
if (remdate == "null") // no remain date
{
lblRemDateName.Visible = false;
lblRemainDate.Visible = false;
}
else
{
lblRemainDate.Text = remdate;
}
}
String[] billibgDet = (String[])Session["billingDetails"];
String name = billibgDet[9] +" "+ billibgDet[1]+ " " +billibgDet[2];
lblName.Text = name;
}
protected void Button1_Click(object sender, EventArgs e)
{
/* insert payment details first then insert reservation details according to the reservation type session variable */
String[] customerD = (String[])Session["billingDetails"]; // all customer details (passport , fname , lname , country , Street add , city , postal code , 4n , mail , salute )
String agentID = "null";
String salute = customerD[9];
String fName = customerD[1];
String lName = customerD[2];
String StateAdd = customerD[4];
String city = customerD[5];
String postelCode = customerD[6];
String phone = customerD[7];
String email = customerD[8];
String country = customerD[3];
String passport = customerD[0];
String cusType = " ";
// before insert check this customer added by sefl or by agent(check any agent is logged now)
if (Session["user"] != null)
{
if (Session["user"].ToString() == "Agent") // agent logged in
{
//get agent id from db
String mail = Session["email"].ToString();
String qry = "select agentID from Agent where email = '" + mail + "'"; // select agent id
dbConnect dc = new dbConnect();
DataTable dt = dc.selectIt(qry);
if (dt != null) // correct agent values are retriewed
{
agentID = dt.Rows[0][0].ToString();
// now insert details to customer
//String salute = customerD[9];
//String fName = customerD[1];
//String lName = customerD[2];
//String StateAdd = customerD[4];
//String city = customerD[5];
//String postelCode = customerD[6];
//String phone = customerD[7];
//String email = customerD[8];
//String country = customerD[3];
//String passport = customerD[0];
cusType = "Agent Through"; // by agent customer if agent wise
String qry2 = "insert into customer (salutation,fname,lname,state_address,city,postelCode,phone,email,country,passport_NIC,customer_Type,Agent_id) " +
" values ('" + salute + "' , '" + fName + "' , '" + lName + "' , '" + StateAdd + "' , '" + city + "' , '" + postelCode + "' , '" + phone + "' , '" + email + "' , '" + country + "' , '" + passport + "' , '" + cusType + "' , '" + agentID + "') ";
dbConnect dc2 = new dbConnect();
bool conf = dc2.insertIt(qry2); // customer details inserted
}
}
else // reseption or admin logged (that means walk in customer)
{
//String agentID = "null";
//String salute = customerD[9];
//String fName = customerD[1];
//String lName = customerD[2];
//String StateAdd = customerD[4];
//String city = customerD[5];
//String postelCode = customerD[6];
//String phone = customerD[7];
//String email = customerD[8];
//String country = customerD[3];
//String passport = customerD[0];
cusType = "Walk-in"; // walkin customer
String qry2 = "insert into customer (salutation,fname,lname,state_address,city,postelCode,phone,email,country,passport_NIC,customer_Type,Agent_id) " +
" values ('" + salute + "' , '" + fName + "' , '" + lName + "' , '" + StateAdd + "' , '" + city + "' , '" + postelCode + "' , '" + phone + "' , '" + email + "' , '" + country + "' , '" + passport + "' , '" + cusType + "' , '" + agentID + "') ";
dbConnect dc2 = new dbConnect();
bool conf = dc2.insertIt(qry2); // customer details inserted if reseption or admin wise
}
}
else // no login ( that means online customer)
{
//String agentID = "null";
//String salute = customerD[9];
//String fName = customerD[1];
//String lName = customerD[2];
//String StateAdd = customerD[4];
//String city = customerD[5];
//String postelCode = customerD[6];
//String phone = customerD[7];
//String email = customerD[8];
//String country = customerD[3];
//String passport = customerD[0];
cusType = "Walk-in"; // walkin customer
String qry2 = "insert into customer (salutation,fname,lname,state_address,city,postelCode,phone,email,country,passport_NIC,customer_Type,Agent_id) " +
" values ('" + salute + "' , '" + fName + "' , '" + lName + "' , '" + StateAdd + "' , '" + city + "' , '" + postelCode + "' , '" + phone + "' , '" + email + "' , '" + country + "' , '" + passport + "' , '" + cusType + "' , '" + agentID + "') ";
dbConnect dc2 = new dbConnect();
bool conf = dc2.insertIt(qry2); // customer details inserted if self reg
}
dbConnect dc22 = new dbConnect();
// now add payment details
//select added customer id
String qry3 = "select customerID from customer where Passport_nic = '" + passport + "'";
DataTable dt3 = dc22.selectIt(qry3);
String cusID = dt3.Rows[0][0].ToString();
String totAmt = ""; // total price
String[] paymentD = new String[6];
// get total amount
if (Session["reservationType"].ToString() == "sport")// Sport reservation request
{
String[] sportD = (String[])Session["sportReservationDetails"]; // passed by sport reservation function
totAmt = sportD[2];
}
else if (Session["reservationType"].ToString() == "wedding")// wedding reservation request
{
totAmt = Session["payAmount"].ToString();
}
else if (Session["reservationType"].ToString() == "Room")
{
String roomD = Session["tot_price"].ToString();
totAmt = roomD;
}
else if (Session["reservationType"].ToString() == "tour")
{
String tourD = Session["price"].ToString();
totAmt = tourD;
}
// get orther payment details from session
paymentD = (String[])Session["payMethodDetails"];
String paid = paymentD[2];
String remAmt = paymentD[3];
String resType = Session["reservationType"].ToString(); // sport , wedding , Room , tour
String remdate = paymentD[4];
String payBy = paymentD[1];
String agntID = paymentD[5];
String reserveID = cusID; // we have to genarate a reservation id
// res id is identtity
String qry4 = "insert into payment (totalAmount,paidAmount,remainamount,reservationType,remainingDate,pay_by,agentID,cusID,resID) " +
" values ('" + totAmt + "' , '" + paid + "' , '" + remAmt + "' , '" + resType + "' , '" + remdate + "' , '" + payBy + "' , '" + agntID + "' , '" + cusID + "' , '" + reserveID + "') ";
dbConnect dc4 = new dbConnect();
bool confpay = dc4.insertIt(qry4);
if (Session["reservationType"].ToString() == "sport")// Sport reservation request
{
String[] sportReserveD = (String[])Session["sportReservationDetails"];
String rid = reserveID;
String sdate = sportReserveD[0];
String edate = sportReserveD[1];
String location = sportReserveD[4];
String fee = sportReserveD[2];
String noOfMem = sportReserveD[3];
String sportID = sportReserveD[5];
String cid = cusID;
String hid;
String qry = "insert into sportsReservation (rid,sdate,edate,location,fee,noofMem,sportId,cid) " +
" values ('" + rid + "' , '" + sdate + "' , '" + edate + "' , '" + location + "' , '" + fee + "' , '" + noOfMem + "' , '" + sportID + "' , '" + cid + "' )";
dbConnect dc = new dbConnect();
bool confSport = dc.insertIt(qry);
if (confSport == true)
{
lblMessage.Visible = true;
}
else
{
lblMessage.Text = "Cannot insert";
lblMessage.Visible = true; ;
}
}
else if (Session["reservationType"].ToString() == "wedding")// wedding reservation request
{
}
else if (Session["reservationType"].ToString() == "Room")
{
}
else if (Session["reservationType"].ToString() == "tour")
{
}
}
}