Esempio n. 1
0
        private void ApplySecurity()
        {
            if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PPartnerTable.GetTableDBName()))
            {
                // need to disable all Fields that are DataBound to p_partner. This continues in the switch statments!
                // timop: I have disabled all controls. usually you have p_partner modify permissions, or none
                CustomEnablingDisabling.DisableControlGroup(pnlContent);
            }

            switch (SharedTypes.PartnerClassStringToEnum(FPartnerClass))
            {
            case TPartnerClass.PERSON:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PPersonTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlPerson, cmbPersonAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlPerson, chkPersonNoSolicitations);

                    // need to disable all Fields that are DataBound to p_person
                    CustomEnablingDisabling.DisableControlGroup(pnlPerson);

                    cmbPersonAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.FAMILY:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PFamilyTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlFamily, cmbFamilyAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlFamily, chkFamilyNoSolicitations);

                    // need to disable all Fields that are DataBound to p_family
                    CustomEnablingDisabling.DisableControlGroup(pnlFamily);

                    cmbFamilyAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.CHURCH:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PChurchTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, cmbOtherAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, chkOtherNoSolicitations);

                    // need to disable all Fields that are DataBound to p_church
                    CustomEnablingDisabling.DisableControlGroup(pnlOther2ndLine);

                    cmbOtherAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.ORGANISATION:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, POrganisationTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, cmbOtherAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, chkOtherNoSolicitations);

                    // need to disable all Fields that are DataBound to p_organisation
                    CustomEnablingDisabling.DisableControlGroup(pnlOther2ndLine);

                    cmbOtherAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.UNIT:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PUnitTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, cmbOtherAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, chkOtherNoSolicitations);

                    // need to disable all Fields that are DataBound to p_unit
                    CustomEnablingDisabling.DisableControlGroup(pnlOther2ndLine);

                    cmbOtherAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.BANK:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PBankTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, cmbOtherAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, chkOtherNoSolicitations);

                    // need to disable all Fields that are DataBound to p_bank
                    CustomEnablingDisabling.DisableControlGroup(pnlOther2ndLine);

                    cmbOtherAddresseeTypeCode.Focus();
                }

                break;

            case TPartnerClass.VENUE:

                if (!UserInfo.GUserInfo.IsTableAccessOK(TTableAccessPermission.tapMODIFY, PVenueTable.GetTableDBName()))
                {
                    // need to disable all Fields that are DataBound to p_partner
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, cmbOtherAddresseeTypeCode);
                    CustomEnablingDisabling.DisableControl(pnlOther2ndLine, chkOtherNoSolicitations);

                    // need to disable all Fields that are DataBound to p_venue
                    CustomEnablingDisabling.DisableControlGroup(pnlOther2ndLine);

                    cmbOtherAddresseeTypeCode.Focus();
                }

                break;

            default:
                MessageBox.Show(String.Format(Catalog.GetString("Unrecognised Partner Class '{0}'!"), FPartnerClass));
                break;
            }
        }