Exemplo n.º 1
0
        //UdList Object Scope Validation check the entire object for validity...
        private byte UdListIsValid(UdList udList, out string errorMessage)
        {
            //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(udList.UdListID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetUdListState(udList);

            if (entityState == EntityStates.Added && UdListExists(udList.UdListID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = UdListList.Count(q => q.UdListID == udList.UdListID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //validate Description
            if (string.IsNullOrEmpty(udList.Name))
            {
                errorMessage = "Name Is Required.";
                return(1);
            }
            return(2);
        }
Exemplo n.º 2
0
        public void DeleteUdListCommand()
        {
            int i  = 0;
            int ii = 0;

            for (int j = SelectedUdListList.Count - 1; j >= 0; j--)
            {
                UdList udList = (UdList)SelectedUdListList[j];
                //get Max Index...
                i = UdListList.IndexOf(udList);
                if (i > ii)
                {
                    ii = i;
                }

                Delete(udList);
                UdListList.Remove(udList);
            }

            if (UdListList != null && UdListList.Count > 0)
            {
                //back off one index from the max index...
                ii = ii - 1;

                //if they delete the first row...
                if (ii < 0)
                {
                    ii = 0;
                }

                //make sure it does not exceed the list count...
                if (ii >= UdListList.Count())
                {
                    ii = UdListList.Count - 1;
                }

                SelectedUdList = UdListList[ii];
                //we will only enable committ for dirty validated records...
                if (Dirty == true)
                {
                    AllowCommit = CommitIsAllowed();
                }
                else
                {
                    AllowCommit = false;
                }
            }
            else//only one record, deleting will result in no records...
            {
                SetAsEmptySelection();
            }
        }
Exemplo n.º 3
0
        //Object.Property Scope Validation...
        private bool UdListIsValid(UdList udList, _udListValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _udListValidationProperties.UdListID:
                //validate key
                if (string.IsNullOrEmpty(udList.UdListID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetUdListState(udList);
                if (entityState == EntityStates.Added && UdListExists(udList.UdListID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = UdListList.Count(q => q.UdListID == udList.UdListID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                break;

            case _udListValidationProperties.Name:
                //validate Description
                if (string.IsNullOrEmpty(udList.Name))
                {
                    errorMessage = "Description Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }