private void button1_Click(object sender, EventArgs e)
        {
            List <Feature> features = new List <Feature>();

            foreach (object o in lstFeatures.SelectedItems)
            {
                Feature f = (Feature)o;
                features.Add(f);
            }
            string RoleID = Role.InsertRole(txtRoleName.Text);

            if (RoleID.Equals("failed"))
            {
                MessageBox.Show("Role Name existed!");
                return;
            }
            int result = FeatureList.InsertsFeaturesWithRoleID(RoleID, features);

            if (result != features.Count)
            {
                MessageBox.Show("Something went wrong! Cant add new Role"); return;
            }
            MessageBox.Show("Added \n Role: " + txtRoleName.Text + "\n RoleID: " + RoleID);

            List <Role> roles = RoleList.GetRoles();

            lstRoles.DataSource    = roles;
            lstRoles.DisplayMember = "RoleName";
            lstRoles.Refresh();
        }
        private void initAdd()
        {
            lstRoles.DataSource    = RoleList.GetRoles();
            lstRoles.DisplayMember = "RoleName";
            lstRoles.SelectedItems.Clear();

            lstFeatures.DataSource    = FeatureList.GetFeatures();
            lstFeatures.DisplayMember = "DisplayName";
            btnCreateAccount.Click   += btnCreate_Click;

            btnEditRole.Hide();
        }
Exemplo n.º 3
0
        public static List <Role> GetRoleByID(string ID)
        {
            List <Role> List = new List <Role>();
            DataTable   dt   = AccountDAO.GetRoleByID(ID);

            foreach (DataRow dr in dt.Rows)
            {
                Role e = new Role();
                e.ID       = dr["RoleID"].ToString();
                e.RoleName = dr["RoleName"].ToString();
                e.Features = FeatureList.GetFeaturesByRoleID(e.ID);
                List.Add(e);
            }
            return(List);
        }
        private void lstRoles_SelectedIndexChanged(object sender, EventArgs e)
        {
            fglFeaturesDisplay.Controls.Clear();


            List <Role> Roles = new List <Role>();

            foreach (object o in lstRoles.SelectedItems)
            {
                Role f = (Role)o;
                Roles.Add(f);
            }

            List <Feature> features = FeatureList.GetFeaturesByListOfRole(Roles);

            foreach (Feature f in features)
            {
                Label lb = new Label();
                lb.Text      = f.Name + "_" + f.Code;
                lb.BackColor = Color.White;
                lb.AutoSize  = true;
                fglFeaturesDisplay.Controls.Add(lb);
            }
        }