Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string userName = textBox1.Text.Trim();
            string password = textBox2.Text.Trim();

            //List<KellPermission.Department> deps = (List<KellPermission.Department>)comboBox1.Tag;
            //List<KellPermission.Project> prjs = (List<KellPermission.Project>)comboBox2.Tag;
            if (deps != null)
            {
                Department          dep         = deps[comboBox1.SelectedIndex];
                string              description = textBox3.Text;
                KellPermission.User user        = null;
                Project             prj         = null;
                try
                {
                    if (prjs != null)
                    {
                        prj = prjs[comboBox2.SelectedIndex - 1];
                    }
                }
                catch
                { }
                if (prj != null)
                {
                    user = new KellPermission.User(userName, password, dep, prj);
                }
                else
                {
                    user = new KellPermission.User(userName, password, dep);
                }
                user.Description = description;
                users.Add(user);
                RefreshUsers(users.Count - 1);
            }
        }
Ejemplo n.º 2
0
 private void button13_Click(object sender, EventArgs e)
 {
     foreach (object obj in listBoxSelecter4.SelectedItems)
     {
         KellPermission.User user = (KellPermission.User)obj;
         if (!user.Projects.Contains(prjs[comboBox12.SelectedIndex]))
         {
             user.Projects.Add(prjs[comboBox12.SelectedIndex]);
         }
     }
 }
Ejemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     foreach (object obj in listBoxSelecter1.SelectedItems)
     {
         KellPermission.User user = (KellPermission.User)obj;
         if (!user.Departments.Contains(deps[comboBox3.SelectedIndex]))
         {
             user.Departments.Add(deps[comboBox3.SelectedIndex]);
         }
     }
 }
Ejemplo n.º 4
0
        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            KellPermission.User user = users[comboBox8.SelectedIndex];
            textBox1.Text = user.UserName;
            textBox2.Text = user.Password;
            textBox3.Text = user.Description;
            foreach (KellPermission.Department d in deps)
            {
                if (user.Departments.Contains(d))
                {
                    comboBox1.SelectedItem = d.Name;
                    break;
                }
            }
            bool have = false;

            foreach (KellPermission.Project p in prjs)
            {
                if (user.Projects.Contains(p))
                {
                    comboBox2.SelectedItem = p.Name;
                    have = true;
                    break;
                }
            }
            if (!have)
            {
                comboBox2.SelectedIndex = 0;
            }
            label14.Text = string.Format("用户[{0}]具有的权限:", user.UserName);
            listBox1.Items.Clear();
            PermissionCollection ps = user.GetAllPermissions();

            foreach (Permission p in ps)
            {
                listBox1.Items.Add(p);
            }
            selectUser = comboBox8.SelectedIndex;
        }
Ejemplo n.º 5
0
        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control c = contextMenuStrip1.SourceControl;

            if (c is Button)
            {
                string name;
                Button btn = c as Button;
                switch (btn.Name)
                {
                case "btn_Perm":
                    name = textBox11.Text.Trim();
                    string mod = comboBox9.Text;
                    string act = comboBox10.Text;
                    KellPermission.Permission per = perms[selectPerm];
                    per.Name           = name;
                    per.TheModule.Name = mod;
                    per.TheAction.Name = act;
                    listBoxSelecter2.UpdateSourceItem(selectPerm, per);
                    break;

                case "btn_Role":
                    name = textBox10.Text.Trim();
                    KellPermission.PermissionCollection pers = new KellPermission.PermissionCollection();
                    foreach (object obj in listBoxSelecter3.SelectedItems)
                    {
                        KellPermission.Permission perr = (KellPermission.Permission)obj;
                        roles[selectRole].Permissions.Add(perr);
                    }
                    roles[selectRole].Name = name;
                    listBoxSelecter3.UpdateSourceItem(selectRole, roles[selectRole]);
                    break;

                case "btn_User":
                    string userName = textBox1.Text.Trim();
                    string password = textBox2.Text.Trim();
                    if (deps != null)
                    {
                        Department          dep         = deps[comboBox1.SelectedIndex];
                        string              description = textBox3.Text;
                        KellPermission.User user        = users[selectUser];
                        Project             prj         = null;
                        try
                        {
                            if (prjs != null)
                            {
                                prj = prjs[comboBox2.SelectedIndex - 1];
                            }
                        }
                        catch
                        { }
                        if (prj != null)
                        {
                            user.Projects.Clear();
                            user.Projects.Add(prj);
                        }
                        else
                        {
                            user.Projects.Clear();
                        }
                        user.UserName = userName;
                        user.Password = password;
                        user.Departments.Clear();
                        user.Departments.Add(dep);
                        user.Description            = description;
                        comboBox8.Items[selectUser] = userName;
                    }
                    break;

                case "btn_Dept":
                    name = textBox7.Text.Trim();
                    KellPermission.Department parent = null;
                    try
                    {
                        parent = deps[comboBox11.SelectedIndex - 1];
                    }
                    catch
                    { }
                    KellPermission.Department depp = deps[selectDept];
                    if (parent != null)
                    {
                        depp.Parent = parent;
                    }
                    else
                    {
                        depp.Parent = null;
                    }
                    depp.Name = name;
                    comboBox3.Items[selectDept]  = depp.Name;
                    comboBox1.Items[selectDept]  = depp.Name;
                    comboBox6.Items[selectDept]  = depp.Name;
                    comboBox11.Items[selectDept] = depp.Name;
                    break;

                case "btn_Proj":
                    name = textBox6.Text.Trim();
                    prjs[selectProj].Name        = name;
                    comboBox12.Items[selectProj] = name;
                    comboBox2.Items[selectProj]  = name;
                    comboBox5.Items[selectProj]  = name;
                    break;

                case "btn_Modu":
                    name = textBox8.Text.Trim();
                    mods[selectModu].Name       = name;
                    comboBox9.Items[selectModu] = name;
                    break;

                case "btn_Actn":
                    name = textBox9.Text.Trim();
                    acts[selectActn].Name        = name;
                    comboBox10.Items[selectActn] = name;
                    break;
                }
            }
        }