Exemplo n.º 1
0
        //ExecutableProgramCode Object Scope Validation check the entire object for validity...
        private byte ExecutableProgramCodeIsValid(ExecutableProgramCode item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.ExecutableProgramCodeID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetExecutableProgramCodeState(item);

            if (entityState == EntityStates.Added && ExecutableProgramCodeExists(item.ExecutableProgramCodeID, ClientSessionSingleton.Instance.CompanyID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = ExecutableProgramCodeList.Count(q => q.ExecutableProgramCodeID == item.ExecutableProgramCodeID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //validate Description
            if (string.IsNullOrEmpty(item.Description))
            {
                errorMessage = "Description Is Required.";
                return(1);
            }
            //a value of 2 is pending changes...
            //On Commit we will give it a value of 0...
            return(2);
        }
Exemplo n.º 2
0
        public void DeleteExecutableProgramCodeCommand()
        {
            try
            {//company is fk to 100's of tables deleting it can be tricky...
                int i  = 0;
                int ii = 0;
                for (int j = SelectedExecutableProgramCodeList.Count - 1; j >= 0; j--)
                {
                    ExecutableProgramCode item = (ExecutableProgramCode)SelectedExecutableProgramCodeList[j];
                    //get Max Index...
                    i = ExecutableProgramCodeList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    ExecutableProgramCodeList.Remove(item);
                }

                if (ExecutableProgramCodeList != null && ExecutableProgramCodeList.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 >= ExecutableProgramCodeList.Count())
                    {
                        ii = ExecutableProgramCodeList.Count - 1;
                    }

                    SelectedExecutableProgramCode = ExecutableProgramCodeList[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();
                }
            }//we try catch company delete as it may be used in another table as a key...
            //As well we will force a refresh to sqare up the UI after the botched delete...
            catch
            {
                NotifyMessage("ExecutableProgramCode/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
Exemplo n.º 3
0
        //Object.Property Scope Validation...
        private bool ExecutableProgramCodeIsValid(ExecutableProgramCode item, _companyValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _companyValidationProperties.ExecutableProgramCodeID:
                //validate key
                if (string.IsNullOrEmpty(item.ExecutableProgramCodeID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetExecutableProgramCodeState(item);
                if (entityState == EntityStates.Added && ExecutableProgramCodeExists(item.ExecutableProgramCodeID, ClientSessionSingleton.Instance.CompanyID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = ExecutableProgramCodeList.Count(q => q.ExecutableProgramCodeID == item.ExecutableProgramCodeID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }

                break;

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