Example #1
0
        //WarehouseType Object Scope Validation check the entire object for validity...
        private byte WarehouseTypeIsValid(WarehouseType item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.WarehouseTypeID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetWarehouseTypeState(item);

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

            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);
        }
Example #2
0
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedWarehouseType.WarehouseTypeID))
     {//check to see if key is part of the current companylist...
         WarehouseType query = WarehouseTypeList.Where(company => company.WarehouseTypeID == SelectedWarehouseType.WarehouseTypeID &&
                                                       company.AutoID != SelectedWarehouseType.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back...
             SelectedWarehouseType.WarehouseTypeID = SelectedWarehouseTypeMirror.WarehouseTypeID;
             //change to the newly selected company...
             SelectedWarehouseType = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         WarehouseTypeList = GetWarehouseTypeByID(SelectedWarehouseType.WarehouseTypeID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (WarehouseTypeList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedWarehouseType.WarehouseTypeID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedWarehouseType = WarehouseTypeList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedWarehouseType.WarehouseTypeID != SelectedWarehouseTypeMirror.WarehouseTypeID)
         {
             SelectedWarehouseType.WarehouseTypeID = SelectedWarehouseTypeMirror.WarehouseTypeID;
         }
     }
 }
Example #3
0
        public void DeleteWarehouseTypeCommand()
        {
            try
            {//company is fk to 100's of tables deleting it can be tricky...
                int i  = 0;
                int ii = 0;
                for (int j = SelectedWarehouseTypeList.Count - 1; j >= 0; j--)
                {
                    WarehouseType item = (WarehouseType)SelectedWarehouseTypeList[j];
                    //get Max Index...
                    i = WarehouseTypeList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    WarehouseTypeList.Remove(item);
                }

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

                    SelectedWarehouseType = WarehouseTypeList[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("WarehouseType/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
Example #4
0
 private void OnSearchResult(object sender, NotificationEventArgs <BindingList <WarehouseType> > e)
 {
     if (e.Data != null && e.Data.Count > 0)
     {
         WarehouseTypeList     = e.Data;
         SelectedWarehouseType = WarehouseTypeList.FirstOrDefault();
         Dirty       = false;
         AllowCommit = false;
     }
     UnregisterToReceiveMessages <BindingList <WarehouseType> >(MessageTokens.WarehouseTypeSearchToken.ToString(), OnSearchResult);
 }
Example #5
0
        //Object.Property Scope Validation...
        private bool WarehouseTypeIsValid(WarehouseType item, _companyValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _companyValidationProperties.WarehouseTypeID:
                //validate key
                if (string.IsNullOrEmpty(item.WarehouseTypeID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetWarehouseTypeState(item);
                if (entityState == EntityStates.Added && WarehouseTypeExists(item.WarehouseTypeID, ClientSessionSingleton.Instance.CompanyID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = WarehouseTypeList.Count(q => q.WarehouseTypeID == item.WarehouseTypeID);
                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);
        }
Example #6
0
        private bool NewWarehouseType(string id)
        {
            WarehouseType item = new WarehouseType();

            //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...
            _newWarehouseTypeAutoId = _newWarehouseTypeAutoId - 1;
            item.AutoID             = _newWarehouseTypeAutoId;
            item.WarehouseTypeID    = id;
            item.CompanyID          = ClientSessionSingleton.Instance.CompanyID;
            item.IsValid            = 1;
            item.NotValidMessage    = "New Record Key Field/s Are Required.";
            WarehouseTypeList.Add(item);
            _serviceAgent.AddToWarehouseTypeRepository(item);
            SelectedWarehouseType = WarehouseTypeList.LastOrDefault();

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
Example #7
0
 public void ClearLogic()
 {
     WarehouseTypeList.Clear();
     SetAsEmptySelection();
 }