示例#1
0
        /// <summary>
        /// this method is called when the current user
        /// wants to add a topic.
        /// </summary>
        protected internal void addTopic()
        {
            DB           db      = new DB();
            Globals      g       = new Globals();
            MainForm     mf      = new MainForm();
            MySqlCommand command = new MySqlCommand("INSERT INTO `topic`(`topic_title`, `topic_desc`, `topic_type`, `topic_date`, `user_name`, `category_type`) VALUES (@title, @desc, @type, now(), @user, @category)", db.getConnection());

            // update topic set uid=(select uid from user where topic.uid = user.uid)
            command.Parameters.Add("@title", MySqlDbType.VarChar).Value    = title_txtBox.Text;
            command.Parameters.Add("@desc", MySqlDbType.VarChar).Value     = desc_txtBox.Text;
            command.Parameters.Add("@type", MySqlDbType.VarChar).Value     = TopicTypeLabel.Text;
            command.Parameters.Add("@category", MySqlDbType.VarChar).Value = LanguageTypeLabel.Text;
            command.Parameters.Add("@user", MySqlDbType.VarChar).Value     = userTxtBox.Text;

            db.openConnection();

            topic                = new TopicControl();
            topic.Title          = title_txtBox.Text;
            topic.Message        = desc_txtBox.Text;
            topic.userLabel.Text = userTxtBox.Text;
            topic.Icon           = Resources.user1;
            mf.tc.AddFirst(topic);
            mf.flowLayoutPanel1.Controls.Add(topic);

            command.ExecuteNonQuery();

            db.closeConnection();
        }
示例#2
0
        /// <summary>
        /// This method is called when the current user
        /// wants to see his/her created topics.
        /// </summary>
        public void showCurrentUserTopic()
        {
            flowLayoutPanel1.Controls.Clear();

            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("SELECT `topic_title`, `topic_desc`, `user_name` FROM `topic` WHERE `user_name` = @user", db.getConnection());

            command.Parameters.Add("@user", MySqlDbType.VarChar).Value = UserAccountLabel.Text;

            db.openConnection();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                topic                = new TopicControl();
                topic.label1.Text    = reader.GetString("topic_title");
                topic.textBox1.Text  = reader.GetString("topic_desc");
                topic.userLabel.Text = reader.GetString("user_name");
                tc.AddFirst(topic);
                flowLayoutPanel1.Controls.Add(topic);
            }
        }
示例#3
0
        /// <summary>
        /// This method is called when the current user
        /// wants to see all topics created by other users.
        /// </summary>
        protected internal void displayTopic()
        {
            flowLayoutPanel1.Controls.Clear();

            int?         count;
            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("SELECT topic_title, topic_desc, topic_type, topic_date, user_name, category_type FROM topic", db.getConnection());


            db.openConnection();
            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                topic                = new TopicControl();
                topic.label1.Text    = reader.GetString("topic_title");
                topic.textBox1.Text  = reader.GetString("topic_desc");
                topic.userLabel.Text = reader.GetString("user_name");
                tc.AddFirst(topic);
                flowLayoutPanel1.Controls.Add(topic);
            }
        }
示例#4
0
        /// <summary>
        /// This method is called when the current user
        /// wants to filter topics by topics.
        /// </summary>
        public void filterTopic()
        {
            flowLayoutPanel1.Controls.Clear();

            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("SELECT topic_title, topic_desc, user_name FROM topic WHERE topic_type = @topic", db.getConnection());

            command.Parameters.Add("@topic", MySqlDbType.VarChar).Value = topic_cb.SelectedItem;

            db.openConnection();
            MySqlDataReader reader = command.ExecuteReader();

            // topic category
            if (topic_cb.SelectedItem == "Inheritance")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (topic_cb.SelectedItem == "Abstraction")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (topic_cb.SelectedItem == "If-Else statements")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (topic_cb.SelectedItem == "Loops")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (topic_cb.SelectedItem == "Arrays")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (topic_cb.SelectedItem == "Declaring variables")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
        }
示例#5
0
        /// <summary>
        /// This method is called when the current user
        /// wants to filter everything by the category given.
        /// </summary>
        public void filterLanguage()
        {
            flowLayoutPanel1.Controls.Clear();

            DB           db      = new DB();
            MySqlCommand command = new MySqlCommand("SELECT topic_title, topic_desc, user_name FROM topic WHERE category_type = @type", db.getConnection());

            command.Parameters.Add("@type", MySqlDbType.VarChar).Value = language_cb.SelectedItem;

            db.openConnection();
            MySqlDataReader reader = command.ExecuteReader();

            // programming language category
            if (language_cb.SelectedItem == "Java")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (language_cb.SelectedItem == "Python")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (language_cb.SelectedItem == "C++")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }
            else if (language_cb.SelectedItem == "C#")
            {
                while (reader.Read())
                {
                    topic                = new TopicControl();
                    topic.label1.Text    = reader.GetString("topic_title");
                    topic.textBox1.Text  = reader.GetString("topic_desc");
                    topic.userLabel.Text = reader.GetString("user_name");
                    tc.AddFirst(topic);
                    flowLayoutPanel1.Controls.Add(topic);
                }
            }



            db.closeConnection();
        }