// // Function: private void Add_User() // // Purpose: Add a new site user after confirmation from a messagebox // private void Add_User() { Users new_user = new Users(); List <Users> exist_users = new List <Users>(); for (int i = 0; i < View_Users.Count; i++) { exist_users.Add(View_Users[i]); } var addusers = new UC_User_Selection(exist_users); var Add_User_Page = new Popup_Info(); Add_User_Page.Title = "Add Users To Site"; Add_User_Page.Content = addusers; Add_User_Page.ShowDialog(); // New site was saved, so update the tabs if (Add_User_Page.DialogResult == true) { List <Users> chosen_users = new List <Users>(); chosen_users = addusers.chosen_users; for (int q = 0; q < chosen_users.Count; q++) { View_Users.Add(chosen_users[q]); } Changes_Made = true; } }
// // Function: public void Load_Site(string Site_Name, int mode) // // Arguments: string Site_Name = Name of site to load // int mode = Mode of load (0 = Create, 1 = Edit/View) // // Purpose: Loads a site for viewing or modifying // public void Load_Site(ListBoxItem Site_Name, int mode) { if (mode == 0) { var NS = new Sites(); var newsite = new UC_Site(NS, 0, current_user); var New_Site_Page = new Popup_Info(); Site_Name.HorizontalContentAlignment = HorizontalAlignment.Left; Site_Name.VerticalContentAlignment = VerticalAlignment.Top; Site_Name.Background = Brushes.LightGray; New_Site_Page.Content = newsite; New_Site_Page.Title = "Create New Site"; Site_Name.DataContext = New_Site_Page; New_Site_Page.ShowDialog(); // New site was saved, so update the tabs if (New_Site_Page.DialogResult == true) { Load_My_Sites(current_user); } } if (SiteList.SelectedItem != null && mode != 0) { bool found = false; int found_tab = 0; Opened_Sites New_Open_Site = new Opened_Sites(); New_Open_Site.Initialize(); Sites View_Site = new Sites(); // See if it's already open if (Open_Sites is null == false) { for (int i = 0; i < Open_Sites.Count; i++) { if (Int32.Parse(Site_Name.Uid) == Open_Sites[i].site_info.Site_ID) { found = true; found_tab = Open_Sites[i].tab_index; } } } // Try to the load the site. If successful, display it otherwise don't (add not found handling later) if (View_Site.Load_Site((string)Site_Name.Content) == true && found == false) { // Generate a new Site_Info tab using the user control UC Site var editsite = new UC_Site(View_Site, mode, current_user); var current_site_user = new Users(); current_site_user = current_site_user.Get_User_Settings(View_Site.Site_ID, current_user.User_ID); // Create a new tab for the Site Tab itself //TabItem sites_tab = new TabItem(); CloseableTab sites_tab = new CloseableTab(); sites_tab.Title = View_Site.Short_Name; sites_tab.AddHandler(CloseableTab.CloseTabEvent, new RoutedEventHandler(this.Close_Site_click)); Sites_Tabs.Items.Add(sites_tab); // Add the site to the Open_Sites variable New_Open_Site.site_info = View_Site; // Create the site tabs for info, tickets, resources, etc TabControl site_tab = new TabControl(); site_tab.SizeChanged += new SizeChangedEventHandler(Sites_Tabs_SizeChanged); TabItem info_tab = new TabItem(); info_tab.Header = "Info"; info_tab.Content = editsite; site_tab.Items.Add(info_tab); // Create the users tab TabItem users_tab = new TabItem(); users_tab.Header = "Users"; // Generate a new Site Users tab using the user control UC Site Tickets var siteusers = new UC_Site_Users(New_Open_Site, mode, current_user, current_site_user); users_tab.Content = siteusers; site_tab.Items.Add(users_tab); // Create the tickets tab TabItem tickets_tab = new TabItem(); tickets_tab.Header = "Tickets"; // Generate a new Site_Tickets tab using the user control UC Site Tickets var sitetickets = new UC_Site_Tickets(View_Site, current_user, current_site_user); tickets_tab.Content = sitetickets; site_tab.Items.Add(tickets_tab); // Create the resources tab TabItem resources_tab = new TabItem(); resources_tab.Header = "Resources"; //resources_tab.Content = sitetickets; site_tab.Items.Add(resources_tab); sites_tab.Content = site_tab; Open_Sites.Add(New_Open_Site); Open_Sites[Open_Sites.Count - 1].PropertyChanged += new PropertyChangedEventHandler(Open_Site_Changed); Open_Sites[Open_Sites.Count - 1].PropertyChanged += new PropertyChangedEventHandler(sitetickets.Open_Site_Changed); // Block out the selected site so they don't try to click on it again // Find the site in the site_list box and re-enable it for (int i = 0; i < SiteList.Items.Count; i++) { ListBoxItem site_list = (ListBoxItem)SiteList.Items[i]; if ((string)site_list.Content == sites_tab.Title) { site_list.IsEnabled = false; } } // Switch focus to the first tab Sites_Tabs.SelectedIndex = Sites_Tabs.Items.Count - 1; } // If it was found, but we want to edit it then just enable the modifying of the proper tab if (found == true && mode == 1) { // Generate a new Site_Info tab using the user control UC Site var editsite = new UC_Site(View_Site, mode, current_user); TabItem site_mod = (TabItem)Sites_Tabs.Items[found_tab]; site_mod.Content = editsite; } } }