public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==clear)
{
tname.setText("");
tpass.setText("");
}
else
{
if(ae.getSource()==Admin)
{
try
{
a=tname.getText();
b=tpass.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:vote");
Statement st= con.createStatement();
ResultSet rs;
rs=st.executeQuery("select * from votelogin where tname='"+a+"'and tpass='"+b+"'");
while(rs.next())
{
aa=rs.getString(1);
bb=rs.getString(2);
}
if(a.equals(aa)&& b.equals(bb))
{
JOptionPane.showMessageDialog(this,"INVALID USER.TRY AGAIN");
System.out.println("invalid user");
}
else
{
JOptionPane.showMessageDialog(this,"VALID USER");
System.out.println("Valid User");
adminframe adf=new adminframe();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==clear)
{
UName.setText("");
PinNo.setText(""); {
if(ea.getSource()==user)
{
try
{
a=UName.getText();
b=PinNO.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:vote");
Statement st= con.createStatement();
ResultSet rs;
rs=st.executeQuery("select * from votelogin where UName='"+a+"'and PinNO='"+b+"'");
while(rs.next())
{
aa=rs.getString(1);
bb=rs.getString(2);
}
if(a.equals(aa)&& b.equals(bb))
{
JOptionPane.showMessageDialog(this,"VALID USER");
System.out.println("Valid User");
userframe usf=new userframe();
}
else
{
JOptionPane.showMessageDialog(this,"INVALID USER.TRY AGAIN");
System.out.println("invalid user");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
else
if(ea.getSource()==exit)
{
System.exit(0);
}
}
}
}
public static void main(String ar[])
{
vote v=new vote();
v.init();
}
}
haribasker -2 Newbie Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
code learner 1 Newbie Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster
naief 3 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.