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