Beispiel #1
0
/**
 *查询同一个会议室的IP是否有重
 */
int FacilityService::SelectFacilityExist(string id, string ip, string mr_id) {
    string sql = "select  facility_id from facility where facility_id=" + Utils::AddSingleQuoteMark(id);
    string sql1 = "select  meetroom_id from facility where facility_ip="	+ Utils::AddSingleQuoteMark(ip);
    DBConn db;
    string facility_id = db.Query_mysql(sql);
    db.Close_mysql();
    if (ip.empty() || mr_id.empty()) {//用户增加一个设备仅填写ID的情况
        if (facility_id.empty()) {
            return 300;
        } else {
            return 301; //ID已存在
        }
    } else {
        if (facility_id.empty()) {
            DBConn db;
            string meetroom_id = db.Query_mysql(sql1);
            db.Close_mysql();
            if (meetroom_id == mr_id) {
                return 302; //IP重复
            } else {
                return 300;
            }
        } else {
            return 301; //ID已存在
        }
    }
    /*
     string sql="select  facility_id from facility where facility_id="+Utils::AddSingleQuoteMark(id);
     cout<<"check sql:"<<sql<<endl;
     string sql1="select  meetroom_id from facility where facility_ip="+Utils::AddSingleQuoteMark(ip);
     cout<<"check sql:"<<sql1<<endl;

     DBConn db;
     string facility_id=db.Query_mysql(sql);
     string res_id=db.Query_mysql(sql1);
     db.Close_mysql();
     if(facility_id.empty()){
     if(res_id!=mr_id){
     return 500;//同一个会议室内无重复IP,可以插入
     }else{
     return 501;//IP 重复
     }
     }else{
     return 502;//ID被用
     }*/
}
Beispiel #2
0
int MeetroomService::SelectMeetroomExist(string mr_id){
	DBConn db;
	string sql=SELECT_MR_ID_SQL+Utils::AddSingleQuoteMark(mr_id);
	string res=db.Query_mysql(sql);
	if(res.empty()==true){
		return 0;
	}
	return -1;
}
Beispiel #3
0
int FacilityService::SelectFacilityExist(string id, string ip) {
    string sql = "select  facility_name from facility where facility_id=" + Utils::AddSingleQuoteMark(id);
    string sql1 = "select  facility_id from facility where facility_ip=" + Utils::AddSingleQuoteMark(ip);

    DBConn db;
    string res_name = db.Query_mysql(sql);
    string res_id = db.Query_mysql(sql1);
    db.Close_mysql();
    if (res_id.empty()) { //查看该IP是否被占用
        if (res_name.empty()) { //查看该ID是否存在
            return 300; //可以添加
        } else {
            return 302; //该ID已存在
        }
    } else {
        return 301; //IP被占用
    }
}
Beispiel #4
0
int UserService::SelectUserExist(string u_id){
	DBConn db;
	string sql="select u_name from user where u_id='"+u_id+"'";
	string res=db.Query_mysql(sql);
	if(res.empty()==true){
		cout<<"无重复,可插入!"<<endl;
		return 0;
	}
	cout<<"重复,不可插入!"<<endl;
	return -1;
}
Beispiel #5
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 res=db.Query_mysql(sql);
	if(res.empty()==true){
		return 102;
	}else if(res==a_psd){
		return 100;
	}else{
		return 101;
	}
}
Beispiel #6
0
/*检查是否已有此id的admin
 *@return 0:无重复   -1:重复
 *
 * */
int AdminService::SelectAdminExist(string a_id){
	DBConn db;
    string sql = "select a_id from admin where a_id='"+a_id+"'";

cout<<"i'm in the AdminService::SelectAdminExist, sql="<<sql<<endl;

	string res = db.Query_mysql(sql);

cout<<"i'm in the AdminService::SelectAdminExist, res="<<res<<endl;
    if(res.empty()==true){
    	cout<<"无重复,可插入!"<<endl;
    	return 0;
    }
    cout<<"重复,不可插入!"<<endl;
    return -1;
}
Beispiel #7
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;
	}
}