Пример #1
0
        //CompanyType Object Scope Validation check the entire object for validity...
        private byte CompanyTypeIsValid(CompanyType item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.CompanyTypeID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            EntityStates entityState = GetCompanyTypeState(item);

            if (entityState == EntityStates.Added && CompanyTypeExists(item.CompanyTypeID))
            {
                errorMessage = "Item AllReady Exists.";
                return(1);
            }
            int count = CompanyTypeList.Count(q => q.CompanyTypeID == item.CompanyTypeID);

            if (count > 1)
            {
                errorMessage = "Item AllReady 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);
        }
Пример #2
0
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedCompanyType.CompanyTypeID))
     {//check to see if key is part of the current itemList...
         CompanyType query = CompanyTypeList.Where(item => item.CompanyTypeID == SelectedCompanyType.CompanyTypeID &&
                                                   item.AutoID != SelectedCompanyType.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back
             SelectedCompanyType.CompanyTypeID = SelectedCompanyTypeMirror.CompanyTypeID;
             //change to the newly selected item...
             SelectedCompanyType = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         CompanyTypeList = GetCompanyTypeByID(SelectedCompanyType.CompanyTypeID);
         if (CompanyTypeList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedCompanyType.CompanyTypeID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedCompanyType = CompanyTypeList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedCompanyType.CompanyTypeID != SelectedCompanyTypeMirror.CompanyTypeID)
         {
             SelectedCompanyType.CompanyTypeID = SelectedCompanyTypeMirror.CompanyTypeID;
         }
     }
 }
Пример #3
0
        public void DeleteCompanyTypeCommand()
        {
            try
            {
                int i  = 0;
                int ii = 0;
                for (int j = SelectedCompanyTypeList.Count - 1; j >= 0; j--)
                {
                    CompanyType item = (CompanyType)SelectedCompanyTypeList[j];
                    //get Max Index...
                    i = CompanyTypeList.IndexOf(item);
                    if (i > ii)
                    {
                        ii = i;
                    }
                    Delete(item);
                    CompanyTypeList.Remove(item);
                }

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

                    SelectedCompanyType = CompanyTypeList[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 item 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("CompanyType/s Can Not Be Deleted.  Contact XERP Admin For More Details.");
                Refresh();
            }
        }
Пример #4
0
 private void OnSearchResult(object sender, NotificationEventArgs <BindingList <CompanyType> > e)
 {
     if (e.Data != null && e.Data.Count > 0)
     {
         CompanyTypeList     = e.Data;
         SelectedCompanyType = CompanyTypeList.FirstOrDefault();
         Dirty       = false;
         AllowCommit = false;
     }
     UnregisterToReceiveMessages <BindingList <CompanyType> >(MessageTokens.CompanyTypeSearchToken.ToString(), OnSearchResult);
 }
Пример #5
0
        private void Save(Member entity)
        {
            entity.MemberId         = EntityId;
            entity.Name             = Name;
            entity.LoginId          = LoginId;
            entity.Password         = Password;
            entity.Company          = Company;
            entity.Status           = Status;
            entity.RegDate          = RegDate;
            entity.CompanyNo        = CompanyNo;
            entity.CompanyNum       = CompanyNum;
            entity.CompanyType      = CompanyType;
            entity.CompanyTypeOther = CompanyTypeOther;
            entity.Email            = Email;
            entity.Contact          = Contact;
            entity.Dept             = Dept;
            entity.JobTitle         = JobTitle;
            entity.Tel               = Tel;
            entity.Tel2              = Tel2;
            entity.Fax               = Fax;
            entity.Content           = Content;
            entity.ReceiveEpaperInfo = ReceiveEpaperInfo;
            if (IndustryId > 0)
            {
                entity.Industry = m_FTISService.GetIndustryById(IndustryId);
            }

            if (CompanyTypeList != null && CompanyTypeList.Count() > 0)
            {
                entity.CompanyType = String.Join(", ", CompanyTypeList);
            }
            else
            {
                entity.CompanyType = string.Empty;
            }

            if (entity.MemberId == 0)
            {
                entity.RegDate = DateTime.Now;
                m_FTISService.CreateMember(entity);
            }
            else
            {
                m_FTISService.UpdateMember(entity);
            }

            LoadEntity(entity.MemberId);
        }
Пример #6
0
        private bool NewCompanyType(string itemID)
        {
            CompanyType item = new CompanyType();

            _newCompanyTypeAutoId = _newCompanyTypeAutoId - 1;
            item.AutoID           = _newCompanyTypeAutoId;
            item.CompanyTypeID    = itemID;
            item.IsValid          = 1;
            item.NotValidMessage  = "New Record Key Field/s Are Required.";
            CompanyTypeList.Add(item);
            _serviceAgent.AddToCompanyTypeRepository(item);
            SelectedCompanyType = CompanyTypeList.LastOrDefault();

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
Пример #7
0
        //Object.Property Scope Validation...
        private bool CompanyTypeIsValid(CompanyType item, _itemValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _itemValidationProperties.CompanyTypeID:
                //validate key
                if (string.IsNullOrEmpty(item.CompanyTypeID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                EntityStates entityState = GetCompanyTypeState(item);
                if (entityState == EntityStates.Added && CompanyTypeExists(item.CompanyTypeID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = CompanyTypeList.Count(q => q.CompanyTypeID == item.CompanyTypeID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }

                break;

            case _itemValidationProperties.Name:
                //validate Description
                if (string.IsNullOrEmpty(item.Description))
                {
                    errorMessage = "Description Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }
Пример #8
0
 public void ClearLogic()
 {
     CompanyTypeList.Clear();
     SetAsEmptySelection();
 }