Exemplo n.º 1
0
        public void InsertSanctionType(SanctionType stype)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT_SANCTIONTYPE, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@stype_name", stype.stype_name);
                command.Parameters.AddWithValue("@stype_ammount", stype.stype_ammount);

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

                while (reader.Read())
                {
                    SanctionType stype = new SanctionType();
                    stype.stype_id = reader.GetInt32(0);
                    stype.stype_ammount = reader.GetInt32(1);
                    stype.stype_name = reader.GetString(2);

                    stypeList.Add(stype);
                }
            }
            return stypeList;
        }
Exemplo n.º 3
0
        public SanctionType SelectOne(int stypeId)
        {
            SanctionType stype = new SanctionType();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ONE, conn);
                command.Parameters.AddWithValue("@stype_id", stypeId);

                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    stype.stype_id = reader.GetInt32(0);
                    stype.stype_name = reader.GetString(1);
                    stype.stype_ammount = reader.GetInt32(2);
                }
                reader.Close();
            }
            return stype;
        }
Exemplo n.º 4
0
        public void Update(SanctionType stype)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(UPDATE_SANCTIONTYPE, conn);

                command.Parameters.AddWithValue("@stype_id", stype.stype_id);
                command.Parameters.AddWithValue("@stype_name", stype.stype_name);
                command.Parameters.AddWithValue("@stype_ammount", stype.stype_ammount);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 5
0
        protected void Button5_Click(object sender, EventArgs e)
        {
            //prida typ sankce
            DatabaseLibrary.SanctionType stype = new DatabaseLibrary.SanctionType();

            stype.stype_ammount = Convert.ToInt32(TextBox_stype_ammount.Text);
            stype.stype_name = TextBox_stype_name.Text;

            new DatabaseLibrary.SanctionTypeTable().InsertSanctionType(stype);

            Response.Redirect(Request.RawUrl);
        }