package stums;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import java.util.Date;
import javax.swing.JOptionPane;
import java.text.SimpleDateFormat;
import java.sql.ResultSet;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class MainFrame1 extends JFrame {
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenuItem jMenuItem1 = new JMenuItem();
JMenuItem jMenuItem2 = new JMenuItem();
JMenu jMenu2 = new JMenu();
JMenuItem jMenuItem3 = new JMenuItem();
JMenu jMenu3 = new JMenu();
JMenuItem jmExit = new JMenuItem();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField txtUsername = new JTextField();
JButton btnOk = new JButton();
JButton btnExit = new JButton();
JPasswordField pwdPwd = new JPasswordField();
String ss="";
public MainFrame1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* MainFrame1
*
* @param string String
*/
public void Time(String ss){
}
public MainFrame1(String string) {
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
this.setJMenuBar(jMenuBar1);
setSize(new Dimension(400, 300));
setTitle("Frame Title");
jMenu1.setText("系统");
jMenu1.setEnabled(false);
jMenuItem1.setText("查询");
jMenuItem1.addActionListener(new MainFrame1_jMenuItem1_actionAdapter(this));
jMenuItem2.setText("选课");
jMenuItem2.addActionListener(new MainFrame1_jMenuItem2_actionAdapter(this));
jMenu2.setText("帮助");
jMenu2.setEnabled(false);
jMenuItem3.setText("关于");
jMenuItem3.addActionListener(new MainFrame1_jMenuItem3_actionAdapter(this));
jMenu3.setText("退出");
jMenu3.setEnabled(false);
jmExit.setText("退出");
jmExit.addActionListener(new MainFrame1_jmExit_actionAdapter(this));
jLabel1.setText("用户名");
jLabel1.setBounds(new Rectangle(105, 42, 48, 30));
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(113, 96, 34, 35));
txtUsername.setBounds(new Rectangle(151, 38, 107, 35));
txtUsername.addActionListener(new MainFrame1_txtUsername_actionAdapter(this));
btnOk.setBounds(new Rectangle(96, 173, 82, 36));
btnOk.setText("登陆");
btnOk.addActionListener(new MainFrame1_btnOk_actionAdapter(this));
//btnOk.setEnabled(false);
btnExit.setBounds(new Rectangle(215, 173, 76, 35));
btnExit.setText("退出");
btnExit.addActionListener(new MainFrame1_btnExit_actionAdapter(this));
pwdPwd.setBounds(new Rectangle(151, 92, 106, 35));
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenuBar1.add(jMenu3);
jMenu1.add(jMenuItem1);
jMenu1.add(jMenuItem2);
jMenu2.add(jMenuItem3);
jMenu3.add(jmExit);
contentPane.add(jLabel2);
contentPane.add(btnExit);
contentPane.add(btnOk);
contentPane.add(txtUsername);
contentPane.add(jLabel1);
contentPane.add(pwdPwd);
this.setResizable(false);//控制窗口最大化
}
public void jmExit_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void txtUsername_actionPerformed(ActionEvent e) {
}
public void btnExit_actionPerformed(ActionEvent e) {
System.exit(0);
}
public void btnOk_actionPerformed(ActionEvent e) {
String username="admin";
String pwd="admin";
if(txtUsername.getText().equals(username)&&pwdPwd.getText().equals(pwd))
{
jMenu1.setEnabled(true);
jMenu2.setEnabled(true);
jMenu3.setEnabled(true);
Date objDate=new Date();
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//System.out.println(simple.format(objDate));
ss=simple.format(objDate);
//System.out.println(ss);
try{
ConDB.GetCon();
String s1="update getTime set nowTime='"+ss+"'";
String s2="select nowTime from getTime";
ResultSet rs=ConDB.ExecuteSql(s2);
while(rs.next())
{
JOptionPane.showMessageDialog(this,"您上次登录时间是:"+rs.getString(1),"提示信息",JOptionPane.INFORMATION_MESSAGE);
}
ConDB.UpdateDB(s1);
//JOptionPane.showMessageDialog(this,"已经记录当前时间");
}catch(Exception ee)
{
ee.printStackTrace();
}
//System.out.println("sth");
MainPanel1 mp1=new MainPanel1();
this.remove(this.getContentPane());
this.setContentPane(mp1);
this.show();
}else
{
JOptionPane.showMessageDialog(this,"用户名或密码错误","错误",JOptionPane.ERROR_MESSAGE);
txtUsername.setText("");
pwdPwd.setText("");
txtUsername.requestFocus();//获得焦点
}
}
public void jMenuItem1_actionPerformed(ActionEvent e) {
PanelQuery pq1=new PanelQuery();
this.remove(this.getContentPane());
this.setContentPane(pq1);
this.show();
}
public void jMenuItem2_actionPerformed(ActionEvent e) {
PanelChoose pc1=new PanelChoose();
this.remove(this.getContentPane());
this.setContentPane(pc1);
this.show();
}
public void jMenuItem3_actionPerformed(ActionEvent e) {
AboutDialog ad=new AboutDialog();
ad.setTitle("关于本软件");
ad.setBounds(new Rectangle(500, 250, 200, 160));
//ad.setSize(400,300);
ad.setVisible(true);
}
}
class MainFrame1_jMenuItem3_actionAdapter implements ActionListener {
private MainFrame1 adaptee;
MainFrame1_jMenuItem3_actionAdapter(MainFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem3_actionPerformed(e);
}
}
class MainFrame1_jMenuItem1_actionAdapter implements ActionListener {
private MainFrame1 adaptee;
MainFrame1_jMenuItem1_actionAdapter(MainFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem1_actionPerformed(e);
}
}
class MainFrame1_jMenuItem2_actionAdapter implements ActionListener {
private MainFrame1 adaptee;
MainFrame1_jMenuItem2_actionAdapter(MainFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuItem2_actionPerformed(e);
}
}
class MainFrame1_btnOk_actionAdapter implements ActionListener {
private MainFrame1 adaptee;
MainFrame1_btnOk_actionAdapter(MainFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnOk_actionPerformed(e);
}
}
class MainFrame1_btnExit_actionA