public IList<Core.Business.Account> GetAllAccount()
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSPReader("usp_SelectAccountsAll");

            if(reader != null)
            {
                while(reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) account.AccountId = reader.GetString(1);
                    if (!reader.IsDBNull(2)) account.Remain = reader.GetDecimal(2);
                    if (!reader.IsDBNull(3)) account.ApplyDate = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) account.UserCode = reader.GetGuid(4);
                    if (!reader.IsDBNull(5)) account.LimitOfCommon = reader.GetDecimal(5);
                    if (!reader.IsDBNull(6)) account.PayTimeOfCommon = reader.GetDateTime(6);
                    if (!reader.IsDBNull(7)) account.PayModeOfCommon = reader.GetString(7);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
        public IList<Core.Business.Account> GetAllAccount()
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllAccount);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) account.Status = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.Birthday = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.Gender = reader.GetDecimal(3);
                    if (!reader.IsDBNull(4)) account.Name = reader.GetString(4);
                    if (!reader.IsDBNull(5)) account.Telephone = reader.GetString(5);
                    if (!reader.IsDBNull(6)) account.Address = reader.GetString(6);
                    if (!reader.IsDBNull(7)) account.LoginName = reader.GetString(7);
                    if (!reader.IsDBNull(8)) account.Password = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.AvatarPath = reader.GetString(9);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
Exemple #3
0
        public IList<Account> GetAccountSameInterestByCurrentUserId(long Currentid, PagingInfo pageInfo)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            #region ����

            string tables = "view_account_all";
            string pK = "Id";
            string sort = "Id Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            //string fields = "";
            string filter = "";
            Core.Business.AccountExtend ace = Core.Business.AccountExtend.Load(Currentid);
            if (ace != null && !string.IsNullOrEmpty(ace.Interest))
            {
                string interestAll = ace.Interest;
                string sqlWhere = " Id!=" + Currentid + " and ";
                if (interestAll.Contains(","))
                {
                    string[] interestTemp = interestAll.Split(',');
                    if (interestTemp != null && interestTemp.Length > 0)
                    {
                        sqlWhere += "( ";
                        for (int i = 0; i < interestTemp.Length; i++)
                        {
                            if (i == interestTemp.Length - 1)
                            {
                                sqlWhere += " interest like '%" + interestTemp[i] + "%' ";
                            }
                            else
                            {
                                sqlWhere += " interest like '%" + interestTemp[i] + "%' or ";
                            }
                        }
                        sqlWhere += " ) ";
                        filter = sqlWhere;
                    }
                }
                else
                {
                    filter = sqlWhere + "interest like '%" + interestAll + "%'";
                }
            }

            string group = String.Empty;

            #endregion

            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            //sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #4
0
        public IList<Account> GetAccountBindedPhoneByGroup(Group sgroup, PagingInfo pageInfo)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            #region ����

            string tables = "Account";
            string pK = "Id";
            string sort = "Id Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            string fields = "[Id],[Credit],[DateCreated],[IsProtected],[HasAvatar],[IsTeacher],[IsPublic],[ViewNumber],[Name],[NickName],[Code]";
            string filter = "[Id] in (Select AccountId From AccountGroup Where GroupId=" + sgroup.Id.ToString() + ")";

            string group = String.Empty;

            #endregion

            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #5
0
        // ��̨����
        public List<Account> GetAccounts(
            string name,
            int gender,
            string bloodType,
            int birthYear,
            int birthMonth,
            int birthDate,
            City hometownCity,
            Province homwtownProvince,
            City resideCity,
            Province resideProvince,
            ClassInfo classInfo,
            Grade grade,
            Major major,
            College college,
            University university,
            string code,
            bool? hasAvatar,
            string nickName,
            bool? isProtected,
            int minViewCount,
            int maxViewCount,
            bool? isPublic,
            string Sort,
            PagingInfo pagingInfo)
        {
            List<Account> accountlist = new List<Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);
            System.Text.StringBuilder sbFilter = new StringBuilder();

            #region Build filter

            sbFilter.Append("1=1 ");

            if (!string.IsNullOrEmpty(name))
            {
                sbFilter.Append(" And [Name] like '%");
                sbFilter.Append(name.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("%'");
            }

            if (gender == 1 || gender == 0)
            {
                sbFilter.Append(" And [Gender] = ");
                sbFilter.Append(gender);
            }

            if (!string.IsNullOrEmpty(bloodType))
            {
                sbFilter.Append(" And BloodType = '");
                sbFilter.Append(bloodType.Replace("'", "").Replace("\"", ""));
                sbFilter.Append(" '");
            }

            if (birthYear > 0)
            {
                sbFilter.Append(" And BirthYear = ");
                sbFilter.Append(birthYear);
            }

            if (birthMonth > 0 && birthMonth < 13)
            {
                sbFilter.Append(" And BirthMonth = ");
                sbFilter.Append(birthMonth);
            }

            if (birthDate > 0 && birthDate < 32)
            {
                sbFilter.Append(" And BirthDate = ");
                sbFilter.Append(birthDate);
            }

            if (hometownCity != null)
            {
                if (hometownCity.Id > 0)
                {
                    sbFilter.Append(" And HometownCityId = ");
                    sbFilter.Append(hometownCity.Id);
                }
            }
            else
            {
                if (homwtownProvince != null && homwtownProvince.Id > 0)
                {
                    sbFilter.Append(" And HometownProvinceId = ");
                    sbFilter.Append(homwtownProvince.Id);
                }
            }

            if (resideCity != null)
            {
                if (resideCity.Id > 0)
                {
                    sbFilter.Append(" And ResideCityId = ");
                    sbFilter.Append(resideCity.Id);
                }
            }
            else
            {
                if (resideProvince != null && resideProvince.Id > 0)
                {
                    sbFilter.Append(" And ResideProvinceId = ");
                    sbFilter.Append(resideProvince.Id);
                }
            }

            if (classInfo != null)
            {
                if (classInfo.Id > 0)
                {
                    sbFilter.Append(" And ClassInfoId = ");
                    sbFilter.Append(classInfo.Id);
                }
            }
            else
            {
                if (grade != null && grade.Id > 0)
                {
                    sbFilter.Append(" And GradeId = ");
                    sbFilter.Append(grade.Id);
                }

                if (major != null)
                {
                    if (major.Id > 0)
                    {
                        sbFilter.Append(" And MajorId = ");
                        sbFilter.Append(major.Id);
                    }
                }
                else
                {
                    if (college != null)
                    {
                        if (college.Id > 0)
                        {
                            sbFilter.Append(" And CollegeId = ");
                            sbFilter.Append(college.Id);
                        }
                    }
                    else
                    {
                        if (university != null && university.Id > 0)
                        {
                            sbFilter.Append(" And UniversityID = ");
                            sbFilter.Append(university.Id);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(code))
            {
                sbFilter.Append(" And Code = '");
                sbFilter.Append(code.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (hasAvatar.HasValue)
            {
                sbFilter.Append(string.Format(" And HasAvatar = '{0}'", hasAvatar.Value ? "1" : "0"));
            }

            if (!string.IsNullOrEmpty(nickName))
            {
                sbFilter.Append(" And NickName = '");
                sbFilter.Append(nickName.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (isProtected.HasValue)
            {
                sbFilter.Append(string.Format(" And IsProtected = '{0}'", isProtected.Value ? "1" : "0"));
            }

            if ((minViewCount > 0) &&
                (maxViewCount > 0) &&
                (minViewCount < maxViewCount))
            {
                sbFilter.Append(string.Format(" And ViewNumber Between {0} and {1} ", minViewCount, maxViewCount));
            }

            if (isPublic.HasValue)
            {
                sbFilter.Append(" And IsPublic = '");
                sbFilter.Append(isPublic.Value ? "1" : "0");
                sbFilter.Append("'");
            }
            //ͨ��������֤�����û�
            sbFilter.Append(" And IsEmailChecked='1'");
            #endregion

            #region BackCode
            /*
            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pagingInfo != null)
            {
                pageSize = pagingInfo.PageSize;
                pageNumber = pagingInfo.CurrentPage;
            }

            String Fields1 = "Id,ViewNumber,DateCreated,IsProtected,HasAvatar,IsTeacher,Name,NickName,Code,Credit,IsPublic,BirthYear,BirthMonth," +
                            "BirthDate,Gender,LoveState,HometownProvinceId,HometownCityId,ResideProvinceId,ResideCityId,Birthday,IsEmailChecked," +
                            "Telephone,Email,QQ,MSN,BloodType,Theme,LibUserId,Password,Interest,MajorId,MajorName,CollegeId,CollegeName,UniversityID,UniversityName,GradeId,GradeYear," +
                            "HometownProvinceName,HometownCityName,ResideProvinceName,ResideCityName,IsShow,FriendCount";

            String Fields2 = "Id,Credit,DateCreated,IsProtected,HasAvatar,IsTeacher,IsPublic,ViewNumber,Name,NickName,Code,FriendCount";

            sql.AddParameter("@Tables", SqlDbType.VarChar, "view_account_all");
            sql.AddParameter("@PK", SqlDbType.VarChar, "Id");
            sql.AddParameter("@Fields", SqlDbType.VarChar, Fields2);//"Id"
            sql.AddParameter("@sort", SqlDbType.NVarChar, Sort + " DESC");
            sql.AddParameter("@Filter", SqlDbType.VarChar, sbFilter.ToString());
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNumber);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");
            */
            #endregion

            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pagingInfo != null)
            {
                pageSize = pagingInfo.PageSize;
                pageNumber = pagingInfo.CurrentPage;
            }

            sql.AddParameter("@PageNum", SqlDbType.Int, pageSize);
            sql.AddParameter("@Num", SqlDbType.Int, pageSize * (pageNumber - 1));

            String Column = "Id,Credit,DateCreated,IsProtected,HasAvatar,IsTeacher,IsPublic,ViewNumber,Name,NickName,Code,(SELECT COUNT(Friendship.Id) FROM Friendship WHERE (Friendship.AccountId = view_account_all.Id) AND (Friendship.IsChecked = 1)) AS FriendCount";
            StringBuilder sbSQL = new StringBuilder();
            sbSQL.Append("SELECT TOP (@PageNum) " + Column + " FROM view_account_all WHERE " + sbFilter.ToString() + " AND [Id] NOT IN ");
            sbSQL.Append("(SELECT TOP (@Num) [Id] FROM view_account_all WHERE " + sbFilter.ToString() + " ORDER BY " + Sort + " DESC) ORDER BY " + Sort + " DESC");

            SqlDataReader reader = sql.ExecuteSqlReader(sbSQL.ToString());

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.FriendCount = reader.GetInt32(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #6
0
        public IList<Account> GetAllAccount(PagingInfo pageinfo)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            #region ����

            string tables = "view_account_all";
            string pK = "Id";
            string sort = "Id Desc";
            int pageNum = pageinfo.CurrentPage;
            int pageSize = pageinfo.PageSize;
            //string fields = "";
            //string filter = "";

            string group = String.Empty;

            #endregion

            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            //sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            //sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #7
0
        public IList<CY.UME.Core.Business.Account> GetAccountByStrId(String StrId, String Sort)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            StringBuilder sb = new StringBuilder();

            sb.Append("SELECT [Id],[Credit],[DateCreated],[IsProtected],[HasAvatar],[IsTeacher],[IsPublic],[ViewNumber],[Name],[NickName],[Code],[Remark] ");
            sb.Append("FROM [Account] WHERE Id IN (" + StrId + "0) ORDER BY " + Sort + " DESC");
            SqlDataReader reader = sql.ExecuteSqlReader(sb.ToString());

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.Remark = reader.GetString(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
Exemple #8
0
        public IList<Core.Business.Account> GetRobotByEmail(String Email, int PageSize, String Sort)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);
            /*
            sql.AddParameter("@Email", SqlDbType.NVarChar, Email);
            sql.AddParameter("@PageSize", SqlDbType.Int, PageSize);
            SqlDataReader reader = sql.ExecuteSPReader("USP_Account_Select_Like_Email");
             */

            StringBuilder sb = new StringBuilder();

            sb.Append("SELECT TOP (" + PageSize + ") [Account].[Id],[Account].[Credit],[Account].[DateCreated],[Account].[IsProtected],[Account].[HasAvatar],[Account].[IsTeacher],[Account].[IsPublic],[Account].[ViewNumber],[Account].[Name],[Account].[NickName],[Account].[Code],[Account].[Remark] ");
            sb.Append("FROM [Account],[AccountExtend] ");
            sb.Append("WHERE [Account].[Id] = [AccountExtend].[Id] ");
            sb.Append("AND [AccountExtend].[Email] LIKE '%" + Email + "%' ORDER BY " + Sort + " DESC");
            SqlDataReader reader = sql.ExecuteSqlReader(sb.ToString());

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.Remark = reader.GetString(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
Exemple #9
0
        public IList<Account> GetStudentByCurrentUserId(long Currentid, PagingInfo pageInfo)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            #region ����

            string tables = "view_account_all";
            string pK = "Id";
            string sort = "Id Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;

            string filter = "";
            Core.Business.AccountExtend ace = Core.Business.AccountExtend.Load(Currentid);
            if (ace != null)
            {
                string sqlwhere = " Id<>" + Currentid;
                if (ace.CollegeId != -1 || ace.UniversityId != -1)
                {
                    sqlwhere += " and ";
                    if (ace.CollegeId != -1)
                    {
                        sqlwhere += " CollegeId=" + ace.CollegeId;
                    }
                    else if (ace.UniversityId != -1)
                    {
                        sqlwhere += " UniversityId=" + ace.UniversityId;
                    }

                }

                filter = sqlwhere;
            }

            string group = String.Empty;

            #endregion

            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            //sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #10
0
        public IList<Account> GetPublicFromView()
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string sqlwhere = "select [id] from view_account_all where IsPublic='true' and IsEmailChecked='true'";

            SqlDataReader reader = sql.ExecuteSqlReader(sqlwhere);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #11
0
        public IList<Account> GetRandomAccList(long uid)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            string sqlwhere = "select Top 14 [Id],[Name] From Account Where Id Not In (Select FriendId From Friendship Where AccountId=" + uid + " ) and Id<>" + uid + " and HasAvatar=1 ORDER BY NEWID() ";

            SqlDataReader reader = sql.ExecuteSqlReader(sqlwhere);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #12
0
        // �����û�����ѯ�û�
        public IList<Account> GetAccountByName(string AccountName)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            sql.AddParameter("@AccountName", SqlDbType.NVarChar, AccountName);
            SqlDataReader reader = sql.ExecuteSPReader("USP_Account_Select_By_Name");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.Remark = reader.GetString(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
Exemple #13
0
        /// <summary>
        /// �õ���ע�ҵ���
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="pinfo"></param>
        /// <returns></returns>
        public IList<Account> GetFollowerAccountByCurrentAccount(long uid, PagingInfo pinfo, string oderby)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            #region ����

            string tables = "Account INNER JOIN AccountFollower ON Account.Id= AccountFollower.FollowerId";
            string pK = "Account.Id";
            string sort = "";
            if (oderby == "")
            {
                sort = "Account.Id Desc";
            }
            else if (oderby == "newcear")
            {
                sort = "AccountFollower.DataCreated Desc";
            }
            else if (oderby == "name")
            {
                sort = "Account.Name";
            }
            int pageNum = pinfo.CurrentPage;
            int pageSize = pinfo.PageSize;
            string fields = "Account.Id,Account.Name";
            string filter = " AccountFollower.AccountId=" + uid;

            string group = String.Empty;

            #endregion

            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #14
0
        public IList<Account> GetAccountById(String StrId, String BeginNum, String EndNum)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            String SQL = String.Empty;

            if (StrId == "")
            {
                SQL = "SELECT [Account].[Id],[Account].[Credit],[Account].[DateCreated],[Account].[IsProtected],[Account].[HasAvatar],[Account].[IsTeacher],[Account].[IsPublic],[Account].[ViewNumber],[Account].[Name],[Account].[NickName],[Account].[Code],[Account].[Remark] " +
                    "FROM [Account],[AccountExtend] " +
                    "WHERE [Account].[Id] = [AccountExtend].[Id] AND [AccountExtend].[IsEmailChecked] = 1 AND [Account].[Id] BETWEEN " + BeginNum + " AND " + EndNum + "";
            }
            else
            {
                SQL = "SELECT [Account].[Id],[Account].[Credit],[Account].[DateCreated],[Account].[IsProtected],[Account].[HasAvatar],[Account].[IsTeacher],[Account].[IsPublic],[Account].[ViewNumber],[Account].[Name],[Account].[NickName],[Account].[Code],[Account].[Remark] " +
                    "FROM [Account],[AccountExtend] " +
                    "WHERE [Account].[Id] = [AccountExtend].[Id] AND [AccountExtend].[IsEmailChecked] = 1 AND [Account].[Id] IN (" + StrId + ")";
            }

            SqlDataReader reader = sql.ExecuteSqlReader(SQL);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.Remark = reader.GetString(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
        public AccountIndexModel Search(AccountSearch packet)
        {
            if (packet == null)
            {
                throw new ArgumentException("packet for search is null!!!!");

            }

            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();

            SqlServerUtility sql = new SqlServerUtility();

            int start = packet.PageIndex.HasValue ? packet.PageIndex.Value - 1 : 0 * (packet.PageSize.HasValue ? packet.PageSize.Value : 10);
            int end = start + (packet.PageSize.HasValue ? packet.PageSize.Value : 10);

            sql.AddParameter("@Name", SqlDbType.NVarChar, !string.IsNullOrEmpty(packet.Name) ? (object)packet.Name : DBNull.Value, 30);
            sql.AddParameter("@Gender", SqlDbType.Int, packet.Gender != Core.Business.Gender.Female && packet.Gender != Core.Business.Gender.Male ? DBNull.Value : (object)packet.Gender);
            sql.AddParameter("@start", SqlDbType.Int, start);
            sql.AddParameter("@end", SqlDbType.Int, end);
            sql.AddOutputParameter("@totalCount", SqlDbType.Int);

            SqlDataReader reader = sql.ExecuteSqlReader(SqlSerchAccount);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) account.Status = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.Birthday = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.Gender = reader.GetDecimal(3);
                    if (!reader.IsDBNull(4)) account.Name = reader.GetString(4);
                    if (!reader.IsDBNull(5)) account.Telephone = reader.GetString(5);
                    if (!reader.IsDBNull(6)) account.Address = reader.GetString(6);
                    if (!reader.IsDBNull(7)) account.LoginName = reader.GetString(7);
                    if (!reader.IsDBNull(8)) account.Password = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.AvatarPath = reader.GetString(9);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            AccountIndexModel model = new AccountIndexModel(packet, new PagedList<Account>(accountlist, packet.PageIndex.Value, packet.PageSize.Value, 10));

            return model;
        }
Exemple #16
0
        public IList<Core.Business.Account> MayBe(Core.Business.AccountExtend ae, int PageSize)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            String SQL = "SELECT TOP(" + PageSize + ") [Account].[Id],[Account].[Credit],[Account].[DateCreated],[Account].[IsProtected],[Account].[HasAvatar],[Account].[IsTeacher],[Account].[IsPublic],[Account].[ViewNumber],[Account].[Name],[Account].[NickName],[Account].[Code],[Account].[Remark] ";
            SQL += "FROM [Account],[AccountExtend] ";
            SQL += "WHERE [Account].[Id] = [AccountExtend].[Id] ";

            if (ae.UniversityId >= 1)
            {
                SQL += "AND [AccountExtend].[UniversityId] = " + ae.UniversityId;
            }

            if (ae.CollegeId >= 1)
            {
                SQL += "AND [AccountExtend].[CollegeId] = " + ae.CollegeId;
            }

            if (ae.Interest != null || ae.Interest != "")
            {
                SQL += "AND [AccountExtend].[Interest] LIKE '%" + ae.Interest + "%'";
            }

            SqlDataReader reader = sql.ExecuteSqlReader(SQL);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.Remark = reader.GetString(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }
        public IList<Account> GetAllFriendshipByOder(long uid, PagingInfo pinfotemp, string oderby, int divernum)
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);
            string sort = "";
            if (oderby == "")
            {
                sort = "Account.Id Desc";
            }
            else if (oderby == "newcear")
            {
                sort = "Friendship.DateCreated Desc";
            }
            else if (oderby == "name")
            {
                sort = "Account.Name ASC";
            }
            int pageNum = pinfotemp.CurrentPage;
            int pageSize = 0;
            if (pageNum == 1)
            {
                pageSize = divernum;
            }
            else
            {
                pageSize = pinfotemp.PageSize;
            }
            string SqlGetUC = "SELECT Top " + pageSize + " Account.Id,Account.Name From Account INNER JOIN Friendship ON Account.Id=Friendship.FriendId WHERE Account.Id not in(SELECT Top ";
            if (pageNum == 1)
            {
                SqlGetUC += "0";
            }
            else
            {
                SqlGetUC += ((pageNum - 2) * pageSize) + divernum;
            }

            SqlGetUC += " Account.Id From Account INNER JOIN Friendship ON Account.Id=Friendship.FriendId WHERE Friendship.AccountId=" + uid + " and IsChecked=1 ORDER BY " + sort + ") and Friendship.AccountId=" + uid + " and IsChecked=1 ORDER BY " + sort;

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetUC);

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
Exemple #18
0
        public IList<Core.Business.Account> GetAllAccount()
        {
            IList<Core.Business.Account> accountlist = new List<Core.Business.Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);

            SqlDataReader reader = sql.ExecuteSPReader("USP_Account_SelectAll");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    long id = reader.GetInt64(0);
                    account = Core.Business.Account.Load(id);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }
            return accountlist;
        }