java登录管理系统_登录 · 陈国基/JAVA管理系统 - Gitee.com

package hospitals;

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.swing.*;

public class denglu extends JFrame {

public static String namew;

public static String user;

public static String user1;

public static String password;

private static final long serialVersionUID=1L;

static jdbc connect=new jdbc();

static java.sql.Connection con=null;

JLabel a=new JLabel("用户名:");

JLabel cuowu=new JLabel("用户名或者密码不对,请重新输入");

JLabel b=new JLabel("密码:");

ImageIcon bj = new ImageIcon("F:/123.jpg");

JLabel label = new JLabel(bj);

JButton c=new JButton("登录");

private boolean flag;

static JTextField d=new JTextField();

static JPasswordField f=new JPasswordField();

denglu(String sTitle){

super(sTitle);

this.setLayout(null);

this.add(cuowu);

this.add(a);

this.add(b);

this.add(c);

this.add(d);

this.add(f);

this.add(label);

cuowu.setBounds(100, 130, 200, 50);

cuowu.setForeground(Color.black);

cuowu.setVisible(false);

label.setBounds(0, -50, 500, 400);

c.addActionListener(new ShowAct());

a.setBounds(10, 10, 100, 50);

a.setFont(new Font("",1,20));

a.setForeground(Color.WHITE);

b.setBounds(10, 90, 100, 50);

b.setForeground(Color.WHITE);

b.setFont(new Font("",1,20));

c.setBounds(20, 180, 100, 50);

c.setBackground(Color.CYAN);

d.setBounds(100, 20, 150, 30);

f.setBounds(100, 100, 150, 30);

this.setSize(400,280); //设置窗口大小

this.setResizable(false); //设置不可调整窗口大小

this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true); //窗口显示

}

public static void main (String args[]){

denglu ts=new denglu("医院管理系统");

}

public class ShowAct implements ActionListener {

public boolean flag=false;

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

try {

String name=d.getText().toString();

String x=f.getText().toString();

con=connect.getConnection();

Statement stmt =con.createStatement();

ResultSet rs=stmt.executeQuery("select * from Hospital_Doctor");

while(rs.next()){

user=rs.getString("DrId");

user1=rs.getString("DrName");

password=rs.getString("DrPhone");

if(user.equals(name)&&password.equals(x)){

this.flag=true;

JOptionPane.showMessageDialog(null, "登录成功");

new mainframe("医院管理系统");

denglu.this.setVisible(false);

break;

}

else{

d.setText("");

f.setText("");

cuowu.setVisible(true);

}

}

} catch (SQLException e2) {

// TODO Auto-generated catch block

System.out.println(e2);

}

}

}

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值