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