using CallCenterApi.DB;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CallCenterApi.DAL
{
    /// <summary>
	/// 数据访问类:UserAccount
	/// </summary>
	public partial class UserAccount
    {
        public UserAccount()
        { }
        #region  Method



        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.UserAccount model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into UserAccount(");
            strSql.Append("F_UserId,F_UserCode,F_Password,F_ExtensionNumber,F_UserName,F_DeptId,F_RoleId,F_GroupId,F_SeatFlag,F_SeatRight,F_SeatLevel,F_SexFlag,F_RemindFlag,F_Remark,F_Telephone,F_Mobile,F_HomePhone,F_Birthday,F_CreateOn,F_CancelOn,F_DeleteFlag,F_APPOnFlag,F_LastActiveTime,F_See,F_HJType,F_PId,F_TmId,F_RoleName,F_DeptName)");
            strSql.Append(" values (");
            strSql.Append("@F_UserId,@F_UserCode,@F_Password,@F_ExtensionNumber,@F_UserName,@F_DeptId,@F_RoleId,@F_GroupId,@F_SeatFlag,@F_SeatRight,@F_SeatLevel,@F_SexFlag,@F_RemindFlag,@F_Remark,@F_Telephone,@F_Mobile,@F_HomePhone,@F_Birthday,@F_CreateOn,@F_CancelOn,@F_DeleteFlag,@F_APPOnFlag,@F_LastActiveTime,@F_See,@F_HJType,@F_PId,@F_TmId,@F_RoleName,@F_DeptName)");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_UserId", SqlDbType.Int,4),
                    new SqlParameter("@F_UserCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Password", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ExtensionNumber", SqlDbType.VarChar,50),
                    new SqlParameter("@F_UserName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_RoleId", SqlDbType.Int,4),
                    new SqlParameter("@F_GroupId", SqlDbType.Int,4),
                    new SqlParameter("@F_SeatFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_SeatRight", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SeatLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SexFlag", SqlDbType.VarChar,50),
                    new SqlParameter("@F_RemindFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_Remark", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Telephone", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Mobile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HomePhone", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Birthday", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
                    new SqlParameter("@F_CancelOn", SqlDbType.DateTime),
                    new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
                    new SqlParameter("@F_APPOnFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_LastActiveTime", SqlDbType.DateTime),
                    new SqlParameter("@F_See", SqlDbType.VarChar,100),
                    new SqlParameter("@F_HJType", SqlDbType.Int,4),
                    new SqlParameter("@F_PId", SqlDbType.Int,4),
                    new SqlParameter("@F_TmId", SqlDbType.Int,4),
                    new SqlParameter("@F_RoleName", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeptName", SqlDbType.VarChar,60)};
            parameters[0].Value = model.F_UserId;
            parameters[1].Value = model.F_UserCode;
            parameters[2].Value = model.F_Password;
            parameters[3].Value = model.F_ExtensionNumber;
            parameters[4].Value = model.F_UserName;
            parameters[5].Value = model.F_DeptId;
            parameters[6].Value = model.F_RoleId;
            parameters[7].Value = model.F_GroupId;
            parameters[8].Value = model.F_SeatFlag;
            parameters[9].Value = model.F_SeatRight;
            parameters[10].Value = model.F_SeatLevel;
            parameters[11].Value = model.F_SexFlag;
            parameters[12].Value = model.F_RemindFlag;
            parameters[13].Value = model.F_Remark;
            parameters[14].Value = model.F_Telephone;
            parameters[15].Value = model.F_Mobile;
            parameters[16].Value = model.F_HomePhone;
            parameters[17].Value = model.F_Birthday;
            parameters[18].Value = model.F_CreateOn;
            parameters[19].Value = model.F_CancelOn;
            parameters[20].Value = model.F_DeleteFlag;
            parameters[21].Value = model.F_APPOnFlag;
            parameters[22].Value = model.F_LastActiveTime;
            parameters[23].Value = model.F_See;
            parameters[24].Value = model.F_HJType;
            parameters[25].Value = model.F_PId;
            parameters[26].Value = model.F_TmId;
            parameters[27].Value = model.F_RoleName;
            parameters[28].Value = model.F_DeptName;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.UserAccount model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update UserAccount set ");
            strSql.Append("F_UserId=@F_UserId,");
            strSql.Append("F_UserCode=@F_UserCode,");
            strSql.Append("F_Password=@F_Password,");
            strSql.Append("F_ExtensionNumber=@F_ExtensionNumber,");
            strSql.Append("F_UserName=@F_UserName,");
            strSql.Append("F_DeptId=@F_DeptId,");
            strSql.Append("F_RoleId=@F_RoleId,");
            strSql.Append("F_GroupId=@F_GroupId,");
            strSql.Append("F_SeatFlag=@F_SeatFlag,");
            strSql.Append("F_SeatRight=@F_SeatRight,");
            strSql.Append("F_SeatLevel=@F_SeatLevel,");
            strSql.Append("F_SexFlag=@F_SexFlag,");
            strSql.Append("F_RemindFlag=@F_RemindFlag,");
            strSql.Append("F_Remark=@F_Remark,");
            strSql.Append("F_Telephone=@F_Telephone,");
            strSql.Append("F_Mobile=@F_Mobile,");
            strSql.Append("F_HomePhone=@F_HomePhone,");
            strSql.Append("F_Birthday=@F_Birthday,");
            strSql.Append("F_CreateOn=@F_CreateOn,");
            strSql.Append("F_CancelOn=@F_CancelOn,");
            strSql.Append("F_DeleteFlag=@F_DeleteFlag,");
            strSql.Append("F_APPOnFlag=@F_APPOnFlag,");
            strSql.Append("F_LastActiveTime=@F_LastActiveTime,");
            strSql.Append("F_See=@F_See,");
            strSql.Append("F_HJType=@F_HJType,");
            strSql.Append("F_PId=@F_PId,");
            strSql.Append("F_TmId=@F_TmId,");
            strSql.Append("F_RoleName=@F_RoleName,");
            strSql.Append("F_DeptName=@F_DeptName");
            strSql.Append(" where ");
            SqlParameter[] parameters = {
                    new SqlParameter("@F_UserId", SqlDbType.Int,4),
                    new SqlParameter("@F_UserCode", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Password", SqlDbType.VarChar,50),
                    new SqlParameter("@F_ExtensionNumber", SqlDbType.VarChar,50),
                    new SqlParameter("@F_UserName", SqlDbType.VarChar,50),
                    new SqlParameter("@F_DeptId", SqlDbType.Int,4),
                    new SqlParameter("@F_RoleId", SqlDbType.Int,4),
                    new SqlParameter("@F_GroupId", SqlDbType.Int,4),
                    new SqlParameter("@F_SeatFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_SeatRight", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SeatLevel", SqlDbType.VarChar,50),
                    new SqlParameter("@F_SexFlag", SqlDbType.VarChar,50),
                    new SqlParameter("@F_RemindFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_Remark", SqlDbType.VarChar,200),
                    new SqlParameter("@F_Telephone", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Mobile", SqlDbType.VarChar,50),
                    new SqlParameter("@F_HomePhone", SqlDbType.VarChar,50),
                    new SqlParameter("@F_Birthday", SqlDbType.DateTime),
                    new SqlParameter("@F_CreateOn", SqlDbType.DateTime),
                    new SqlParameter("@F_CancelOn", SqlDbType.DateTime),
                    new SqlParameter("@F_DeleteFlag", SqlDbType.SmallInt,2),
                    new SqlParameter("@F_APPOnFlag", SqlDbType.Bit,1),
                    new SqlParameter("@F_LastActiveTime", SqlDbType.DateTime),
                    new SqlParameter("@F_See", SqlDbType.VarChar,100),
                    new SqlParameter("@F_HJType", SqlDbType.Int,4),
                    new SqlParameter("@F_PId", SqlDbType.Int,4),
                    new SqlParameter("@F_TmId", SqlDbType.Int,4),
                    new SqlParameter("@F_RoleName", SqlDbType.NVarChar,50),
                    new SqlParameter("@F_DeptName", SqlDbType.VarChar,60)};
            parameters[0].Value = model.F_UserId;
            parameters[1].Value = model.F_UserCode;
            parameters[2].Value = model.F_Password;
            parameters[3].Value = model.F_ExtensionNumber;
            parameters[4].Value = model.F_UserName;
            parameters[5].Value = model.F_DeptId;
            parameters[6].Value = model.F_RoleId;
            parameters[7].Value = model.F_GroupId;
            parameters[8].Value = model.F_SeatFlag;
            parameters[9].Value = model.F_SeatRight;
            parameters[10].Value = model.F_SeatLevel;
            parameters[11].Value = model.F_SexFlag;
            parameters[12].Value = model.F_RemindFlag;
            parameters[13].Value = model.F_Remark;
            parameters[14].Value = model.F_Telephone;
            parameters[15].Value = model.F_Mobile;
            parameters[16].Value = model.F_HomePhone;
            parameters[17].Value = model.F_Birthday;
            parameters[18].Value = model.F_CreateOn;
            parameters[19].Value = model.F_CancelOn;
            parameters[20].Value = model.F_DeleteFlag;
            parameters[21].Value = model.F_APPOnFlag;
            parameters[22].Value = model.F_LastActiveTime;
            parameters[23].Value = model.F_See;
            parameters[24].Value = model.F_HJType;
            parameters[25].Value = model.F_PId;
            parameters[26].Value = model.F_TmId;
            parameters[27].Value = model.F_RoleName;
            parameters[28].Value = model.F_DeptName;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete()
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from UserAccount ");
            strSql.Append(" where ");
            SqlParameter[] parameters = {
};

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.UserAccount GetModel()
        {
            //该表无主键信息，请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 F_UserId,F_UserCode,F_Password,F_ExtensionNumber,F_UserName,F_DeptId,F_RoleId,F_GroupId,F_SeatFlag,F_SeatRight,F_SeatLevel,F_SexFlag,F_RemindFlag,F_Remark,F_Telephone,F_Mobile,F_HomePhone,F_Birthday,F_CreateOn,F_CancelOn,F_DeleteFlag,F_APPOnFlag,F_LastActiveTime,F_See,F_HJType,F_PId,F_TmId,F_RoleName,F_DeptName from UserAccount ");
            strSql.Append(" where ");
            SqlParameter[] parameters = {
};

            Model.UserAccount model = new Model.UserAccount();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["F_UserId"] != null && ds.Tables[0].Rows[0]["F_UserId"].ToString() != "")
                {
                    model.F_UserId = int.Parse(ds.Tables[0].Rows[0]["F_UserId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_UserCode"] != null && ds.Tables[0].Rows[0]["F_UserCode"].ToString() != "")
                {
                    model.F_UserCode = ds.Tables[0].Rows[0]["F_UserCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_Password"] != null && ds.Tables[0].Rows[0]["F_Password"].ToString() != "")
                {
                    model.F_Password = ds.Tables[0].Rows[0]["F_Password"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_ExtensionNumber"] != null && ds.Tables[0].Rows[0]["F_ExtensionNumber"].ToString() != "")
                {
                    model.F_ExtensionNumber = ds.Tables[0].Rows[0]["F_ExtensionNumber"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_UserName"] != null && ds.Tables[0].Rows[0]["F_UserName"].ToString() != "")
                {
                    model.F_UserName = ds.Tables[0].Rows[0]["F_UserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DeptId"] != null && ds.Tables[0].Rows[0]["F_DeptId"].ToString() != "")
                {
                    model.F_DeptId = int.Parse(ds.Tables[0].Rows[0]["F_DeptId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RoleId"] != null && ds.Tables[0].Rows[0]["F_RoleId"].ToString() != "")
                {
                    model.F_RoleId = int.Parse(ds.Tables[0].Rows[0]["F_RoleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_GroupId"] != null && ds.Tables[0].Rows[0]["F_GroupId"].ToString() != "")
                {
                    model.F_GroupId = int.Parse(ds.Tables[0].Rows[0]["F_GroupId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_SeatFlag"] != null && ds.Tables[0].Rows[0]["F_SeatFlag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_SeatFlag"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_SeatFlag"].ToString().ToLower() == "true"))
                    {
                        model.F_SeatFlag = true;
                    }
                    else
                    {
                        model.F_SeatFlag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["F_SeatRight"] != null && ds.Tables[0].Rows[0]["F_SeatRight"].ToString() != "")
                {
                    model.F_SeatRight = ds.Tables[0].Rows[0]["F_SeatRight"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_SeatLevel"] != null && ds.Tables[0].Rows[0]["F_SeatLevel"].ToString() != "")
                {
                    model.F_SeatLevel = ds.Tables[0].Rows[0]["F_SeatLevel"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_SexFlag"] != null && ds.Tables[0].Rows[0]["F_SexFlag"].ToString() != "")
                {
                    model.F_SexFlag = ds.Tables[0].Rows[0]["F_SexFlag"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_RemindFlag"] != null && ds.Tables[0].Rows[0]["F_RemindFlag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_RemindFlag"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_RemindFlag"].ToString().ToLower() == "true"))
                    {
                        model.F_RemindFlag = true;
                    }
                    else
                    {
                        model.F_RemindFlag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["F_Remark"] != null && ds.Tables[0].Rows[0]["F_Remark"].ToString() != "")
                {
                    model.F_Remark = ds.Tables[0].Rows[0]["F_Remark"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_Telephone"] != null && ds.Tables[0].Rows[0]["F_Telephone"].ToString() != "")
                {
                    model.F_Telephone = ds.Tables[0].Rows[0]["F_Telephone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_Mobile"] != null && ds.Tables[0].Rows[0]["F_Mobile"].ToString() != "")
                {
                    model.F_Mobile = ds.Tables[0].Rows[0]["F_Mobile"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_HomePhone"] != null && ds.Tables[0].Rows[0]["F_HomePhone"].ToString() != "")
                {
                    model.F_HomePhone = ds.Tables[0].Rows[0]["F_HomePhone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_Birthday"] != null && ds.Tables[0].Rows[0]["F_Birthday"].ToString() != "")
                {
                    model.F_Birthday = DateTime.Parse(ds.Tables[0].Rows[0]["F_Birthday"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CreateOn"] != null && ds.Tables[0].Rows[0]["F_CreateOn"].ToString() != "")
                {
                    model.F_CreateOn = DateTime.Parse(ds.Tables[0].Rows[0]["F_CreateOn"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_CancelOn"] != null && ds.Tables[0].Rows[0]["F_CancelOn"].ToString() != "")
                {
                    model.F_CancelOn = DateTime.Parse(ds.Tables[0].Rows[0]["F_CancelOn"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_DeleteFlag"] != null && ds.Tables[0].Rows[0]["F_DeleteFlag"].ToString() != "")
                {
                    model.F_DeleteFlag = int.Parse(ds.Tables[0].Rows[0]["F_DeleteFlag"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_APPOnFlag"] != null && ds.Tables[0].Rows[0]["F_APPOnFlag"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["F_APPOnFlag"].ToString() == "1") || (ds.Tables[0].Rows[0]["F_APPOnFlag"].ToString().ToLower() == "true"))
                    {
                        model.F_APPOnFlag = true;
                    }
                    else
                    {
                        model.F_APPOnFlag = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["F_LastActiveTime"] != null && ds.Tables[0].Rows[0]["F_LastActiveTime"].ToString() != "")
                {
                    model.F_LastActiveTime = DateTime.Parse(ds.Tables[0].Rows[0]["F_LastActiveTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_See"] != null && ds.Tables[0].Rows[0]["F_See"].ToString() != "")
                {
                    model.F_See = ds.Tables[0].Rows[0]["F_See"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_HJType"] != null && ds.Tables[0].Rows[0]["F_HJType"].ToString() != "")
                {
                    model.F_HJType = int.Parse(ds.Tables[0].Rows[0]["F_HJType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_PId"] != null && ds.Tables[0].Rows[0]["F_PId"].ToString() != "")
                {
                    model.F_PId = int.Parse(ds.Tables[0].Rows[0]["F_PId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_TmId"] != null && ds.Tables[0].Rows[0]["F_TmId"].ToString() != "")
                {
                    model.F_TmId = int.Parse(ds.Tables[0].Rows[0]["F_TmId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["F_RoleName"] != null && ds.Tables[0].Rows[0]["F_RoleName"].ToString() != "")
                {
                    model.F_RoleName = ds.Tables[0].Rows[0]["F_RoleName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["F_DeptName"] != null && ds.Tables[0].Rows[0]["F_DeptName"].ToString() != "")
                {
                    model.F_DeptName = ds.Tables[0].Rows[0]["F_DeptName"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select F_UserId,F_UserCode,F_Password,F_ExtensionNumber,F_UserName,F_DeptId,F_RoleId,F_GroupId,F_SeatFlag,F_SeatRight,F_SeatLevel,F_SexFlag,F_RemindFlag,F_Remark,F_Telephone,F_Mobile,F_HomePhone,F_Birthday,F_CreateOn,F_CancelOn,F_DeleteFlag,F_APPOnFlag,F_LastActiveTime,F_See,F_HJType,F_PId,F_TmId,F_RoleName,F_DeptName ");
            strSql.Append(" FROM UserAccount ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" F_UserId,F_UserCode,F_Password,F_ExtensionNumber,F_UserName,F_DeptId,F_RoleId,F_GroupId,F_SeatFlag,F_SeatRight,F_SeatLevel,F_SexFlag,F_RemindFlag,F_Remark,F_Telephone,F_Mobile,F_HomePhone,F_Birthday,F_CreateOn,F_CancelOn,F_DeleteFlag,F_APPOnFlag,F_LastActiveTime,F_See,F_HJType,F_PId,F_TmId,F_RoleName,F_DeptName ");
            strSql.Append(" FROM UserAccount ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM UserAccount ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T. desc");
            }
            strSql.Append(")AS Row, T.*  from UserAccount T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(strSql.ToString());
        }

        #endregion  Method
    }
}
