ImageVerifierCode 换一换
格式:DOCX , 页数:32 ,大小:21.76KB ,
资源ID:4423504      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/4423504.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(能源管理系统源代码.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

能源管理系统源代码.docx

1、能源管理系统源代码登陆界面的源代码package loginframe;import java.awt.BorderLayout;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.sql.Statement;import java

2、.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import java.awt.GridBagConstraints;import java.awt.Insets;impo

3、rt javax.swing.JPasswordField;import mainmenu.mainFrame;public class login extends JFrame implements ActionListener /* * */ private static final long serialVersionUID = 1L; private Connection con = null; Statement stmt = null; private ResultSet r = null; private JLabel idlabel = new JLabel(ID ); pri

4、vate JTextField id = new JTextField(10); private JLabel pwdlabel = new JLabel(密码 ); private JPasswordField pwd = new JPasswordField(10); private JButton commit = new JButton(登陆); private String command = null; public login() setTitle(能源管理系统); setSize(236, 248); addWindowListener(new WindowAdapter()

5、public void windowClosing(WindowEvent e) System.exit(0); ); getContentPane().setLayout(new GridBagLayout(); JPanel jp1 = new JPanel(); GridBagConstraints gbc_jp1 = new GridBagConstraints(); gbc_jp1.anchor = GridBagConstraints.SOUTHEAST; gbc_jp1.insets = new Insets(0, 0, 5, 0); gbc_jp1.gridx = 0; gbc

6、_jp1.gridy = 0; getContentPane().add(jp1, gbc_jp1); jp1.add(idlabel); jp1.add(id); JPanel jp2 = new JPanel(); jp2.add(pwdlabel); jp2.add(pwd); JPanel jp9 = new JPanel(); jp9.setLayout(new GridLayout(3, 1); jp9.add(jp2); JPanel jp10 = new JPanel(); jp10.setLayout(new BorderLayout(); jp10.add(West, jp

7、9); jp9.add(commit); commit.addActionListener(this); GridBagConstraints gbc_jp10 = new GridBagConstraints(); gbc_jp10.insets = new Insets(0, 0, 5, 0); gbc_jp10.gridx = 0; gbc_jp10.gridy = 1; getContentPane().add(jp10, gbc_jp10); try String url = jdbc:sqlserver:/localhost:1433;databaseName=energy_man

8、agement;integratedSecurity=true; Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); System.out.println(驱动程序已装载); System.out.println(即将连接数据库); con = DriverManager.getConnection(url, sa, 123456); System.out.println(load ok); stmt = con.createStatement(); catch (Exception ex) System.out.print

9、ln(ex.getMessage(); public void actionPerformed(ActionEvent evt) try String uid = id.getText().trim(); String upwd = pwd.getText(); String c1 = like + uid + ; String c2 = like + upwd + ; command = select * + from manager_info + where id + c1 + and password + c2; r = stmt.executeQuery(command); if (u

10、id.length() != 0 | upwd.length() != 0) if (r.next() JOptionPane.showMessageDialog(commit, 登陆成功, 提示, JOptionPane.INFORMATION_MESSAGE); mainFrame mf = new mainFrame(); mf.showf(); setVisible(false); else JOptionPane.showMessageDialog(commit, ID或者密码错误, 警告, JOptionPane.ERROR_MESSAGE); else JOptionPane.s

11、howMessageDialog(commit, ID或者密码不能为空, 警告, JOptionPane.ERROR_MESSAGE); catch (Exception ex) System.out.println(ex.getMessage(); public static void main(String args) JFrame myframe = new login(); myframe.setVisible(true); 操作界面源代码package mainmenu;import java.awt.Container;import java.awt.event.ActionEve

12、nt;import java.awt.event.ActionListener;import java.awt.event.InputEvent;import java.awt.event.KeyEvent;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JToolBar;im

13、port javax.swing.KeyStroke;import consume_query.Queryconsume;import price_management.queryprice;import price_management.updateprice;import user_info_insert.insert_user_information;import user_info_insert.user_info_delete;import user_record_insert.insert_user_record;import loginframe.login;public cla

14、ss mainFrame extends JFrame public mainFrame() /* * */ private static final long serialVersionUID = 1L; public static final int h = 200; public static final int w = 370; JFrame mainframe; public void showf() mainframe = new JFrame(); mainframe.setTitle(管理员操作); mainframe.setSize(500, 130); mainframe.

15、setResizable(true); meaushow(); showtool(); mainframe.show(); public void meaushow() JMenuBar meaubar = new JMenuBar(); JMenu file = new JMenu(文件); JMenuItem logout = new JMenuItem(注销, L); JMenuItem exit = new JMenuItem(退出, E); JMenu help = new JMenu(帮助); JMenuItem about = new JMenuItem(关于, A); logo

16、ut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK); exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK); about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK); logout.addActionListener(new ActionListener() Override pub

17、lic void actionPerformed(ActionEvent e) mainframe.setVisible(false); login myframe = new login(); myframe.setVisible(true); / TODO Auto-generated method stub ); exit.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) System.exit(0);/ TODO Auto-generated method

18、 stub ); about.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) JOptionPane.showMessageDialog(mainframe, 这是一个能源管理收费系统,关于, JOptionPane.INFORMATION_MESSAGE); ; ); meaubar.add(file); meaubar.add(help); file.add(logout); file.add(exit); help.add(about); mainfram

19、e.setJMenuBar(meaubar); public void showtool() JToolBar toolbar = new JToolBar(); JButton l1 = new JButton(用户信息录入); JButton l2 = new JButton(价格查询); JButton l3 = new JButton(价格更改); JButton l4 = new JButton(用户记录信息录入); JButton l5 = new JButton(收费查询); JButton l6 = new JButton(删除用户); toolbar.add(l1); too

20、lbar.add(l2); toolbar.add(l3); toolbar.add(l4); toolbar.add(l5); toolbar.add(l6); Container contentpane = mainframe.getContentPane(); contentpane.add(toolbar); l1.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) JFrame myframe = new insert_user_information()

21、; myframe.setVisible(true); / TODO Auto-generated method stub ); l2.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) JFrame myframe = new queryprice(); myframe.setVisible(true); / TODO Auto-generated method stub ); l3.addActionListener(new ActionListener() O

22、verride public void actionPerformed(ActionEvent e) JFrame myframe = new updateprice(); myframe.setVisible(true); / TODO Auto-generated method stub ); l4.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) JFrame myframe = new insert_user_record(); myframe.setVi

23、sible(true); / TODO Auto-generated method stub ); l5.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) JFrame myframe = new Queryconsume(); myframe.setVisible(true); / TODO Auto-generated method stub ); l6.addActionListener(new ActionListener() Override publi

24、c void actionPerformed(ActionEvent e) JFrame mFrame=new user_info_delete(); mFrame.setVisible(true); / TODO Auto-generated method stub ); public static void main(String args) mainFrame mf = new mainFrame(); mf.showf(); 各个操作的源代码:(1)录入用户基本信息:package user_info_insert;import java.awt.BorderLayout;import

25、 java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Statement;import java.sql.Connection;import java.sql.DriverManager;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swi

26、ng.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class insert_user_information extends JFrame implements ActionListener /* * */ private static final long serialVersionUID = 1L; private Connection con = null; Statement stmt = null; privat

27、e JLabel Title = new JLabel(请输入新用户的信息, SwingConstants.CENTER); private JLabel idlabel = new JLabel(用户ID ); private JTextField id = new JTextField(15); private JLabel namelabel = new JLabel(姓名 ); private JTextField name = new JTextField(15); private JLabel sexlabel = new JLabel(性别 ); private JTextFie

28、ld sex = new JTextField(15); private JLabel addresslabel = new JLabel(家庭地址); private JTextField address = new JTextField(15); private JLabel telephonelabel = new JLabel(电话 ); private JTextField telephone = new JTextField(15); private JLabel workplacelabel = new JLabel(工作地点); private JTextField workp

29、lace = new JTextField(15); private JLabel departmentlabel = new JLabel(部门 ); private JTextField department = new JTextField(15); private JLabel remarklabel = new JLabel(备注 ); private JTextField remark = new JTextField(15); private JButton commit = new JButton(提交); public insert_user_information() setTitle(用户

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1