Esempio n. 1
0
 //
 //  Function:   public void Remove_User(int user_type, int index_no)
 //
 //  Arguments:  int user_type = Type of user to remove (0 = System User, 1 = Site)
 //              int index_no = Index number of user to remove from list
 //
 //  Purpose:    Removes an entire record of a user at a certain index
 //
 public void Remove_User(int user_type, int index_no)
 {
     User_Name.RemoveAt(index_no);
     User_ID.RemoveAt(index_no);
     Access.RemoveAt(index_no);
     if (user_type == 1)
     {
         Site_User_ID.RemoveAt(index_no);
         Site_ID.RemoveAt(index_no);
         View_Resources.RemoveAt(index_no);
         Add_Resources.RemoveAt(index_no);
         Modify_Resources.RemoveAt(index_no);
         Del_Resources.RemoveAt(index_no);
         View_Tickets.RemoveAt(index_no);
         Add_Tickets.RemoveAt(index_no);
     }
 }
Esempio n. 2
0
        //
        //  Function:   public void Get_List(int mode, long site_id)
        //
        //  Arguments:  int mode = Mode of list to get (0 = All Users, 1 = Only Users For This Site)
        //              long site_id = Site ID to get the list for (if mode is 1)
        //
        //  Purpose:    Gets a list of all users (mode = 0) or ones granted rights to see a site (mode = 1)
        //
        public void Get_List(int mode, long site_id = 0)
        {
            List <int> site_users = new List <int>();

            Initialize();

            // If the user name is blank then get it from the system and try to log in with AD security
            string connString = SQLConnString;

            // Query the User Database for the user
            StringBuilder query = new StringBuilder("SELECT * FROM ");

            switch (mode)
            {
            // All Users
            case 0:
                query.Append(tblUserInfo);
                query.Append(" ORDER BY User_Name");
                using (SqlConnection sqlCon = new SqlConnection(connString))
                {
                    sqlCon.Open();
                    SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                    using SqlDataReader reader = SqlCmd.ExecuteReader();
                    while (reader.Read())
                    {
                        User_ID.Add((int)reader[0]);
                        User_Name.Add(String.Format("{0}", reader[1]));
                        Access.Add((int)reader[2]);
                    }
                    sqlCon.Close();
                }
                break;

            // Site_ID users
            case 1:
                query.Append(tblSiteUsers);
                query.Append(" WHERE Site_ID = ");
                query.Append(site_id.ToString());
                // Get list of User_ID's
                using (SqlConnection sqlCon = new SqlConnection(connString))
                {
                    sqlCon.Open();
                    SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                    using SqlDataReader reader = SqlCmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Site_User_ID.Add((long)reader[0]);
                        Site_ID.Add((long)reader[1]);
                        site_users.Add((int)reader[2]);
                        User_ID.Add((int)reader[2]);
                        View_Resources.Add((bool)reader[3]);
                        Add_Resources.Add((bool)reader[4]);
                        Modify_Resources.Add((bool)reader[5]);
                        Del_Resources.Add((bool)reader[6]);
                        View_Tickets.Add((bool)reader[7]);
                        Add_Tickets.Add((bool)reader[8]);
                        Mark_Delete.Add(false);
                    }
                    sqlCon.Close();
                }

                // Convert that list to actual names for display
                foreach (int id in site_users)
                {
                    query.Clear();
                    query.Append("SELECT * FROM ");
                    query.Append(tblUserInfo);
                    query.Append(" WHERE User_ID = ");
                    query.Append(id.ToString());
                    using (SqlConnection sqlCon = new SqlConnection(connString))
                    {
                        sqlCon.Open();
                        SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                        using SqlDataReader reader = SqlCmd.ExecuteReader();
                        while (reader.Read())
                        {
                            User_Name.Add(String.Format("{0}", reader[1]));
                        }
                        sqlCon.Close();
                    }
                }
                break;
            }
        }