📄 dialogkit.java
字号:
package bookmanager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.*;
import java.util.Vector;
public class dialogkit {//控制类
Statement s;
ResultSet rs;
dbconnection db=new dbconnection();
public dialogkit() {
try {
jbInit();
s = db.getconnection().createStatement();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/******************查询满足条件的读者资料信息*************************************/
public Vector dialogread(String u)
{
Vector vvr=new Vector();
try {
rs = s.executeQuery("select * from readinfo where readid='"+u+"'");
while (rs.next()) {
Vector vt=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
vt.add(rs.getString(i));
}
vvr.add(vt);
}
} catch (SQLException ex) {
}
return vvr;
}
/****************************查询所有读者资料信息********************************/
public Vector dialogll()
{
Vector vvr=new Vector();
try {
rs = s.executeQuery("select * from readinfo");
while (rs.next()) {
Vector vt=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
vt.add(rs.getString(i));
}
vvr.add(vt);
}
} catch (SQLException ex) {
}
return vvr;
}
/************************查询所有用户表的信息**********************************/
public ArrayList dialog()
{
ArrayList list=new ArrayList();
try {
rs = s.executeQuery("select * from userinfo");
while (rs.next()) {
userinfo user=new userinfo();
user.setusername(rs.getString(1));
user.setpwd(rs.getString(2));
list.add(user);
}
} catch (SQLException ex) {
}
return list;
}
/******************判断用户名和密码是否正确**************************************/
public boolean ifusernamepwd(String user,String pwd)
{
try {
rs = s.executeQuery("select * from userinfo where username='" +
user + "' and pwd='" + pwd + "'");
int i=0;
while(rs.next())
{
i++;
}
if(i==0)
return false;
} catch (SQLException ex) {
}
return true;
}
/**********************判断用户修改密码是否正确********************************/
public boolean ifusernamepwd(String pwd)
{
try {
rs = s.executeQuery("select * from userinfo where pwd='" + pwd + "'");
int i=0;
while(rs.next())
{
i++;
}
if(i==0)
return false;
} catch (SQLException ex) {
}
return true;
}
/*************************更新密码******************************************/
public void update(String str1,String str3)
{
try {
s.executeUpdate("update userinfo set pwd='" + str1 + "'" +
" where username='" + str3 + "'");
} catch (SQLException ex) {
}
}
/***********************查询有此编号的所有图书信息*******************************/
public Vector vectornum(String a)
{
Vector vv=new Vector();
try {
rs = s.executeQuery("select * from bookinfo where bookid='"+a+"'");
while(rs.next())
{
Vector v=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
v.add(rs.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
/************************根据图书名称进行模糊查询*******************************/
public Vector vectornumj(String ef)
{
Vector vv=new Vector();
try {
rs = s.executeQuery("select * from bookinfo where bookname like '%"+ef+"%'");
while(rs.next())
{
Vector v=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
v.add(rs.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
/*********************************根据图书作者进行模糊查询***********************/
public Vector vectornumber(String b)
{
Vector vv=new Vector();
try {
rs = s.executeQuery("select * from bookinfo where bookautor like '%"+b+"%'");
while(rs.next())
{
Vector v=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
v.add(rs.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
/********************根据出版社进行模糊查询*************************************/
public Vector vectornumb(String c)
{
Vector vv=new Vector();
try {
rs = s.executeQuery("select * from bookinfo where bookwhere like '%"+c+"%'");
while(rs.next())
{
Vector v=new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
v.add(rs.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
/***************************插入图书入库的记录**********************************/
public int ifreadture(bookinfo b)
{
int i=0;
try {
String tr = "insert into bookinfo(bookid,bookname,bookautor,bookbalance,bookwhere,booktime,booknotes,outtime,onoutctrl) values('"
+ b.getbookid() + "','" + b.getbookname() + "','" + b.getbookautor() + "'," + b.getbookbalance() + ",'" +
b.getbookwhere() + "','" + b.getbooktime() + "'," + b.getbooknotes() + ",'" + b.getouttime() + "','" +
b.getonoutctrl() + "')";
i=s.executeUpdate(tr);
} catch (SQLException ex) {
}
return i;
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -