📄 sysconfig.java~144~
字号:
package client;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import server.io.Userio;
import server.dao.Userdao;
import java.util.Vector;
public class Sysconfig extends JPanel{
//变量的定义
JPanel sysconfigpnl = new JPanel();
JPanel config1 = new JPanel();
JPanel config2 = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField txfsysconfigsuperuserpwd = new JTextField();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JButton btnuserok = new JButton();
JLabel jLabel4 = new JLabel();
JComboBox cobuserid = new JComboBox();
JTextField txfuserpwd = new JTextField();
Vector vctpwd=new Vector();
int temp=0;
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JTextField txfmaxcdoutdate = new JTextField();
JTextField txfmaxcdoutnum = new JTextField();
JTextField txfforfei = new JTextField();
JButton jButton1 = new JButton();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
String maxcdoutdate="";
String maxcdoutnum="";
String cdoutforfei="";
public Sysconfig() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(null);
sysconfigpnl.setBorder(BorderFactory.createEtchedBorder());
sysconfigpnl.setInputVerifier(null);
sysconfigpnl.setBounds(new Rectangle(115, 60, 570,310));
sysconfigpnl.setLayout(null);
config1.setBorder(BorderFactory.createEtchedBorder());
config1.setBounds(new Rectangle(17, 47, 259, 229));
config1.setLayout(null);
config2.setBorder(BorderFactory.createEtchedBorder());
config2.setBounds(new Rectangle(292, 47, 259, 229));
config2.setLayout(null);
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel1.setText("管理员密码:");
jLabel1.setBounds(new Rectangle(21, 105, 153, 30));
txfsysconfigsuperuserpwd.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
txfsysconfigsuperuserpwd.setHorizontalAlignment(SwingConstants.LEFT);
txfsysconfigsuperuserpwd.setText("");
txfsysconfigsuperuserpwd.setBounds(new Rectangle(21, 62, 210, 27));
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel2.setText("业务设置:");
jLabel2.setBounds(new Rectangle(292, 14, 117, 34));
jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel3.setText("帐户设置:");
jLabel3.setBounds(new Rectangle(21, 14, 117, 34));
btnuserok.setBounds(new Rectangle(162, 189, 81, 27));
btnuserok.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
btnuserok.setToolTipText("");
btnuserok.setText("确 定");
btnuserok.addActionListener(new Sysconfig_btnuserok_actionAdapter(this));
jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel4.setText("超级管理员密码:");
jLabel4.setBounds(new Rectangle(21, 20, 153, 30));
cobuserid.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
cobuserid.setBounds(new Rectangle(21, 145, 91, 25));
cobuserid.addActionListener(new Sysconfig_cobuserid_actionAdapter(this));
txfuserpwd.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
txfuserpwd.setText("");
txfuserpwd.setBounds(new Rectangle(133, 145, 91, 25));
jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel5.setText("最大借阅天数:");
jLabel5.setBounds(new Rectangle(23, 21, 95, 31));
jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel6.setText("最大借阅张数:");
jLabel6.setBounds(new Rectangle(23, 80, 95, 31));
jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel7.setText("超期罚款");
jLabel7.setBounds(new Rectangle(23, 139, 57, 31));
jLabel8.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel8.setText("元/每天");
jLabel8.setBounds(new Rectangle(186, 139, 50, 33));
txfmaxcdoutdate.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
txfmaxcdoutdate.setBounds(new Rectangle(123, 22, 81, 29));
txfmaxcdoutnum.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
txfmaxcdoutnum.setBounds(new Rectangle(123, 81, 81, 29));
txfforfei.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
txfforfei.setBounds(new Rectangle(82, 140, 94, 29));
jButton1.setBounds(new Rectangle(166, 184, 78, 27));
jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jButton1.setText("确 定");
jButton1.addActionListener(new Sysconfig_jButton1_actionAdapter(this));
jLabel9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel9.setText("天");
jLabel9.setBounds(new Rectangle(210, 23, 26, 26));
jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12));
jLabel10.setText("张");
jLabel10.setBounds(new Rectangle(210, 82, 26, 26));
config1.add(txfsysconfigsuperuserpwd);
config1.add(btnuserok);
config1.add(jLabel4);
config1.add(cobuserid);
config1.add(txfuserpwd);
config1.add(jLabel1);
sysconfigpnl.add(config2);
config2.add(jButton1);
config2.add(txfforfei);
config2.add(txfmaxcdoutdate);
config2.add(jLabel6);
config2.add(txfmaxcdoutnum);
config2.add(jLabel7);
config2.add(jLabel5);
config2.add(jLabel8);
config2.add(jLabel9);
config2.add(jLabel10);
sysconfigpnl.add(jLabel3);
sysconfigpnl.add(jLabel2);
sysconfigpnl.add(config1);
this.add(sysconfigpnl);
//初始化超级用户密码
txfsysconfigsuperuserpwd.setText(Userio.getsuperuserpwd());
//初始化用户名
Vector userid=new Userdao().getallusername();
for(int i=0;i<userid.size();i++)
{cobuserid.addItem(userid.elementAt(i));}
//初始化用户密码
vctpwd=new Userdao().getalluserpwd();
txfuserpwd.setText(vctpwd.elementAt(0).toString());
//初始化业务参数
txfmaxcdoutdate.setText(server.entity.Sysconfig.getcdoutdate()+"");
txfmaxcdoutnum.setText(server.entity.Sysconfig.getcdoutmaxnum()+"");
txfforfei.setText(server.entity.Sysconfig.getforfei()+"");
//得到原始数据
maxcdoutdate=txfmaxcdoutdate.getText().trim();
maxcdoutnum=txfmaxcdoutnum.getText().trim();
cdoutforfei=txfforfei.getText().trim();
}
//系统帐户按钮动作
public void btnuserok_actionPerformed(ActionEvent e) {
//保存当前的值
Userio.setsuperuserpwd(txfsysconfigsuperuserpwd.getText());
new Userdao().setuserpwd(cobuserid.getSelectedItem().toString(),txfuserpwd.getText());
//信息提示
JOptionPane.showMessageDialog(this,"保存完成!","提示",JOptionPane.INFORMATION_MESSAGE);
}
//显示相应的密码
public void cobuserid_actionPerformed(ActionEvent e) {
//先判断以避免每次读取数据库
if(temp==0)
{vctpwd=new Userdao().getalluserpwd();}
temp=1;
txfuserpwd.setText(vctpwd.elementAt(cobuserid.getSelectedIndex()).toString());
}
//设置业务参数
public void jButton1_actionPerformed(ActionEvent e) {
try{
server.entity.Sysconfig.setcdoutdate(Integer.parseInt(txfmaxcdoutdate.getText()));
server.entity.Sysconfig.setcdoutmaxnum(Integer.parseInt(txfmaxcdoutnum.getText()));
server.entity.Sysconfig.setforfei(Float.parseFloat(txfforfei.getText()));
new JOptionPane().showMessageDialog(this,"保存完毕。","提示",JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception ex)
{
//还原数据
txfmaxcdoutdate.setText(maxcdoutdate);
txfmaxcdoutnum.setText(maxcdoutnum);
txfforfei.setText(cdoutforfei);
new JOptionPane().showMessageDialog(this,"保存错误!","警告!",JOptionPane.WARNING_MESSAGE);
}
}
}
//监听器
class Sysconfig_btnuserok_actionAdapter implements ActionListener {
private Sysconfig adaptee;
Sysconfig_btnuserok_actionAdapter(Sysconfig adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnuserok_actionPerformed(e);
}
}
class Sysconfig_cobuserid_actionAdapter implements ActionListener {
private Sysconfig adaptee;
Sysconfig_cobuserid_actionAdapter(Sysconfig adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.cobuserid_actionPerformed(e);
}
}
class Sysconfig_jButton1_actionAdapter implements ActionListener {
private Sysconfig adaptee;
Sysconfig_jButton1_actionAdapter(Sysconfig adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -