Esempio n. 1
0
        //查找当前聊天室的人数
        public int searchNum(int id)
        {
            string sql = "select COUNT (*) as [num] from  [chatroom_member] where [chatroom_id]=@ID";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
            parameters[0].Value = id;
            int result = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            return(result);
        }
Esempio n. 2
0
        //判断当前群名字是否存在
        public bool isExist(string Name)
        {
            string sql = "select COUNT(*) as num from [chatroom] where [name] =@Name";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 50));
            parameters[0].Value = Name;
            int result = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public bool checkUniqueEmail(String email)
        {
            string sql = "select count(*) from [user] where email=@Email";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 50));
            parameters[0].Value = email;
            int row = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            if (row >= 1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 4
0
        //判断好友关系
        public bool IsFriend(int curr_ID, int search_ID)
        {
            string sql = "select count(*) from [friend] where u_id=@curr_ID and friend_id=@search_ID";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@curr_ID", SqlDbType.Int));
            parameters.Add(new SqlParameter("@search_ID", SqlDbType.Int));
            parameters[0].Value = curr_ID;
            parameters[1].Value = search_ID;
            int result = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        //判断是否是群成员
        public bool isMember(int UId, int c_id)
        {
            string sql = "select COUNT (*) as num  from  [chatroom_member] where [chatroom_id]=@chatroom_id and [u_id]=@UId";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@chatroom_id", SqlDbType.Int));
            parameters.Add(new SqlParameter("@UId", SqlDbType.Int));
            parameters[0].Value = c_id;
            parameters[1].Value = UId;
            int result = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            if (result != 1)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 6
0
        public bool checkLogin(string email, string password)
        {
            string sql = "select count(*) from [user] where email=@Email and password=@Password";
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar, 50));
            parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 50));
            parameters[0].Value = email;
            parameters[1].Value = AppUtil.Encrypt(password);

            int result = (int)SqlDbHelper.ExecuteScalar(sql, CommandType.Text, parameters);

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        //判断分组是否存在
        public bool isGroupByName(int uId, string name)
        {
            string sqlStr = "select count(*) from [group] where u_id=@UId and name=@Name";
            List <SqlParameter> parameters = new List <SqlParameter>();
            SqlParameter        UId        = new SqlParameter("@UId", SqlDbType.Int);
            SqlParameter        Name       = new SqlParameter("@Name", SqlDbType.VarChar);

            UId.Value  = uId;
            Name.Value = name;
            parameters.Add(UId);
            parameters.Add(Name);

            int result = (int)SqlDbHelper.ExecuteScalar(sqlStr, CommandType.Text, parameters);

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }