|
 |
|
Java/MySQL รบกวนช่วยทำหน่อยครับ เรื่องการล็อคอินตรวจสอบจากฐานข้อมูล มือใหม่ครับ |
|
 |
|
|
 |
 |
|
นี้เป็นโค้ดของหน้า login ที่ผมไม่รู้จะทำยังไงครับ ผมจะให้มันล็อคอินไป3หน้า ให้มันตรวจสอบ department ในตาราง officer ในฐานข้อมูลและให้มันเด้งไปหน้า PersonmanagerFram FinancialmanagerFram และ AccountingmanagerFram
Code (Java)
private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cnn = MysqlConnect.connectDB();
String sql1 = "select * from officer where Officer_ID=? and ID_Card=? ;";
try{
pst = cnn.prepareStatement(sql1);
pst.setString(1, txtusername.getText());
pst.setString(2, txtpassword.getText());
rs = pst.executeQuery();
if(rs.next()){
if(department==Person){
JOptionPane.showMessageDialog(null, "ยินดีต้อนรับเข้าสู่ระบบจัดการสมาชิก");
PersonmanagerFram PersonFrm = new PersonmanagerFram();
PersonFrm.setVisible(true);
String name = rs.getString(2);
String surname = rs.getString(3);
String Officer_ID = rs.getString(1);
PersonFrm.PersonmanagerFram(name, surname, Officer_ID);
rs.close();
pst.close();
cnn.close();
}
else if(department==Financial){
JOptionPane.showMessageDialog(null, "ยินดีต้อนรับเข้าสู่ระบบจัดการสมาชิก");
FinancialmanagerFram FinancialFrm = new FinancialmanagerFram();
FinancialFrm.setVisible(true);
String name = rs.getString(2);
String surname = rs.getString(3);
String Officer_ID = rs.getString(1);
FinancialFrm.FinancialmanagerFram(name, surname, Officer_ID);
rs.close();
pst.close();
cnn.close();
}
else (department==Accounting){
JOptionPane.showMessageDialog(null, "ยินดีต้อนรับเข้าสู่ระบบจัดการสมาชิก");
AccountingmanagerFram AccountingFrm = new AccountingmanagerFram();
AccountingFrm.setVisible(true);
String name = rs.getString(2);
String surname = rs.getString(3);
String Officer_ID = rs.getString(1);
AccountingFrm.AccountingmanagerFram(name, surname, Officer_ID);
rs.close();
pst.close();
cnn.close();
}
}else{
JOptionPane.showMessageDialog(null, "กรุณากรอกข้อมูลให้ถูกต้อง");
}
}catch (SQLException sqle){
JOptionPane.showMessageDialog(null, sqle);
}
}
อันนี้เป็นรูปตาราง officer ในฐานข้อมูลครับ

Tag : Java, MySQL, JAVA

|
ประวัติการแก้ไข 2017-03-09 14:49:36
|
 |
 |
 |
 |
Date :
2017-03-09 14:45:24 |
By :
pls. |
View :
1123 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ศึกษาจากบทความนี้เลยครับ แล้วจะได้อะไรมากมาย

How to use : Java GUI Pass Variable / Class Between Frame
|
 |
 |
 |
 |
Date :
2017-03-09 17:45:16 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมขอรบกวนช่วยแก้ไขให้ผมได้ไมครับ พอดีผมงมโค้ดไม่ไหว พื้นฐานไม่แน่นเลยครับ
|
 |
 |
 |
 |
Date :
2017-03-09 19:35:57 |
By :
thaicreatepoeysian |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|