该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
package yun;
public class Position_Score{
static String cc[],gg[];
static JFrame ps;
static Label id, ln,pr,st, lb,soc;
static TextField Id;
static Button b1, b2;
JTable tab;
static Choice g,c,sc;
static JScrollPane jsp;
static Object rowData[][];
static String[] columnNames={"Id","岗位","分制类别","分值"};
static Panel north, center, p1, p2, p3,p4,p5,p6,p7;
Position_Score() {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433;Databasename=bishe";
String userName = "sa";
String userPwd = "123";
Statement stmt=null;
String choice="select * from pssc";
ResultSet rs=null;
Connection dbConn=null;
int count=0;
rowData=new Object[10][4];
jsp=new JScrollPane(tab);
g= new Choice();
c= new Choice();
sc=new Choice();
// cc=new String[40];
//gg=new String[40];
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
stmt = dbConn.createStatement();
rs = stmt.executeQuery(choice);
while(rs.next()){
rowData[count][0]=rs.getString(1);
rowData[count][1]=rs.getString(2);
rowData[count][2]=rs.getString(3);
rowData[count][3]=rs.getString(4);
count++;
tab=new JTable(rowData,columnNames);
ps.getContentPane().add(jsp,BorderLayout.SOUTH);
}
rs.close();stmt.close();dbConn.close();
}
catch(Exception ex){
}finally{
try{if(rs!=null){rs.close();}}catch(Exception ex){}
try{if(stmt!=null){stmt.close();}}catch(Exception ex){}
try{if(dbConn!=null){dbConn.close();}}catch(Exception ex){}
}
for(int i=1;i<=13;i++){
String j=String.valueOf(i);
sc.addItem(j);
}
ps = new JFrame("岗位分值——添加");
id = new Label("ID: ");
ln = new Label("岗位: ");
pr = new Label("分值项: ");
soc= new Label("分值");
Id = new TextField(20);
b1 = new Button("确定");
b2 = new Button("取消");
lb = new Label("岗位分值列表");
north = new Panel();
center = new Panel();
p1 = new Panel();
p2 = new Panel();
p3 = new Panel();
p4 = new Panel();
p5 = new Panel();
p6 = new Panel();
b1.addActionListener(new Action_PS());
b2.addActionListener(new Action_PS());
ps.addWindowListener(new Winclose());
ps.setSize(350, 400);
ps.setLocation(540, 300);
ps.setBackground(Color.LIGHT_GRAY);
ps.setVisible(true);
p1.add(id);
p1.add(Id);
p1.setVisible(true);
g.add("");
g.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
if(g.getSelectedItem().equals("")){
System.out.println("nihao");
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433;Databasename=bishe";
String userName = "sa";
String userPwd = "123";
Statement stmt=null;
String choice="select pname from post";
ResultSet rs=null;
Connection dbConn=null;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
stmt = dbConn.createStatement();
rs = stmt.executeQuery(choice);
while(rs.next()){
String gw=rs.getString(1);
System.out.println(gw);
g.add(gw);
}
rs.close();stmt.close();dbConn.close();
}
catch(Exception ex){
}finally{
try{if(rs!=null){rs.close();}}catch(Exception ex){}
try{if(stmt!=null){stmt.close();}}catch(Exception ex){}
try{if(dbConn!=null){dbConn.close();}}catch(Exception ex){}
}
}
}
});
p2.add(ln);
p2.add(g);
p2.setVisible(true);
p4.add(pr);
p4.add(c);
p4.setVisible(true);
p4.add(soc);
p4.add(sc);
p4.setVisible(true);