Created
June 1, 2014 15:08
-
-
Save anugrahbsoe/0a8744baabf5cdc742f4 to your computer and use it in GitHub Desktop.
Autonumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//pasang saat form di load | |
autoNomer("Aturan_Tidak", "T", JFrame.EXIT_ON_CLOSE); //("nama tabel database","string depan",frame) | |
//method | |
public String autoNomer(String tabel,String strAwal,Integer pnj){ | |
String auto=""; | |
try{ | |
java.sql.Statement stat=connect.createStatement(); | |
ResultSet rs=stat.executeQuery("select * from "+tabel); | |
rs.last(); | |
String s,s1; | |
Integer j; | |
s=Integer.toString(rs.getRow()+1); | |
j=s.length(); | |
s1=""; | |
for(int i = 1;i<=pnj-j;i++){ | |
s1=s1+"0"; | |
} | |
rs.close(); | |
stat.close(); | |
auto=strAwal+s1+s; | |
}catch(Exception e){ | |
System.out.println("Pesan Error : "+e); | |
JOptionPane.showMessageDialog(null,"Maaf, Query tidak bisa dijalankan...!!!!"); | |
} | |
return auto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment