Exemplo n.º 1
0
        protected void Button11_Click(object sender, EventArgs e)
        {
            //prida do ActionCategory
            DatabaseLibrary.ActionCategory actCat = new DatabaseLibrary.ActionCategory();

            actCat.action_id = Convert.ToInt32(DropDownList_actionCategory_action_id.SelectedValue);
            actCat.category_id = Convert.ToInt32(DropDownList_actionCategory_category_id.SelectedValue);

            new DatabaseLibrary.ActionCategoryTable().InsertActionCategory(actCat);

            Response.Redirect(Request.RawUrl);
        }
Exemplo n.º 2
0
        public void InsertActionCategory(ActionCategory actcat)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@action_id", actcat.action_id);
                command.Parameters.AddWithValue("@category_id", actcat.category_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 3
0
        public List<ActionCategory> SelectAll()
        {
            List<ActionCategory> catList = new List<ActionCategory>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALL, conn);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    ActionCategory actcat = new ActionCategory();
                    actcat.action_id = reader.GetInt32(0);
                    actcat.category_id = reader.GetInt32(1);

                    catList.Add(actcat);
                }
            }
            return catList;
        }
Exemplo n.º 4
0
        public ActionCategory SelectOne(int ActionCategoryId)
        {
            ActionCategory actcat = new ActionCategory();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ONE, conn);
                command.Parameters.AddWithValue("@actioncategory_id", ActionCategoryId);

                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    actcat.action_id = reader.GetInt32(0);
                    actcat.category_id = reader.GetInt32(1);
                }
                reader.Close();
            }
            return actcat;
        }