private void ProjectButton_Click(object sender, RoutedEventArgs e) { int[] allowedEntities = EntityFunctions.AllowedEntityIDs(selectedStaffID); if (!allowedEntities.Contains(Globals.CurrentEntityID)) { MessageFunctions.InvalidMessage("This staff member does not have access to this Entity, so they cannot have any projects in it.", "Invalid Entity"); return; } else { PageFunctions.ShowProjectTeamsPage(pageMode, selectedStaffID, "StaffPage"); } }
private void createNewClient(string accountManagerName) { int newID = 0; bool inCurrentEntity = (selectedEntityID == Globals.CurrentEntityID); string savedInEntity = ""; string contactsCopied = ""; try { newID = ClientFunctions.NewClient(ClientCode.Text, ClientName.Text, accountManagerName, (bool)ActiveCheckBox.IsChecked, selectedEntityID); } catch (Exception generalException) { MessageFunctions.Error("Error creating new client record", generalException); } if (newID > 0) { try { if (!inCurrentEntity) { if (CopyContactsCheckBox.IsChecked == true) { bool success = ClientFunctions.CopyContacts(selectedRecord.ID, newID); contactsCopied = success ? ", and all active linked contacts have been copied to it" : " but contacts could not be copied"; } savedInEntity = " in Entity '" + EntityFunctions.GetEntityName(selectedEntityID) + "'" + contactsCopied + ". Switch to that Entity if you need to work with the new record"; } MessageFunctions.SuccessAlert("New client '" + ClientName.Text + "' saved successfully" + savedInEntity + ".", "Client Created"); if (pageMode == PageFunctions.Amend) { resetAmendPage(accountManagerName); if (inCurrentEntity) { refreshClientGrid(); // This is not necessarily done for us by the Account Managers list ClientDataGrid.SelectedValue = gridList.First(c => c.ID == newID); ClientDataGrid.ScrollIntoView(ClientDataGrid.SelectedItem); } AddButtonText.Text = "Add Another"; } else { ClientFunctions.ReturnToTilesPage(); } } catch (Exception generalException) { MessageFunctions.Error("Error updating page for new client record", generalException); } } }
// ---------------------- // // -- Event Management -- // // ---------------------- // // Control-specific events // private void CommitButton_Click(object sender, RoutedEventArgs e) { string name = EntityName.Text; string description = EntityDescription.Text; if (pageMode == PageFunctions.Switch) { EntityFunctions.SwitchEntity(ref selectedEntity, (bool)MakeDefaultCheckBox.IsChecked); } else if (pageMode == PageFunctions.New) { EntityFunctions.NewEntity(name, description, (bool)SwitchToCheckBox.IsChecked, (bool)MakeDefaultCheckBox.IsChecked); } else if (pageMode == PageFunctions.Amend) { EntityFunctions.AmendEntity(ref selectedEntity, name, description); } else if (pageMode == PageFunctions.Default) { EntityFunctions.ChangeDefaultEntity(ref selectedEntity, name); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { try { try { pageMode = PageFunctions.pageParameter(this, "Mode"); } catch (Exception generalException) { MessageFunctions.Error("Error retrieving query details", generalException); PageFunctions.ShowTilesPage(); } if (pageMode == PageFunctions.Switch) { PageHeader.Content = "Change Current Entity"; HeaderImage2.SetResourceReference(Image.SourceProperty, "ChangeEntityIcon"); Instructions.Content = "Pick an Entity from the list to change to it."; EntityName.Visibility = Visibility.Hidden; SwitchToCheckBox.Visibility = Visibility.Hidden; EntityDescription.IsEnabled = false; EntityCombo.Margin = EntityName.Margin; CommitButtonText.Text = "Change"; ChangeNameLabel.Visibility = Visibility.Hidden; EntityCombo.ItemsSource = EntityFunctions.EntityList(Globals.MyStaffID, false, Globals.CurrentEntityID); if (EntityCombo.Items.Count == 1) { EntityCombo.SelectedIndex = 0; } } else if (pageMode == PageFunctions.New) { EntityCombo.Visibility = Visibility.Hidden; ChangeNameLabel.Visibility = Visibility.Hidden; } else if (pageMode == PageFunctions.Amend) { PageHeader.Content = "Amend Existing Entity"; HeaderImage2.SetResourceReference(Image.SourceProperty, "AmendIcon"); Instructions.Content = "Pick an Entity from the list to amend it."; SwitchToCheckBox.Visibility = Visibility.Hidden; MakeDefaultCheckBox.Visibility = Visibility.Hidden; EntityDescription.IsEnabled = false; Thickness nameMargin = EntityName.Margin; EntityName.Margin = EntityCombo.Margin; EntityCombo.Margin = nameMargin; CommitButtonText.Text = "Amend"; EntityCombo.ItemsSource = EntityFunctions.EntityList(Globals.MyStaffID, false); } else if (pageMode == PageFunctions.Default) { PageHeader.Content = "Change Default Entity"; HeaderImage2.SetResourceReference(Image.SourceProperty, "PinIcon"); HeaderImage2.Width = 25; HeaderImage2.Stretch = System.Windows.Media.Stretch.UniformToFill; Instructions.Content = "Pick an Entity from the list to set it as your default."; EntityName.Visibility = Visibility.Hidden; SwitchToCheckBox.Visibility = Visibility.Hidden; MakeDefaultCheckBox.Visibility = Visibility.Hidden; EntityDescription.IsEnabled = false; EntityCombo.Margin = EntityName.Margin; CommitButtonText.Text = "Set Default"; ChangeNameLabel.Visibility = Visibility.Hidden; EntityCombo.ItemsSource = EntityFunctions.EntityList(Globals.MyStaffID, false, Globals.MyDefaultEntityID); if (Globals.MyDefaultEntityID != Globals.CurrentEntityID) { try { EntityCombo.SelectedItem = Globals.CurrentEntityName; } catch (Exception generalException) { MessageFunctions.Error("Error setting current entity", generalException); } } else { if (EntityCombo.Items.Count == 1) { EntityCombo.SelectedIndex = 0; } } } else // Not sure { EntityCombo.Visibility = Visibility.Hidden; } } catch (Exception generalException) { MessageFunctions.Error("Error setting initial values", generalException); } }