📄 searchbean.java
字号:
package dbBean;
import java.sql.ResultSet;
import dbBean.dbConnection;
public class searchBean
{
public void initSearch(int Book_type_ID,String Book_name,String author,String Translator,String Publish_house,String ISBN,String Congshu_name)//,int storage)
{
this.Book_type_ID=Book_type_ID;
this.Book_name=Book_name;
this.author=author;
this.Translator=Translator;
this.Publish_house=Publish_house;
this.ISBN=ISBN;
this.Congshu_name=Congshu_name;
this.storage=storage;
}
public void initSearch(String email,String User_name,String Birthday,String i)
{
this.email=email;
this.User_name=User_name;
this.Birthday=Birthday;
this.Sex=Integer.parseInt(i);
if(email=="")
{
this.email=null;
}
if(User_name=="")
{
this.User_name=null;
}
if(Birthday=="")
{
this.Birthday=null;
}
}
public ResultSet SearchUser(String user,String psw)
{
System.out.println(Birthday);
dbConnection dbConn=new dbConnection();
dbConn.getConnect("bookshop", user, psw);
String sql="select * from Consumer where ";
//+" and Book_name='"+Book_name+"'"+" and author='"+author+"'"+" and Translator='"+Translator+"'"+" and Publish_house='"+Publish_house+"'"+" and ISBN='"+ISBN+"'"+" and Storage_num>0";
// String sql="select * from Book where Book_name like '"+Book_name+"'";
if(email!=null)
{
sql=sql+" Emails='"+email+"'" ;
}
if(User_name!=null)
{
if(email!=null)
sql=sql+" and User_name='"+User_name+"'";
else
sql=sql+"User_name='"+User_name+"'";
}
if(Birthday!=null)
{
if(User_name!=null)
sql=sql+" and Birthday='"+Birthday+"'";
else
sql=sql+"Birthday='"+Birthday+"'";
}
if(Sex==1)
{if(Birthday!=null)
sql=sql+" and sex='man'";
else
sql=sql+" sex='man'";
}
if(Sex==0)
{
if(Birthday!=null)
sql=sql+" and sex='woman'";
else
sql=sql+" sex='woman'";
}
System.out.println(sql);
ResultSet rs=dbConn.selectSql(sql);
return rs;
}
public ResultSet SearchBook()
{
//任何人都可以查询,则USER设置为everyUser
dbConnection dbConn=new dbConnection();
dbConn.getConnect("bookshop", "user", "123");
String sql="select * from Book where Book_type_ID="+Book_type_ID;
//+" and Book_name='"+Book_name+"'"+" and author='"+author+"'"+" and Translator='"+Translator+"'"+" and Publish_house='"+Publish_house+"'"+" and ISBN='"+ISBN+"'"+" and Storage_num>0";
// String sql="select * from Book where Book_name like '"+Book_name+"'";
if(Book_name!="")
{
sql=sql+" and Book_name='"+Book_name+"'" ;
}
if(author!="")
{
sql=sql+" and author='"+author+"'";
}
if(Translator!="")
{
sql=sql+" and Translator='"+Translator+"'";
}
if(Publish_house!="")
{
sql=sql+" and Publish_house='"+Publish_house+"'";
}
if(ISBN!="")
{
sql=sql+" and ISBN='"+ISBN+"'";
}
/** if(storage==1)
{
sql=sql+" and Storage_num>0";
}
**/
System.out.println(sql);
ResultSet rs=dbConn.selectSql(sql);
return rs;
}
private int Book_type_ID;
private String Book_name;
private String author;
private String Translator;
private String Publish_house;
private String ISBN;
private String Congshu_name;
private int storage;
private String email;
private String User_name;
private String Birthday;
private int Sex;
//private dbConnection dbConn;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -