示例#1
0
        /// <summary>
        /// Gets all post that have below 5 reports
        /// </summary>
        /// <returns>A list with posts</returns>
        public static List <Post> GetSafePost()
        {
            List <Post> Postlist = new List <Post>();

            byte[] File;
            string Attachment;

            if (DatabaseConnectie.OpenConnection())
            {
                try
                {
                    DatabaseConnectie.OpenConnection();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = DatabaseConnectie.connect;

                    cmd.CommandText = "SELECT * FROM Post WHERE Rapportaties < 5 AND PostID IS NULL";
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int      ID         = Convert.ToInt32(reader["ID"]);
                        int      TimelineID = Convert.ToInt32(reader["TijdlijnID"]);
                        int      AccountID  = Convert.ToInt32(reader["AccountID"]);
                        string   PostID     = (reader["PostID"].ToString());
                        string   Category   = (reader["Categorie"].ToString());
                        string   Text       = (reader["Tekstinhoud"].ToString());
                        DateTime Date       = Convert.ToDateTime(reader["Datum"]);
                        int      Likes      = Convert.ToInt32(reader["Likes"]);
                        int      Reports    = Convert.ToInt32(reader["Rapportaties"]);
                        bool     Readable   = (Convert.ToBoolean(reader["Leesbaar"]));
                        if (reader["Bestand"] != DBNull.Value)
                        {
                            Attachment = "Bijlage";
                            File       = (byte[])reader["Bestand"];
                        }
                        else
                        {
                            Attachment = "None";
                            File       = null;
                        }

                        Account Account = DatabaseGetAccounts.GetSingleAccountID(AccountID);

                        Post GottenPost = new Post(ID, Text, Category, AccountID, TimelineID, Likes, Account, File, Attachment, PostID);
                        Postlist.Add(GottenPost);
                    }
                    return(Postlist);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(Postlist);
        } //Gets all posts who havent been reported 5 times or more
示例#2
0
        /// <summary>
        /// //Returns the posts that contain the searched word and category (ook slecht)
        /// </summary>
        /// <param name="Fwoord">Woord van post</param>
        /// <param name="Fcat">categorie van post</param>
        /// <returns>A list with posts</returns>
        public static List <Post> GetWordCategory(string Fwoord, string Fcat)
        {
            List <Post> Postlist = new List <Post>();

            byte[] File;
            string Attachment;

            if (DatabaseConnectie.OpenConnection())
            {
                try
                {
                    DatabaseConnectie.OpenConnection();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = DatabaseConnectie.connect;

                    cmd.CommandText = "SELECT p.Categorie, p.AccountID, p.TijdlijnID, p.Tekstinhoud, p.Likes, a.Naam, p.Bestand FROM Post p, Account a WHERE p.AccountID = a.ID AND p.Tekstinhoud LIKE " + "'%" + Fwoord + "%'" + "AND p.Categorie = " + "'" + Fcat + "'" + ";";
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        //int ID = Convert.ToInt32(reader["ID"]);
                        int TimelineID = Convert.ToInt32(reader["TijdlijnID"]);
                        int AccountID  = Convert.ToInt32(reader["AccountID"]);
                        //string PostID = (reader["PostID"].ToString());
                        string Category = (reader["Categorie"].ToString());
                        string Text     = (reader["Tekstinhoud"].ToString());
                        //DateTime Date = Convert.ToDateTime(reader["Datum"]);
                        int Likes = Convert.ToInt32(reader["Likes"]);
                        //int Reports = Convert.ToInt32(reader["Rapportaties"]);
                        //bool Readable = (Convert.ToBoolean(reader["Leesbaar"]));
                        if (reader["Bestand"] != DBNull.Value)
                        {
                            Attachment = "Bijlage";
                            File       = (byte[])reader["Bestand"];
                        }
                        else
                        {
                            Attachment = "None";
                            File       = null;
                        }

                        Account Account = DatabaseGetAccounts.GetSingleAccountID(AccountID);

                        Post GottenPost = new Post(Text, Category, AccountID, TimelineID, Likes, Account, File, Attachment);
                        Postlist.Add(GottenPost);
                    }
                    return(Postlist);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(Postlist);
        }
示例#3
0
 /// <summary>
 /// Returns an account if it is checked in to this event.
 /// </summary>
 /// <param name="RFIDtag">The RFID tag from an RFID reader.</param>
 /// <returns>Returns a single account.</returns>
 public Account Checkuit_CheckAccount(string RFIDtag)
 {
     if (DatabaseGetAccounts.GetAccountRFID_Checkuit(RFIDtag, ID) != null) //database
     {
         Account Account = DatabaseGetAccounts.GetAccountRFID_Checkuit(RFIDtag, ID);
         return(Account);
     }
     else
     {
         return(null);
     }
 }
示例#4
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            Account = DatabaseGetAccounts.GetAccountFromRFID(rfid.CurrentRFIDTag);

            if (Account == null)
            {
                MessageBox.Show("Account kon niet worden gevonden.");
                return;
            }

            materiallist = material.GetMaterialForAccount(Event.ID, Account.ID);
            Refreshform();
        }
示例#5
0
        private void btnInleveren_Click(object sender, EventArgs e)
        {
            Account account = DatabaseGetAccounts.GetAccountFromRFID(rfid.CurrentRFIDTag);

            if (account == null)
            {
                MessageBox.Show("Account kon niet worden gevonden.");
                return;
            }

            material.Return(selectedlist, account.ID);
            selectedlist.Clear();
            Refreshform();
        }
示例#6
0
        /// <summary>
        /// Gets the account that has the specified RFID tag
        /// </summary>
        /// <param name="RFIDtag">The RFID tag from an RFID reader</param>
        /// <returns>Returns a single account</returns>
        public Account GetAccountRFID(string RFIDtag)
        {
            Account account = DatabaseGetAccounts.GetAccountFromRFID(RFIDtag);

            return(account);
        }
示例#7
0
        /// <summary>
        /// Used to get all accounts that have a specific function.
        /// </summary>
        /// <param name="function">The function the account has.</param>
        /// <returns>Returns a list of accounts.</returns>
        public List <Account> GetAccountsFunction(Function function)
        {
            List <Account> accountList = DatabaseGetAccounts.GetAccountsFunction(function);

            return(accountList);
        }
示例#8
0
        /// <summary>
        /// Get a Guests list for a specific event (people who are present at an event)
        /// </summary>
        /// <returns>A list with all Accounts for a event<returns>
        public List <Account> GetGuestList()
        {
            List <Account> GuestList = DatabaseGetAccounts.GetAccountsEventID(ID);

            return(GuestList);
        }