Java固定资产管理系统源代码_第1页
Java固定资产管理系统源代码_第2页
Java固定资产管理系统源代码_第3页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、/用户登录/perty;importjava.awt.GridLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.*;importjava.sql.Statement;importjava.sql.ResultSet;importjavax.swing.JButton;importjavax.swing.JLabel;importjavax.swing.JTextField;importjavax.swing.JPasswor

2、dField;importjavax.swing.JPanel;importjavax.swing.JFrame;publicclassuser_landextendsJFrameimplementsActionListenerstaticConnectionconn=null;staticStatementstat=null;staticResultSetrs=null;staticStringurl="jdbc:sqlserver:/:1433;DatabaseName=_Property”;staticStringuser="sa”;staticSt

3、ringpassword=""JPanelp1,p2,p3,p4,p5;JLabellbl1,lbl2,lbl3,lbl4;JTextFieldtxt_name;JPasswordFieldtxt_pwd;JButtonbtn1,btn2,btn3;statictryClass.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");catch(Exceptione)(System.out.println("加载驱动失败");e.printStackTrace();this.se

4、tTitle("固定资产及设备用户登录");p1=newJPanel();p2=newJPanel();p3=newJPanel();p4=newJPanel();p5=newJPanel();lbl1=newJLabel("欢迎登录");lbl2=newJLabel("用户名:");lbl3=newJLabel("密码:");lbl4=newJLabel();txt_name=newJTextField(10);txt_pwd=newJPasswordField(10);btn1=newJButton("

5、;登录");btn2=newJButton("清空");btn3=newJButton("退出");p1.add(lbl1);p2.add(lbl2);p2.add(txt_name);p3.add(lbl3);p3.add(txt_pwd);p4.add(btn1);p4.add(btn2);p4.add(btn3);p5.add(lbl4);this.setLayout(newGridLayout(5,1);this.add(p1);this.add(p2);this.add(p3);this.add(p4);this.add(p5);th

6、is.setBounds(400,300,400,300);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);添加按钮登录事件btn1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)if(txt_name.getText().equals("")=true)&&(txt_pwd.getText().equals("")=false)lbl4.setTe

7、xt(”登录失败,用户名不能为空");if(txt_name.getText().equals("")=false)&&(txt_pwd.getText().equals("")=true)lbl4.setText("登录失败,密码不能为空");if(txt_name.getText().equals("")=true)&&(txt_pwd.getText().equals("")=true)lbl4.setText(”登录失败,用户名/密码不能为空&q

8、uot;);if(is_Property()newSys_interface().show();elseif(txt_name.getText().equals("")=false)&&(txt_pwd.getText().equals("")=false)lbl4.setText(”登录失败,用户名/密码错误"););btn1.addActionListener(this);清空用户名和密码btn2.addActionListener(newActionListener()publicvoidactionPerformed(A

9、ctionEvente)txt_name.setText(null);txt_pwd.setText(null);lbl4.setText(null););/退出btn3.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)System.exit(0););/TODOAuto-generatedmethodstubpublicbooleanis_Property()(try(conn=DriverManager.getConnection(url,user,password);/System.o

10、ut.println("连接成功");stat=conn.createStatement();Stringsql="select*fromAdmin_Info"rs=stat.executeQuery(sql);while(rs.next()/System.out.println(rs.getString("A_name")+"t"+rs.getString("A_pwd");Stringname=txt_name.getText();Stringpwd=txt_pwd.getText();if

11、(name.equals(rs.getString("A_name")&&pwd.equals(rs.getString("A_pwd")/System.out.println(”登录成功!");returntrue;catch(SQLExceptione)System.out.println("连接失败!!”);e.printStackTrace();/关闭数据库finallytryif(rs!=null)rs.close();if(stat!=null)stat.close();if(conn!=null)conn

12、.close();catch(Exceptione2)System.out.println("关闭失败");e2.printStackTrace();returnfalse;publicstaticvoidmain(Stringargs)(newuser_land();publicvoidactionPerformed(ActionEvente)(/System.exit(0);this.setVisible(false);/主界面/perty;importjava.awt.BorderLayout;importjava.awt.Co

13、lor;importjava.awt.Dialog;importjava.awt.FlowLayout;importjava.awt.Font;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JMenu;importjavax.swing.JPanel;impor

14、tjavax.swing.JTextArea;importjavax.swing.JTextField;publicclassSys_interfaceextendsJFrameimplementsActionListener(JPanelp=null;JMenuItemjmi_1,jmi_2,jmi_3,jmi_4,jmi_5,jmi_6,jmi_7,jmi_8,jmi_9,jmi_10;JMenuBarjmb=null;JMenujm_1=null,jm_2=null,jm_3=null,jm_4=null;JLabeltext;publicSys_interface()this.setT

15、itle("固定资产及设备管理系统");text=newJLabel("欢迎进入固定资产及设备管理系统");text.setFont(newFont("宋体”,1,28);text.setForeground(Color.blue);p=newJPanel();jmb=newJMenuBar();jm_1=newJMenu("系统功能");jm_2=newJMenu("资产管理");jm_3=newJMenu("系统查询");jm_4=newJMenu("帮助");

16、jmi_1=newJMenuItem("用户登录");jmi_2=newJMenuItem("注销用户");jmi_3=newJMenuItem("用户添加");jmi_4=newJMenuItem("退出系统"););););););jmi_5=newJMenuItem("资产借出管理jmi_6=newJMenuItem("资产信息管理jmi_7=newJMenuItem("资产信息查询jmi_8=newJMenuItem("资产借出查询jmi_9=newJMenuItem

17、("资产归还查询jmi_10=newJMenuItem("关于");jm_1.add(jmi_1);jm_1.add(jmi_2);jm_1.add(jmi_3);jm_1.add(jmi_4);jm_2.add(jmi_5);jm_2.add(jmi_6);jm_3.add(jmi_7);jm_3.add(jmi_8);jm_3.add(jmi_9);jm_4.add(jmi_10);jmb.add(jm_1);jmb.add(jm_2);jmb.add(jm_3);jmb.add(jm_4);add(text,BorderLayout.CENTER);this

18、.setJMenuBar(jmb);/this.setLayout(newBorderLayout();/this.add(p,BorderLayout.NORTH);jmi_1.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)newuser_land().show(););jmi_2.addActionListener(this);jmi_2.addActionListener(newActionListener()OverridepublicvoidactionPerformed(Act

19、ionEventarg0)newuser_land().show(););jmi_3.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)newPass_word().show(););jmi_4.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)System.exit(0););jmi_5.addActionListener(newActionListener()publicvoidactio

20、nPerformed(ActionEvente)newloan_prop_manage().show(););jmi_6.addActionListener(newActionListener()(publicvoidactionPerformed(ActionEvente)(newproperty_Info().show(););jmi_7.addActionListener(newActionListener()(publicvoidactionPerformed(ActionEvente)(newprop_info_select().show(););jmi_8.addActionLis

21、tener(newActionListener()(publicvoidactionPerformed(ActionEvente)(newLoan_prop_select().show(););jmi_9.addActionListener(newActionListener()(publicvoidactionPerformed(ActionEvente)(newback_prop_select().show(););jmi_10.addActionListener(newActionListener()(publicvoidactionPerformed(ActionEvente)(new

22、about().show(););this.setBounds(200,200,500,400);this.setDefaultCloseOperation(EXIT_ON_CLOSE);publicvoidactionPerformed(ActionEvente)(/System.exit(0);this.setVisible(false);publicstaticvoidmain(Stringargs)(newSys_interface().show();/资产借出管理/perty;importjava.awt.*;importjava.awt.ev

23、ent.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.*;importjava.util.Vector;importjavax.swing.*;importjava.awt.event.FocusEvent;importjava.awt.event.FocusListener;importjava.awt.event.MouseEvent;importjava.awt.event.MouseListener;importjavax.swing.event.ListSelectionEvent;importjavax

24、.swing.event.ListSelectionListener;importjavax.swing.event.TableModelListener;importjavax.swing.event.TableModelEvent;importjavax.swing.table.DefaultTableModel;importjavax.swing.table.TableModel;publicclassloan_prop_manageextendsJFrameimplementsActionListener(Vector<Vector>data=null;DefaultTab

25、leModelmodel=null;Connectionconn=null;Statementstat=null;ResultSetrs1=null;JTableloan_prop=null;JLabellabel;JTextFieldtext;JTextFieldtxt01,txt02,txt03,txt04,txt05,txt06;JPanelp1=null,p2=null,p3=null,p4,p5,p6,p7,p8,p9,p10;Choicec1=null,c2=null;JLabellb1=null,lb2=null,lb3=null,lb4=null,lb5=null,lb6=nu

26、ll;JButtonbtn_ok=null;JButtonbtn_exit=null;JButtonbtn_fresh=null;JButtonbtn_save=null;JButtonbtn_del=null;Vector<String>columnName=newVector();publicloan_prop_manage()text=newJTextField();columnName.add("资产编号");columnName.add("资产名称");columnName.add("资产型号");columnN

27、ame.add("借出时间");columnName.add("借出数量");columnName.add("借出人");p1=newJPanel();p2=newJPanel();p3=newJPanel();p4=newJPanel();p5=newJPanel();p6=newJPanel();p7=newJPanel();p8=newJPanel();p9=newJPanel();p10=newJPanel();lb1=newJLabel(lb2=newJLabel(lb3=newJLabel(lb4=newJLabel(lb

28、5=newJLabel(lb6=newJLabel(资产编号");资产名称");资产型号");借出时间");借出数量");借出人");txt01=newJTextField(8);txt02=newJTextField(8);txt03=newJTextField(8);txt04=newJTextField(8);txt05=newJTextField(8);txt06=newJTextField(8);c1=newChoice();c2=newChoice();text=newJTextField(5);c1.add("

29、资产编号");c2.add("=");btn_ok=newJButton("确定");btn_exit=newJButton("退出");btn_fresh=newJButton("刷新");btn_save=newJButton("保存");btn_del=newJButton("删除");p1.add(newJLabel("查询字段");p1.add(c1);p1.add(newJLabel("运算符");p1.add(c

30、2);p1.add(newJLabel("输入数据");p1.add(text);p1.add(btn_ok);p1.add(btn_exit);p1.setBorder(BorderFactory.createTitledBorder("请操作");p3.add(lb1);p3.add(txt01);p4.add(lb2);p4.add(txt02);p5.add(lb3);p5.add(txt03);p6.add(lb4);p6.add(txt04);p7.add(lb5);p7.add(txt05);p8.add(lb6);p8.add(txt06

31、);p10.add(btn_fresh);p10.add(btn_save);p10.add(btn_del);p2.setLayout(newGridLayout(3,2);p2.add(p3);p2.add(p4);p2.add(p5);p2.add(p6);p2.add(p7);p2.add(p8);loan_prop=newJTable(this.getDate(),columnName);model=newDefaultTableModel(getDate(),columnName);p9.add(newJScrollPane(loan_prop);this.setLayout(ne

32、wGridLayout(4,1);this.add(p1);this.add(p9);this.add(p2);this.add(p10);this.setBounds(400,300,500,400);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setTitle("资产借出管理");btn_save.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventarg0)tryClass.forName("com.micr

33、osoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver:/:1433;DatabaseName=_property","sa","");stat=conn.createStatement();Stringsql="insertintoloan_info(prop_name,prop_type,loan_time,loan_num)"+"values('

34、"+txt02.getText()+"','"+txt03.getText()+"','”+txt04.getText()+"','"+txt05.getText()+"')”;stat.executeUpdate(sql);DefaultTableModelmod=newDefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.update

35、UI();catch(Exceptione)System.out.println(e.getMessage();tryif(rs1!=null)rs1.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exceptione2)System.out.println("关闭失败");e2.printStackTrace(););btn_ok.addActionListener(newActionListener()publicvoidactionPerformed(ActionEvente)d

36、tb=newDefaultTableModelDefaultTableModel(selectDate(),columnName);loan_prop.setModel(dtb);loan_prop.repaint();loan_prop.updateUI(););/*btn_exit.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventarg0);*/btn_exit.addActionListener(this);btn_fresh.addActionListener(newActionList

37、ener()publicvoidactionPerformed(ActionEventarg0)DefaultTableModelmod=newDefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.updateUI(););loan_prop.getSelectionModel().addListSelectionListener(newListSelectionListener()publicvoidvalueChanged(ListSelectionEven

38、te)btn_del.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventarg0)tryintj=loan_prop.getSelectedRow();Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver:/:1433;DatabaseName=_property",&quo

39、t;sa","");stat=conn.createStatement();Stringsql1="deletefromloan_infowhereprop_id="+""+data.get(j).get(0)+""stat.executeUpdate(sql1);catch(Exceptionee)System.out.println(ee.getMessage();finallytryif(rs1!=null)rs1.close();if(stat!=null)(stat.close();if(con

40、n!=null)(conn.close();catch(Exceptione2)(System.out.println("关闭失败");e2.printStackTrace();DefaultTableModelmod=newDefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.updateUI();););loan_prop.getSelectionModel().addListSelectionListener(newListSelect

41、ionListener()(publicvoidvalueChanged(ListSelectionEvente)(inti=loan_prop.getSelectedRow();txt01.setText(data.get(i).get(0).toString();txt02.setText(String)data.get(i).get(1);txt03.setText(String)data.get(i).get(2);txt04.setText(data.get(i).get.toString();txt05.setText(data.get(i).get(4).toString();t

42、xt06.setText(data.get(i).get(5).toString(););publicVectorselectDate()(data=newVector<Vector>();try(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver:/:1433;DatabaseName=_property","sa","&qu

43、ot;);stat=conn.createStatement();intx=Integer.parseInt(text.getText().trim();/System.out.println(x);rs1=stat.executeQuery("select*fromloan_infowhereprop_id="+x);while(rs1.next()(Vectoral=newVector();al.add(rs1.getInt("prop_id");al.add(rs1.getString("prop_name");al.add(r

44、s1.getString("prop_type");al.add(rs1.getDate("loan_time");al.add(rs1.getInt("loan_num");al.add(rs1.getString("u_name");data.add(al);catch(Exceptione)(e.printStackTrace();finally(try(if(rs1!=null)(rs1.close();if(stat!=null)(stat.close();if(conn!=null)(conn.clos

45、e();catch(Exceptione2)(System.out.println("关闭失败");e2.printStackTrace();returndata;publicVectorgetDate()(data=newVector<Vector>();try(Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jdbc:sqlserver:/:1433;DatabaseN

46、ame=_property","sa","");stat=conn.createStatement();rs1=stat.executeQuery("select*fromloan_info");while(rs1.next()(Vectoral=newVector();al.add(rs1.getInt("prop_id");al.add(rs1.getString("prop_name");al.add(rs1.getString("prop_type");al

47、.add(rs1.getDate("loan_time");al.add(rs1.getInt("loan_num");al.add(rs1.getString("u_name");data.add(al);catch(Exceptione)System.out.println(e.getMessage();finallytryif(rs1!=null)rs1.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exceptione2)System.o

48、ut.println("关闭失败");e2.printStackTrace();returndata;publicstaticvoidmain(Stringargs)newloan_prop_manage().show();publicvoidactionPerformed(ActionEvente)/System.exit(0);this.setVisible(false);/资产借出查询/perty;importjava.sql.*;importjava.util.ArrayList;importjavax.swing.JButt

49、on;importjava.awt.event.*;importjavax.swing.JTextField;importjava.util.Vector;importjava.awt.BorderLayout;importjava.awt.Choice;importjava.awt.FlowLayout;importjavax.swing.BorderFactory;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JPanel;importjavax.swing.JScrollPane;importjav

50、ax.swing.JTable;importjavax.swing.table.DefaultTableModel;publicclassLoan_prop_selectextendsJFrameimplementsActionListenerConnectionconn=null;Statementstat=null;ResultSetrs=null;JTabletable=null;JLabellabel;JTextFieldtext;JButtonbtn_ok=null,btn_exit=null;JPanelp1=null,p2=null;Vector<String>col

51、umnName=newVector();publicLoan_prop_select()this.setTitle("资产借出查询");columnName.add("流水号");columnName.add("资产编号");columnName.add("借用人");columnName.add("借出数量");columnName.add("借出时间");p1=newJPanel();p2=newJPanel();text=newJTextField();text=new

52、JTextField(5);btn_ok=newJButton("查询");btn_exit=newJButton("退出");p1.add(newJLabel("资产编号");pl.add(text);p1.add(btn_ok);p1.add(btn_exit);p1.setBorder(BorderFactory.createTitledBorder(”数据查询");btn_exit.addActionListener(this);table=newJTable(this.getDate(),columnName);t

53、his.setLayout(newBorderLayout();this.add(p1,BorderLayout.NORTH);this.add(newJScrollPane(table),BorderLayout.CENTER);this.setBounds(400,300,500,400);this.setDefaultCloseOperation(EXIT_ON_CLOSE);btn_ok.addActionListener(newActionListener()OverridepublicvoidactionPerformed(ActionEventarg0)DefaultTableM

54、odeldtm=newDefaultTableModel(selectDate(),columnName);table.setModel(dtm);table.repaint();table.updateUI(););publicVectorselectDate()Vector<Vector>data=newVector<Vector>();tryClass.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.getConnection("jd

55、bc:sqlserver:/:1433;DatabaseName=_property","sa","");stat=conn.createStatement();intx=Integer.parseInt(text.getText().trim();/System.out.println(x);rs=stat.executeQuery("select*fromloan_infowhereprop_id="+x);while(rs.next()Vectoral=newVector();al.add(rs.ge

56、tString("loan_id");al.add(rs.getString("prop_id");al.add(rs.getString("u_id");al.add(rs.getString("loan_num");al.add(rs.getString("loan_time");data.add(al);catch(Exceptione)System.out.println(e.getMessage();finally/关闭tryif(rs!=null)rs.close();if(stat

57、!=null)stat.close();if(conn!=null)conn.close();catch(Exceptione2)System.out.println("关闭失败");e2.printStackTrace();returndata;publicVectorgetDate()Vector<Vector>data=newVector<Vector>();tryClass.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");conn=DriverManager.

58、getConnection("jdbc:sqlserver:/:1433;DatabaseName=_property","sa","");stat=conn.createStatement();rs=stat.executeQuery("select*fromloan_Info");while(rs.next()Vectoral=newVector();al.add(rs.getString("loan_id");al.add(rs.getString("prop_

59、id");al.add(rs.getString("u_id");al.add(rs.getString("loan_num");al.add(rs.getString("loan_time");data.add(al);catch(Exceptione)(System.out.println(e.getMessage();finally(/关闭try(if(rs!=null)(rs.close();if(stat!=null)(stat.close();if(conn!=null)(conn.close();catch(E

60、xceptione2)(System.out.println("关闭失败");e2.printStackTrace();returndata;publicstaticvoidmain(Stringargs)(newLoan_prop_select().show();publicvoidactionPerformed(ActionEvente)(/System.exit(0);this.setVisible(false);/资产归还查询/perty;importjava.sql.*;importjava.util.Vector;importjava.awt.BorderLayout;importjava.awt.event.ActionEv

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论