Beispiel #1
0
 private void button12_Click(object sender, EventArgs e)
 {
     KellPermission.Department parent = null;
     try
     {
         parent = deps[comboBox11.SelectedIndex - 1];
     }
     catch
     { }
     KellPermission.Department dep = null;
     if (parent != null)
     {
         dep = new KellPermission.Department(textBox7.Text.Trim(), parent);
     }
     else
     {
         dep = new KellPermission.Department(textBox7.Text.Trim());
     }
     deps.Add(dep);
     RefreshDeps(deps.Count - 1);
 }
Beispiel #2
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;
                }
            }
        }