Exemple #1
0
        public List <RoleInfo> GetRoleInfoPageList(IDbCommand icmd, string fileds, string whereCondition, int startIndex, int pageSize)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(fileds))
            {
                sb.AppendFormat("select {0} from t_role_info ", fileds);
            }
            if (!string.IsNullOrEmpty(whereCondition))
            {
                sb.AppendFormat("{0} ", whereCondition);
            }
            sb.AppendFormat("limit {0},{1}", startIndex, pageSize);
            List <RoleInfo> list = new List <RoleInfo>();
            DataTable       dt   = new DataTable();

            if (dt.Rows.Count > 0)
            {
                RoleInfo info = null;
                foreach (DataRow dr in dt.Rows)
                {
                    info = new RoleInfo();
                    info.AllParse(dr);
                    if (info != null)
                    {
                        list.Add(info);
                    }
                }
            }
            return(list);
        }
Exemple #2
0
        public RoleInfo GetRoleInfoById(IDbCommand icmd, Guid id)
        {
            icmd.Parameters.Clear();
            MySqlCommand cmd = icmd as MySqlCommand;

            cmd.CommandType = CommandType.Text;
            string sql = @"select id,name,description,updatetime,status
                            from t_role_info
                            where id = '{0}'";

            cmd.CommandText = string.Format(sql, id);
            DataTable dt   = new DataTable();
            RoleInfo  info = null;

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                info = new RoleInfo();
                info.AllParse(dt.Rows[0]);
            }
            return(info);
        }