饭卡管理系统java.docx
- 文档编号:9646009
- 上传时间:2023-05-20
- 格式:DOCX
- 页数:16
- 大小:17.67KB
饭卡管理系统java.docx
《饭卡管理系统java.docx》由会员分享,可在线阅读,更多相关《饭卡管理系统java.docx(16页珍藏版)》请在冰点文库上搜索。
饭卡管理系统java
packagemysql;
importjava.awt.*;
importjava.awt.event.*;
importjava.sql.*;
importjavax.swing.*;
classLoginextendsJFrame
{
privatestaticfinallongserialVersionUID=1L;
privatestaticJFrameframe=newJFrame("学生饭卡管理系统登录界面");
privateJButtonsubmit=newJButton("登陆");
privateJButtonreset=newJButton("重置");
privateJButtonassign=newJButton("注册");
JLabelnameLab=newJLabel("用户名:
");
privateJLabelpasswdLab=newJLabel("密码:
");
privateJLabellab=newJLabel();
publicJTextFieldnameText=newJTextField(20);
publicJPasswordFieldpasswdText=newJPasswordField(20);
publicLogin(){}
publicvoidlogin(){
nameLab.setBounds(60,20,100,20);
passwdLab.setBounds(60,50,100,20);
lab.setBounds(100,90,200,20);
nameText.setBounds(120,20,100,20);
passwdText.setBounds(120,50,100,20);
submit.setBounds(120,120,100,30);
reset.setBounds(250,50,60,20);
assign.setBounds(250,20,60,20);
//passwdText.setEchoChar('*');
frame.add(nameLab);
frame.add(passwdLab);
frame.add(lab);
frame.add(nameText);//用户名
frame.add(passwdText);//用户密码
frame.add(submit);
frame.add(reset);
frame.add(assign);
frame.setSize(400,220);
frame.setLocation(400,250);
ImagePanelimg=newImagePanel();
img.setBounds(0,0,400,200);
frame.add(img);
frame.setVisible(true);
submit.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
@SuppressWarnings("deprecation")
Stringpasswd=passwdText.getText().toString();
Stringname=nameText.getText();
try{
ResultSetsqlRst=null;
Class.forName("com.mysql.jdbc.Driver");
Connectionconn=DriverManager.getConnection("jdbc:
mysql:
//localhost:
3306/test1","root","123456");
Statementst=conn.createStatement();
Stringsql="select*fromuserwherename='"+name+"'andpasswd='"+passwd+"';";
sqlRst=st.executeQuery(sql);
if(sqlRst.next()){
frame.dispose();
newFankajiemain();
}
else{
lab.setForeground(Color.red);
lab.setText("登陆失败!
密码或账号错误!
");
}
}catch(ClassNotFoundExceptione1){
e1.printStackTrace();
}catch(SQLExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
}
});
assign.addActionListener(newActionListener(){//注册按钮,点击进入到第三层界面输入学号
publicvoidactionPerformed(ActionEvente){
frame.dispose();
newZhuce();
}
}
);
reset.addActionListener(newActionListener(){//重置按钮
publicvoidactionPerformed(ActionEvente){
nameText.setText("");//用户名重置
passwdText.setText("");//密码重置
}
}
);
}
publicstaticvoidmain(Stringargs[]){
Loginlog=newLogin();
log.login();
}
classImagePanelextendsJLabel{//构建一个图片容器
privatestaticfinallongserialVersionUID=1L;
protectedvoidpaintComponent(Graphicsg){
super.paintComponent(g);
ImageIconimg=newImageIcon("D:
\\Login.jpg");
g.drawImage(img.getImage(),0,0,this);
}
}
}
packagemysql;
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.SQLException;
importjava.sql.Statement;
classZhuce
{
privateJFramejrf=newJFrame("注册窗口");
privateJLabeljla1=newJLabel("用户名:
");
privateJLabeljla2=newJLabel("密码:
");
privateJLabeljla3=newJLabel("确认密码:
");
privateJLabeljla4=newJLabel("姓名:
");
privateJLabeljla5=newJLabel("性别:
");
privateJLabeljla6=newJLabel("年龄:
");
privateJLabeljla7=newJLabel("生日:
");
privateJLabeljla8=newJLabel("身份证:
");
privateJLabeljla9=newJLabel("班级:
");
privateJLabeljla10=newJLabel("学院:
");
privateJLabeljla13=newJLabel("金额:
");
privateJLabeljla14=newJLabel("余额:
");
privateJLabeljla11=newJLabel("");
privateJLabeljla12=newJLabel("xxxx-xx-xx");//日期的格式
privateJTextFieldjtx1=newJTextField("");
privateJTextFieldjtx2=newJTextField("");
privateJTextFieldjtx3=newJTextField("");
privateJTextFieldjtx4=newJTextField("");
privateJTextFieldjtx5=newJTextField("");
privateJTextFieldjtx6=newJTextField("");
privateJTextFieldjtx7=newJTextField("");
privateJTextFieldjtx8=newJTextField("");
privateJTextFieldjtx9=newJTextField("");
privateJTextFieldjtx10=newJTextField("");
privateJTextFieldjtx13=newJTextField("");
privateJTextFieldjtx14=newJTextField("");
privateJButtonjbt=newJButton("提交");
privateJButtonjbt1=newJButton("返回");
Zhuce(){
Containercp=jrf.getContentPane();
//jrf.setBounds(500,200,300,300);
jla1.setBounds(40,20,100,20);
jla2.setBounds(40,60,100,20);
jla3.setBounds(40,100,100,20);
jla4.setBounds(40,140,100,20);
jla5.setBounds(40,180,100,20);
jla6.setBounds(40,220,100,20);
jla7.setBounds(40,260,100,20);
jla8.setBounds(40,300,100,20);
jla9.setBounds(40,340,100,20);
jla10.setBounds(40,380,100,20);
jla11.setBounds(120,500,150,20);
jla12.setBounds(270,260,100,20);
jla13.setBounds(40,420,100,20);
jla14.setBounds(40,460,100,20);
jtx1.setBounds(110,20,150,20);
jtx2.setBounds(110,60,150,20);
jtx3.setBounds(110,100,150,20);
jtx4.setBounds(110,140,150,20);
jtx5.setBounds(110,180,150,20);
jtx6.setBounds(110,220,150,20);
jtx7.setBounds(110,260,150,20);
jtx8.setBounds(110,300,150,20);
jtx9.setBounds(110,340,150,20);
jtx10.setBounds(110,380,150,20);
jtx13.setBounds(110,420,150,20);
jtx14.setBounds(110,460,150,20);
jbt.setBounds(90,550,80,30);
jbt1.setBounds(190,550,80,30);
cp.add(jla1);
cp.add(jla2);
cp.add(jla3);
cp.add(jla4);
cp.add(jla5);
cp.add(jla6);
cp.add(jla7);
cp.add(jla8);
cp.add(jla9);
cp.add(jla10);
cp.add(jla13);
cp.add(jla14);
cp.add(jla11);//提醒注册错误
cp.add(jla12);
cp.add(jtx1);
cp.add(jtx2);
cp.add(jtx3);
cp.add(jtx4);
cp.add(jtx5);
cp.add(jtx6);
cp.add(jtx7);
cp.add(jtx8);
cp.add(jtx9);
cp.add(jtx10);
cp.add(jtx13);
cp.add(jtx14);
cp.add(jbt);
cp.add(jbt1);
cp.setLayout(null);
ImagePanimg=newImagePan();
img.setBounds(0,0,400,600);
jrf.add(img);
jrf.setSize(400,640);
jrf.setLocation(450,40);
jrf.setVisible(true);
jbt.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
try{
Class.forName("com.mysql.jdbc.Driver");
Connectionconn=DriverManager.getConnection("jdbc:
mysql:
//localhost:
3306/test1","root","123456");
Statementst=conn.createStatement();
Stringsql="insertintouser(userNo,passwd)values('"+jtx1.getText()+"','"+jtx2.getText()+"');";
Stringsql1="insertintostudentvalues('"+jtx1.getText()+"','"+jtx4.getText()+"','"+jtx5.getText()+"','"+jtx6.getText()+"','"+jtx7.getText()+"','"+jtx8.getText()+"','"+jtx9.getText()+"','"+jtx10.getText()+"','"+jtx13.getText()+"','"+jtx14.getText()+"');";
if((jtx2.getText().compareTo(jtx3.getText())==0)&&((String)(jtx2.getText())).length()>0&&((String)(jtx1.getText())).length()>0){
jla11.setForeground(Color.blue);
jla11.setText("注册成功!
");
st.executeUpdate(sql);
st.executeUpdate(sql1);
jrf.setVisible(true);
}
else{
jla11.setForeground(Color.red);
jla11.setText("注册失败!
");
}
}catch(ClassNotFoundExceptione1){
e1.printStackTrace();
}catch(SQLExceptione1){
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
jrf.setVisible(true);
}
});
jbt1.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
jrf.dispose();
Loginl=newLogin();
l.login();
}
});
}
publicstaticvoidmain(Stringargs[])throwsSQLException,ClassNotFoundException{
newZhuce();
}
classImagePanextendsJLabel{//构建一个图片容器
privatestaticfinallongserialVersionUID=1L;
protectedvoidpaintComponent(Graphicsg){
super.paintComponent(g);
ImageIconicon=newImageIcon("D:
\\Eclipse\\zhuce.jpg");
g.drawImage(icon.getImage(),0,0,this);
}
}
}
packagemysql;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
publicclassFankajiemainextendsLoginimplementsActionListener{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
@SuppressWarnings("deprecation")
Stringpasswd=passwdText.getText().toString();
Stringname=nameText.getText();
privateJFrameframe=newJFrame("学生饭卡管理系统");
Containercp=frame.getContentPane();
privateJLabeluser_name=newJLabel(name);
privateJLabeljtx_hu=newJLabel("欢迎您:
");
JMenuBarmb=newJMenuBar();
JMenumenu1=newJMenu("管理");
JMenuItemmi2=newJMenuItem("退出");
JMenumenu2=newJMenu("信息维护");
JMenuItemmi2_1=newJMenuItem("密码修改");
JMenuItemmi2_2=newJMenuItem("更改信息");
JMenumenu3=newJMenu("信息查询");
JMenuItemmi3_1=newJMenuItem("个人信息");
Fankajiemain(){
//user_name.setText(name);
mb.add(menu1);
mb.add(menu2);
mb.add(menu3);
menu1.add(mi2);
menu2.add(mi2_1);
menu2.add(mi2_2);
menu3.add(mi3_1);
mi2.addActionListener(this);
mi2_1.addActionListener(this);
mi2_2.addActionListener(this);
mi3_1.addActionListener(this);
user_name.setBounds(800,20,200,20);
jtx_hu.setBounds(750,20,200,20);
frame.add(user_name);
frame.add(jtx_hu);
frame.setSize(900,700);
frame.setJMenuBar(mb);
frame.setLocation(250,20);
ImagePanelimg=newImagePanel();
img.setBounds(0,0,400,200);
frame.add(img);
frame.setVisible(true);
mi2.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
frame.dispose();
}
});
mi2_1.addActionListener(newAc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 管理 系统 java