?? factory.java
字號:
zp.gridy++;
paneMinxizp.add(lblMinxizp[8],zp);
paneMinxizp.add(txtMinxizp[8],zp);
paneMinxizp.add(lblMinxizp[9],zp);
paneMinxizp.add(txtMinxizp[9],zp);
zp.gridy++;
paneMinxizp.add(lblMinxizp[10],zp);
zp.gridwidth=3;
paneMinxizp.add(areaMinxizp,zp);
//工具條
barZhaopin=new JToolBar();
barZhaopin.setBorder(BorderFactory.createLoweredBevelBorder());
barZhaopin.setBackground(new Color(239,251,198));
barZhaopin.setOrientation(JToolBar.VERTICAL);
toolZhaopin[0]=new JLabel("新增記錄");
toolZhaopin[1]=new JLabel("保存記錄");
toolZhaopin[1].setEnabled(false);
toolZhaopin[2]=new JLabel("更新記錄");
toolZhaopin[3]=new JLabel("刪除記錄");
for(int i=0;i<4;i++)
{
toolZhaopin[i].addMouseListener(this);
toolZhaopin[i].setIcon(new ImageIcon("img/zhaopin.gif"));
toolZhaopin[i].setForeground(new Color(148,139,253));
barZhaopin.addSeparator();
barZhaopin.add(toolZhaopin[i]);
}
//窗口
f=new JFrame("招聘信息");
Container cpzp=f.getContentPane();
cpzp.setLayout(new BorderLayout());
cpzp.add(paneMinxizp,BorderLayout.CENTER);
cpzp.add(barZhaopin,BorderLayout.EAST);
f.pack();
f.setLocation(200,200);
}
//讀取招聘信息
void getzhaopin(int row)
{
String s1=txtFactory[0].getText();
txtMinxiNo.setText(s1);
String s2=lockZhaopin.tableOne.getValueAt(row,0).toString();
DataBase db=new DataBase();
db.GetResultSet("select * from 招聘信息 where 單位編號 = '"+s1+"' and 招聘專業(yè) = '"+s2+"'");
try
{
db.rs.next();
for(int i=2;i<db.rsmd.getColumnCount()-1;i++)
{
txtMinxizp[i-2].setText(db.rs.getString(i));
}
areaMinxizp.setText(db.rs.getString(db.rsmd.getColumnCount()));
db.rs.close();
}catch(SQLException e){}
}
//清空記錄
void clear()
{
for(int i=0;i<10;i++)
txtFactory[i].setText("");
areaFactory.setText("");
lblTool[5].setEnabled(true);
lblTool[6].setEnabled(false);
for(int i=0;i<lockZhaopin.tableOne.getRowCount();i++)
for(int j=0;j<lockZhaopin.tableOne.getColumnCount();j++)
lockZhaopin.tableOne.setValueAt("",i,j);
for(int i=0;i<lockZhaopin.tableTwo.getRowCount();i++)
for(int j=0;j<lockZhaopin.tableTwo.getColumnCount();j++)
lockZhaopin.tableTwo.setValueAt("",i,j);
}
//set choice
void setchoice(Choice c,String str)
{
DataBase db=new DataBase();
db.GetResultSet(str);
try
{
for(int i=0;i<db.rsmd.getColumnCount();i++)
c.addItem(db.rsmd.getColumnName(i+1));
db.st.close();
}catch(SQLException e){}
}
//讀取企業(yè)信息
void getinfo(int row)
{
try
{
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
db.rs.absolute(row);
for(int i=0;i<10;i++)
txtFactory[i].setText(db.rs.getString(i+1));
areaFactory.setText(db.rs.getString(11));
db.st.close();
}catch(SQLException e){}
String s=txtFactory[0].getText().trim();
getmodel("select * from 招聘信息 where 單位編號 = "+"'"+s+"'",1);
lockZhaopin.tableOne.setModel(model);
getmodel("select * from 招聘信息 where 單位編號 = "+"'"+s+"'",4);
lockZhaopin.tableTwo.setModel(model);
}
public void mouseClicked(MouseEvent parm1)
{
//企業(yè)表格
if(parm1.getClickCount()==2&&(parm1.getSource()==lockMoreFactory.tableOne||parm1.getSource()==lockMoreFactory.tableTwo))
{
Point pt=parm1.getPoint();
int row=lockMoreFactory.tableOne.rowAtPoint(pt);
String s=lockMoreFactory.tableOne.getValueAt(row,0).toString();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息 ");
int cout=0;
try
{
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).equalsIgnoreCase(s))
break;
}
pane.removeAll();
pane.add(paneFactory,BorderLayout.NORTH);
pane.add(lockZhaopin.scroll,BorderLayout.CENTER);
getinfo(cout);
pane.setVisible(false);
pane.setVisible(true);
}catch(SQLException e){}
}
//招聘表格
if(parm1.getClickCount()==2&&(parm1.getSource()==lockMoreZhaopin.tableOne||parm1.getSource()==lockMoreZhaopin.tableTwo))
{
Point pt=parm1.getPoint();
int row=lockMoreZhaopin.tableOne.rowAtPoint(pt);
String s=lockMoreZhaopin.tableOne.getValueAt(row,0).toString();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息 ");
int cout=0;
try
{
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).equalsIgnoreCase(s))
break;
}
pane.removeAll();
pane.add(paneFactory,BorderLayout.NORTH);
pane.add(lockZhaopin.scroll,BorderLayout.CENTER);
getinfo(cout);
pane.setVisible(false);
pane.setVisible(true);
}catch(SQLException e){}
}
}
public void mousePressed(MouseEvent parm1)
{
//首條記錄
if(parm1.getSource()==lblTool[0])
getinfo(1);
//末條記錄
if(parm1.getSource()==lblTool[1])
{
try
{
String s=txtFactory[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
int cout=0;
while(db.rs.next())
cout++;
getinfo(cout);
}catch(SQLException e){}
}
//前條記錄
if(parm1.getSource()==lblTool[2])
{
try
{
String s=txtFactory[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).equalsIgnoreCase(s)==true)
break;
}
getinfo(cout-1);
}catch(SQLException e){}
}
//后條記錄
if(parm1.getSource()==lblTool[3])
{
try
{
String s=txtFactory[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).equalsIgnoreCase(s)==true)
break;
}
System.out.print(cout);
getinfo(cout+1);
}catch(SQLException e){}
}
//新增記錄
if(parm1.getSource()==lblTool[4])
{
clear();
}
//保存記錄
if(parm1.getSource()==lblTool[5])
{
int flag=1;
int op=JOptionPane.showConfirmDialog(null,"確定要添加這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
db.rs.moveToInsertRow();
for(int i=0;i<db.rsmd.getColumnCount()-1;i++)
db.rs.updateString(i+1,txtFactory[i].getText().trim());
db.rs.updateString(11,areaFactory.getText());
db.rs.insertRow();
db.st.close();
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null,"單位編號重復(fù)");
txtFactory[0].setText("");
flag=0;
}
if(flag==1)
{
JOptionPane.showMessageDialog(null,"記錄添加成功!!!","提示",JOptionPane.WARNING_MESSAGE);
clear();
}
}
else
JOptionPane.showMessageDialog(null,"該記錄添加失敗!!!","警告",JOptionPane.WARNING_MESSAGE);
}
//更新記錄
if(parm1.getSource()==lblTool[6])
{
int op=JOptionPane.showConfirmDialog(null,"確定要更新這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
String s=txtFactory[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息 where 單位編號 = '"+s+"'");
db.rs.next();
for(int i=0;i<db.rsmd.getColumnCount()-1;i++)
db.rs.updateString(i+1,txtFactory[i].getText().trim());
db.rs.updateString(11,areaFactory.getText());
db.rs.updateRow();
db.st.close();
}catch(Exception e){}
JOptionPane.showMessageDialog(null,"記錄已經(jīng)更新!!!");
}
else
JOptionPane.showMessageDialog(null,"記錄更新失敗!!!");
}
//刪除記錄
if(parm1.getSource()==lblTool[7])
{
int op=JOptionPane.showConfirmDialog(null,"確定要刪除這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
String s=txtFactory[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 企業(yè)信息");
db.st.execute("delete from 企業(yè)信息 where 單位編號 = "+"'"+s+"'");
db.st.close();
}catch(Exception e){}
clear();
JOptionPane.showMessageDialog(null,"該記錄已經(jīng)刪除!!!","提示",JOptionPane.WARNING_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"該記錄刪除失敗!!!","警告",JOptionPane.WARNING_MESSAGE);
}
//信息招聘信息明細
if(parm1.getSource()==txtFactory[0]&&parm1.getClickCount()==2||parm1.getSource()==lockZhaopin.tableOne||parm1.getSource()==lockZhaopin.tableTwo)
{
showzhaopin();
f.show();
try
{
int row=lockZhaopin.tableOne.getSelectedRow();
getzhaopin(row);
}catch(Exception e){}
}
//招聘信息明細工具條////
////////////////////////
//新增按鈕
if(parm1.getSource()==toolZhaopin[0])
{
for(int i=0;i<10;i++)
txtMinxizp[i].setText("");
areaMinxizp.setText("");
txtMinxiNo.setEditable(true);
toolZhaopin[1].setEnabled(true);
toolZhaopin[2].setEnabled(false);
}
//保存按鈕
if(parm1.getSource()==toolZhaopin[1])
{
int op=JOptionPane.showConfirmDialog(null,"確定要添加這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
DataBase db=new DataBase();
db.GetResultSet("select * from 招聘信息");
try
{
db.rs.moveToInsertRow();
db.rs.updateString(1,txtMinxiNo.getText());
for(int i=2;i<db.rsmd.getColumnCount();i++)
{
db.rs.updateString(i,txtMinxizp[i-2].getText());
}
db.rs.updateString(12,areaMinxizp.getText());
db.rs.insertRow();
db.st.close();
}catch(SQLException e){}
JOptionPane.showMessageDialog(null,"該記錄添加成功!!!");
for(int i=0;i<10;i++)
txtMinxizp[i].setText("");
areaMinxizp.setText("");
txtMinxiNo.setEditable(true);
toolZhaopin[1].setEnabled(true);
toolZhaopin[2].setEnabled(false);
/////刷新記錄
String str=txtMinxiNo.getText();
DataBase dbse=new DataBase();
dbse.GetResultSet("select * from 企業(yè)信息 ");
try
{
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -