-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenAccount.java
More file actions
98 lines (95 loc) · 3.94 KB
/
OpenAccount.java
File metadata and controls
98 lines (95 loc) · 3.94 KB
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
import java.util.Scanner;
public class OpenAccount extends Admin{
Scanner in =new Scanner(System.in);
String name,username,password, occupation,email,acno,actype,balance,phone,branch,address,ano=null,un = null;
OpenAccount(){
super();
}
public void openAccount()
{
System.out.print("Enter Account Holder FULL NAME : ");
name=in.nextLine();
System.out.print("Enter Account Holder Phone Number : ");
phone=in.nextLine();
System.out.print("Enter Account Holder Occupation : ");
occupation=in.nextLine();
System.out.print("Enter Account Holder Email : ");
email=in.nextLine();
System.out.print("Enter Account Holder Address : ");
address=in.nextLine();
System.out.print("Enter NEW Account Number : ");
acno=in.nextLine();
System.out.print("Enter Account Type : ");
actype=in.nextLine();
System.out.print("Enter Account Holder Branch : ");
branch=in.nextLine();
System.out.print("Enter Amount Is going to Crideted : ");
balance=in.nextLine();
System.out.print("Enter Account Holder Username : ");
username=in.nextLine();
System.out.print("Enter Account Holder Password : ");
password=in.nextLine();
this.insert();
}
public void insert( ){
try{
stm=con.createStatement();
re=stm.executeQuery("SELECT * FROM `users` WHERE username='"+username+"'");
if(re.next()){
un=re.getString("username");
}
re=stm.executeQuery("SELECT * FROM `users` WHERE acno='"+acno+"'");
if(re.next()){
ano=re.getString("acno");
}
if(username.equalsIgnoreCase(un)&&acno.equalsIgnoreCase(ano)){
System.out.println("Username And Acount Number are Alredy in Use");
System.out.print("Enter New Username : ");
username=in.nextLine();
System.out.print("Enter New Account Number : ");
acno=in.nextLine();
this.insert();
}
else if(username.equalsIgnoreCase(un)){
System.out.println("\n**************************");
System.out.println("*Username is Alredy in Use*");
System.out.println("***************************\n");
System.out.print("Enter New Username : ");
username=in.nextLine();
this.insert();
}
else if(acno.equals(ano)){
System.out.println("\n********************************");
System.out.println("*Account Number is Alredy in Use*");
System.out.println("********************************\n");
System.out.print("Enter New Account Number : ");
acno=in.nextLine();
this.insert();
}
else{
try{
String q= "INSERT INTO `users`(`name`, `username`, `password`, `occupation`, `email`, `acno`, `actype`, `balance`, `branch`,`phone`,`address`)"
+ "VALUES('"+name+"','"+username+"','"+password+"','"+ occupation+"','"+email+"','"+acno+"','"+actype+"','"+balance+"','"+branch+"','"+phone+"','"+address+"')";
st=con.prepareStatement(q);
st.executeUpdate();
q="CREATE TABLE `"+acno+"`(id INTEGER not NULL AUTO_INCREMENT,PRIMARY KEY (id),cd varchar(255) not NULL,amount INTEGER(11) NOT NULL,reason varchar(255) not NULL,balance INTEGER(11) not NULL)";
st=con.prepareStatement(q);
st.executeUpdate();
q= "INSERT INTO `"+acno+"`(`cd`,`amount`,`reason`,`balance`)VALUES('Credited','"+balance+"','Self Deposit','"+balance+"')";
st=con.prepareStatement(q);
st.executeUpdate();
this.clearScreen();
System.out.println("*********************************");
System.out.println("* New Account Created *");
System.out.println("*********************************");
this.amenu();
}
catch(Exception e){
System.out.println(e);
}
}
}catch(Exception e){
System.out.println(e);
}
}
}