教室管理系统的源代码Word文档下载推荐.docx
《教室管理系统的源代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《教室管理系统的源代码Word文档下载推荐.docx(55页珍藏版)》请在冰点文库上搜索。
![教室管理系统的源代码Word文档下载推荐.docx](https://file1.bingdoc.com/fileroot1/2023-5/4/2d87367d-5218-4686-a75f-d5c096194dc0/2d87367d-5218-4686-a75f-d5c096194dc01.gif)
50'
02'
insertTeacherInfo
0A'
李萍'
计算机系统分'
讲师'
0B'
李明'
C语言'
教授'
insertClassRoomInfo
8:
00'
10:
12:
insertmanager
jack'
20120521'
2.创建登录界面
packagedev.chall.otherinterface;
importjava.awt.Cursor;
importjava.awt.FlowLayout;
importjava.awt.Frame;
importjava.awt.GridLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.awt.event.WindowEvent;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.PreparedStatement;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjavax.swing.JButton;
importjavax.swing.JDialog;
importjavax.swing.JLabel;
importjavax.swing.JPanel;
importjavax.swing.JPasswordField;
importjavax.swing.JTextField;
publicclassLoginextendsJDialogimplementsActionListener{
privateJLabelname;
privateJLabelpsw;
privateJTextFieldnameV;
privateJPasswordFieldpswV;
privateJButtonlogin,quit;
privateJPaneltop;
privateJPanelcenter;
privateJPanelbottom;
privateJLabelprompt;
publicstaticStringloginName;
publicLogin(Frameowner,Stringtitle,booleanmodal){
super(owner,title,modal);
init();
}
privatevoidinit()
{
name=newJLabel("
登录名:
"
nameV=newJTextField(10);
top=newJPanel();
top.add(name);
top.add(nameV);
this.add(top);
psw=newJLabel("
密码:
pswV=newJPasswordField(10);
center=newJPanel();
center.add(psw);
center.add(pswV);
this.add(center);
login=newJButton();
login.setText("
登录"
login.setActionCommand("
login"
login.addActionListener(this);
quit=newJButton("
退出"
quit.setActionCommand("
quit"
quit.addActionListener(this);
bottom=newJPanel();
bottom.add(login);
bottom.add(quit);
this.add(bottom);
prompt=newJLabel();
this.add(prompt);
this.setLayout(newGridLayout(4,1));
this.setLocation(550,230);
this.setSize(200,200);
this.setVisible(true);
@Override
publicvoidactionPerformed(ActionEventarg0){
if(arg0.getActionCommand()=="
{
Stringname=nameV.getText();
Stringpsw=pswV.getText();
if(name.length()<
=0||psw.length()<
=0)
{
prompt.setText("
提示:
用户名或密码为空!
return;
}
if(checkCount(name,psw))
this.dispose();
}else
用户名或密码错误!
}elseif(arg0.getActionCommand()=="
System.exit(0);
}
privatebooleancheckCount(Stringname,Stringpsw)
Connectionconnection=null;
PreparedStatementps=null;
ResultSetrs=null;
try{
//加载驱动
Class.forName("
sun.jdbc.odbc.JdbcOdbcDriver"
//得到连接
connection=DriverManager.getConnection("
jdbc:
odbc:
classManager"
"
sa"
songchao"
//创建访问数据库接口
ps=connection.prepareStatement("
select*frommanager"
rs=ps.executeQuery();
while(rs.next())
Stringnamet=rs.getString
(1);
Stringpswt=rs.getString
(2);
System.out.println(namet+"
<
>
+pswt+"
-------"
+name+"
+psw+"
---"
if(namet.equals(name)&
&
pswt.equals(psw))
{
loginName=namet;
returntrue;
}
System.out.println("
false"
}catch(Exceptione){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
connection.close();
}catch(SQLExceptione){
e.printStackTrace();
returnfalse;
protectedvoidprocessWindowEvent(WindowEventarg0){
super.processWindowEvent(arg0);
if(arg0.getID()==WindowEvent.WINDOW_CLOSING)
}
3.实现主界面,实现各按钮的作用
packagedev.chall.main;
importjava.awt.BorderLayout;
importjava.awt.Font;
importjava.awt.event.ItemEvent;
importjava.awt.event.ItemListener;
importjava.util.Iterator;
importjava.util.Vector;
importjavax.swing.JComboBox;
importjavax.swing.JFrame;
importjavax.swing.JScrollBar;
importjavax.swing.JScrollPane;
importjavax.swing.JTable;
importdev.chall.otherinterface.Delete;
importdev.chall.otherinterface.Insert;
importdev.chall.otherinterface.Update;
importdev.chall.otherinterface.Login;
importdev.chall.otherinterface.RemindDialog;
importdev.chall.util.MyTableModel;
publicclassControlInterfaceextendsJFrameimplementsActionListener{
//登录界面
Loginlogin;
//主控制界面
privateJPaneltopBar,rightBar;
//topBar
privateJLabeluserName;
privateJButtonquit;
//rightBar
privateJPaneloperationP,buttonP,searchP;
privateJLabeloperationT,search;
privateJComboBoxoperation;
privateJButtonsearchB,alert,insert,delete;
privateJTextFieldsearchT;
//搜索字样
//centerBar
privateJScrollPanescroll;
privateJTablecontent;
privateMyTableModelmodel;
privateString[]list=newString[]{"
教师信息"
"
教室信息"
教室使用情况"
教室具体使用情况"
};
privateJLabelremind;
publicstaticvoidmain(String[]args)
newControlInterface();
publicControlInterface()
//登录界面--------------------------------------------
login=newLogin(this,"
true);
//登陆界面回来之后
//topBar
topBar=newJPanel();
userName=newJLabel();
userName.setText(Login.loginName);
userName.setFont(newFont("
隶书"
1,25));
//字体,1代表样式,字号
userName.setLocation(this.getWidth()/2-userName.getWidth()/2,userName.getHeight()/3);
topBar.add(userName,BorderLayout.CENTER);
quit=newJButton("
quit.setLocation((int)(this.getWidth()-quit.getWidth()*1.5),userName.getHeight()/3);
topBar.add(quit,BorderLayout.EAST);
this.add(topBar,BorderLayout.NORTH);
//rightBar
rightBar=newJPanel();
rightBar.setLayout(newGridLayout(4,1));
this.add(rightBar,BorderLayout.EAST);
operationP=newJPanel();
operationP.setLayout(newFlowLayout());
operationT=newJLabel("
选择表:
operation=newJComboBox(list);
operation.addItemListener(newItemListener(){
@Override
publicvoiditemStateChanged(ItemEventarg0){
searchT.setText("
请输入"
+
operation.getSelectedItem().toString().substring(0,2)+"
编号"
model=newMyTableModel(operation.getSelectedItem().toString());
content.setModel(model);
});
operationP.add(operationT);
operationP.add(operation);
buttonP=newJPanel();
buttonP.setLayout(newGridLayout(3,1));
alert=newJButton("
修改"
alert.addActionListener(this);
alert.setActionCommand("
alert"
insert=newJButton("
增加"
insert.addActionListener(this);
insert.setActionCommand("
insert"
delete=newJButton("
删除"
delete.addActionListener(this);
delete.setActionCommand("
delete"
buttonP.add(alert);
buttonP.add(insert);
buttonP.add(delete);
operationP.add(buttonP);
rightBar.add(operationP);
search=newJLabel("
关键字:
searchT=newJTextField(10);
searchT.setText("
+operation.getSelectedItem().toString().substring(0,2)+"
searchB=newJButton("
搜索"
searchB.addActionListener(this);
searchB.setActionCommand("
search"
searchP=newJPanel();
searchP.setLayout(newFlowLayout());
searchP.add(search);
searchP.add(searchT);
searchP.add(searchB);
rightBar.add(searchP);
remind=newJLabel();
rightBar.add(remind);
//centerBar
model=newMyTableModel(operation.getSelectedItem().toString());
content=newJTable(model);
scroll=newJScrollPane(content);
this.add(scroll,BorderLayout.CENTER);
this.setTitle("
教室管理系统"
this.setResizable(false);
this.setLocation(180,60);
this.setSize(1000,600);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
search2UnionTable();
return;
if(((String)operation.getSelectedItem())=="
newRemindDialog(this,"
提示"
true,0);
newInsert(this,"
增加新数据"
true,operation.getSelectedItem().toString());
model=newMyTableModel(operation.getSelectedItem().toString());
content.setModel(model);
if(content.getSelectedRow()==-1)
true,1);
Vectorv=(Vector)MyTableModel.rowData.get(content.getSelectedRow());
newUpdate(this,"
true,operation.getSelectedItem().toString(),v);
Vectorv=(Vector)MyTableModel.rowData.get(content.getSelectedRow());
newDelete(this,"
true,v,operation.getSelectedItem().toString());
model=newMyTableModel(operation.ge