コード例 #1
0
        static public Country GetById(int id)
        {
            Country       country       = null;
            Role          user_role     = Role.Admin;
            Type          type          = typeof(CountryBLL);
            MethodInfo    method        = type.GetMethod("GetById");
            RoleAttribute attribute     = method.GetCustomAttribute <RoleAttribute>();
            Role          function_role = attribute.Role;

            if (user_role == function_role)
            {
                DataRow dr = CountryBLL.GetById(id);
                country = new Country();

                country.ID           = dr.Field <int>("ID");
                country.Country_Name = dr.Field <string>("Name");
            }
            return(country);
        }
コード例 #2
0
ファイル: CitySL.cs プロジェクト: MernaNashaat/Ado.Layers_C-
        static public City GetById(int id, Role user_role)
        {
            City          city          = null;
            Type          type          = typeof(CityBLL);
            MethodInfo    method        = type.GetMethod("GetById");
            RoleAttribute attribute     = method.GetCustomAttribute <RoleAttribute>();
            Role          function_role = attribute.Role;

            if (user_role == function_role)
            {
                DataRow dr = CityBLL.GetById(id);
                if (dr != null)
                {
                    city = new City();
                    //foreach (DataColumn c in dr.Table.Columns)
                    //{
                    //    var x = c.ColumnName;
                    //}
                    city.ID        = dr.Field <int>("ID");
                    city.City_Name = dr.Field <string>("City_Name");
                }
            }
            return(city);
        }