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