📄 readersystempanel.java
字号:
int size = 0;
try {
while (dh.rs.next())
size++;
date = new Object[size][title.length];
boolean a = dh.rs.first();
for (int i = 0; a; i++) {
date[i][0] = dh.rs.getString(1).trim();
date[i][1] = dh.rs.getString(2).trim();
date[i][2] = dh.rs.getString(3).trim();
date[i][3] = dh.rs.getString(4).trim();
date[i][4] = dh.rs.getString(5).trim();
date[i][5] = dh.rs.getString(6).trim();
date[i][6] = "" + dh.rs.getBoolean(7);
date[i][7] = "" + dh.rs.getInt(8);
date[i][8] = dh.rs.getString(9).trim();
date[i][9] = dh.rs.getString(10).trim();
a = dh.rs.next();
}
DefaultTableModel model = new DefaultTableModel(date, title);
jta.setModel(model);
jta.updateUI();
} catch (SQLException ex) {
System.out.println(ex.toString());
}
dh.myClose(1);
}
public void btnW_actionPerformed(ActionEvent e) {
shuaxin(radearjTable, 0);
}
public void btnY_actionPerformed(ActionEvent e) {
shuaxin(radearjTable, 1);
}
//生成读者编号
public void readerNumber()
{
String sNum = "";
String num1 = "";
int num = 0;
String sql = "select top 1 readerID from readerInfo order by id desc";
dh.search(sql);
try {
if (dh.rs.next()) {
sNum = dh.rs.getString(1);
try {
num = Integer.parseInt(sNum.substring(2).trim())+1;
} catch (RuntimeException ex) {
System.out.println(ex.toString());
}
num1=""+num;
}else
num1 = "000001";
while(num1.length()<6)
num1="0"+num1;
} catch (SQLException ex) {
System.out.println(ex.toString());
}
dh.myClose(1);
int i=0;
char a='A';
while(i<ztype.length){
if (jtxType1.getSelectedIndex() == i)
{
a=(char)((int)a+i);
xnum=a+"0"+num1;
break;
}
i++;
}
jtxNum1.setText(xnum);
}
public void jtxNum1_mouseClicked(MouseEvent e) {
readerNumber();
yajingShow();
}
private void banzheng()
{
String bgtime = jtxDangqianTime.getText().trim();
String add = jtxAdd1.getText().trim();
String tel = jtxTelphone1.getText();
String zhengjian = jtxZhengjian1.getSelectedItem().toString().trim();
String name = jtxName1.getText().trim();
String type = jtxType1.getSelectedItem().toString().trim();
String zhengjianNum = jtxZhengjianNum1.getText().trim();
String sex;
if (jRadioButton2.isSelected())
sex = jRadioButton2.getText().trim();
else
sex = jRadioButton1.getText().trim();
if(name.equals(""))
JOptionPane.showMessageDialog(null, "姓名不能为空!!!","用户名错误",JOptionPane.ERROR_MESSAGE);
else
if(zhengjianNum.equals(""))
JOptionPane.showMessageDialog(null, "证件号码不能为空!!!","证件号码错误",JOptionPane.ERROR_MESSAGE);
else{
//提示输入押金
JOptionPane.showInputDialog(null,
"请支付办证的押金: " + yj + "\n并输入其金额交费的金额",
"" + yj);
String sql = "insert into readerInfo (readerID,readerName,readerSex,readerTypeName,beginTime, beginHandlers,state,certificateName,certificateNum,readerAddress,readerTelephone) values(?,?,?,?,default,?,default,?,?,?,?)";
PreparedStatement pstmt = null;
try {
pstmt = dh.conn.prepareStatement(sql);
pstmt.setString(1, xnum);
pstmt.setString(2, name);
pstmt.setString(3, sex);
pstmt.setString(4, type);
// pstmt.setString(5, SystemFrame1.dateTime);
pstmt.setString(5, SystemFrame1.login);
pstmt.setString(6, zhengjian);
pstmt.setString(7, zhengjianNum);
pstmt.setString(8, add);
pstmt.setString(9, tel);
if (dh.add(pstmt)) {
JOptionPane.showMessageDialog(null, "添加成功");
qingkong();
} else
JOptionPane.showMessageDialog(null, "添加失败");
} catch (SQLException ex) {
System.out.println(ex.toString());
}
dh.myClose(1);
}
}
public void jButton2_actionPerformed(ActionEvent e) {
banzheng();
}
public void jtxType1_itemStateChanged(ItemEvent e) {
readerNumber();
yajingShow();
}
public void jScrollPane1_componentResized(ComponentEvent e) {
radearjTable.setSize(jScrollPane1.getWidth(),jScrollPane1.getHeight());
}
public void inputReaderNum(JTextField a,JTextArea b)
{
String bianhao="";
try {
bianhao= JOptionPane.showInputDialog(null,"请输入读者编号 例如 ","A0000001").trim();
} catch (Exception ex) {
// JOptionPane.showMessageDialog(null, "你没有输入读者信息");
}
if(!bianhao.equals("")){
if ((int)bianhao.charAt(0)>='A' && (int)bianhao.charAt(0) <= 'Z' )
{
a.setText(""+bianhao);
borrowBooksNum(a, b);
}
}
}
//点击查询读者的借书数量
public void borrowBooksNum(JTextField a,JTextArea b)
{
String bianhao = "";
if (!a.getText().trim().equals(""))
bianhao = a.getText().trim();
String snum = "";
int num=0;
String readerTypeNameTemp = "";
if ((int)bianhao.charAt(0)>='A' && (int)bianhao.charAt(0) <= 'Z' ) {
Dbcom readerDB = new Dbcom();
ResultSet rs = null;
//查询读者的借书数量
String sql =
"select borrowBooksNum,readerTypeName from readerInfo where readerID='" +
bianhao + "'";
rs = readerDB.search(sql);
try {
if (rs.next()) {
snum = rs.getString(1);
if (snum == null)
snum="0";
num = Integer.parseInt(snum);
isReader = true;
} else
JOptionPane.showMessageDialog(null, "此读者不存在,请核对借阅证!!!", "错误",
JOptionPane.ERROR_MESSAGE);
} catch (SQLException ex) {
System.out.println(ex.toString());
}
if(num>0)
b.setText(" 该用户还有 " + num + " 本书没有归还") ;
readerDB.myClose(1);
}
}
public void jtxReaderNumY_mouseClicked(MouseEvent e) {
inputReaderNum(jtxReaderNumY,jlbMassageY);
}
public void jtxReaderNumZ_mouseClicked(MouseEvent e) {
inputReaderNum(jtxReaderNumZ,jlbMassage);
}
public void jTpRightBottomjPanel1_componentResized(ComponentEvent e) {
if(jTpRightBottomjPanel1.getWidth()/2-350>0 )
{
if (jTpRightBottomjPanel1.getWidth() / 2 - 350 < 150) {
if ((jTpRightBottomjPanel1.getHeight() - 238) > 2) {
int a=(jTpRightBottomjPanel1.getHeight()-238)/2;
jPanelleftJ.setBounds((jTpRightBottomjPanel1.getWidth()/2-347)/2,a, 347, 238);
jPanelRigthJ.setBounds(jTpRightBottomjPanel1.getWidth() / 2+(jTpRightBottomjPanel1.getWidth() /2-347)/2,a, 347, 238);
}
else
{
jPanelleftJ.setBounds((jTpRightBottomjPanel1.getWidth()/2-347)/2,1, 347, 238);
jPanelRigthJ.setBounds(jTpRightBottomjPanel1.getWidth() / 2+(jTpRightBottomjPanel1.getWidth() /2-347)/2,1, 347, 238);
}
}
else
{
if ((jTpRightBottomjPanel1.getHeight() - 238) > 2)
{
jPanelleftJ.setBounds(110,(jTpRightBottomjPanel1.getHeight() - 238)/2, 347, 238);
jPanelRigthJ.setBounds(560,(jTpRightBottomjPanel1.getHeight() - 238)/2, 347, 238);
}
else
{
jPanelleftJ.setBounds(110,1, 347, 238);
jPanelRigthJ.setBounds(560,1, 347, 238);
}
}
}
}
public void jTpRightBottomjPanel2_componentResized(ComponentEvent e) {
if(jTpRightBottomjPanel2.getWidth()*2/5-320>0 )
{
if (jTpRightBottomjPanel2.getWidth() / 2 - 320 < 200) {
if ((jTpRightBottomjPanel2.getHeight() - 240) > 2) {
int a=(jTpRightBottomjPanel2.getHeight()-240)/2;
jPanelLeftY.setBounds((jTpRightBottomjPanel2.getWidth()*2/5-320)/2,a, 320, 240);
jPanelRigthY.setBounds(jTpRightBottomjPanel2.getWidth()*2/5+(jTpRightBottomjPanel2.getWidth()*2/5-320)/2,a, 480, 240);
}
else
{
jPanelLeftY.setBounds((jTpRightBottomjPanel2.getWidth()*2/5-320)/2,1, 320, 240);
jPanelRigthY.setBounds(jTpRightBottomjPanel2.getWidth()*2/5 +(jTpRightBottomjPanel2.getWidth()*2/5-325)/2,1, 480, 240);
}
}
else
{
if ((jTpRightBottomjPanel2.getHeight() - 240) > 2)
{
jPanelLeftY.setBounds(70,(jTpRightBottomjPanel2.getHeight() - 240)/2, 320, 240);
jPanelRigthY.setBounds(470,(jTpRightBottomjPanel2.getHeight() - 240)/2, 480, 240);
}
else
{
jPanelLeftY.setBounds(70,1, 320, 240);
jPanelRigthY.setBounds(470,1, 480, 240);
}
}
}
}
public void jTpRightBottomjPanel3_componentResized(ComponentEvent e) {
if(jTpRightBottomjPanel3.getWidth()*2/5-320>0 )
{
if (jTpRightBottomjPanel3.getWidth() / 2 - 320 < 200) {
if ((jTpRightBottomjPanel3.getHeight() - 240) > 2) {
int a=(jTpRightBottomjPanel3.getHeight()-240)/2;
jPanelLeft1.setBounds((jTpRightBottomjPanel3.getWidth()*2/5-320)/2,a, 320, 240);
jPanelRigth1.setBounds(jTpRightBottomjPanel3.getWidth()*2/5+(jTpRightBottomjPanel3.getWidth()*2/5-320)/2,a, 480, 240);
}
else
{
jPanelLeft1.setBounds((jTpRightBottomjPanel3.getWidth()*2/5-320)/2,1, 320, 240);
jPanelRigth1.setBounds(jTpRightBottomjPanel3.getWidth()*2/5 +(jTpRightBottomjPanel3.getWidth()*2/5-325)/2,1, 480, 240);
}
}
else
{
if ((jTpRightBottomjPanel3.getHeight() - 240) > 2)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -