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