private void Page_Loaded(object sender, RoutedEventArgs e) { FirstName.Focus(); if (!Globals.MyPermissions.Allow("ActivateClientStaff")) { ActiveCheckBox.IsEnabled = false; ActiveCheckBox.ToolTip = ActiveLabel.ToolTip = "Your current permissions do not allow activating or disabling contacts"; } try { pageMode = PageFunctions.pageParameter(this, "Mode"); selectedContactID = Int32.Parse(PageFunctions.pageParameter(this, "ContactID")); //selectedClientID = Int32.Parse(PageFunctions.pageParameter(this, "ClientID")); } catch (Exception generalException) { MessageFunctions.Error("Error retrieving query details", generalException); ClientFunctions.ReturnToTilesPage(); } //Clients thisClient = ClientFunctions.GetClientByID(selectedClientID, true); ClientCode.Text = Globals.SelectedClient.ClientCode; ClientName.Text = Globals.SelectedClient.ClientName; if (pageMode == PageFunctions.New) { PageHeader.Content = "Create New Contact"; HeaderImage2.SetResourceReference(Image.SourceProperty, "AddIcon"); Instructions.Content = "Fill in the details as required and then click 'Save' to create the record."; } else if (pageMode == PageFunctions.Amend) { if (selectedContactID > 0) { try { thisContact = ClientFunctions.GetContact(selectedContactID); FirstName.Text = thisContact.FirstName; Surname.Text = thisContact.Surname; JobTitle.Text = thisContact.JobTitle; ActiveCheckBox.IsChecked = thisContact.Active; PhoneNumber.Text = thisContact.PhoneNumber; Email.Text = thisContact.Email; } catch (Exception generalException) { MessageFunctions.Error("Error populating contact data", generalException); ClientFunctions.ReturnToContactPage(selectedContactID); } } else { MessageFunctions.Error("Load error: no contact loaded.", null); ClientFunctions.ReturnToContactPage(selectedContactID); } } }
private bool chooseSingleContact() { try { if (selectedClientGridRecord == null) { ClientDataGrid.SelectedItem = clientGridList.ElementAt(0); } selectedContact = ClientFunctions.GetContactByName(selectedClientGridRecord.ID, ContactLike.Text); return(selectedContact != null); } catch (Exception generalException) { MessageFunctions.Error("Error selecting the displayed contact name", generalException); return(false); } }
private void ContactDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (ContactDataGrid.SelectedItem != null) { selectedContactGridRecord = (ContactProxy)ContactDataGrid.SelectedItem; AmendButton.IsEnabled = true; selectedContact = ClientFunctions.GetContact(selectedContactGridRecord.ID); AmendButton.ToolTip = "Amend " + selectedContact.FullName + "'s details"; toggleActiveButton(selectedContact.Active); } else { clearContactSelection(); } } catch (Exception generalException) { MessageFunctions.Error("Error processing client selection", generalException); clearContactSelection(); } }
private void clearContactSelection() { selectedContactGridRecord = null; selectedContact = null; AmendButton.IsEnabled = DisableButton.IsEnabled = false; }