专业设计报告.docx

上传人:b****8 文档编号:9355441 上传时间:2023-05-18 格式:DOCX 页数:35 大小:289.55KB
下载 相关 举报
专业设计报告.docx_第1页
第1页 / 共35页
专业设计报告.docx_第2页
第2页 / 共35页
专业设计报告.docx_第3页
第3页 / 共35页
专业设计报告.docx_第4页
第4页 / 共35页
专业设计报告.docx_第5页
第5页 / 共35页
专业设计报告.docx_第6页
第6页 / 共35页
专业设计报告.docx_第7页
第7页 / 共35页
专业设计报告.docx_第8页
第8页 / 共35页
专业设计报告.docx_第9页
第9页 / 共35页
专业设计报告.docx_第10页
第10页 / 共35页
专业设计报告.docx_第11页
第11页 / 共35页
专业设计报告.docx_第12页
第12页 / 共35页
专业设计报告.docx_第13页
第13页 / 共35页
专业设计报告.docx_第14页
第14页 / 共35页
专业设计报告.docx_第15页
第15页 / 共35页
专业设计报告.docx_第16页
第16页 / 共35页
专业设计报告.docx_第17页
第17页 / 共35页
专业设计报告.docx_第18页
第18页 / 共35页
专业设计报告.docx_第19页
第19页 / 共35页
专业设计报告.docx_第20页
第20页 / 共35页
亲,该文档总共35页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

专业设计报告.docx

《专业设计报告.docx》由会员分享,可在线阅读,更多相关《专业设计报告.docx(35页珍藏版)》请在冰点文库上搜索。

专业设计报告.docx

专业设计报告

实验报告

 

课程名称:

专业课程设计

设计项目:

购书管理系统

专业班级:

计算机科学与技术

姓名:

学号:

指导教师:

成绩:

沈阳工业大学实验报告

(适用计算机程序设计类)

1设计任务目标:

1)本系统是小型购书系统,转为某校设计的。

2)本系统启动后需要登陆,然后进入主界,在这个界面我们可以选择所需要的功能模块来完成所要执行的功能。

3)系统共有3个功能模块:

用户管理、图书流动管理、查询统计。

2.设计内容:

系统功能包括:

登录、用户注册、购书、退书、用户查询、书籍查询、购书查询、新书通告。

3.设计完成情况:

上述功能基本可以实现,原计划还想加入一个支付功能和入库功能,但是比较复杂,

所以没能加上。

4.实验步骤或程序(程序见后面附录A)

5.程序运行结果

(1)主界面

(2)用户注册

注册后数据库表格:

(3)购书

(4)退书

退书后数据库表格

(5)按书名查询图书

(6)按编码查询图书

(7)用户查询

(8)购书清单查询

 

附件A沈阳工业大学实验报告

(适用计算机程序设计类)

实验步骤或程序:

1)登录类

publicclassloginextendsJFrame

{privateJLabelJLb1;

privateJLabelJLb2;

privateJButtonOk_btn;

privateJButtonCancel_btn;

privateJTextFieldJtfld1;

privateJPasswordFieldJtfld2;

privateJFrameframe;

privateConnectioncon;

privateStatementstmt;

publiclogin()

{Fonts=newFont("楷体",Font.PLAIN,12);

UIManager.put("Component.font",s);

UIManager.put("Label.font",s);

UIManager.put("ComboBox.font",s);

UIManager.put("Button.font",s);

UIManager.put("Menu.font",s);

UIManager.put("MenuItem.font",s);

//JFrame.setDefaultLookAndFeelDecorated(true);

frame=newJFrame("登陆");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Containercontent=frame.getContentPane();

content.setLayout(newGridLayout(3,2,20,20));

JLb1=newJLabel("用户名:

");

JLb2=newJLabel("密码:

");

Jtfld1=newJTextField();

Jtfld2=newJPasswordField();

Ok_btn=newJButton("确定");

Cancel_btn=newJButton("取消");

Ok_btn.addActionListener(newActionHandler());

Cancel_btn.addActionListener(newActionHandler());

content.add(JLb1);

content.add(Jtfld1);

content.add(JLb2);

content.add(Jtfld2);

content.add(Ok_btn);

content.add(Cancel_btn);

frame.pack();

frame.setLocationRelativeTo(null);

frame.setSize(300,200);

frame.setVisible(true);

try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:

odbc:

sun");

stmt=con.createStatement();}

catch(ClassNotFoundExceptione){}

catch(SQLExceptionex){}}

classActionHandlerimplementsActionListener

{publicvoidactionPerformed(ActionEvente)

{Stringstr1,str2,username,sqlStr;

Objectobj=e.getSource();

str1=Jtfld1.getText().trim();

str2=Jtfld2.getText().trim();

try{if(obj.equals(Ok_btn))

{if(str1.equals(""))

{JOptionPane.showMessageDialog(frame,"用户名不能为空!

");

return;}

if(str2.equals(""))

{JOptionPane.showMessageDialog(frame,"密码不能为空!

");

return;}

sqlStr="select*fromloginwhereuser_name="+"'"+str1+"'"+

"andpsw="+"'"+str2+"'";

ResultSetresult=stmt.executeQuery(sqlStr);

if(result.next())

{username=result.getString("user_name");

if(username.equals("guest"))

{mamainFrame=newma();

mainFrame.menuItem1.setEnabled(false);

mainFrame.menuItem10.setEnabled(false);

mainFrame.menuItem3.setEnabled(false);

mainFrame.menuItem4.setEnabled(false);

mainFrame.menuItem6.setEnabled(false);

mainFrame.menuItem7.setEnabled(false);

mainFrame.menuItem9.setEnabled(false);

mainFrame.menuItem16.setEnabled(false);

mainFrame.menuItem12.setEnabled(false);}

else

{newma();}

frame.dispose();

stmt.close();

con.close();}

else

{JOptionPane.showMessageDialog(frame,"用户名或密码错误,请重新输入!

");}}

elseif(obj.equals(Cancel_btn)){System.exit(0);}}

catch(SQLExceptionex)

{System.err.println(ex);}}}

publicstaticvoidmain(String[]args)

{javax.swing.SwingUtilities.invokeLater(newRunnable()

{publicvoidrun()

{newlogin();}});}}

(3)用户注册类

publicclassuserimplementsActionListener

{privateJButtonbtn1,btn2,btn3,btn4;

privateJTextFieldtfd1,tfd3,tfd4,tfd5;

privateJComboBoxjcb1,jcb2,jcb3;

privatePreparedStatementpstmt;

privateConnectioncon;

privateJFrameframe;

privatestaticStatementstmt;

publicuser()

{Fonts=newFont("楷体",Font.PLAIN,12);

UIManager.put("Component.font",s);

UIManager.put("Label.font",s);

UIManager.put("ComboBox.font",s);

UIManager.put("Button.font",s);

UIManager.put("Menu.font",s);

UIManager.put("MenuItem.font",s);

//JFrame.setDefaultLookAndFeelDecorated(true);

frame=newJFrame("用户注册");

Containercontent=frame.getContentPane();

frame.addWindowListener(newWindowAdapter()

{publicvoidwindowCloing(WindowEvente)

{try{pstmt.close();

con.close();

stmt.close();

frame.dispose();}

catch(SQLExceptionsqle){}}});

content.setLayout(newBorderLayout());

JPanelJpl=newJPanel();

JPanelJpl2=newJPanel();

Jpl.setLayout(newGridLayout(7,2,2,6));

Jpl2.setLayout(newGridLayout(1,4,2,0));

JLabellb1=newJLabel("姓名:

");

JLabellb2=newJLabel("性别:

");

JLabellb3=newJLabel("身份:

");

JLabellb4=newJLabel("学院:

");

JLabellb5=newJLabel("密码:

");

JLabellb6=newJLabel("注册日期:

");

JLabellb7=newJLabel("账户名:

");

btn1=newJButton("添加");

btn2=newJButton("删除");

btn3=newJButton("撤消");

btn4=newJButton("退出");

btn1.addActionListener(this);

btn2.addActionListener(this);

btn3.addActionListener(this);

btn4.addActionListener(this);

tfd1=newJTextField();

tfd3=newJTextField();

tfd4=newJTextField();

tfd5=newJTextField();

tfd4.addFocusListener(newFocusHandler());

tfd5.addFocusListener(newFocusHandler());

String[]str_sex={"男","女"};

String[]str_office={"医药信息工程学院","医药商学院","药科学院","中药学院","临床学院","信息学院","材料学院","机械学院","电气学院","文法学院","管理学院","外语学院"};

String[]str_status={"学生","教师"};

jcb1=newJComboBox(str_sex);

jcb2=newJComboBox(str_status);

jcb3=newJComboBox(str_office);

jcb2.setEditable(true);

Jpl.add(lb1);

Jpl.add(tfd1);

Jpl.add(lb2);

Jpl.add(jcb1);

Jpl.add(lb3);

Jpl.add(jcb2);

Jpl.add(lb4);

Jpl.add(jcb3);

Jpl.add(lb5);

Jpl.add(tfd3);

Jpl.add(lb6);

Jpl.add(tfd4);

Jpl.add(lb7);

Jpl.add(tfd5);

Jpl.setBorder(BorderFactory.createTitledBorder("用户注册"));

Jpl2.add(btn1);

Jpl2.add(btn2);

Jpl2.add(btn3);

Jpl2.add(btn4);Jpl2.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));

content.add(Jpl,BorderLayout.CENTER);

content.add(Jpl2,BorderLayout.SOUTH);

frame.pack();

frame.setLocationRelativeTo(null);

frame.setSize(450,400);

frame.setVisible(true);

try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:

odbc:

sun");

Stringstr;

str="insertintouser(user_name,user_sex,user_status,user_office,"+"user_passwd,user_registerdate,user_cardnumber,user_state)values(?

?

?

?

?

?

?

'正常')";

pstmt=con.prepareStatement(str,ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_UPDATABLE);

stmt=con.createStatement();}

catch(SQLExceptione){}

catch(ClassNotFoundExceptioncnfe){}}

classFocusHandlerimplementsFocusListener

{java.util.Datetoday=newjava.util.Date();

java.util.Datetoday2=newjava.util.Date();

Stringformatted2;

DateFormatfmt=DateFormat.getDateInstance();

Stringformatted=fmt.format(today);

publicvoidfocusGained(FocusEvente)

{Objectobj=(JTextField)e.getSource();

if(obj==tfd4)

{tfd4.setText(formatted);}}

publicvoidfocusLost(FocusEvente){}}

publicvoidactionPerformed(ActionEvente)

{Stringstr1,str2,str3,str4,str5,str6,str7;

java.sql.Datetoday1;

str1=tfd1.getText().trim();

str2=jcb1.getSelectedItem().toString();

str3=jcb2.getSelectedItem().toString();

str4=jcb3.getSelectedItem().toString();

str5=tfd3.getText().trim();

str6=tfd4.getText().trim();

str7=tfd5.getText().trim();

StringsqlStr="deletefromuserwhereuser_cardnumber="+"'"+str5+"'";

Objectobj=(JButton)e.getSource();

try{if(obj==btn1)

{today1=java.sql.Date.valueOf(str6);

pstmt.setString(1,str1);

pstmt.setString(2,str2);

pstmt.setString(3,str3);

pstmt.setString(4,str4);

pstmt.setString(5,str5);

pstmt.setDate(6,today1);

pstmt.setString(7,str7);

pstmt.executeUpdate();}

elseif(obj==btn2){stmt.executeUpdate(sqlStr);}

elseif(obj==btn3){tfd1.setText("");

tfd3.setText("");

tfd4.setText("");

tfd5.setText("");}

elseif(obj==btn4{pstmt.close();

stmt.close();

con.close();

frame.dispose();}}

catch(SQLExceptionsqle){System.err.println(sqle.getMessage());}}

publicstaticvoidmain(String[]args){newuser();}}

(4)购书类

publicclassshopextendsJFrameimplementsActionListener

{privateJTextFieldjtfd1,jtfd2,jtfd3,jtfd4;

privateJButtonbtn1,btn2,btn3;

privateConnectioncon;

privateStatementstmt;

privatePreparedStatementpstmt;

privateJFrameframe;

privateJLabellb5;

publicshop()

{Fonts=newFont("楷体",Font.PLAIN,12);

UIManager.put("Component.font",s);

UIManager.put("Label.font",s);

UIManager.put("ComboBox.font",s);

UIManager.put("Button.font",s);

UIManager.put("Menu.font",s);

UIManager.put("MenuItem.font",s);

frame=newJFrame("购书");

Containercontent=frame.getContentPane();

content.setLayout(newGridLayout(6,2,10,10));

JLabellb1=newJLabel("用户名:

");

JLabellb2=newJLabel("图书编码:

");

JLabellb3=newJLabel("购书日期:

");

JLabellb4=newJLabel("价格:

");

lb5=newJLabel("付款:

");

jtfd1=newJTextField();

jtfd2=newJTextField();

jtfd3=newJTextField();

jtfd4=newJTextField();

jtfd1.addFocusListener(newFocusHandler());

jtfd2.addFocusListener(newFocusHandler());

jtfd3.addFocusListener(newFocusHandler());

jtfd4.addFocusListener(newFocusHandler());

btn1=newJButton("确定");

btn2=newJButton("退出");

btn3=newJButton("交款");

btn1.addActionListener(this);

btn2.addActionListener(this);

btn3.addActionListener(this);

content.add(lb1);

content.add(jtfd1);

content.add(lb2);

content.add(jtfd2);

content.add(lb3);

content.add(jtfd3);

content.add(lb4);

content.add(jtfd4);

content.add(lb5);

content.add(btn3);

content.add(btn1);

content.add(btn2);

frame.setBounds(100,100,420,320);

try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:

odbc:

sun");

stmt=con.cre

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2