📄 usercondb.java~49~
字号:
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (!Id.equals("") && Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Id = '" + Id +
"' and Popedom = '" + Popedom + "'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (Id.equals("") && !Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Name = '" + Name +
"' and Popedom = '" + Popedom + "'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (!Id.equals("") && !Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Id = '" + Id +
"' and Name = '" + Name + "' and Popedom = '" +
Popedom + "'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
}
}
else
{
if (!Id.equals("") && Name.equals("") && Popedom.equals("")) {
try {
String str = "select * from Operator where Id like '%" + Id +
"%'";
rs = st.executeQuery(str);
while (rs.next())
{
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (Id.equals("") && !Name.equals("") && Popedom.equals("")) {
try {
String str = "select * from Operator where Name like '%" + Name +
"%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (Id.equals("") && Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Popedom like '%" +
Popedom + "%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (!Id.equals("") && !Name.equals("") && Popedom.equals("")) {
try {
String str = "select * from Operator where Id like '%" + Id +
"%' and Name like '%" + Name + "%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (!Id.equals("") && Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Id like '%" + Id +
"%' and Popedom like '%" + Popedom + "%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (Id.equals("") && !Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Name like '%" + Name +
"%' and Popedom like '%" + Popedom + "%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i<=rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
} else if (!Id.equals("") && !Name.equals("") && !Popedom.equals("")) {
try {
String str = "select * from Operator where Id like '%" + Id +
"%' and Name like '%" + Name + "%' and Popedom like '%" +
Popedom + "%'";
rs = st.executeQuery(str);
while (rs.next()) {
Vector tempvt = new Vector();
for(int i=1;i <= rs.getMetaData().getColumnCount();i++)
{
if(i!=4)
tempvt.add(rs.getString(i));
}
vt.add(tempvt);
}
rs.close();
} catch (SQLException ex) {
}
}
}
return vt;
}
public boolean UpdateUser(String Id, String Password, String Popedom, String Name, String Sex,
String BirthTime, String IdentityCard, String Tel, String Address, String Remark)
{
boolean Success = true;
try {
String strSQL = "update Operator set Password = '" + Password +
"', Popedom = '" + Popedom +
"', Name = '" + Name + "', Sex = '" + Sex +
"', BirthTime = '" + BirthTime +
"', IdentityCard = '" + IdentityCard + "', Tel = '" +
Tel + "', Address = '" +
Address + "', Remark = '" + Remark + "' where Id = '" +
Id + "'";
pst = con.prepareStatement(strSQL);
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
Success = false;
}
return Success;
}
public void AddUser(String Id, String Password, String Popedom, String Name, String Sex,
String BirthTime, String IdentityCard, String Tel, String Address, String Remark)
{
try {
String strSQL = "insert Operator values ('" + Id + "','" + Password +
"','" + Popedom +
"','0','" + Name + "','" + Sex + "','" + BirthTime +
"','" +
IdentityCard + "','" + Tel + "','" + Address + "','" +
Remark + "')";
pst = con.prepareStatement(strSQL);
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
}
}
public User SearchUsing()
{
User user = new User();
try {
String str = "select * from Operator where IsUsing = '1'";
rs = st.executeQuery(str);
while (rs.next()) {
user.setId(rs.getString(1));
user.setPassword(rs.getString(2));
user.setPopedom(rs.getString(3));
user.setName(rs.getString(5));
user.setSex(rs.getString(6));
user.setBirthTime(rs.getString(7));
user.setIdentityCard(rs.getString(8));
user.setTel(rs.getString(9));
user.setAddress(rs.getString(10));
user.setRemark(rs.getString(11));
}
rs.close();
} catch (SQLException ex) {
}
return user;
}
public void DeleteUser(String Id)
{
try {
String strSQL = "delete from Operator where Id = '" + Id + "'";
pst = con.prepareStatement(strSQL);
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
}
}
public void CloseUserDB()
{
try {
st.close();
con.close();
} catch (SQLException ex) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -