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 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);
 }