/**
 * return 103;//管理员添加成功
 * return 104;//管理员添加失败
 * return 105;//管理员添加失败:ID重复
 */
int AdminService::addAdmin(Admin admin){
	string sql="insert into admin(a_id,a_name,a_psd,a_priority)values('"+admin.getId()+"','"
			+admin.getName()+"','"+admin.getPsd()+"','"+admin.getPriority()+"')";
	string sql1="update admin set a_loginState='0' where a_id='"+admin.getId()+"'";
cout<<"insert admin sql:"<<sql<<endl;
	int tmp = this->SelectAdminExist(admin.getId());
	if(tmp==0){
		DBConn db;
		if(db.Execute_mysql(sql)==0){
			db.Execute_mysql(sql1);           //添加成功一个admin,默认登录状况为未登录把loginState设置为“0”
			db.Close_mysql();
			return 103;      //添加成功
		}
		db.Close_mysql();
		return 104;         //添加失败
	}else{
		return 105;         //添加失败:ID重复
	}
}
//为会议室添加设备 成功
int FacilityService::UpdateForRoom(string id,string mr_id) {
    string sql = "update facility set meetroom_id = '"  + mr_id + "' where facility_id = " + Utils::AddSingleQuoteMark(id);
    DBConn db;
    if (db.Execute_mysql(sql) == 0) {
        db.Close_mysql();
        return 330;
    } else
        db.Close_mysql();
    return 331;
}
/**
 * return 106;//管理删除成功
 * return 107;//管理员删除失败
 */
int AdminService::deleteSingleAdmin(string a_id){

	string sql="delete from admin where a_id="+Utils::AddSingleQuoteMark(a_id);
		DBConn db;
		if(db.Execute_mysql(sql)==0){
			db.Close_mysql();
				return 106;
		}else{
			db.Close_mysql();
				return 107;
		}
}
/**
 * return 106;//管理删除成功
 * return 107;//管理员删除失败
 */
int AdminService::deleteAllAdmin(){

	string sql="delete from admin";
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
		return 108;
	}else{
		db.Close_mysql();
		return 109;
	}
}
int MeetroomService::DeleteSignle(string mr_id){
	string sql=DELETE_SINGLE_MR_SQL+Utils::AddSingleQuoteMark(mr_id);
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
			return 410;
	}else{
		db.Close_mysql();
			return 411;
	}

}
Exemple #6
0
int UserService::DeleteSignle(string u_id){
	string sql="delete from user where u_id="+Utils::AddSingleQuoteMark(u_id);
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
			return 400;
	}else{
		db.Close_mysql();
			return 401;
	}

}
int MeetroomService::Update(Meetroom mr){

	string sql = "update meetroom set meetroom_name='"+ mr.getMeetroomName() + "',meetroom_addr='" + mr.getMeetroomAddr() + "',available_state='"+ mr.getAvailableState() + "',meetroom_size='"+mr.getMeetroomSize()+"' where meetroom_id='"+mr.getMeetroomId()+"'";
	cout<<"update sql:"<<sql<<endl;
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
		return 420;
	}else{
		db.Close_mysql();
		return 421;
	}
}
//删除facility成功600 失败601
int FacilityService::DeleteSignle(string id) {
    string sql = "delete from facility where facility_id="
                 + Utils::AddSingleQuoteMark(id);
    DBConn db;
    if (db.Execute_mysql(sql) == 0) {
        db.Close_mysql();
        return 310;
    } else {
        db.Close_mysql();
        return 311;
    }

}
//更新设备成功 320 失败321
int FacilityService::Update(Facility fac) {
    string sql = "update facility set facility_name='" + fac.getFacilityName()
                 + "',available_state='" + fac.getAvailableState()
                 + "',meetroom_id='" + fac.getMeetroomId() + "',facility_ip='"
                 + fac.getFacilityIp() + "'where facility_id="+Utils::AddSingleQuoteMark(fac.getFacilityId());
    DBConn db;
    if (db.Execute_mysql(sql) == 0) {
        db.Close_mysql();
        return 320;
    } else
        db.Close_mysql();
    return 321;
}
Exemple #10
0
/**
 * return 108;//管理员更新成功
 * return 109;//管理员更新失败
 */
int AdminService::updateAdmin(Admin admin){

	string sql = "update admin set a_name='"+ admin.getName() + "',a_psd='" + admin.getPsd() + "',a_priority='"+ admin.getPriority() +"' where u_id='"+admin.getId()+"'";
cout<<"AdminService::updateAdmin ---- update sql="<<sql<<endl;
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
		return 108;
	}else{

		db.Close_mysql();
		return 109;
	}
}
Exemple #11
0
int UserService::Update(User user){

	string sql = "update user set u_name='"+ user.getName() + "',u_phone='" + user.getPhone() + "',u_department='"+ user.getDepartment() + "',u_gender='"+user.getGender()+"' where u_id='"+user.getId()+"'";
	cout<<"update sql:"<<sql<<endl;
	DBConn db;
	if(db.Execute_mysql(sql)==0){
		db.Close_mysql();
		return 0;
	}else{

		db.Close_mysql();
		return -1;
	}
}
Exemple #12
0
int MeetroomService::Add(Meetroom mr){

	int tmp=this->SelectMeetroomExist(mr.getMeetroomId());
	if(tmp==0){
		string sql=ADD_MR_SQL+ mr.getMeetroomId() + "','" +mr.getMeetroomName()+ "','" +mr.getMeetroomAddr() +
						"','"+mr.getAvailableState() +"','"+mr.getMeetroomSize()+ "')";
			DBConn db;
			if(db.Execute_mysql(sql)==0){
				db.Close_mysql();
				return 400; //添加成功
			}
			db.Close_mysql();
			return 402;//添加失败
	}else{
		return 401;//ID重复
	}
}
Exemple #13
0
/**
 * return 100;//登录成功
 * return 101;//登录失败 :密码错误
 * return 102;//登录失败:ID不存在
 */
int AdminService::LoginSys(string a_id,string a_psd){
	DBConn db;
	string sql="select a_psd from admin where a_id="+Utils::AddSingleQuoteMark(a_id);
	string sql1="update admin set a_loginState='1' where a_id='"+a_id+"'";
	string res=db.Query_mysql(sql);
	db.Close_mysql();
	if(res.empty()==true){
		return 102;
	}else if(res==a_psd){
cout<<"AdminServcie::LoginSys-------- i'm before db.Execute_mysql"<<endl;
        DBConn db;
		db.Execute_mysql(sql1);    //如果登录成功,就把loginState设为“1”
cout<<"AdminServcie::LoginSys-------- i'm after db.Execute_mysql"<<endl;
		db.Close_mysql();
		return 100;
	}else{
		return 101;
	}
}
Exemple #14
0
int UserService::Add(User user){

	int tmp=this->SelectUserExist(user.getId());
	if(tmp==0){
		string sql="insert into user(u_id,u_name,u_department,u_phone,u_gender)values('"+ user.getId() + "','" +user.getName()+ "','" + user.getDepartment() +
						"','"+user.getPhone() +"','"+user.getGender()+ "')";
			DBConn db;
			if(db.Execute_mysql(sql)==0){
				db.Close_mysql();
				return 200; //添加成功
			}
			db.Close_mysql();
			return 201;//添加失败
	}else{
		return 202;//添加失败:ID重复
	}


}
Exemple #15
0
int FacilityService::Add(Facility fac) {
    string sql =
        "insert into facility(facility_id,facility_name,available_state,meetroom_id,facility_ip)values('"
        + fac.getFacilityId() + "','" + fac.getFacilityName()
        + "','" + fac.getAvailableState() + "','"
        + fac.getMeetroomId() + "','" + fac.getFacilityIp() + "')";
    int check = this->SelectFacilityExist(fac.getFacilityId(),fac.getFacilityIp(), fac.getMeetroomId());
    DBConn db;
    if (check == 300) {
        db.Execute_mysql(sql);
        db.Close_mysql();
        return 300;
    } else if (check == 301) {
        db.Close_mysql();
        return 301;
    } else {
        db.Close_mysql();
        return 302;
    }
}