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

下载本文档

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

文档简介

1、 / 用户登录 / package perty; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.*; import java.sql.Statement; import java.sql.ResultSet; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField; im

2、port javax.swing.JPasswordField; import javax.swing.JPanel; import javax.swing.JFrame; public class user_land extends JFrame implements ActionListener static Connection conn=null; static Statement stat=null; static ResultSet rs=null; static String url=jdbc:sqlserver:/:1433;DatabaseName=_Pro

3、perty; static String user=sa; static String password=; JPanel p1,p2,p3,p4,p5; JLabel lbl1,lbl2,lbl3,lbl4; JTextField txt_name; JPasswordField txt_pwd; JButton btn1,btn2,btn3; static try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(Exception e) System.out.println(加载驱动失败); e.prin

4、tStackTrace(); public user_land() this.setTitle(固定资产及设备用户登录); p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); lbl1=new JLabel(欢迎登录); lbl2=new JLabel(用户名:); lbl3=new JLabel(密 码:); lbl4=new JLabel(); txt_name=new JTextField(10); txt_pwd=new JPasswordField(10); btn1

5、=new JButton(登录); btn2=new JButton(清空); btn3=new JButton(退出); 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(new GridLayout(5,1); this.add(p1); this.add(p2); this.add(p3); this.add(p4); this.add(p5);

6、 this.setBounds(400, 300, 400, 300); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true); /添加按钮登录事件 btn1.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) if(txt_name.getText().equals()=true)&&(txt_pwd.getText().equals()=false) lbl4.setText(登录

7、失败,用户名不能为空); 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(登录失败,用户名/密码不能为空); if(is_Property() new Sys_interface().show(); else if(txt_name.getTex

8、t().equals()=false)&&(txt_pwd.getText().equals()=false) lbl4.setText(登录失败,用户名/密码错误); ); btn1.addActionListener(this); /清空用户名和密码 btn2.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) txt_name.setText(null); txt_pwd.setText(null); lbl4.setText(null); ); /退出 bt

9、n3.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) System.exit(0); ); protected void user_land(Object setVisible) / TODO Auto-generated method stub public boolean is_Property() try conn=DriverManager.getConnection(url, user, password); /System.out.println(连接成功); st

10、at=conn.createStatement(); String sql=select * from Admin_Info; rs=stat.executeQuery(sql); while(rs.next() /System.out.println(rs.getString(A_name)+t+rs.getString(A_pwd); String name=txt_name.getText(); String pwd=txt_pwd.getText(); if(name.equals(rs.getString(A_name) && pwd.equals(rs.getStr

11、ing(A_pwd) /System.out.println(登录成功!); return true; catch(SQLException e) System.out.println(连接失败!); e.printStackTrace(); /关闭数据库 finally try if(rs!=null) rs.close(); if(stat!=null) stat.close(); if(conn!=null) conn.close(); catch(Exception e2) System.out.println(关闭失败); e2.printStackTrace(); return f

12、alse; public static void main(String args) new user_land(); public void actionPerformed(ActionEvent e) /System.exit(0); this.setVisible(false); / 主界面 / package perty; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dialog; import java.awt.FlowLayout; import java.awt

13、.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JMenu; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JText

14、Field; public class Sys_interface extends JFrame implements ActionListener JPanel p=null; JMenuItem jmi_1,jmi_2,jmi_3,jmi_4,jmi_5,jmi_6,jmi_7,jmi_8,jmi_9,jmi_10; JMenuBar jmb=null; JMenu jm_1=null,jm_2=null,jm_3=null,jm_4=null; JLabel text; public Sys_interface() this.setTitle(固定资产及设备管理系统); text=new

15、 JLabel( 欢迎进入固定资产及设备管理系统); text.setFont(new Font(宋体,1,28); text.setForeground(Color.blue); p=new JPanel(); jmb=new JMenuBar(); jm_1=new JMenu(系统功能); jm_2=new JMenu(资产管理); jm_3=new JMenu(系统查询); jm_4=new JMenu(帮助); jmi_1=new JMenuItem(用户登录); jmi_2=new JMenuItem(注销用户); jmi_3=new JMenuItem(用户添加); jmi_4=

16、new JMenuItem(退出系统); jmi_5=new JMenuItem(资产借出管理); jmi_6=new JMenuItem(资产信息管理); jmi_7=new JMenuItem(资产信息查询); jmi_8=new JMenuItem(资产借出查询); jmi_9=new JMenuItem(资产归还查询); jmi_10=new JMenuItem(关于); 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.a

17、dd(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.setJMenuBar(jmb); /this.setLayout(new BorderLayout(); /this.add(p,BorderLayout.NORTH); jmi_1.addActionListener( new ActionListener() public v

18、oid actionPerformed(ActionEvent e) new user_land().show(); ); jmi_2.addActionListener(this); jmi_2.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent arg0) new user_land().show(); ); jmi_3.addActionListener( new ActionListener() public void actionPerformed(Action

19、Event e) new Pass_word().show(); ); jmi_4.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) System.exit(0); ); jmi_5.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) new loan_prop_manage().show(); ); jmi_6.addActionListener( new Acti

20、onListener() public void actionPerformed(ActionEvent e) new property_Info().show(); ); jmi_7.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) new prop_info_select().show(); ); jmi_8.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) n

21、ew Loan_prop_select().show(); ); jmi_9.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) new back_prop_select ().show(); ); jmi_10.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) new about().show(); ); this.setBounds(200,200,500,400

22、); this.setDefaultCloseOperation(EXIT_ON_CLOSE); public void actionPerformed(ActionEvent e) /System.exit(0); this.setVisible(false); public static void main(String args) new Sys_interface().show(); / 资产借出管理 / package perty; import java.awt.*; import java.awt.event.ActionEvent; import ja

23、va.awt.event.ActionListener; import java.sql.*; import java.util.Vector; import javax.swing.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.event.ListSelectionEvent; import javax.swing

24、.event.ListSelectionListener; import javax.swing.event.TableModelListener; import javax.swing.event.TableModelEvent; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; public class loan_prop_manage extends JFrame implements ActionListener Vector<Vector> data=null;

25、 DefaultTableModel model = null; Connection conn=null; Statement stat=null; ResultSet rs1=null; JTable loan_prop=null; JLabel label; JTextField text; JTextField txt01,txt02,txt03,txt04,txt05,txt06; JPanel p1=null,p2=null,p3=null,p4,p5,p6,p7,p8,p9,p10; Choice c1=null,c2=null; JLabel lb1=null,lb2=null

26、,lb3=null,lb4=null,lb5=null,lb6=null; JButton btn_ok=null; JButton btn_exit=null; JButton btn_fresh=null; JButton btn_save=null; JButton btn_del=null; Vector<String> columnName=new Vector(); public loan_prop_manage() text=new JTextField(); columnName.add(资产编号); columnName.add(资产名称); columnName

27、.add(资产型号); columnName.add(借出时间); columnName.add(借出数量); columnName.add(借出人); p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); p6=new JPanel(); p7=new JPanel(); p8=new JPanel(); p9=new JPanel(); p10=new JPanel(); lb1=new JLabel(资产编号); lb2=new JLabel(资产名称); lb3=new

28、JLabel(资产型号); lb4=new JLabel(借出时间); lb5=new JLabel(借出数量); lb6=new JLabel(借 出 人); txt01=new JTextField(8); txt02=new JTextField(8); txt03=new JTextField(8); txt04=new JTextField(8); txt05=new JTextField(8); txt06=new JTextField(8); c1=new Choice(); c2=new Choice(); text=new JTextField(5); c1.add(资产编号

29、); c2.add(=); btn_ok=new JButton(确定); btn_exit=new JButton(退出); btn_fresh=new JButton(刷新); btn_save=new JButton(保存); btn_del=new JButton(删除); p1.add(new JLabel(查询字段); p1.add(c1); p1.add(new JLabel(运算符); p1.add(c2); p1.add(new JLabel(输入数据); p1.add(text); p1.add(btn_ok); p1.add(btn_exit); p1.setBorder

30、(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); p10.add(btn_fresh); p10.add(btn_save); p10.add(btn_del); p2.setLayout(new GridLayout(3, 2);

31、p2.add(p3); p2.add(p4); p2.add(p5); p2.add(p6); p2.add(p7); p2.add(p8); loan_prop=new JTable(this.getDate(),columnName); model = new DefaultTableModel(getDate(),columnName); p9.add(new JScrollPane(loan_prop); this.setLayout(new GridLayout(4, 1); this.add(p1); this.add(p9); this.add(p2); this.add(p10

32、); this.setBounds(400,300,500,400); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setTitle(资产借出管理); btn_save.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); conn=DriverManager.getConnection(jdb

33、c:sqlserver:/:1433;DatabaseName=_property,sa,); stat=conn.createStatement(); String sql=insert into loan_info (prop_name,prop_type,loan_time,loan_num)+values('+txt02.getText()+','+txt03.getText()+','+txt04.getText()+','+txt05.getText()+'); stat.executeUpdate(

34、sql); DefaultTableModel mod= new DefaultTableModel(getDate(),columnName); loan_prop.setModel(mod); loan_prop.repaint(); loan_prop.updateUI(); catch(Exception e) System.out.println(e.getMessage(); try if(rs1!=null) rs1.close(); if(stat!=null) stat.close(); if(conn!=null) conn.close(); catch(Exception

35、 e2) System.out.println(关闭失败); e2.printStackTrace(); ); btn_ok.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) DefaultTableModel dtb=new DefaultTableModel(selectDate(),columnName); loan_prop.setModel(dtb); loan_prop.repaint(); loan_prop.updateUI(); ); /*btn_exit.ad

36、dActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) );*/ btn_exit.addActionListener(this); btn_fresh.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) DefaultTableModel mod = new DefaultTableModel(getDate(),columnName); loan_prop.setM

37、odel(mod); loan_prop.repaint(); loan_prop.updateUI(); ); loan_prop.getSelectionModel().addListSelectionListener( new ListSelectionListener() public void valueChanged(ListSelectionEvent e) btn_del.addActionListener(new ActionListener() public void actionPerformed(ActionEvent arg0) try int j= loan_pro

38、p.getSelectedRow(); Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); conn=DriverManager.getConnection(jdbc:sqlserver:/:1433;DatabaseName=_property,sa,); stat=conn.createStatement(); String sql1=delete from loan_info where prop_id=+data.get(j).get(0)+; stat.executeUpdate(sql1); c

39、atch(Exception ee) System.out.println(ee.getMessage(); finally try if(rs1!=null) rs1.close(); if(stat!=null) stat.close(); if(conn!=null) conn.close(); catch(Exception e2) System.out.println(关闭失败); e2.printStackTrace(); DefaultTableModel mod = new DefaultTableModel(getDate(),columnName); loan_prop.s

40、etModel(mod); loan_prop.repaint(); loan_prop.updateUI(); ); ); loan_prop.getSelectionModel().addListSelectionListener( new ListSelectionListener() public void valueChanged(ListSelectionEvent e) int i= loan_prop.getSelectedRow(); txt01.setText(data.get(i).get(0).toString(); txt02.setText(String)data.

41、get(i).get(1); txt03.setText(String)data.get(i).get(2); txt04.setText(data.get(i).get(3).toString(); txt05.setText(data.get(i).get(4).toString(); txt06.setText(data.get(i).get(5).toString(); ); public Vector selectDate() data=new Vector<Vector>(); try Class.forName(com.microsoft.sqlserver.jdbc

42、.SQLServerDriver); conn=DriverManager.getConnection(jdbc:sqlserver:/:1433;DatabaseName=_property,sa,); stat=conn.createStatement(); int x=Integer.parseInt(text.getText().trim(); /System.out.println(x); rs1=stat.executeQuery(select * from loan_info where prop_id=+x); while(rs1.next() Vector

43、al=new Vector(); al.add(rs1.getInt(prop_id); al.add(rs1.getString(prop_name); al.add(rs1.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(Exception e) e.printStackTrace(); finally try if(rs1!=null) rs1.close(); if(stat!=null) stat.close(); if(conn!=null) conn.close(); catch(Exception e2) System.out.

温馨提示

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

评论

0/150

提交评论