private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedMenuItemType.MenuItemTypeID))
     {//check to see if key is part of the current companylist...
         MenuItemType query = MenuItemTypeList.Where(company => company.MenuItemTypeID == SelectedMenuItemType.MenuItemTypeID &&
                                                     company.AutoID != SelectedMenuItemType.AutoID).FirstOrDefault();
         if (query != null)
         {//revert it back...
             SelectedMenuItemType.MenuItemTypeID = SelectedMenuItemTypeMirror.MenuItemTypeID;
             //change to the newly selected company...
             SelectedMenuItemType = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         MenuItemTypeList = GetMenuItemTypeByID(SelectedMenuItemType.MenuItemTypeID, XERP.Client.ClientSessionSingleton.Instance.CompanyID);
         if (MenuItemTypeList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedMenuItemType.MenuItemTypeID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedMenuItemType = MenuItemTypeList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedMenuItemType.MenuItemTypeID != SelectedMenuItemTypeMirror.MenuItemTypeID)
         {
             SelectedMenuItemType.MenuItemTypeID = SelectedMenuItemTypeMirror.MenuItemTypeID;
         }
     }
 }
 private void OnSearchResult(object sender, NotificationEventArgs <BindingList <MenuItemType> > e)
 {
     if (e.Data != null && e.Data.Count > 0)
     {
         MenuItemTypeList     = e.Data;
         SelectedMenuItemType = MenuItemTypeList.FirstOrDefault();
         Dirty       = false;
         AllowCommit = false;
     }
     UnregisterToReceiveMessages <BindingList <MenuItemType> >(MessageTokens.MenuItemTypeSearchToken.ToString(), OnSearchResult);
 }