📄 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 招聘专业 = '"+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){}
}
//读取企业信息
void getinfo(int row)
{
try
{
DataBase db=new DataBase();
db.GetResultSet("select * from 企业信息");
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)
{
//企业表格
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 企业信息 ");
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 企业信息 ");
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 企业信息");
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 企业信息");
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 企业信息");
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 企业信息");
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,"单位编号重复");
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 企业信息 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,"记录已经更新!!!");
}
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 企业信息");
db.st.execute("delete from 企业信息 where 单位编号 = "+"'"+s+"'");
db.st.close();
}catch(Exception e){}
clear();
JOptionPane.showMessageDialog(null,"该记录已经删除!!!","提示",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 企业信息 ");
try
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -