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