-
Notifications
You must be signed in to change notification settings - Fork 0
/
MembersInfo_jsp.java
882 lines (719 loc) · 30.5 KB
/
MembersInfo_jsp.java
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
public class MembersInfo_jsp extends HttpJspBase {
//
// Filename: Common.jsp
// Generated with CodeCharge v.1.2.0
// JSP.ccp build 05/21/2001
//
static final String CRLF = "\r\n";
static final int UNDEFINT=Integer.MIN_VALUE;
static final int adText = 1;
static final int adDate = 2;
static final int adNumber = 3;
static final int adSearch_ = 4;
static final int ad_Search_ = 5;
static final String appPath ="/";
//Database connection string
static final String DBDriver ="";
static final String strConn ="";
static final String DBusername="";
static final String DBpassword="";
public static String loadDriver () {
String sErr = "";
try {
java.sql.DriverManager.registerDriver((java.sql.Driver)(Class.forName(DBDriver).newInstance()));
}
catch (Exception e) {
sErr = e.toString();
}
return (sErr);
}
public static void absolute(java.sql.ResultSet rs, int row) throws java.sql.SQLException{
for(int x=1;x<row;x++) rs.next();
}
java.sql.ResultSet openrs(java.sql.Statement stat, String sql) throws java.sql.SQLException {
java.sql.ResultSet rs = stat.executeQuery(sql);
return (rs);
}
String dLookUp(java.sql.Statement stat, String table, String fName, String where) {
java.sql.Connection conn1 = null;
java.sql.Statement stat1 = null;
try {
conn1 = cn();
stat1 = conn1.createStatement();
java.sql.ResultSet rsLookUp = openrs( stat1, "SELECT " + fName + " FROM " + table + " WHERE " + where);
if (! rsLookUp.next()) {
rsLookUp.close();
stat1.close();
conn1.close();
return "";
}
String res = rsLookUp.getString(1);
rsLookUp.close();
stat1.close();
conn1.close();
return (res == null ? "" : res);
}
catch (Exception e) {
return "";
}
}
long dCountRec(java.sql.Statement stat, String table, String sWhere) {
long lNumRecs = 0;
try {
java.sql.ResultSet rs = stat.executeQuery("select count(*) from " + table + " where " + sWhere);
if ( rs != null && rs.next() ) {
lNumRecs = rs.getLong(1);
}
rs.close();
}
catch (Exception e ) {};
return lNumRecs;
}
String proceedError(javax.servlet.http.HttpServletResponse response, Exception e) {
return e.toString();
}
String[] getFieldsName ( java.sql.ResultSet rs ) throws java.sql.SQLException {
java.sql.ResultSetMetaData metaData = rs.getMetaData();
int count = metaData.getColumnCount();
String[] aFields = new String[count];
for(int j = 0; j < count; j++) {
aFields[j] = metaData.getColumnLabel(j+1);
}
return aFields;
}
java.util.Hashtable getRecordToHash ( java.sql.ResultSet rs, java.util.Hashtable rsHash, String[] aFields ) throws java.sql.SQLException {
for ( int iF = 0; iF < aFields.length; iF++ ) {
rsHash.put( aFields[iF], getValue(rs, aFields[iF]));
}
return rsHash;
}
java.sql.Connection cn() throws java.sql.SQLException {
return java.sql.DriverManager.getConnection(strConn , DBusername, DBpassword);
}
String toURL(String strValue){
if ( strValue == null ) return "";
if ( strValue.compareTo("") == 0 ) return "";
return java.net.URLEncoder.encode(strValue);
}
String toHTML(String value) {
if ( value == null ) return "";
value = replace(value, "&", "&");
value = replace(value, "<", "<");
value = replace(value, ">", ">");
value = replace(value, "\"", "&" + "quot;");
return value;
}
String getValueHTML(java.sql.ResultSet rs, String fieldName) {
try {
String value = rs.getString(fieldName);
if (value != null) {
return toHTML(value);
}
}
catch (java.sql.SQLException sqle) {}
return "";
}
String getValue(java.sql.ResultSet rs, String strFieldName) {
if ((rs==null) ||(isEmpty(strFieldName)) || ("".equals(strFieldName))) return "";
try {
String sValue = rs.getString(strFieldName);
if ( sValue == null ) sValue = "";
return sValue;
}
catch (Exception e) {
return "";
}
}
String getParam(javax.servlet.http.HttpServletRequest req, String paramName) {
String param = req.getParameter(paramName);
if ( param == null || param.equals("") ) return "";
param = replace(param,"&","&");
param = replace(param,"<","<");
param = replace(param,">",">");
param = replace(param,"&lt;","<");
param = replace(param,"&gt;",">");
return param;
}
boolean isNumber (String param) {
boolean result;
if ( param == null || param.equals("")) return true;
param=param.replace('d','_').replace('f','_');
try {
Double dbl = new Double(param);
result = true;
}
catch (NumberFormatException nfe) {
result = false;
}
return result;
}
boolean isEmpty (int val){
return val==UNDEFINT;
}
boolean isEmpty (String val){
return (val==null || val.equals("")||val.equals(Integer.toString(UNDEFINT)));
}
String getCheckBoxValue (String val, String checkVal, String uncheckVal, int ctype) {
if (val==null || val.equals("") ) return toSQL(uncheckVal, ctype);
else return toSQL(checkVal, ctype);
}
String toWhereSQL(String fieldName, String fieldVal, int type) {
String res = "";
switch(type) {
case adText:
if (! "".equals(fieldVal)) {
res = " " + fieldName + " like '%" + fieldVal + "%'";
}
case adNumber:
res = " " + fieldName + " = " + fieldVal + " ";
case adDate:
res = " " + fieldName + " = '" + fieldVal + "' ";
default:
res = " " + fieldName + " = '" + fieldVal + "' ";
}
return res;
}
String toSQL(String value, int type) {
if ( value == null ) return "Null";
String param = value;
if ("".equals(param) && (type == adText || type == adDate) ) {
return "Null";
}
switch (type) {
case adText: {
param = replace(param, "'", "''");
param = replace(param, "&", "&");
param = "'" + param + "'";
break;
}
case adSearch_:
case ad_Search_: {
param = replace(param, "'", "''");
break;
}
case adNumber: {
try {
if (! isNumber(value) || "".equals(param)) param="null";
else param = value;
}
catch (NumberFormatException nfe) {
param = "null";
}
break;
}
case adDate: {
param = "'" + param + "'";
break;
}
}
return param;
}
private String replace(String str, String pattern, String replace) {
if (replace == null) {
replace = "";
}
int s = 0, e = 0;
StringBuffer result = new StringBuffer((int) str.length()*2);
while ((e = str.indexOf(pattern, s)) >= 0) {
result.append(str.substring(s, e));
result.append(replace);
s = e + pattern.length();
}
result.append(str.substring(s));
return result.toString();
}
String getOptions( java.sql.Connection conn, String sql, boolean isSearch, boolean isRequired, String selectedValue ) {
String sOptions = "";
String sSel = "";
if ( isSearch ) {
sOptions += "<option value=\"\">All</option>";
}
else {
if ( ! isRequired ) {
sOptions += "<option value=\"\"></option>";
}
}
try {
java.sql.Statement stat = conn.createStatement();
java.sql.ResultSet rs = null;
rs = openrs (stat, sql);
while (rs.next() ) {
String id = toHTML( rs.getString(1) );
String val = toHTML( rs.getString(2) );
if ( id.compareTo(selectedValue) == 0 ) {
sSel = "SELECTED";
}
else {
sSel = "";
}
sOptions += "<option value=\""+id+"\" "+sSel+">"+val+"</option>";
}
rs.close();
stat.close();
}
catch (Exception e) {}
return sOptions;
}
String getOptionsLOV( String sLOV, boolean isSearch, boolean isRequired, String selectedValue ) {
String sSel = "";
String slOptions = "";
String sOptions = "";
String id = "";
String val = "";
java.util.StringTokenizer LOV = new java.util.StringTokenizer( sLOV, ";", true);
int i = 0;
String old = ";";
while ( LOV.hasMoreTokens() ) {
id = LOV.nextToken();
if ( ! old.equals(";") && ( id.equals(";") ) ) {
id = LOV.nextToken();
}
else {
if ( old.equals(";") && ( id.equals(";") ) ) {
id = "";
}
}
if ( ! id.equals("") ) { old = id; }
i++;
if (LOV.hasMoreTokens()) {
val = LOV.nextToken();
if ( ! old.equals(";") && (val.equals(";") ) ) {
val = LOV.nextToken();
}
else {
if (old.equals(";") && (val.equals(";"))) {
val = "";
}
}
if ( val.equals(";") ) { val = ""; }
if ( ! val.equals("")) { old = val; }
i++;
}
if ( id.compareTo( selectedValue ) == 0 ) {
sSel = "SELECTED";
}
else {
sSel = "";
}
slOptions += "<option value=\""+id+"\" "+sSel+">"+val+"</option>";
}
if ( ( i % 2 ) == 0 ) sOptions += slOptions;
return sOptions;
}
String getValFromLOV( String selectedValue , String sLOV) {
String sRes = "";
String id = "";
String val = "";
java.util.StringTokenizer LOV = new java.util.StringTokenizer( sLOV, ";", true);
int i = 0;
String old = ";";
while ( LOV.hasMoreTokens() ) {
id = LOV.nextToken();
if ( ! old.equals(";") && ( id.equals(";") ) ) {
id = LOV.nextToken();
}
else {
if ( old.equals(";") && ( id.equals(";") ) ) {
id = "";
}
}
if ( ! id.equals("") ) { old = id; }
i++;
if (LOV.hasMoreTokens()) {
val = LOV.nextToken();
if ( ! old.equals(";") && (val.equals(";") ) ) {
val = LOV.nextToken();
}
else {
if (old.equals(";") && (val.equals(";"))) {
val = "";
}
}
if ( val.equals(";") ) { val = ""; }
if ( ! val.equals("")) { old = val; }
i++;
}
if ( id.compareTo( selectedValue ) == 0 ) {
sRes = val;
}
}
return sRes;
}
String checkSecurity(int iLevel, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request){
try {
Object o1 = session.getAttribute("UserID");
Object o2 = session.getAttribute("UserRights");
boolean bRedirect = false;
if ( o1 == null || o2 == null ) { bRedirect = true; }
if ( ! bRedirect ) {
if ( (o1.toString()).equals("")) { bRedirect = true; }
else if ( (new Integer(o2.toString())).intValue() < iLevel) { bRedirect = true; }
}
if ( bRedirect ) {
response.sendRedirect("Login.jsp?querystring=" + toURL(request.getQueryString()) + "&ret_page=" + toURL(request.getRequestURI()));
return "sendRedirect";
}
}
catch(Exception e){};
return "";
}
//
// Filename: MembersInfo.jsp
// Generated with CodeCharge v.1.2.0
// JSP.ccp build 05/21/2001
//
static final String sFileName = "MembersInfo.jsp";
String RecordAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sAction, String sForm, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
String sRecordErr ="";
try {
if (sAction.equals("")) return "";
String sSQL="";
String transitParams = "";
String primaryKeyParams = "";
String sQueryString = "";
String sPage = "";
String sParams = "";
String sActionFileName = "AdminMenu.jsp";
String sWhere = " ";
boolean bErr = false;
long iCount = 0;
String pPKmember_id = "";
final int iinsertAction = 1;
final int iupdateAction = 2;
final int ideleteAction = 3;
int iAction = 0;
if ( sAction.equalsIgnoreCase("insert") ) { iAction = iinsertAction; }
if ( sAction.equalsIgnoreCase("update") ) { iAction = iupdateAction; }
if ( sAction.equalsIgnoreCase("delete") ) { iAction = ideleteAction; }
// Create WHERE statement
String fldmember_id="";
String fldmember_level="";
// Load all form fields into variables
sSQL = "";
// Create SQL statement
if ( sRecordErr.length() > 0 ) return sRecordErr;
try {
// Execute SQL statement
stat.executeUpdate(sSQL);
}
catch(java.sql.SQLException e) {
sRecordErr = e.toString(); return (sRecordErr);
}
try {
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
}
catch ( java.sql.SQLException ignore ) {}
response.sendRedirect (sActionFileName);
return "sendRedirect";
}
catch (Exception e) {out.println(e.toString()); }
return (sRecordErr);
}
void Record_Show(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sRecordErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
try {
String sSQL="";
String sQueryString = "";
String sPage = "";
String sWhere = "";
String transitParams = "";
String transitParamsHidden = "";
String requiredParams = "";
String primaryKeyParams ="";
java.util.Hashtable rsHash = new java.util.Hashtable();
String pmember_id = "";
String fldmember_id="";
String fldmember_login="";
String fldmember_level="";
String fldname="";
String fldlast_name="";
String fldemail="";
String fldphone="";
String fldaddress="";
String fldnotes="";
boolean bPK = true;
if ( "".equals(sRecordErr)) {
// Load primary key and form parameters
pmember_id = getParam( request, "member_id");
}
else {
// Load primary key, form parameters and form fields
fldmember_id = getParam( request, "member_id");
pmember_id = getParam( request, "PK_member_id");
}
if ( isEmpty(pmember_id)) { bPK = false; }
sWhere += "member_id=" + toSQL(pmember_id, adNumber);
primaryKeyParams += "<input type=\"hidden\" name=\"PK_member_id\" value=\""+pmember_id+"\"/>";
sSQL = "select * from members where " + sWhere;
out.println(" <table style=\"\">");
out.println(" <tr>\n <td style=\"background-color: #336699; text-align: Center; border-style: outset; border-width: 1\" colspan=\"2\"><font style=\"font-size: 12pt; color: #FFFFFF; font-weight: bold\">Member Info</font></td>\n </tr>");
if ( ! sRecordErr.equals("")) {
out.println(" <tr>\n <td style=\"background-color: #FFFFFF; border-width: 1\" colspan=\"2\"><font style=\"font-size: 10pt; color: #000000\">"+sRecordErr+"</font></td>\n </tr>");
}
sRecordErr="";
out.println(" <form method=\"get\" action=\""+sFileName+"\" name=\"Record\">");
java.sql.ResultSet rs = null;
if ( bPK && ! (sAction.equals("insert") && "Record".equals(sForm))) {
// Open recordset
rs = openrs( stat, sSQL);
rs.next();
String[] aFields = getFieldsName( rs );
getRecordToHash( rs, rsHash, aFields );
rs.close();
fldmember_id = (String) rsHash.get("member_id");
fldmember_login = (String) rsHash.get("member_login");
fldmember_level = (String) rsHash.get("member_level");
fldname = (String) rsHash.get("first_name");
fldlast_name = (String) rsHash.get("last_name");
fldemail = (String) rsHash.get("email");
fldphone = (String) rsHash.get("phone");
fldaddress = (String) rsHash.get("address");
fldnotes = (String) rsHash.get("notes");
if (sAction.equals("") || ! "Record".equals(sForm)) {
fldmember_id = (String) rsHash.get("member_id");
fldmember_login = (String) rsHash.get("member_login");
fldmember_level = (String) rsHash.get("member_level");
fldname = (String) rsHash.get("first_name");
fldlast_name = (String) rsHash.get("last_name");
fldemail = (String) rsHash.get("email");
fldphone = (String) rsHash.get("phone");
fldaddress = (String) rsHash.get("address");
fldnotes = (String) rsHash.get("notes");
}
else {
fldmember_id = (String) rsHash.get("member_id");
fldmember_login = (String) rsHash.get("member_login");
fldmember_level = (String) rsHash.get("member_level");
fldname = (String) rsHash.get("first_name");
fldlast_name = (String) rsHash.get("last_name");
fldemail = (String) rsHash.get("email");
fldphone = (String) rsHash.get("phone");
fldaddress = (String) rsHash.get("address");
fldnotes = (String) rsHash.get("notes");
}
}
else {
}
// Show form field
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Login</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<a href=\"MembersRecord.jsp?"+transitParams+"member_id="+toURL((String) rsHash.get("member_id"))+"&\"><font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldmember_login)+"</font></a>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Level</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldmember_level)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">First Name</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldname)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Last Name</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldlast_name)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Email</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldemail)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Phone</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldphone)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Address</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldaddress)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td style=\"background-color: #FFEAC5; border-style: inset; border-width: 0\"><font style=\"font-size: 10pt; color: #000000\">Notes</font></td><td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldnotes)+" </font>");
out.println("</td>\n </tr>");
out.print(" <tr>\n <td colspan=\"2\" align=\"right\">");
if ( bPK && ! (sAction.equals("insert") && "Record".equals(sForm))) {
out.print("<input type=\"hidden\" name=\"FormName\" value=\"Record\"><input type=\"hidden\" value=\"\" name=\"FormAction\">");
}
out.print("<input type=\"hidden\" name=\"member_id\" value=\""+toHTML(fldmember_id)+"\">");
out.print(transitParamsHidden+requiredParams+primaryKeyParams);
out.println("</td>\n </tr>\n </form>\n </table>");
}
catch (Exception e) { out.println(e.toString()); }
}
void Orders_Show (javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, javax.servlet.jsp.JspWriter out, String sOrdersErr, String sForm, String sAction, java.sql.Connection conn, java.sql.Statement stat) throws java.io.IOException {
String sWhere = "";
int iCounter=0;
int iPage = 0;
boolean bIsScroll = true;
boolean hasParam = false;
String sOrder = "";
String sSQL="";
String transitParams = "";
String sQueryString = "";
String sPage = "";
int RecordsPerPage = 20;
String sSortParams = "";
String formParams = "";
String pmember_id="";
transitParams = "member_id=" + toURL(getParam( request, "member_id")) + "&";
formParams = "member_id=" + toURL(getParam( request, "member_id")) + "&";boolean bReq = true;
// Build WHERE statement
//-- Check member_id parameter and create a valid sql for where clause
pmember_id = getParam( request, "member_id");
if ( ! isNumber (pmember_id)) {
pmember_id = "";
}
if (pmember_id != null && ! pmember_id.equals("")) {
hasParam = true;
sWhere += "o.member_id=" + pmember_id;
}
else bReq = false;
if (hasParam) { sWhere = " AND (" + sWhere + ")"; }
// Build ORDER statement
String sSort = getParam( request, "FormOrders_Sorting");
String sSorted = getParam( request, "FormOrders_Sorted");
String sDirection = "";
String sForm_Sorting = "";
int iSort = 0;
try {
iSort = Integer.parseInt(sSort);
}
catch (NumberFormatException e ) {
sSort = "";
}
if ( iSort == 0 ) {
sForm_Sorting = "";
}
else {
if ( sSort.equals(sSorted)) {
sSorted="0";
sForm_Sorting = "";
sDirection = " DESC";
sSortParams = "FormOrders_Sorting=" + sSort + "&FormOrders_Sorted=" + sSort + "&";
}
else {
sSorted=sSort;
sForm_Sorting = sSort;
sDirection = " ASC";
sSortParams = "FormOrders_Sorting=" + sSort + "&FormOrders_Sorted=" + "&";
}
if ( iSort == 1) { sOrder = " order by o.order_id" + sDirection; }
if ( iSort == 2) { sOrder = " order by i.name" + sDirection; }
if ( iSort == 3) { sOrder = " order by o.quantity" + sDirection; }
}
// Build full SQL statement
sSQL = "select o.item_id as o_item_id, " +
"o.member_id as o_member_id, " +
"o.order_id as o_order_id, " +
"o.quantity as o_quantity, " +
"i.item_id as i_item_id, " +
"i.name as i_name " +
" from orders o, items i" +
" where i.item_id=o.item_id ";
sSQL = sSQL + sWhere + sOrder;
String sNoRecords = " <tr>\n <td colspan=\"3\" style=\"background-color: #FFFFFF; border-width: 1\"><font style=\"font-size: 10pt; color: #000000\">No records</font></td>\n </tr>";
String tableHeader = "";
tableHeader = " <tr>\n <td style=\"background-color: #FFFFFF; border-style: inset; border-width: 0\"><a href=\""+sFileName+"?"+formParams+"FormOrders_Sorting=1&FormOrders_Sorted="+sSorted+"&\"><font style=\"font-size: 10pt; color: #CE7E00; font-weight: bold\">Order</font></a></td>\n <td style=\"background-color: #FFFFFF; border-style: inset; border-width: 0\"><a href=\""+sFileName+"?"+formParams+"FormOrders_Sorting=2&FormOrders_Sorted="+sSorted+"&\"><font style=\"font-size: 10pt; color: #CE7E00; font-weight: bold\">Item</font></a></td>\n <td style=\"background-color: #FFFFFF; border-style: inset; border-width: 0\"><a href=\""+sFileName+"?"+formParams+"FormOrders_Sorting=3&FormOrders_Sorted="+sSorted+"&\"><font style=\"font-size: 10pt; color: #CE7E00; font-weight: bold\">Quantity</font></a></td>\n </tr>";
try {
out.println(" <table style=\"\">");
out.println(" <tr>\n <td style=\"background-color: #336699; text-align: Center; border-style: outset; border-width: 1\" colspan=\"3\"><a name=\"Orders\"><font style=\"font-size: 12pt; color: #FFFFFF; font-weight: bold\">Shopping Cart</font></a></td>\n </tr>");
out.println(tableHeader);
if ( ! bReq ) {
out.println(sNoRecords);
out.println(" </table>");
return;
}
}
catch (Exception e) {}
try {
java.sql.ResultSet rs = null;
// Open recordset
rs = openrs( stat, sSQL);
iCounter = 0;
java.util.Hashtable rsHash = new java.util.Hashtable();
String[] aFields = getFieldsName( rs );
// Show main table based on recordset
while ( rs.next() ) {
getRecordToHash( rs, rsHash, aFields );
String flditem_id = (String) rsHash.get("i_name");
String fldorder_id = (String) rsHash.get("o_order_id");
String fldquantity = (String) rsHash.get("o_quantity");
out.println(" <tr>");
out.print(" <td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<a href=\"OrdersRecord.jsp?"+transitParams+"order_id="+toURL((String) rsHash.get("o_order_id"))+"&\"><font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldorder_id)+"</font></a>");
out.println("</td>");
out.print(" <td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(flditem_id)+" </font>");
out.println("</td>");
out.print(" <td style=\"background-color: #FFFFFF; border-width: 1\">"); out.print("<font style=\"font-size: 10pt; color: #000000\">"+toHTML(fldquantity)+" </font>");
out.println("</td>");
out.println(" </tr>");
iCounter++;
}
if (iCounter == 0) {
// Recordset is empty
out.println(sNoRecords);
iCounter = RecordsPerPage+1;
bIsScroll = false;
}
if ( rs != null ) rs.close();
out.println(" </table>");
}
catch (Exception e) { out.println(e.toString()); }
}
private static java.util.Vector _jspx_includes;
static {
_jspx_includes = new java.util.Vector(1);
_jspx_includes.add("/Common.jsp");
}
public java.util.List getIncludes() {
return _jspx_includes;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
javax.servlet.jsp.PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html;charset=ISO-8859-1");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
String cSec = checkSecurity(2, session, response, request);
if ("sendRedirect".equals(cSec) ) return;
boolean bDebug = false;
String sAction = getParam( request, "FormAction");
String sForm = getParam( request, "FormName");
String sRecordErr = "";
String sOrdersErr = "";
java.sql.Connection conn = null;
java.sql.Statement stat = null;
String sErr = loadDriver();
conn = cn();
stat = conn.createStatement();
if ( ! sErr.equals("") ) {
try {
out.println(sErr);
}
catch (Exception e) {}
}
if ( sForm.equals("Record") ) {
sRecordErr = RecordAction(request, response, session, out, sAction, sForm, conn, stat);
if ( "sendRedirect".equals(sRecordErr)) return;
}
out.write(" \r\n<html>\r\n<head>\r\n<title>Book Store</title>\r\n<meta name=\"GENERATOR\" content=\"YesSoftware CodeCharge v.1.2.0 / JSP.ccp build 05/21/2001\"/>\r\n<meta http-equiv=\"pragma\" content=\"no-cache\"/>\r\n<meta http-equiv=\"expires\" content=\"0\"/>\r\n<meta http-equiv=\"cache-control\" content=\"no-cache\"/>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n</head>\r\n<body style=\"background-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helveticabackground-color: #FFFFFF; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica\">\r\n");
JspRuntimeLibrary.include(request, response, "Header.jsp", out, true);
out.write("\r\n <table>\r\n <tr>\r\n \r\n <td valign=\"top\">\r\n");
Record_Show(request, response, session, out, sRecordErr, sForm, sAction, conn, stat);
out.write("\r\n \r\n </td>\r\n </tr>\r\n </table>\r\n <table>\r\n <tr>\r\n <td valign=\"top\">\r\n");
Orders_Show(request, response, session, out, sOrdersErr, sForm, sAction, conn, stat);
out.write("\r\n \r\n </td>\r\n </tr>\r\n </table>\r\n\r\n");
JspRuntimeLibrary.include(request, response, "Footer.jsp", out, true);
out.write("\r\n<center><font face=\"Arial\"><small>This dynamic site was generated with <a href=\"http://www.codecharge.com\">CodeCharge</a></small></font></center>\r\n</body>\r\n</html>\r\n");
out.write("\r\n");
if ( stat != null ) stat.close();
if ( conn != null ) conn.close();
out.write("\r\n");
} catch (Throwable t) {
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
}
}