Ejemplo n.º 1
0
        private void FillRoles(DropDownList ddl)
        {
            try {
                ddl.Items.Clear();
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCSecurity.SecurityRoleGetAll(conn)) {
                        System.Web.UI.WebControls.ListItem item = new ListItem("All", "0");
                        ddl.Items.Add(item);

                        while (dr.Read())
                        {
                            int roleID = dr.GetInt16(dr.GetOrdinal("sro_role_id"));
                            item = new ListItem(dr.GetString(dr.GetOrdinal("sro_role_name")),
                                                roleID.ToString());

                            ddl.Items.Add(item);
                        }
                    }
                }
                ddl.SelectedIndex = 0;
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException("Security.FillRoles", ex);
                throw (wex);
            }
        }
Ejemplo n.º 2
0
        private void FillRoles(ListBox lst)
        {
            try {
                lst.Items.Clear();
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BeetConn"].ToString())) {
                    using (SqlDataReader dr = WSCSecurity.SecurityRoleGetAll(conn)) {
                        while (dr.Read())
                        {
                            int      roleID = dr.GetInt16(dr.GetOrdinal("sro_role_id"));
                            ListItem item   = new ListItem(dr.GetString(dr.GetOrdinal("sro_role_name")),
                                                           roleID.ToString());

                            lst.Items.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex) {
                Common.CException wex = new Common.CException("Security.FillRoles", ex);
                throw (wex);
            }
        }