-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateMember.java
964 lines (775 loc) · 27.6 KB
/
CreateMember.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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
public class CreateMember extends JFrame implements ActionListener, MouseListener
{
private JButton buttonSubmit, buttonExit,buttonUpload, buttonBack;
private JTextField UserIdTF, NameTF, BloodGroupTF, EmailTF, PhoneTF, GurdianPhoneTF, FeeTF, WeightTF ;
private JTextArea AddressTF;
private JLabel LabelTitle, LabelPic, LabelName, LabelAddress, LabelGender, LabelBirthday, LabelUserID, LabelMaritalstatus, LabelHeight, LabelWeight, LabelBloodGroup, LabelEmail, LabelPhone, LabelPhoto, LabelAdmissionDate, LabelPaidDate, LabelFee , LabelGuardianContact, LabelCourse, LabelBatch;
private JLabel LabelDD, LabelMM, LabelYYYY, LabelFeet, LabelInch, LabelADD, LabelAMM, LabelAYYYY, LabelPDD, LabelPMM, LabelPYYYY;
private JSpinner spinnerDD, spinnerMM, spinnerYYYY, spinnerFt, spinnerIn, spinnerADD, spinnerAMM, spinnerAYYYY, spinnerPDD, spinnerPMM, spinnerPYYYY;
private SpinnerModel valueDD, valueMM, valueYYYY,valueADD, valueAMM, valueAYYYY,valuePDD, valuePMM, valuePYYYY, valueFt , valueIn;
private JRadioButton RadioMale, RadioFemale, RadioOther, RadioB1, RadioB2, RadioB3;
private JComboBox combo, courseCombo;
private ButtonGroup bgGender, bgBatch;
private JFileChooser chooser;
private FileNameExtensionFilter filter;
private JPanel panel;
private String queryTransaction, choosertitle, Convert;
private String Name,Height,Gender,Batch,BloodGroup,Email,Phone,GuardianPhone,MaritalStatus,Address,Course,picPath;
private double Weight, Fee, Salary;
private boolean flagName,flagtransaction, flagacc, flagDB, flagGender, flagUserId, flagBatch,flagBloodGroup, flagEmail, flagPhone, flagGuardianPhone, flagMaritalStatus, flagAddress, flagWeight, flagCourse, flagFee, flagPicPath;
private String DOB, AddmissionDate, PaidDate, Password, Status, Validity;
private int Pass, UserID, AdminId,Month, Year,transactionNo=100;
public CreateMember(int AdminId)
{
super("Create Member Account");
Color lightButton = new Color(71, 92, 150);
Color lightBlue = new Color(172, 166, 255);
this.setSize(545, 650);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
panel = new JPanel();
panel.setLayout(null);
panel.setBackground(Color.WHITE);
ImageIcon img = new ImageIcon("icon.jpg");
this.setIconImage(img.getImage());
Status="Member";
this.AdminId = AdminId;
buttonSubmit = new JButton("Submit");
buttonSubmit.setBounds(120,550,130,28);
buttonSubmit.setFont(new Font("Ariel", Font.PLAIN, 16));
buttonSubmit.setForeground(Color.BLACK);
buttonSubmit.setBackground(lightButton);
buttonSubmit.addActionListener(this);
panel.add(buttonSubmit);
buttonBack = new JButton("Back");
buttonBack.setBounds(290,550,130,28);
buttonBack.setFont(new Font("Ariel", Font.PLAIN, 16));
buttonBack.setForeground(Color.BLACK);
buttonBack.setBackground(lightButton);
buttonBack.addActionListener(this);
panel.add(buttonBack);
buttonUpload = new JButton("Load");
buttonUpload.setBounds(152, 510, 65, 20);
buttonUpload.setFont(new Font("Ariel", Font.PLAIN, 12));
buttonUpload.setForeground(Color.BLACK);
buttonUpload.setBackground(lightBlue);
buttonUpload.addActionListener(this);
panel.add(buttonUpload);
//JfileChooser
filter = new FileNameExtensionFilter("Image Files", "jpg", "png", "gif", "jpeg");
chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle(choosertitle);
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setFileFilter(filter);
chooser.setAcceptAllFileFilterUsed(false);
///BirthDate
valueDD = new SpinnerNumberModel(1, //initial value
1, //minimum value
31, //maximum value
1); //step
valueMM = new SpinnerNumberModel(1, //initial value
1, //minimum value
12, //maximum value
1); //step
valueYYYY = new SpinnerNumberModel(1900, //initial value
1900, //minimum value
3000, //maximum value
1); //step
//AdmissionDate
valueADD = new SpinnerNumberModel(1, //initial value
1, //minimum value
31, //maximum value
1); //step
valueAMM = new SpinnerNumberModel(1, //initial value
1, //minimum value
12, //maximum value
1); //step
valueAYYYY = new SpinnerNumberModel(2017, //initial value
2017, //minimum value
3000, //maximum value
1); //step
//PaidDate
valuePDD = new SpinnerNumberModel(1, //initial value
1, //minimum value
31, //maximum value
1); //step
valuePMM = new SpinnerNumberModel(1, //initial value
1, //minimum value
12, //maximum value
1); //step
valuePYYYY = new SpinnerNumberModel(2017, //initial value
2017, //minimum value
3000, //maximum value
1); //step
valueFt = new SpinnerNumberModel(1, //initial value
1, //minimum value
20, //maximum value
1); //step
valueIn = new SpinnerNumberModel(0, //initial value
0, //minimum value
12, //maximum value
1); //step
UserIdTF = new JTextField();
UserIdTF.setBounds(152, 60, 150, 20);
panel.add(UserIdTF);
NameTF = new JTextField();
NameTF.setBounds(152, 90, 150, 20);
panel.add(NameTF);
WeightTF = new JTextField("");
WeightTF.setBounds(400, 180, 60, 20);
panel.add(WeightTF);
BloodGroupTF = new JTextField();
BloodGroupTF.setBounds(152, 210, 60, 20);
panel.add(BloodGroupTF);
EmailTF = new JTextField();
EmailTF.setBounds(152, 240, 150, 20);
panel.add(EmailTF);
PhoneTF = new JTextField("+880");
PhoneTF.setBounds(152, 270, 150, 20);
panel.add(PhoneTF);
GurdianPhoneTF = new JTextField("+880");
GurdianPhoneTF.setBounds(152, 300, 150, 20);
panel.add(GurdianPhoneTF);
AddressTF = new JTextArea();
AddressTF.setBounds(152, 330, 150, 50);
AddressTF.setBackground(Color.LIGHT_GRAY);
panel.add(AddressTF);
FeeTF = new JTextField();
FeeTF.setBounds(152, 480, 66, 20);
panel.add(FeeTF);
LabelTitle = new JLabel(" Member Account Form");
LabelTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
LabelTitle.setForeground(Color.BLACK);
LabelTitle.setBounds(170, 10, 500, 30);
panel.add(LabelTitle);
LabelUserID = new JLabel("User ID :");
LabelUserID.setFont(new Font("Tahoma", Font.PLAIN, 15));
LabelUserID.setBounds(30,60, 120, 20);
panel.add(LabelUserID);
LabelName = new JLabel("Name :");
LabelName.setFont(new Font("Tahoma", Font.PLAIN, 15));
LabelName.setBounds(30,90, 120, 20);
panel.add(LabelName);
LabelGender = new JLabel("Gender :");
LabelGender.setFont(new Font("Tahoma", Font.PLAIN, 15));
LabelGender.setBounds(30, 120, 120, 20);
panel.add(LabelGender);
LabelBirthday = new JLabel("Date of birth :");
LabelBirthday.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelBirthday.setForeground(Color.GRAY);
LabelBirthday.setBounds(30, 150, 120, 20);
panel.add(LabelBirthday);
spinnerDD = new JSpinner(valueDD);
spinnerDD.setBounds(175,152,35,20);
spinnerDD.addMouseListener(this);
JFormattedTextField tfd = ((JSpinner.DefaultEditor)spinnerDD.getEditor()).getTextField();
tfd.setEditable(false);
panel.add(spinnerDD);
spinnerMM = new JSpinner(valueMM);
spinnerMM.setBounds(248,152,35,20);
spinnerMM.addMouseListener(this);
JFormattedTextField tfm = ((JSpinner.DefaultEditor)spinnerMM.getEditor()).getTextField();
tfm.setEditable(false);
panel.add(spinnerMM);
spinnerYYYY = new JSpinner(valueYYYY);
spinnerYYYY.setBounds(330,152,50,20);
spinnerYYYY.addMouseListener(this);
JFormattedTextField tfy = ((JSpinner.DefaultEditor)spinnerYYYY.getEditor()).getTextField();
tfy.setEditable(false);
panel.add(spinnerYYYY);
LabelDD = new JLabel("DD");
LabelDD.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelDD.setForeground(Color.GRAY);
LabelDD.setBounds(152, 150, 20, 20);
panel.add(LabelDD);
LabelMM = new JLabel("MM");
LabelMM.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelMM.setForeground(Color.GRAY);
LabelMM.setBounds(222, 150, 20, 20);
panel.add(LabelMM);
LabelYYYY = new JLabel("YYYY");
LabelYYYY.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelYYYY.setForeground(Color.GRAY);
LabelYYYY.setBounds(292, 150, 40, 20);
panel.add(LabelYYYY);
LabelBloodGroup = new JLabel("Blood Group :");
LabelBloodGroup.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelBloodGroup.setForeground(Color.GRAY);
LabelBloodGroup.setBounds(30, 210, 120, 20);
panel.add(LabelBloodGroup);
LabelMaritalstatus = new JLabel("Marital Status :");
LabelMaritalstatus.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelMaritalstatus.setForeground(Color.GRAY);
LabelMaritalstatus.setBounds(292, 210, 120, 20);
panel.add(LabelMaritalstatus);
LabelHeight = new JLabel("Height :");
LabelHeight.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelHeight.setForeground(Color.GRAY);
LabelHeight.setBounds(30, 180, 120, 20);
panel.add(LabelHeight);
spinnerFt = new JSpinner(valueFt);
spinnerFt.setBounds(175,182,35,20);
spinnerFt.addMouseListener(this);
JFormattedTextField tff = ((JSpinner.DefaultEditor)spinnerFt.getEditor()).getTextField();
tff.setEditable(false);
panel.add(spinnerFt);
spinnerIn = new JSpinner(valueIn);
spinnerIn.setBounds(248,182,35,20);
spinnerIn.addMouseListener(this);
JFormattedTextField tfi = ((JSpinner.DefaultEditor)spinnerIn.getEditor()).getTextField();
tfi.setEditable(false);
panel.add(spinnerIn);
LabelFeet = new JLabel("Ft");
LabelFeet.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelFeet.setForeground(Color.GRAY);
LabelFeet.setBounds(152, 180, 20, 20);
panel.add(LabelFeet);
LabelInch = new JLabel("In");
LabelInch.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelInch.setForeground(Color.GRAY);
LabelInch.setBounds(220, 180, 20, 20);
panel.add(LabelInch);
LabelWeight = new JLabel("Weight :");
LabelWeight.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelWeight.setForeground(Color.GRAY);
LabelWeight.setBounds(292, 180, 120, 20);
panel.add(LabelWeight);
LabelEmail = new JLabel("Email :");
LabelEmail.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelEmail.setForeground(Color.GRAY);
LabelEmail.setBounds(30, 240, 120, 20);
panel.add(LabelEmail);
LabelPhone = new JLabel("Phone No :");
LabelPhone.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelPhone.setForeground(Color.GRAY);
LabelPhone.setBounds(30, 270, 120, 20);
panel.add(LabelPhone);
LabelGuardianContact = new JLabel("Guardian Phone :");
LabelGuardianContact.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelGuardianContact.setForeground(Color.GRAY);
LabelGuardianContact.setBounds(30, 300, 120, 20);
panel.add(LabelGuardianContact);
LabelAddress = new JLabel("Address :");
LabelAddress.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelAddress.setForeground(Color.GRAY);
LabelAddress.setBounds(30, 330, 120, 20);
panel.add(LabelAddress);
LabelCourse = new JLabel("Course :");
LabelCourse.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelCourse.setForeground(Color.GRAY);
LabelCourse.setBounds(310, 390, 60, 20);
panel.add(LabelCourse);
LabelBatch = new JLabel("Batch :");
LabelBatch.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelBatch.setForeground(Color.GRAY);
LabelBatch.setBounds(30, 390, 120, 20);
panel.add(LabelBatch);
LabelAdmissionDate = new JLabel("Admission Date :");
LabelAdmissionDate.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelAdmissionDate.setForeground(Color.GRAY);
LabelAdmissionDate.setBounds(30, 420, 120, 20);
panel.add(LabelAdmissionDate);
LabelADD = new JLabel("DD");
LabelADD.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelADD.setForeground(Color.GRAY);
LabelADD.setBounds(152, 420, 20, 20);
panel.add(LabelADD);
LabelAMM = new JLabel("MM");
LabelAMM.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelAMM.setForeground(Color.GRAY);
LabelAMM.setBounds(222, 420, 20, 20);
panel.add(LabelAMM);
LabelAYYYY = new JLabel("YYYY");
LabelAYYYY.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelAYYYY.setForeground(Color.GRAY);
LabelAYYYY.setBounds(292, 420, 40, 20);
panel.add(LabelAYYYY);
spinnerADD = new JSpinner(valueADD);
spinnerADD.setBounds(175,422,35,20);
spinnerADD.addMouseListener(this);
JFormattedTextField tfad = ((JSpinner.DefaultEditor)spinnerADD.getEditor()).getTextField();
tfad.setEditable(false);
panel.add(spinnerADD);
spinnerAMM = new JSpinner(valueAMM);
spinnerAMM.setBounds(248,422,35,20);
spinnerAMM.addMouseListener(this);
JFormattedTextField tfam = ((JSpinner.DefaultEditor)spinnerAMM.getEditor()).getTextField();
tfam.setEditable(false);
panel.add(spinnerAMM);
spinnerAYYYY = new JSpinner(valueAYYYY);
spinnerAYYYY.setBounds(330,422,50,20);
spinnerAYYYY.addMouseListener(this);
JFormattedTextField tfay = ((JSpinner.DefaultEditor)spinnerAYYYY.getEditor()).getTextField();
tfay.setEditable(false);
panel.add(spinnerAYYYY);
LabelPaidDate = new JLabel("Paid Date :");
LabelPaidDate.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelPaidDate.setForeground(Color.GRAY);
LabelPaidDate.setBounds(30, 450, 120, 20);
panel.add(LabelPaidDate);
LabelPDD = new JLabel("DD");
LabelPDD.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelPDD.setForeground(Color.GRAY);
LabelPDD.setBounds(152, 450, 20, 20);
panel.add(LabelPDD);
LabelPMM = new JLabel("MM");
LabelPMM.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelPMM.setForeground(Color.GRAY);
LabelPMM.setBounds(222, 450, 20, 20);
panel.add(LabelPMM);
LabelPYYYY = new JLabel("YYYY");
LabelPYYYY.setFont(new Font("Tahoma", Font.PLAIN, 12));
//LabelPYYYY.setForeground(Color.GRAY);
LabelPYYYY.setBounds(292, 450, 40, 20);
panel.add(LabelPYYYY);
spinnerPDD = new JSpinner(valuePDD);
spinnerPDD.setBounds(175,452,35,20);
spinnerPDD.addMouseListener(this);
JFormattedTextField tfpd = ((JSpinner.DefaultEditor)spinnerPDD.getEditor()).getTextField();
tfpd.setEditable(false);
panel.add(spinnerPDD);
spinnerPMM = new JSpinner(valuePMM);
spinnerPMM.setBounds(248,452,35,20);
spinnerPMM.addMouseListener(this);
JFormattedTextField tfpm = ((JSpinner.DefaultEditor)spinnerPMM.getEditor()).getTextField();
tfpm.setEditable(false);
panel.add(spinnerPMM);
spinnerPYYYY = new JSpinner(valuePYYYY);
spinnerPYYYY.setBounds(330,452,50,20);
spinnerPYYYY.addMouseListener(this);
JFormattedTextField tfpy = ((JSpinner.DefaultEditor)spinnerPYYYY.getEditor()).getTextField();
tfpy.setEditable(false);
panel.add(spinnerPYYYY);
LabelFee = new JLabel("Fee (Tk.) :");
LabelFee.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelFee.setForeground(Color.GRAY);
LabelFee.setBounds(30, 480, 120, 20);
panel.add(LabelFee);
LabelPhoto = new JLabel("Select Photo :");
LabelPhoto.setFont(new Font("Tahoma", Font.PLAIN, 15));
//LabelPhoto.setForeground(Color.GRAY);
LabelPhoto.setBounds(30, 510, 120, 20);
panel.add(LabelPhoto);
RadioMale = new JRadioButton("Male");
RadioMale.setBounds(150, 120, 60, 20);
RadioMale.setBackground(Color.WHITE);
RadioMale.addActionListener(this);
panel.add(RadioMale);
RadioFemale = new JRadioButton("Female");
RadioFemale.setBounds(210, 120, 70, 20);
RadioFemale.setBackground(Color.WHITE);
RadioFemale.addActionListener(this);
panel.add(RadioFemale);
RadioOther = new JRadioButton("Other");
RadioOther.setBounds(280, 120, 60, 20);
RadioOther.setBackground(Color.WHITE);
RadioOther.addActionListener(this);
panel.add(RadioOther);
bgGender= new ButtonGroup();
bgGender.add(RadioMale);
bgGender.add(RadioFemale);
bgGender.add(RadioOther);
RadioB1 = new JRadioButton("B1");
RadioB1.setBounds(150, 390, 40, 20);
RadioB1.setBackground(Color.WHITE);
RadioB1.addActionListener(this);
panel.add(RadioB1);
RadioB2 = new JRadioButton("B2");
RadioB2.setBounds(200, 390, 40, 20);
RadioB2.setBackground(Color.WHITE);
RadioB2.addActionListener(this);
panel.add(RadioB2);
RadioB3 = new JRadioButton("B3");
RadioB3.setBounds(250, 390, 40, 20);
RadioB3.setBackground(Color.WHITE);
RadioB3.addActionListener(this);
panel.add(RadioB3);
bgBatch= new ButtonGroup();
bgBatch.add(RadioB1);
bgBatch.add(RadioB2);
bgBatch.add(RadioB3);
String s[] = {"Select", "Single ", "Married", "Devorce"};
combo = new JComboBox(s);
combo.setBounds(400, 210, 75, 20);
combo.setBackground(Color.WHITE);
combo.addActionListener(this);
panel.add(combo);
String c[] = {"Select", "Fat Lose ", "Weight Gain ", "Build Body "};
courseCombo = new JComboBox(c);
courseCombo.setBounds(380, 390, 95, 20);
courseCombo.setBackground(Color.WHITE);
courseCombo.addActionListener(this);
panel.add(courseCombo);
this.add(panel);
}
public void actionPerformed(ActionEvent ae) throws NumberFormatException
{
if(ae.getSource()==buttonBack)
{
CreateAccount acc = new CreateAccount(AdminId);
try{
this.setVisible(false);
acc.setVisible(true);
}catch(Exception ex){}
}
if(ae.getSource()==buttonSubmit)
{
flagacc=true;
if(UserIdTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter UserID");
}
else
{
flagUserId=true;
try{
UserID=Integer.parseInt(UserIdTF.getText());
}catch(NumberFormatException en)
{ flagUserId=false;
JOptionPane.showMessageDialog(this, "Invalid Char in UserID : "+en.getMessage());
System.out.println("Number Format execption caught: "+en.getMessage());
}
}
if(NameTF.getText().isEmpty())
{
//System.out.println(flagName);
JOptionPane.showMessageDialog(this, "Please Enter Name");
}
else
{
flagName=true;
Name=NameTF.getText();
}
if(WeightTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter Weight");
}
else
{
flagWeight=true;
try{
Weight=Double.parseDouble(WeightTF.getText());
}catch(NumberFormatException ew)
{ flagWeight=false;
JOptionPane.showMessageDialog(this, "Invalid Char in Weight :"+ew.getMessage());
System.out.println("Number Format execption caught: "+ew.getMessage());
}
}
if(BloodGroupTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter Blood Group");
}
else
{
flagBloodGroup=true;
BloodGroup=BloodGroupTF.getText();
}
if(EmailTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter Email");
}
else
{
flagEmail=true;
Email=EmailTF.getText();
}
if(PhoneTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter Phone");
}
else
{
flagPhone=true;
Phone=PhoneTF.getText();
}
if(GurdianPhoneTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Enter Phone");
}
else
{
flagGuardianPhone=true;
GuardianPhone=GurdianPhoneTF.getText();
}
if(flagCourse==false)
{
JOptionPane.showMessageDialog(this, "Please Select Course");
}
if(flagBatch==false)
{
JOptionPane.showMessageDialog(this, "Please Select Batch");
}
if(flagMaritalStatus==false)
{
JOptionPane.showMessageDialog(this, "Please Select Marital Status");
}
if(flagGender==false)
{
JOptionPane.showMessageDialog(this, "Please Select Gender");
}
if(AddressTF.getText().isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Select Address");
}
else
{
flagAddress=true;
Address=AddressTF.getText();
}
if(FeeTF.getText().isEmpty())
{
}
else
{
flagFee=true;
try{
Fee=Double.parseDouble(FeeTF.getText());
}catch(NumberFormatException ef)
{ flagFee=false;
JOptionPane.showMessageDialog(this, "Invalid Char in Fee (Tk.) :"+ef.getMessage());
System.out.println("Number Format execption caught: "+ef.getMessage());
}
}
try{
if(picPath.isEmpty())
{
JOptionPane.showMessageDialog(this, "Please Select Pic");
}
else
{
flagPicPath=true;
}}catch(Exception e)
{
JOptionPane.showMessageDialog(this, "Please Select Pic");
}
if(flagName && flagGender && flagUserId && flagBatch && flagBloodGroup && flagEmail && flagPhone && flagGuardianPhone && flagMaritalStatus && flagAddress && flagWeight && flagCourse && flagFee && flagPicPath)
{
getDOB();
getAddmissionDate();
getPaidDate();
getMHeight();
createPass();
Validity="Valid";
insertIntoDB();
if(flagDB)
{
Back();
}
}
else
{
System.out.println(flagUserId);
System.out.println(flagName);
System.out.println(flagGender);
System.out.println(flagBatch);
System.out.println(flagBloodGroup);
System.out.println(flagEmail);
System.out.println(flagPhone);
System.out.println(flagGuardianPhone);
System.out.println(flagMaritalStatus);
System.out.println(flagAddress);
System.out.println(flagWeight);
System.out.println(flagCourse);
System.out.println(flagFee);
System.out.println(flagPicPath);
System.out.println(flagDB);
//JOptionPane.showMessageDialog(this, "Please Complete From");
}
}
if(ae.getSource()==RadioMale || ae.getSource()==RadioFemale|| ae.getSource()==RadioOther)
{
flagGender=true;
Gender=ae.getActionCommand();
}
if(ae.getSource()==RadioB1 || ae.getSource()==RadioB2|| ae.getSource()==RadioB3)
{
flagBatch=true;
Batch=ae.getActionCommand();
}
if(ae.getSource()==combo)
{
flagMaritalStatus=true;
MaritalStatus=combo.getSelectedItem().toString();;
}
if(ae.getSource()==courseCombo)
{
flagCourse=true;
Course=courseCombo.getSelectedItem().toString();;
System.out.println("Course selected: "+ Course);
}
/// picupload
if (ae.getSource()==buttonUpload &&chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
{
System.out.println("getCurrentDirectory(): "
+ chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : "
+ chooser.getSelectedFile());
Convert=chooser.getSelectedFile().getPath();
picPath=Convert.replace('\\', '/');
System.out.println("PATH FOR SAVE: " +picPath);
JLabelContainer();
}
/*else
{
System.out.println("No Selection ");
} */
}
public void JLabelContainer() {
//LabelPic.setEnabled(false);
ImageIcon imgThisNEWImg = new ImageIcon(picPath);
JLabel LabelPic = new JLabel(imgThisNEWImg);
LabelPic.setIcon(imgThisNEWImg);
LabelPic.setBounds(360,40, 100, 100);
panel.add(LabelPic);
}
public void mouseEntered(MouseEvent me){}
public void mouseExited(MouseEvent me){}
public void mouseReleased(MouseEvent me){}
public void mousePressed(MouseEvent me){}
public void mouseClicked(MouseEvent me){}
public void getDOB()
{
Integer DD = (Integer)spinnerDD.getValue();
String ConvertDD = Integer.toString(DD);
Integer MM = (Integer)spinnerMM.getValue();
String ConvertMM = Integer.toString(MM);
Integer YYYY = (Integer)spinnerYYYY.getValue();
String ConvertYYYY = Integer.toString(YYYY);
DOB = ConvertDD +"/"+ConvertMM+"/"+ConvertYYYY ;
}
public void getAddmissionDate()
{
Integer AAD = (Integer)spinnerADD.getValue();
String ConvertAAD = Integer.toString(AAD);
Integer AMM = (Integer)spinnerAMM.getValue();
String ConvertAMM = Integer.toString(AMM);
Integer AYYY = (Integer)spinnerAYYYY.getValue();
String ConvertAYYY = Integer.toString(AYYY);
AddmissionDate = ConvertAAD+"/"+ConvertAMM+"/"+ConvertAYYY ;
}
public void getPaidDate()
{
Integer PDD = (Integer)spinnerPDD.getValue();
String ConvertPDD = Integer.toString(PDD);
Integer PMM = (Integer)spinnerPMM.getValue();
Month = PMM;
String ConvertPMM = Integer.toString(PMM);
Integer PYYYY = (Integer)spinnerPYYYY.getValue();
Year = PYYYY;
String ConvertPYYYY = Integer.toString(PYYYY);
PaidDate = ConvertPDD+"/"+ConvertPMM+"/"+ConvertPYYYY ;
}
public void getMHeight()
{
Integer ft = (Integer)spinnerFt.getValue();
String Convertft = Integer.toString(ft);
Integer in = (Integer)spinnerIn.getValue();
String Convertin = Integer.toString(in);
Height = Convertft+"ft"+Convertin+"in";
}
public void createPass()
{
Random rand1 = new Random();
Pass = rand1.nextInt(9999) + 1000;
Password=Integer.toString(Pass);
}
public void insertIntoDB()
{
String queryAccounts = "INSERT INTO accounts VALUES ("+UserID+",'"+Password+"','"+Status+"','"+Validity+"');";
String queryMember = "INSERT INTO memberacc VALUES ("+UserID+",'"+Name+"','"+Gender+"','"+DOB+"','"+MaritalStatus+"','"+Height+"',"+Weight+",'"+ BloodGroup+"','"+ Email+"','"+ Phone+"','"+ Address+"','"+ picPath+"','"+ AddmissionDate+"','"+ PaidDate+"','"+ GuardianPhone+"','"+ Course+"','"+ Batch+"');";
System.out.println(queryAccounts);
System.out.println(queryMember);
//System.out.println(queryTransaction);
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/group8f", "root", "");
Statement stm = con.createStatement();
CheckTransactionNo();
if(flagtransaction)
{
stm.execute(queryAccounts);
flagacc=true;
}
if(flagacc){
stm.execute(queryMember);
System.out.println("transactionNo: "+transactionNo);
stm.execute(queryTransaction);
flagDB=true;
}
stm.close();
con.close();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(this, "Already Registered UserId :" +UserIdTF.getText());
System.out.println("Exception : " +ex.getMessage());
flagDB=false;
flagacc=false;
}
}
public void CheckTransactionNo()
{
String queryTransactionNo = "SELECT `TransactionNo` FROM transaction ORDER BY `TransactionNo` DESC LIMIT 1;";
Connection con=null;
Statement st = null;
ResultSet rs = null;
try{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("driver loaded");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Group8F","root","");
System.out.println("connection done");
st = con.createStatement();
System.out.println("statement created");
rs = st.executeQuery(queryTransactionNo);
System.out.println("results received");
if(rs.next()){
int t = rs.getInt("TransactionNo");
transactionNo=t+1;
}
System.out.println("TransactionNo: "+ transactionNo);
queryTransaction = "INSERT INTO transaction VALUES ("+transactionNo+","+UserID+",'"+Status+"',"+Fee+","+Salary+","+Month+","+Year+",'"+PaidDate+"',"+AdminId+");";
flagtransaction=true;
}
catch(Exception ex)
{
flagtransaction=true;
System.out.println("Error:xxx "+ ex.getMessage());
queryTransaction = "INSERT INTO transaction VALUES ("+transactionNo+","+UserID+",'"+Status+"',"+Fee+","+Salary+","+Month+","+Year+",'"+PaidDate+"',"+AdminId+");";
System.out.println("TransactionNo:xxx "+ transactionNo);
}
finally
{
try
{
if(rs!=null)
rs.close();
if(st!=null)
st.close();
if(con!=null)
con.close();
}
catch(Exception ex){}
}
}
public void Back()
{
JOptionPane.showMessageDialog(this, "Succesfully Sumbited");
JOptionPane.showMessageDialog(this, "USer Id : "+UserIdTF.getText() +"& Default Password : " +String.valueOf(Password));
flagDB=true;
CreateAccount acc = new CreateAccount(AdminId);
try{
this.setVisible(false);
acc.setVisible(true);
}catch(Exception ex){}
}
}