Esempio n. 1
0
        public override bool CanDelete(DataRow row)
        {
            atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)row;

            bool ok = false;

            atSecurity.SecurityManager.LevelPermissions perm = myA.AtMng.SecurityManager.CanDelete(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime);
            switch (perm)
            {
            case atSecurity.SecurityManager.LevelPermissions.All:
                ok = true;
                break;

            case atSecurity.SecurityManager.LevelPermissions.Mine:
                if (dr.OfficerId == myA.AtMng.OfficerLoggedOn.OfficerId)
                {
                    ok = true;
                }
                else if (dr.OfficerId == myA.AtMng.WorkingAsOfficer.OfficerId)
                {
                    ok = true;
                }
                break;

            case atSecurity.SecurityManager.LevelPermissions.MyOffice:
                if (dr.OfficeId == myA.AtMng.OfficerLoggedOn.OfficeId)
                {
                    ok = true;
                }
                break;

            case atSecurity.SecurityManager.LevelPermissions.No:
                ok = false;
                break;

            default:
                ok = false;
                break;
            }

            bool canOverride = myA.AtMng.SecurityManager.CanOverride(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) == atSecurity.SecurityManager.ExPermissions.Yes;

            if (dr.Final && !dr.IsIRPIdNull() && !canOverride)
            {
                ok = false;
            }
            return(ok);
        }
Esempio n. 2
0
        public override bool CanEdit(DataRow ddr)
        {
            atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)ddr;
            if (!myA.IsVirtualFM && dr.FileId != myA.CurrentFile.FileId)
            {
                return(false);
            }
            //2017-08-21 JLL: On refresh, ActivityRow is null, return false;
            if (dr.ActivityRow == null)
            {
                return(false);
            }
            if (dr.ActivityRow.EFileRow.RowState == DataRowState.Added)
            {
                return(true);
            }

            bool doCheck = false;

            if (dr.RowState != DataRowState.Modified)
            {
                doCheck = true;
            }
            else
            {
                //if only fileid or audit values was changed then return true
                foreach (DataColumn dc in dr.Table.Columns)
                {
                    switch (dc.ColumnName.ToLower())
                    {
                    case "fileid":
                    case "updatedate":
                    case "updateuser":
                        break;

                    default:
                        if (myA.IsFieldChanged(dc, dr))
                        {
                            doCheck = true;
                        }
                        break;
                    }
                }
            }
            if (doCheck)
            {
                bool ok = false;// myA.AtMng.SecurityManager.CanUpdate(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) > atSecurity.SecurityManager.LevelPermissions.No;
                atSecurity.SecurityManager.LevelPermissions perm = myA.AtMng.SecurityManager.CanUpdate(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime);
                switch (perm)
                {
                case atSecurity.SecurityManager.LevelPermissions.All:
                    ok = true;
                    break;

                case atSecurity.SecurityManager.LevelPermissions.Mine:
                    if (dr.OfficerId == myA.AtMng.OfficerLoggedOn.OfficerId)
                    {
                        ok = true;
                    }
                    else
                    {
                        OfficeManager myOfficeMng = myA.AtMng.GetOffice(myA.AtMng.OfficeLoggedOn.OfficeId);

                        foreach (lmDatasets.officeDB.OfficerDelegateRow odr in myOfficeMng.GetOfficerDelegate().DelegatesForOfficer(myA.AtMng.OfficerLoggedOn.OfficerId))
                        {
                            if (dr.OfficerId == odr.OfficerId)
                            {
                                ok = true;
                            }
                        }
                    }
                    //else if (dr.OfficerId == myA.AtMng.WorkingAsOfficer.OfficerId)
                    //    ok = true;
                    break;

                case atSecurity.SecurityManager.LevelPermissions.MyOffice:
                    if (dr.OfficeId == myA.AtMng.OfficerLoggedOn.OfficeId)
                    {
                        ok = true;
                    }
                    break;

                case atSecurity.SecurityManager.LevelPermissions.No:
                    ok = false;
                    break;

                default:
                    ok = false;
                    break;
                }


                bool canOverride = myA.AtMng.SecurityManager.CanOverride(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) == atSecurity.SecurityManager.ExPermissions.Yes;
                if (dr.Final && !dr.IsIRPIdNull() && !canOverride)
                {
                    ok = false;
                }

                return(ok | AllowEdit);
            }
            else
            {
                return(true);
            }
        }