コード例 #1
0
        //
        //  Function:   public void Update_Sites_List(User_Sites sites)
        //
        //  Arguments:  sites = User_Sites array of accessible sites
        //
        //  Purpose:    Displays all of the Sites associated with this user.
        //
        public void Update_Sites_List(User_Sites sites)
        {
            int i = 0;

            SiteList.Items.Clear();
            foreach (string sname in sites.site_name)
            {
                ListBoxItem site = new ListBoxItem();
                site.Uid     = sites.site_id[i].ToString();
                site.Content = sname;
                // Block out any open site so they don't try to click on it again
                if (Open_Sites is null)
                {
                    site.IsEnabled = true;
                }
                else
                {
                    for (int j = 0; j < Open_Sites.Count; j++)
                    {
                        if (Open_Sites[j].site_info.Site_ID == sites.site_id[i])
                        {
                            site.IsEnabled = false;
                        }
                    }
                }
                SiteList.Items.Add(site);
                // Increment index
                i++;
            }
        }
コード例 #2
0
        //
        //  Function:   private void CUser_PropertyChanged(object sender, PropertyChangedEventArgs e)
        //
        //  Arguments:  object sender = Built in variable of calling object (menuitem)
        //              RoutedEventArgs e = Built in variable to hold sending objects arguments
        //
        //  Purpose:    Check for the modified user settings and respond appropriately
        //
        private void CUser_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "User_ID":
                if (current_user.User_ID > 0)
                {
                    mmenu_login.Header  = "Logout";
                    this.Title          = AppTitle + " - " + current_user.User_Name;
                    user_sites          = Load_My_Sites(current_user);
                    SiteList.Visibility = Visibility.Visible;
                }
                else
                {
                    mmenu_login.Header  = "Login...";
                    this.Title          = AppTitle + " - Not Logged In";
                    SiteList.Visibility = Visibility.Hidden;
                }
                Update_Main_Menu(current_user.Access);
                break;

            case "Modified":
                if (current_user.Modified)
                {
                    Load_My_Sites(current_user);
                    SiteList.Visibility   = Visibility.Visible;
                    current_user.Modified = false;
                }
                break;

            case "Access":
                break;

            default:
                break;
            }
        }
コード例 #3
0
        //
        //  Function:   public void Load_My_Sites(User_Info user)
        //
        //  Arguments:  user = User Info of currently logged in user
        //              mode = Mode of list to retrieve (0 = Just Mine 'Default', 1 = All For Supervisors Only)
        //
        //  Return:     User_Sites = Structure holding all the sites
        //              accessible to the current user.
        //
        //  Purpose:    Loads the sites accessible to the current user
        //              into a structure for parsing/using.
        //
        public User_Sites Load_My_Sites(User_Info user)
        {
            string connString = SQLConnString;

            var sites = new User_Sites();

            sites.Initialize();

            // Query the Site Users Database for the sites for this user
            StringBuilder query = new StringBuilder("SELECT * FROM ");

            query.Append(tblSiteUsers);

            // Read the user's sites unless they're management
            if (user.Access != 9999 || System_Settings.Show_All_Sites == false)
            {
                query.Append(" WHERE User_ID = ");
                query.Append(user.User_ID.ToString());
            }

            // Read all the sites associated with this user
            using (SqlConnection sqlCon = new SqlConnection(connString))
            {
                sqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                using SqlDataReader reader = SqlCmd.ExecuteReader();
                while (reader.Read())
                {
                    if (sites.site_id.Contains((long)reader[1]) == false)
                    {
                        sites.site_id.Add((long)reader[1]);
                        sites.View_Resources.Add((bool)reader[3]);
                        sites.Add_Resources.Add((bool)reader[4]);
                        sites.Modify_Resources.Add((bool)reader[5]);
                        sites.Del_Resources.Add((bool)reader[6]);
                        sites.View_Tickets.Add((bool)reader[7]);
                        sites.Add_Tickets.Add((bool)reader[8]);
                    }
                }
            }

            // Query the Site Info Database for each of the sites names
            query = new StringBuilder("SELECT Short_Name FROM ");
            query.Append(tblSiteInfo);
            query.Append(" WHERE Site_ID = ");
            foreach (int sid in sites.site_id)
            {
                query.Append(sid.ToString());
                query.Append(" OR Site_ID = ");
            }
            query.Remove(query.Length - 14, 14);

            // Read all the sites associated with this user
            using (SqlConnection sqlCon = new SqlConnection(connString))
            {
                sqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                using SqlDataReader reader = SqlCmd.ExecuteReader();
                while (reader.Read())
                {
                    sites.site_name.Add((string)reader[0]);
                }
                sqlCon.Close();
            }
            Update_Sites_List(sites);
            return(sites);
        }