public void InsertSanctionsHistory(SanctionsHistory sanHis)
        {
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(INSERT_SANCTIONSHISTORY, conn);

                /* Add parameters into the command */
                command.Parameters.AddWithValue("@client_id", sanHis.client_id);
                command.Parameters.AddWithValue("@sanction_desc", sanHis.sanction_desc);
                command.Parameters.AddWithValue("@sanction_grant", sanHis.sanction_grant);
                command.Parameters.AddWithValue("@sanction_paid", sanHis.sanction_paid);
                command.Parameters.AddWithValue("@stype_id", sanHis.stype_id);

                /* Executes the command */
                command.ExecuteNonQuery();
            }
        }
        public List<SanctionsHistory> SelectAll()
        {
            List<SanctionsHistory> sanHisList = new List<SanctionsHistory>();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ALL, conn);
                MySqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    SanctionsHistory sanHis = new SanctionsHistory();
                    sanHis.sanction_id = reader.GetInt32(0);
                    sanHis.sanction_grant = reader.GetDateTime(1);
                    sanHis.sanction_paid = reader.GetDateTime(2);
                    sanHis.sanction_desc = reader.GetString(3);
                    sanHis.client_id = reader.GetInt32(4);
                    sanHis.stype_id = reader.GetInt32(5);

                    sanHisList.Add(sanHis);
                }
            }
            return sanHisList;
        }
        public SanctionsHistory SelectOne(int sanctionId)
        {
            SanctionsHistory sanHis = new SanctionsHistory();
            using (MySqlConnection conn = new MySqlConnection(connString))
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand(SELECT_ONE, conn);
                command.Parameters.AddWithValue("@sanction_id", sanctionId);

                MySqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    sanHis.sanction_id = reader.GetInt32(0);
                    sanHis.sanction_grant = reader.GetDateTime(1);
                    sanHis.sanction_paid = reader.GetDateTime(2);
                    sanHis.sanction_desc = reader.GetString(3);
                    sanHis.client_id = reader.GetInt32(4);
                    sanHis.stype_id = reader.GetInt32(5);
                }
                reader.Close();
            }
            return sanHis;
        }
Beispiel #4
0
        protected void Button6_Click(object sender, EventArgs e)
        {
            //prida zaznam do sanction history
            DatabaseLibrary.SanctionsHistory sanHis = new DatabaseLibrary.SanctionsHistory();

            string sanction_grant = TextBox_sanction_grant.Text;
            string[] items = sanction_grant.Split('/');
            DateTime sanction_grant_toDB = new DateTime(Int32.Parse(items[2]), Int32.Parse(items[1]), Int32.Parse(items[0]));

            string sanction_paid = TextBox_sanction_paid.Text;
            string[] items2 = sanction_paid.Split('/');
            DateTime sanction_paid_toDB = new DateTime(Int32.Parse(items2[2]), Int32.Parse(items2[1]), Int32.Parse(items2[0]));

            sanHis.client_id = Convert.ToInt32(DropDownList_sanction_client_id.SelectedValue);
            sanHis.sanction_desc = TextBox_sanction_desc.Text;
            sanHis.sanction_grant = sanction_grant_toDB;
            sanHis.sanction_paid = sanction_paid_toDB;
            sanHis.stype_id = Convert.ToInt32(DropDownList_sanction_stype_id.SelectedValue); ;

            new DatabaseLibrary.SanctionsHistoryTable().InsertSanctionsHistory(sanHis);

            Response.Redirect(Request.RawUrl);
        }