版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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;import javax.sw
2、ing.JPasswordField;import javax.swing.JPanel;import javax.swing.JFrame;public class user_land extends JFrame implements ActionListenerstatic Connection conn=null;static Statement stat=null;static ResultSet rs=null;static String url=jdbc:sqlserver:/:1433;DatabaseName=_Property;static String
3、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;statictryClass.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);catch(Exception e)System.out.println(加載驅(qū)動(dòng)失敗);e.printStackTrace();public user_land()t
4、his.setTitle(固定資產(chǎn)及設(shè)備用戶登錄);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=new JButton(登錄);btn2=new JButton(清空);btn3=new
5、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);this.setBounds(400, 300, 400, 300);this.setDefaultCloseOperation
6、(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(登錄失敗,用戶名不能為空); if(txt_name.getText().equals()=false)&(txt_pwd.getText().equals()=t
7、rue) 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.getText().equals()=false)&(txt_pwd.getText().equals()=false) lbl4.setText(登錄失敗,用戶名/密碼錯(cuò)誤););btn1.addAction
8、Listener(this);/清空用戶名和密碼btn2.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) txt_name.setText(null);txt_pwd.setText(null);lbl4.setText(null););/退出btn3.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) System.exit(0););protected void use
9、r_land(Object setVisible) / TODO Auto-generated method stubpublic boolean is_Property()tryconn=DriverManager.getConnection(url, user, password);/System.out.println(連接成功);stat=conn.createStatement();String sql=select * from Admin_Info;rs=stat.executeQuery(sql);while(rs.next()/System.out.println(rs.ge
10、tString(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.getString(A_pwd)/System.out.println(登錄成功!);return true;catch(SQLException e)System.out.println(連接失敗!);e.printStackTrace();/關(guān)閉數(shù)據(jù)庫(kù)finallytryif(rs!=null
11、)rs.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exception e2)System.out.println(關(guān)閉失敗);e2.printStackTrace();return false;public static void main(String args) new user_land();public void actionPerformed(ActionEvent e) /System.exit(0);this.setVisible(false);/ 主界面/package com.new
12、perty;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dialog;import java.awt.FlowLayout;import java.awt.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.sw
13、ing.JMenuItem;import javax.swing.JMenu;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.JTextField;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
14、 jm_1=null,jm_2=null,jm_3=null,jm_4=null;JLabel text;public Sys_interface()this.setTitle(固定資產(chǎn)及設(shè)備管理系統(tǒng));text=new JLabel( 歡迎進(jìn)入固定資產(chǎn)及設(shè)備管理系統(tǒng));text.setFont(new Font(宋體,1,28);text.setForeground(Color.blue);p=new JPanel();jmb=new JMenuBar();jm_1=new JMenu(系統(tǒng)功能);jm_2=new JMenu(資產(chǎn)管理);jm_3=new JMenu(系統(tǒng)查詢);jm_4=
15、new JMenu(幫助);jmi_1=new JMenuItem(用戶登錄);jmi_2=new JMenuItem(注銷用戶);jmi_3=new JMenuItem(用戶添加);jmi_4=new JMenuItem(退出系統(tǒng));jmi_5=new JMenuItem(資產(chǎn)借出管理);jmi_6=new JMenuItem(資產(chǎn)信息管理);jmi_7=new JMenuItem(資產(chǎn)信息查詢);jmi_8=new JMenuItem(資產(chǎn)借出查詢);jmi_9=new JMenuItem(資產(chǎn)歸還查詢);jmi_10=new JMenuItem(關(guān)于);jm_1.add(jmi_1);j
16、m_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.setJMenuBar(jmb);/this.setLayout(new BorderLayout();/this.add(p,B
17、orderLayout.NORTH);jmi_1.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) new user_land().show(););jmi_2.addActionListener(this);jmi_2.addActionListener(new ActionListener() Overridepublic void actionPerformed(ActionEvent arg0) new user_land().show(););jmi_3.addAction
18、Listener(new ActionListener()public void actionPerformed(ActionEvent 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_pro
19、p_manage().show(););jmi_6.addActionListener(new ActionListener()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()p
20、ublic void actionPerformed(ActionEvent e) new 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()
21、;);this.setBounds(200,200,500,400);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();/ 資產(chǎn)借出管理/package perty;import java.awt.*;import java.awt.even
22、t.ActionEvent;import java.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;impo
23、rt javax.swing.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 ActionListenerVector data=null;Defaul
24、tTableModel 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,lb3=null,lb4=nu
25、ll,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 columnName=new Vector();public loan_prop_manage()text=new JTextField();columnName.add(資產(chǎn)編號(hào));columnName.add(資產(chǎn)名稱);columnName.add(資產(chǎn)型號(hào));columnName.add(借出時(shí)間);columnNam
26、e.add(借出數(shù)量);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(資產(chǎn)編號(hào));lb2=new JLabel(資產(chǎn)名稱);lb3=new JLabel(資產(chǎn)型號(hào));lb4=new JLabel(借出時(shí)間);lb5=new JLabel(借出數(shù)量);lb
27、6=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(資產(chǎn)編號(hào));c2.add(=);btn_ok=new JButton(確定);btn_exit=new JButton(退出);btn_fresh=
28、new JButton(刷新);btn_save=new JButton(保存);btn_del=new JButton(刪除);p1.add(new JLabel(查詢字段);p1.add(c1);p1.add(new JLabel(運(yùn)算符);p1.add(c2);p1.add(new JLabel(輸入數(shù)據(jù));p1.add(text);p1.add(btn_ok); p1.add(btn_exit);p1.setBorder(BorderFactory.createTitledBorder(請(qǐng)操作);p3.add(lb1);p3.add(txt01);p4.add(lb2);p4.add(
29、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);p2.add(p3);p2.add(p4);p2.add(p5);p2.add(p6);p2.add(p7);p2.add(p8);loan_prop=new JTable(this.getDate()
30、,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);this.setBounds(400,300,500,400);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setTitle(資產(chǎn)借出管理);btn_save.addA
31、ctionListener(new ActionListener()public void actionPerformed(ActionEvent arg0)tryClass.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);conn=DriverManager.getConnection(jdbc:sqlserver:/:1433;DatabaseName=_property,sa,);stat=conn.createStatement();String sql=insert into loan_info (prop
32、_name,prop_type,loan_time,loan_num)+values(+txt02.getText()+,+txt03.getText()+,+txt04.getText()+,+txt05.getText()+);stat.executeUpdate(sql);DefaultTableModel mod= new DefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.updateUI();catch(Exception e)System.out
33、.println(e.getMessage();tryif(rs1!=null)rs1.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exception e2)System.out.println(關(guān)閉失敗);e2.printStackTrace(););btn_ok.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) DefaultTableModel dtb=new DefaultTableM
34、odel(selectDate(),columnName);loan_prop.setModel(dtb);loan_prop.repaint();loan_prop.updateUI(););/*btn_exit.addActionListener(new ActionListener()public void actionPerformed(ActionEvent arg0);*/btn_exit.addActionListener(this);btn_fresh.addActionListener(new ActionListener()public void actionPerform
35、ed(ActionEvent arg0)DefaultTableModel mod = new DefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.updateUI(););loan_prop.getSelectionModel().addListSelectionListener(new ListSelectionListener()public void valueChanged(ListSelectionEvent e)btn_del.addAction
36、Listener(new ActionListener()public void actionPerformed(ActionEvent arg0)tryint j= loan_prop.getSelectedRow();Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);conn=DriverManager.getConnection(jdbc:sqlserver:/:1433;DatabaseName=_property,sa,);stat=conn.createStatement();String sq
37、l1=delete from loan_info where prop_id=+data.get(j).get(0)+;stat.executeUpdate(sql1);catch(Exception ee)System.out.println(ee.getMessage();finallytryif(rs1!=null)rs1.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exception e2)System.out.println(關(guān)閉失敗);e2.printStackTrace();Default
38、TableModel mod = new DefaultTableModel(getDate(),columnName);loan_prop.setModel(mod);loan_prop.repaint();loan_prop.updateUI();););loan_prop.getSelectionModel().addListSelectionListener(new ListSelectionListener()public void valueChanged(ListSelectionEvent e)int i= loan_prop.getSelectedRow();txt01.se
39、tText(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(3).toString();txt05.setText(data.get(i).get(4).toString();txt06.setText(data.get(i).get(5).toString(););public Vector selectDate()data=new Vector();tryCla
40、ss.forName(com.microsoft.sqlserver.jdbc.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 pro
41、p_id=+x);while(rs1.next()Vector 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();finallytryif(rs1!=null)
42、rs1.close();if(stat!=null)stat.close();if(conn!=null)conn.close();catch(Exception e2)System.out.println(關(guān)閉失敗);e2.printStackTrace();return data;public Vector getDate()data=new Vector();tryClass.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);conn=DriverManager.getConnection(jdbc:sqlserver:/:1433;DatabaseName=_property,sa,);stat=conn.createStatement();rs1=stat.executeQuery(select * from loan_info);while(rs1.next()Vector al=new Vector();al.add(rs1.getInt(prop_id);al.add(rs1.getString(
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度終止供貨協(xié)議范本:關(guān)于智能機(jī)器人核心部件供應(yīng)合同終止
- 二零二五年度食堂員工職業(yè)健康監(jiān)護(hù)合同
- 2025年度搬運(yùn)工職業(yè)健康體檢與服務(wù)合同
- 二零二五年度路橋工程安全生產(chǎn)教育與監(jiān)督合同
- 二零二五年度醫(yī)療機(jī)構(gòu)陪護(hù)人員招聘及培訓(xùn)合同
- 二零二五年度電子商務(wù)平臺(tái)注冊(cè)及跨境物流服務(wù)合同
- 二零二五年度新能源汽車車庫(kù)抵押借款合同
- 二零二五年度終止勞動(dòng)合同通知書范本及離職補(bǔ)償計(jì)算方法
- 心臟再同步治療
- 業(yè)務(wù)流程再造分析案例
- 北京市海淀區(qū)2024-2025學(xué)年高一上學(xué)期期末考試歷史試題(含答案)
- 常用口服藥品的正確使用方法
- 2024年鉆探工程勞務(wù)協(xié)作協(xié)議樣式版B版
- 《心肺復(fù)蘇機(jī)救治院內(nèi)心搏驟?;颊咦o(hù)理專家共識(shí)》解讀
- 計(jì)算機(jī)二級(jí)WPS考試試題
- 智聯(lián)招聘行測(cè)題庫(kù)及答案
- 前程無(wú)憂測(cè)評(píng)題庫(kù)及答案
- 毛渣采購(gòu)合同范例
- 《2025年日歷》電子版模板年歷月歷工作學(xué)習(xí)計(jì)劃?rùn)M版整年帶農(nóng)歷
- 機(jī)械年終考核述職報(bào)告
- 2024年實(shí)驗(yàn)室保密協(xié)議
評(píng)論
0/150
提交評(píng)論