public IEnumerable <ExecutableProgramCode> GetExecutableProgramCodes(ExecutableProgramCode executableProgramCodeQuerryObject, string companyID)
        {
            _repositoryContext             = new MenuSecurityEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = from q in _repositoryContext.ExecutableProgramCodes
                              where q.CompanyID == companyID
                              select q;

            if (!string.IsNullOrEmpty(executableProgramCodeQuerryObject.Code))
            {
                queryResult = queryResult.Where(q => q.Code.StartsWith(executableProgramCodeQuerryObject.Code.ToString()));
            }

            if (!string.IsNullOrEmpty(executableProgramCodeQuerryObject.Description))
            {
                queryResult = queryResult.Where(q => q.Description.StartsWith(executableProgramCodeQuerryObject.Description.ToString()));
            }

            if (!string.IsNullOrEmpty(executableProgramCodeQuerryObject.ExecutableProgramCodeID))
            {
                queryResult = queryResult.Where(q => q.Description.StartsWith(executableProgramCodeQuerryObject.ExecutableProgramCodeID.ToString()));
            }

            return(queryResult);
        }
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedExecutableProgramCode.ExecutableProgramCodeID))
     {//check to see if key is part of the current companylist...
         ExecutableProgramCode query = ExecutableProgramCodeList.Where(company => company.ExecutableProgramCodeID == SelectedExecutableProgramCode.ExecutableProgramCodeID &&
                                                                       company.AutoID != SelectedExecutableProgramCode.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back...
             SelectedExecutableProgramCode.ExecutableProgramCodeID = SelectedExecutableProgramCodeMirror.ExecutableProgramCodeID;
             //change to the newly selected item...
             SelectedExecutableProgramCode = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         ExecutableProgramCodeList = GetExecutableProgramCodeByID(SelectedExecutableProgramCode.ExecutableProgramCodeID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (ExecutableProgramCodeList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedExecutableProgramCode.ExecutableProgramCodeID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedExecutableProgramCode = ExecutableProgramCodeList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedExecutableProgramCode.ExecutableProgramCodeID != SelectedExecutableProgramCodeMirror.ExecutableProgramCodeID)
         {
             SelectedExecutableProgramCode.ExecutableProgramCodeID = SelectedExecutableProgramCodeMirror.ExecutableProgramCodeID;
         }
     }
 }
        //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);
        }
        public void DeleteFromRepository(ExecutableProgramCode executableProgramCode)
        {
            if (_repositoryContext.GetEntityDescriptor(executableProgramCode) != null)
            {//if it exists in the db delete it from the db
                MenuSecurityEntities context = new MenuSecurityEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                ExecutableProgramCode deletedExecutableProgramCode = (from q in context.ExecutableProgramCodes
                                                                      where q.ExecutableProgramCodeID == executableProgramCode.ExecutableProgramCodeID
                                                                      select q).FirstOrDefault();
                if (deletedExecutableProgramCode != null)
                {
                    context.DeleteObject(deletedExecutableProgramCode);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetExecutableProgramCodeEntityState(executableProgramCode) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(executableProgramCode);
                }
            }
        }
        public static List <Temp> GetMetaData(this ExecutableProgramCode entityObject)
        {
            XERP.Server.DAL.MenuSecurityDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (MenuSecurityEntities ctx = new MenuSecurityEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.ExecutableProgramCodes.FirstOrDefault();
                var queryResults = from meta in ctx.MetadataWorkspace.GetItems(DataSpace.CSpace)
                                   .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType)
                                   from query in (meta as EntityType).Properties
                                   .Where(p => p.DeclaringType.Name == entityObject.GetType().Name)
                                   select query;

                if (queryResults.Count() > 0)
                {
                    foreach (var queryResult in queryResults.ToList())
                    {
                        Temp temp = new Temp();
                        temp.ID          = id;
                        temp.Name        = queryResult.Name.ToString();
                        temp.ShortChar_1 = queryResult.TypeUsage.EdmType.Name;
                        if (queryResult.TypeUsage.EdmType.Name == "String")
                        {
                            temp.Int_1 = Convert.ToInt32(queryResult.TypeUsage.Facets["MaxLength"].Value);
                        }
                        temp.Bool_1 = false; //we use this as a error trigger false = not an error...
                        tempList.Add(temp);
                        id++;
                    }
                }
            }
            return(tempList);
        }
        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();
            }
        }
        private BindingList <ExecutableProgramCode> GetExecutableProgramCodes(ExecutableProgramCode itemCode, string companyID)
        {
            BindingList <ExecutableProgramCode> itemCodeList = new BindingList <ExecutableProgramCode>(_serviceAgent.GetExecutableProgramCodes(itemCode, companyID).ToList());

            Dirty       = false;
            AllowCommit = false;
            return(itemCodeList);
        }
        public static void SetPropertyValue(this ExecutableProgramCode myObj, object propertyName, object propertyValue)
        {
            var propInfo = typeof(ExecutableProgramCode).GetProperty((string)propertyName);

            if (propInfo != null)
            {
                propInfo.SetValue(myObj, propertyValue, null);
            }
        }
 private void SetAsEmptySelection()
 {
     SelectedExecutableProgramCode = new ExecutableProgramCode();
     AllowEdit    = false;
     AllowDelete  = false;
     Dirty        = false;
     AllowCommit  = false;
     AllowRowCopy = false;
 }
 public void UpdateRepository(ExecutableProgramCode itemCode)
 {
     if (_repositoryContext.GetEntityDescriptor(itemCode) != null)
     {
         itemCode.LastModifiedBy        = XERP.Client.ClientSessionSingleton.Instance.SystemUserID;
         itemCode.LastModifiedByDate    = DateTime.Now;
         _repositoryContext.MergeOption = MergeOption.AppendOnly;
         _repositoryContext.UpdateObject(itemCode);
     }
 }
 public EntityStates GetExecutableProgramCodeEntityState(ExecutableProgramCode executableProgramCode)
 {
     if (_repositoryContext.GetEntityDescriptor(executableProgramCode) != null)
     {
         return(_repositoryContext.GetEntityDescriptor(executableProgramCode).State);
     }
     else
     {
         return(EntityStates.Detached);
     }
 }
Esempio n. 12
0
 public void OnChangeExecutableProgramTypes(ExecutableProgramCode executableProgramCode, UpdateOperations operations)
 {
     if (operations == UpdateOperations.Delete)
     {//update a null to any place the Code was used by its parent record...
         XERP.Server.DAL.MenuSecurityDAL.DALUtility dalUtility = new DALUtility();
         var context = new MenuSecurityEntities(dalUtility.EntityConectionString);
         context.ExecutablePrograms.MergeOption = System.Data.Objects.MergeOption.NoTracking;
         string companyID = executableProgramCode.CompanyID;
         string codeID    = executableProgramCode.ExecutableProgramCodeID;
         string sqlstring = "UPDATE ExecutablePrograms SET ExecutableProgramCodeID = null WHERE CompanyID = '" + companyID + "' and ExecutableProgramCodeID = '" + codeID + "'";
         context.ExecuteStoreCommand(sqlstring);
     }
 }
Esempio n. 13
0
        public static object GetPropertyValue(this ExecutableProgramCode myObj, string propertyName)
        {
            var propInfo = typeof(ExecutableProgramCode).GetProperty(propertyName);

            if (propInfo != null)
            {
                return(propInfo.GetValue(myObj, null));
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 14
0
        public static string GetPropertyCode(this ExecutableProgramCode myObj, string propertyName)
        {
            var propInfo = typeof(ExecutableProgramCode).GetProperty(propertyName);

            if (propInfo != null)
            {
                return(propInfo.PropertyType.Name.ToString());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 15
0
 //udpate merely updates the repository a commit is required
 //to commit it to the db...
 private bool Update(ExecutableProgramCode item)
 {
     _serviceAgent.UpdateExecutableProgramCodeRepository(item);
     Dirty = true;
     if (CommitIsAllowed())
     {
         AllowCommit = true;
     }
     else
     {
         AllowCommit = false;
     }
     return(AllowCommit);
 }
Esempio n. 16
0
        public IQueryable <Temp> GetMetaData(string tableName)
        {
            switch (tableName)
            {
            case "MenuItems":
                MenuItem menuItem = new MenuItem();
                return(menuItem.GetMetaData().AsQueryable());

            case "MenuItemTypes":
                MenuItemType menuItemType = new MenuItemType();
                return(menuItemType.GetMetaData().AsQueryable());

            case "MenuItemCodes":
                MenuItemCode menuItemCode = new MenuItemCode();
                return(menuItemCode.GetMetaData().AsQueryable());

            case "ExecutablePrograms":
                ExecutableProgram executablePrograms = new ExecutableProgram();
                return(executablePrograms.GetMetaData().AsQueryable());

            case "ExecutableProgramTypes":
                ExecutableProgramType executableProgramType = new ExecutableProgramType();
                return(executableProgramType.GetMetaData().AsQueryable());

            case "ExecutableProgramCodes":
                ExecutableProgramCode executableProgramCode = new ExecutableProgramCode();
                return(executableProgramCode.GetMetaData().AsQueryable());

            case "MenuSecurities":
                MenuSecurity menuSecurity = new MenuSecurity();
                return(menuSecurity.GetMetaData().AsQueryable());

            case "SecurityGroups":
                SecurityGroup securityGroup = new SecurityGroup();
                return(securityGroup.GetMetaData().AsQueryable());

            default:     //no table exists for the given tablename given...
                List <Temp> tempList = new List <Temp>();
                Temp        temp     = new Temp();
                temp.ID          = 0;
                temp.Int_1       = 0;
                temp.Bool_1      = true; //bool_1 will flag it as an error...
                temp.Name        = "Error";
                temp.ShortChar_1 = "Table " + tableName + " Is Not A Valid Table Within The Given Entity Collection, Or Meta Data Is Not Publc For The Given Table Name";
                tempList.Add(temp);
                return(tempList.AsQueryable());
            }
        }
Esempio n. 17
0
        public CodeSearchViewModel(IExecutableProgramServiceAgent serviceAgent)
        {
            this._serviceAgent = serviceAgent;

            SearchObject = new ExecutableProgramCode();
            ResultList   = new BindingList <ExecutableProgramCode>();
            SelectedList = new BindingList <ExecutableProgramCode>();
            //make sure of session authentication...
            if (XERP.Client.ClientSessionSingleton.Instance.SessionIsAuthentic)//make sure user has rights to UI...
            {
                DoFormsAuthentication();
            }
            else
            {//User is not authenticated...
                RegisterToReceiveMessages <bool>(MessageTokens.StartUpLogInToken.ToString(), OnStartUpLogIn);
                FormIsEnabled = false;
                //we will do forms authentication once the log in returns a valid System User...
            }
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        private bool NewExecutableProgramCode(string id)
        {
            ExecutableProgramCode item = new ExecutableProgramCode();

            //all new records will be give a negative int autoid...
            //when they are updated then sql will generate one for them overiding this set value...
            //it will allow us to give uniqueness to the tempory new records...
            //Before they are updated to the entity and given an autoid...
            //we use a negative number and keep subtracting by 1 for each new item added...
            //This will allow it to alwasy be unique and never interfere with SQL's positive autoid...
            _newExecutableProgramCodeAutoId = _newExecutableProgramCodeAutoId - 1;
            item.AutoID = _newExecutableProgramCodeAutoId;
            item.ExecutableProgramCodeID = id;
            item.CompanyID       = ClientSessionSingleton.Instance.CompanyID;
            item.IsValid         = 1;
            item.NotValidMessage = "New Record Key Field/s Are Required.";
            ExecutableProgramCodeList.Add(item);
            _serviceAgent.AddToExecutableProgramCodeRepository(item);
            SelectedExecutableProgramCode = ExecutableProgramCodeList.LastOrDefault();

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
Esempio n. 20
0
 private BindingList <ExecutableProgramCode> GetExecutableProgramCodes(ExecutableProgramCode itemQueryObject, string companyID)
 {
     return(new BindingList <ExecutableProgramCode>(_serviceAgent.GetExecutableProgramCodes(itemQueryObject, companyID).ToList()));
 }
 public EntityStates GetExecutableProgramCodeEntityState(ExecutableProgramCode executableProgramCode)
 {
     return(ExecutableProgramCodeSingletonRepository.Instance.GetExecutableProgramCodeEntityState(executableProgramCode));
 }
 public void DeleteFromExecutableProgramCodeRepository(ExecutableProgramCode executableProgramCode)
 {
     ExecutableProgramCodeSingletonRepository.Instance.DeleteFromRepository(executableProgramCode);
 }
 public void AddToExecutableProgramCodeRepository(ExecutableProgramCode executableProgramCode)
 {
     ExecutableProgramCodeSingletonRepository.Instance.AddToRepository(executableProgramCode);
 }
 public void UpdateExecutableProgramCodeRepository(ExecutableProgramCode executableProgramCode)
 {
     ExecutableProgramCodeSingletonRepository.Instance.UpdateRepository(executableProgramCode);
 }
 public IEnumerable <ExecutableProgramCode> GetExecutableProgramCodes(ExecutableProgramCode executableProgramCodeQuerryObject, string companyID)
 {
     return(ExecutableProgramCodeSingletonRepository.Instance.GetExecutableProgramCodes(executableProgramCodeQuerryObject, companyID));
 }
Esempio n. 26
0
 private EntityStates GetExecutableProgramCodeState(ExecutableProgramCode itemCode)
 {
     return(_serviceAgent.GetExecutableProgramCodeEntityState(itemCode));
 }
 public void AddToRepository(ExecutableProgramCode executableProgramCode)
 {
     _repositoryContext.MergeOption = MergeOption.AppendOnly;
     _repositoryContext.AddToExecutableProgramCodes(executableProgramCode);
 }
Esempio n. 28
0
 private bool Delete(ExecutableProgramCode itemCode)
 {
     _serviceAgent.DeleteFromExecutableProgramCodeRepository(itemCode);
     return(true);
 }