Esempio n. 1
0
        public PermissionInfo GetPermissionInfoById(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_permission_info
                            where id = '{0}'";

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

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                info = new PermissionInfo();
                info.AllParse(dt.Rows[0]);
            }
            return(info);
        }
Esempio n. 2
0
        public List <PermissionInfo> GetPermissionInfoPageList(IDbCommand icmd, string fields, 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(fields))
            {
                sb.AppendFormat("select {0} from t_permission_info ", fields);
            }
            if (!string.IsNullOrEmpty(whereCondition))
            {
                sb.AppendFormat("{0} ", whereCondition);
            }
            sb.AppendFormat("limit {0},{1}", startIndex, pageSize);
            cmd.CommandText = sb.ToString();
            List <PermissionInfo> list = new List <PermissionInfo>();
            DataTable             dt   = new DataTable();

            dt.Load(cmd.ExecuteReader());
            if (dt.Rows.Count > 0)
            {
                PermissionInfo info = null;
                foreach (DataRow dr in dt.Rows)
                {
                    info = new PermissionInfo();
                    info.AllParse(dr);
                    if (null != info)
                    {
                        list.Add(info);
                    }
                }
            }
            return(list);
        }