Esempio n. 1
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            var record = (PermissionGroup)dataGridView2.Rows[e.RowIndex].DataBoundItem;

            record.CompanyId = Session.Instance.AuthUser.CompanyId;

            var permissions = PermissionBS.GetPermissionByPermissionGroupId(record.PermissionGroupId);

            mSelectedPermissionGroupId   = record.PermissionGroupId;
            mSelectedPermissionGroupName = record.PermissionGroupName;

            if (e.ColumnIndex == dataGridView2.Columns["Save"].Index)
            {
                if (permissions == null || permissions.Count < 1)
                {
                    List <Permission> perms = new List <Permission>();

                    for (int i = 1; i < typeof(Modules).GetEnumNames().Count(); i++)
                    {
                        PermissionBS.AddPermission(new Permission()
                        {
                            PermissionGroupId = mSelectedPermissionGroupId, ModuleId = i, CompanyId = Session.Instance.AuthUser.CompanyId
                        });
                    }
                }

                var entry = PermissionBS.AddPermissionGroup(record);
                mSelectedPermissionGroupId = entry.PermissionGroupId;
                PopulatPermissionGroups();
                PopulatPermissions(PermissionBS.GetPermissionByPermissionGroupId(mSelectedPermissionGroupId));

                return;
            }
            if (e.ColumnIndex == dataGridView2.Columns["Delete"].Index)
            {
                PermissionBS.DeletePermissionByPermissionGroupId(mSelectedPermissionGroupId);
                PopulatPermissionGroups();
                PopulatPermissions(PermissionBS.GetPermissionByPermissionGroupId(mSelectedPermissionGroupId));

                return;
            }

            PopulatPermissions(PermissionBS.GetPermissionByPermissionGroupId(mSelectedPermissionGroupId));
        }
Esempio n. 2
0
        private void button_save_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                Permission perm = new Permission();
                perm.PermissionId      = ((Permission)dataGridView1.Rows[row.Index].DataBoundItem).PermissionId;
                perm.PermissionGroupId = mSelectedPermissionGroupId;
                perm.CompanyId         = Session.Instance.AuthUser.CompanyId;
                perm.ModuleId          = (int)dataGridView1.Rows[row.Index].Cells["ModuleId"].Value;
                perm.FullAccess        = (bool)dataGridView1.Rows[row.Index].Cells["FullAccess"].Value;
                perm.CanEdit           = (bool)dataGridView1.Rows[row.Index].Cells["CanEdit"].Value;
                perm.CanRead           = (bool)dataGridView1.Rows[row.Index].Cells["CanRead"].Value;
                perm.CanView           = (bool)dataGridView1.Rows[row.Index].Cells["CanView"].Value;

                PermissionBS.AddPermission(perm);
            }

            PopulatPermissions(PermissionBS.GetPermissionByPermissionGroupId(mSelectedPermissionGroupId));
        }