예제 #1
0
        private void bt_PermsEdit_Click(object sender, EventArgs e)
        {
            try
            {
                int userid = int.Parse(dgv_Users.SelectedRows[0].Cells[0].Value.ToString());

                if (userid == Main.user.ID)
                {
                    throw new Exception("You can't change your own permissions!");
                }

                List <string> perms     = Database.GetData.List("Permissions", "Permission");
                List <string> userPerms = Database_Connector.Select.UserPermissions(userid);

                SidebySideSelection sbs_Form = new SidebySideSelection(perms, userPerms, "Users Permissions Edit");
                DialogResult        dr       = sbs_Form.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    if (sbs_Form.AddedList.Count > 0)
                    {
                        Database_Connector.Insert.UserPermissions(userid, sbs_Form.AddedList);
                    }
                    if (sbs_Form.DeletedList.Count > 0)
                    {
                        Database_Connector.Delete.UserPermissions(userid, sbs_Form.DeletedList);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void bt_PermsEdit_Click(object sender, EventArgs e)
        {
            try
            {
                int userid = int.Parse(dgv_Users.SelectedRows[0].Cells[0].Value.ToString());

                if (userid == Main.user.ID) throw new Exception("You can't change your own permissions!");

                List<string> perms = Database.GetData.List("Permissions", "Permission");
                List<string> userPerms = Database_Connector.Select.UserPermissions(userid);

                SidebySideSelection sbs_Form = new SidebySideSelection(perms, userPerms, "Users Permissions Edit");
                DialogResult dr = sbs_Form.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    if (sbs_Form.AddedList.Count > 0)
                        Database_Connector.Insert.UserPermissions(userid, sbs_Form.AddedList);
                    if (sbs_Form.DeletedList.Count > 0)
                        Database_Connector.Delete.UserPermissions(userid, sbs_Form.DeletedList);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }