String sql4 = "update admin set logintimes = logintimes+1 where username = '"+username+"' ";
DBO dbo = new DBO();
String pwd;
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
pwd = rs.getString("password");
if(pwd.trim().equals(md5password)){
dbo.executeUpdate(sql2);
dbo.executeUpdate(sql4);
return Constant.SUCCESS;
}
else{
dbo.executeUpdate(sql3);
return Constant.PASSWORD_ERROR;
}
}
else{
dbo.executeUpdate(sql3);
return Constant.NAME_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//查询管理员信息
public List getAdminInfo(String username){
String sql = "select * from admin where username='"+username+"' ";
DBO dbo = new DBO();
dbo.open();
list = new ArrayList();
try{
rs = dbo.executeQuery(sql);
rs.next();
list.add(rs.getString("username"));
list.add(rs.getInt("flag"));
list.add(rs.getInt("logintimes"));
list.add(date);
list.add(rs.getString("quanxian"));
return list;
}catch(Exception e){
e.printStackTrace();
return list;
}finally{
dbo.close();
}
}
//admin edit password
public int editPassword(String username,String oldpwd,String newpwd){
String sql="select * from admin where username = '"+username+"' and password = '"+oldpwd+"'";
String sql2="update admin set password = '"+newpwd+"' where username = '"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql);
if(rs.next()){
int i = dbo.executeUpdate(sql2);
if(i == 1){
return Constant.SUCCESS;
}
else{
return Constant.SYSTEM_ERROR;
}
}
else{
return Constant.PASSWORD_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//add manager
public int addManager(String username,String password,String type,String isuse){
String sql = "insert into admin(username,password,creattime,flag,isuse,logintimes,quanxian) values('"+username+"','"+password+"','"+date+"','"+type+"','"+isuse+"','0','111')";
String sql2 = "select * from admin where username = '"+username+"'";
DBO dbo = new DBO();
dbo.open();
try{
rs = dbo.executeQuery(sql2);
if(rs.next()){
return Constant.SAME_NAME;
}
else{
int i = dbo.executeUpdate(sql);
if(i == 1)return Constant.SUCCESS;
else return Constant.SYSTEM_ERROR;
}
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//update manager
public int updateManager(String username,String password,String type,String isuse){
String sql;
if(password.equals("")){
sql = "update admin set flag = '"+type+"' ,isuse = '"+isuse+"' where username = '"+username+"'";
}
else{
sql = "update admin set password = '"+password+"' ,flag = '"+type+"' ,isuse = '"+isuse+"' where username = '"+username+"'";
}
DBO dbo = new DBO();
dbo.open();
try{
int i = dbo.executeUpdate(sql);
if(i == 1)return Constant.SUCCESS;
else return Constant.SYSTEM_ERROR;
}catch(Exception e){
e.printStackTrace();
return Constant.SYSTEM_ERROR;
}finally{
dbo.close();
}
}
//get all manager
public List getAllManager(){
String sql = "select * from admin where flag !='1' order by id asc";
DBO dbo = new DBO();
list = new ArrayList();
dbo.open();
try{
rs = dbo.executeQuery(sql);
while(rs.next()){
List list2 = new ArrayList();
推荐阅读
- 额定功率、实际功率 测小灯泡的电功率
- 行为偏差高中学生个案分析 学生个案分析
- 妇科炎症吃什么药好,辨清类型再开方 妇科炎症吃什么药好
- 今日立夏,为何立夏节气要吃鸡蛋 立夏为什么要吃蛋
- 2月杭州TOP10酒店 杭州酒店查询
- 最值得看的5部穿越剧 关于穿越时空的电视剧
- 野炊、露营、星空,这才是夏天最正确的玩法 野炊露营
- 2021最洋气的减龄发型图片 短发什么发型好看
- 可还记得QQ游戏大厅? qq游戏论坛