private bool NewWarehouseLocationBin(string itemID)
        {
            WarehouseLocationBin newItem = new WarehouseLocationBin();

            //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...
            _newWarehouseLocationBinAutoId = _newWarehouseLocationBinAutoId - 1;
            newItem.AutoID = _newWarehouseLocationBinAutoId;
            newItem.WarehouseLocationBinID = itemID;
            newItem.CompanyID       = ClientSessionSingleton.Instance.CompanyID;
            newItem.IsValid         = 1;
            newItem.NotValidMessage = "New Record Key Field/s Are Required.";
            WarehouseLocationBinList.Add(newItem);
            _serviceAgent.AddToWarehouseLocationBinRepository(newItem);
            SelectedWarehouseLocationBin = WarehouseLocationBinList.LastOrDefault();

            AllowEdit     = true;
            Dirty         = false;
            AllowKeyEntry = true;
            return(true);
        }
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedWarehouseLocationBin.WarehouseLocationBinID))
     {//check to see if key is part of the current companylist...
         WarehouseLocationBin query = WarehouseLocationBinList.Where(company => company.WarehouseLocationBinID == SelectedWarehouseLocationBin.WarehouseLocationBinID &&
                                                                     company.AutoID != SelectedWarehouseLocationBin.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back
             SelectedWarehouseLocationBin.WarehouseLocationBinID = SelectedWarehouseLocationBinMirror.WarehouseLocationBinID;
             //change to the newly selected company...
             SelectedWarehouseLocationBin = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         WarehouseLocationBinList = GetWarehouseLocationBinByID(SelectedWarehouseLocationBin.WarehouseLocationBinID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (WarehouseLocationBinList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedWarehouseLocationBin.WarehouseLocationBinID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedWarehouseLocationBin = WarehouseLocationBinList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedWarehouseLocationBin.WarehouseLocationBinID != SelectedWarehouseLocationBinMirror.WarehouseLocationBinID)
         {
             SelectedWarehouseLocationBin.WarehouseLocationBinID = SelectedWarehouseLocationBinMirror.WarehouseLocationBinID;
         }
     }
 }
        private void Refresh()
        {//refetch current records...
            long   selectedAutoID = SelectedWarehouseLocationBin.AutoID;
            string autoIDs        = "";

            //bool isFirstItem = true;
            foreach (WarehouseLocationBin item in WarehouseLocationBinList)
            {//auto seeded starts at 1 any records at 0 or less or not valid records...
                if (item.AutoID > 0)
                {
                    autoIDs = autoIDs + item.AutoID.ToString() + ",";
                }
            }
            if (autoIDs.Length > 0)
            {
                //ditch the extra comma...
                autoIDs = autoIDs.Remove(autoIDs.Length - 1, 1);
                WarehouseLocationBinList     = new BindingList <WarehouseLocationBin>(_serviceAgent.RefreshWarehouseLocationBin(autoIDs).ToList());
                SelectedWarehouseLocationBin = (from q in WarehouseLocationBinList
                                                where q.AutoID == selectedAutoID
                                                select q).FirstOrDefault();
                Dirty       = false;
                AllowCommit = false;
            }
        }
Esempio n. 4
0
        public void DeleteFromRepository(WarehouseLocationBin item)
        {
            if (_repositoryContext.GetEntityDescriptor(item) != null)
            {
                //if it exists in the db delete it from the db
                WarehouseEntities context = new WarehouseEntities(_rootUri);
                context.MergeOption = MergeOption.AppendOnly;
                context.IgnoreResourceNotFoundException = true;
                WarehouseLocationBin deletedWarehouseLocationBin = (from q in context.WarehouseLocationBins
                                                                    where q.WarehouseLocationBinID == item.WarehouseLocationBinID
                                                                    select q).FirstOrDefault();
                if (deletedWarehouseLocationBin != null)
                {
                    context.DeleteObject(deletedWarehouseLocationBin);
                    context.SaveChanges();
                }
                context = null;

                _repositoryContext.MergeOption = MergeOption.AppendOnly;
                //if it is being tracked remove it...
                if (GetWarehouseLocationBinEntityState(item) != EntityStates.Detached)
                {
                    _repositoryContext.Detach(item);
                }
            }
        }
Esempio n. 5
0
        public IEnumerable <WarehouseLocationBin> GetWarehouseLocationBins(WarehouseLocationBin itemQuerryObject, string companyID)
        {
            _repositoryContext             = new WarehouseEntities(_rootUri);
            _repositoryContext.MergeOption = MergeOption.AppendOnly;
            _repositoryContext.IgnoreResourceNotFoundException = true;
            var queryResult = from q in _repositoryContext.WarehouseLocationBins.Expand("WarehouseLocation/Warehouse/Plant")
                              where q.CompanyID == companyID
                              select q;

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

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

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

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

            return(queryResult);
        }
        public static List <Temp> GetMetaData(this WarehouseLocationBin entityObject)
        {
            XERP.Server.DAL.WarehouseDAL.DALUtility dalUtility = new DALUtility();
            List <Temp> tempList = new List <Temp>();
            int         id       = 0;

            using (WarehouseEntities ctx = new WarehouseEntities(dalUtility.EntityConectionString))
            {
                var c            = ctx.Companies.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 DeleteWarehouseLocationBinCommand()
        {
            try
            {
                int i  = 0;
                int ii = 0;
                for (int j = SelectedWarehouseLocationBinList.Count - 1; j >= 0; j--)
                {
                    WarehouseLocationBin item = (WarehouseLocationBin)SelectedWarehouseLocationBinList[j];
                    //get Max Index...
                    i = WarehouseLocationBinList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    WarehouseLocationBinList.Remove(item);
                }

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

                    SelectedWarehouseLocationBin = WarehouseLocationBinList[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("WarehouseLocationBin/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
        private BindingList <WarehouseLocationBin> GetWarehouseLocationBins(WarehouseLocationBin item, string companyID)
        {
            BindingList <WarehouseLocationBin> itemList = new BindingList <WarehouseLocationBin>(_serviceAgent.GetWarehouseLocationBins(item, companyID).ToList());

            Dirty       = false;
            AllowCommit = false;
            return(itemList);
        }
 private void SetAsEmptySelection()
 {
     SelectedWarehouseLocationBin = new WarehouseLocationBin();
     AllowEdit    = false;
     AllowDelete  = false;
     Dirty        = false;
     AllowCommit  = false;
     AllowRowCopy = false;
 }
Esempio n. 10
0
        public static void SetPropertyValue(this WarehouseLocationBin myObj, object propertyName, object propertyValue)
        {
            var propInfo = typeof(WarehouseLocationBin).GetProperty((string)propertyName);

            if (propInfo != null)
            {
                propInfo.SetValue(myObj, propertyValue, null);
            }
        }
Esempio n. 11
0
 public void UpdateRepository(WarehouseLocationBin item)
 {
     if (_repositoryContext.GetEntityDescriptor(item) != null)
     {
         item.LastModifiedBy            = XERP.Client.ClientSessionSingleton.Instance.SystemUserID;
         item.LastModifiedByDate        = DateTime.Now;
         _repositoryContext.MergeOption = MergeOption.AppendOnly;
         _repositoryContext.UpdateObject(item);
     }
 }
Esempio n. 12
0
 private void OnSearchResult(object sender, NotificationEventArgs <BindingList <WarehouseLocationBin> > e)
 {
     if (e.Data != null && e.Data.Count > 0)
     {
         WarehouseLocationBinList     = e.Data;
         SelectedWarehouseLocationBin = WarehouseLocationBinList.FirstOrDefault();
         Dirty       = false;
         AllowCommit = false;
     }
     UnregisterToReceiveMessages <BindingList <WarehouseLocationBin> >(MessageTokens.WarehouseLocationBinSearchToken.ToString(), OnSearchResult);
 }
Esempio n. 13
0
 public EntityStates GetWarehouseLocationBinEntityState(WarehouseLocationBin item)
 {
     if (_repositoryContext.GetEntityDescriptor(item) != null)
     {
         return(_repositoryContext.GetEntityDescriptor(item).State);
     }
     else
     {
         return(EntityStates.Detached);
     }
 }
Esempio n. 14
0
        public static object GetPropertyValue(this WarehouseLocationBin myObj, string propertyName)
        {
            var propInfo = typeof(WarehouseLocationBin).GetProperty(propertyName);

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

            if (propInfo != null)
            {
                return(propInfo.PropertyType.Name.ToString());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 16
0
 //udpate merely updates the repository a commit is required to commit it to the db...
 private bool Update(WarehouseLocationBin item)
 {
     _serviceAgent.UpdateWarehouseLocationBinRepository(item);
     Dirty = true;
     if (CommitIsAllowed())
     {
         AllowCommit = true;
     }
     else
     {
         AllowCommit = false;
     }
     return(AllowCommit);
 }
Esempio n. 17
0
        //Object.Property Scope Validation...
        private bool WarehouseLocationBinIsValid(WarehouseLocationBin item, _warehouseLocationBinValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _warehouseLocationBinValidationProperties.WarehouseLocationBinID:
                //validate key
                if (string.IsNullOrEmpty(item.WarehouseLocationBinID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetWarehouseLocationBinState(item);
                if (entityState == EntityStates.Added && WarehouseLocationBinExists(item.WarehouseLocationBinID, item.WarehouseLocationID, item.WarehouseID, item.PlantID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = WarehouseLocationBinList.Count(q => q.WarehouseLocationBinID == item.WarehouseLocationBinID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                break;

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

            case _warehouseLocationBinValidationProperties.WarehouseLocationID:
                //validate 2ndary key...
                if (string.IsNullOrEmpty(item.WarehouseLocationID))
                {
                    errorMessage = "Warehouse Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }
Esempio n. 18
0
        public MainSearchViewModel(IWarehouseServiceAgent serviceAgent)
        {
            this._serviceAgent           = serviceAgent;
            WarehouseLocationBinTypeList = GetWarehouseLocationBinTypes();
            WarehouseLocationBinCodeList = GetWarehouseLocationBinCodes();

            SearchObject = new WarehouseLocationBin();
            ResultList   = new BindingList <WarehouseLocationBin>();
            SelectedList = new BindingList <WarehouseLocationBin>();
            //make sure of session authentication...
            if (ClientSessionSingleton.Instance.SessionIsAuthentic) //make sure user has rights to UI...
            {
                DoFormsAuthentication();
            }
            else
            {//User is not authenticated...
                RegisterToReceiveMessages <bool>(MessageTokens.StartUpLogInToken.ToString(), OnStartUpLogIn);
                FormIsEnabled = false;
            }
        }
Esempio n. 19
0
        public IQueryable <Temp> GetMetaData(string tableName)
        {
            switch (tableName)
            {
            case "Warehouses":
                Warehouse Warehouse = new Warehouse();
                return(Warehouse.GetMetaData().AsQueryable());

            case "WarehouseTypes":
                WarehouseType WarehouseType = new WarehouseType();
                return(WarehouseType.GetMetaData().AsQueryable());

            case "WarehouseCodes":
                WarehouseCode WarehouseCode = new WarehouseCode();
                return(WarehouseCode.GetMetaData().AsQueryable());

            case "WarehouseLocationBins":
                WarehouseLocationBin WarehouseLocationBin = new WarehouseLocationBin();
                return(WarehouseLocationBin.GetMetaData().AsQueryable());

            case "WarehouseLocationBinTypes":
                WarehouseLocationBinType WarehouseLocationBinType = new WarehouseLocationBinType();
                return(WarehouseLocationBinType.GetMetaData().AsQueryable());

            case "WarehouseLocationBinCodes":
                WarehouseLocationBinCode WarehouseLocationBinCode = new WarehouseLocationBinCode();
                return(WarehouseLocationBinCode.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 Was Not Defined For The Given Table Name";
                tempList.Add(temp);
                return(tempList.AsQueryable());
            }
        }
Esempio n. 20
0
        //WarehouseLocationBin Object Scope Validation check the entire object for validity...
        private byte WarehouseLocationBinIsValid(WarehouseLocationBin item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.WarehouseLocationBinID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetWarehouseLocationBinState(item);

            if (entityState == EntityStates.Added && WarehouseLocationBinExists(item.WarehouseLocationBinID, item.WarehouseLocationID, item.WarehouseID, item.PlantID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = WarehouseLocationBinList.Count(q => q.WarehouseLocationBinID == item.WarehouseLocationBinID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists...";
                return(1);
            }
            //validate Name
            if (string.IsNullOrEmpty(item.Name))
            {
                errorMessage = "Name Is Required.";
                return(1);
            }
            //validate WarehouseLocationID
            if (string.IsNullOrEmpty(item.WarehouseLocationID))
            {
                errorMessage = "Warehouse Location Is Required.";
                return(1);
            }
            //a value of 2 is pending changes...
            //On Commit we will give it a value of 0...
            return(2);
        }
Esempio n. 21
0
 public void AddToWarehouseLocationBinRepository(WarehouseLocationBin item)
 {
     WarehouseLocationBinSingletonRepository.Instance.AddToRepository(item);
 }
Esempio n. 22
0
 public void AddToRepository(WarehouseLocationBin item)
 {
     item.CompanyID = XERP.Client.ClientSessionSingleton.Instance.CompanyID;
     _repositoryContext.MergeOption = MergeOption.AppendOnly;
     _repositoryContext.AddToWarehouseLocationBins(item);
 }
Esempio n. 23
0
 public void DeleteFromWarehouseLocationBinRepository(WarehouseLocationBin item)
 {
     WarehouseLocationBinSingletonRepository.Instance.DeleteFromRepository(item);
 }
Esempio n. 24
0
 private BindingList <WarehouseLocationBin> GetWarehouseLocationBins(WarehouseLocationBin itemQueryObject, string companyID)
 {//note this get is to the singleton repository...
     return(new BindingList <WarehouseLocationBin>(_serviceAgent.GetWarehouseLocationBins(itemQueryObject, companyID).ToList()));
 }
Esempio n. 25
0
 public EntityStates GetWarehouseLocationBinEntityState(WarehouseLocationBin item)
 {
     return(WarehouseLocationBinSingletonRepository.Instance.GetWarehouseLocationBinEntityState(item));
 }
Esempio n. 26
0
 private bool Delete(WarehouseLocationBin item)
 {//deletes are done indenpendently of the repository as a delete will not commit
     //dirty records it will simply just delete the record...
     _serviceAgent.DeleteFromWarehouseLocationBinRepository(item);
     return(true);
 }
Esempio n. 27
0
 public void UpdateWarehouseLocationBinRepository(WarehouseLocationBin item)
 {
     WarehouseLocationBinSingletonRepository.Instance.UpdateRepository(item);
 }
Esempio n. 28
0
 private EntityStates GetWarehouseLocationBinState(WarehouseLocationBin item)
 {
     return(_serviceAgent.GetWarehouseLocationBinEntityState(item));
 }
Esempio n. 29
0
 public IEnumerable <WarehouseLocationBin> GetWarehouseLocationBins(WarehouseLocationBin itemQuerryObject, string companyID)
 {
     return(WarehouseLocationBinSingletonRepository.Instance.GetWarehouseLocationBins(itemQuerryObject, companyID));
 }