Save in the database a column of the datagrid

0

I need to get the value of the discount column of my datagrid and save it to my database, I can calculate it when I register the consumption according to the quantity, follow the code below:

foreach(varleiturainleituras){totalConsumo+=leitura.Consumo;totalDesconto+=leitura.Desconto;}dgv[0,dgv.Rows.Count-1].Value="Total";
dgv[1, dgv.Rows.Count - 1].Value = totalConsumo.ToString();
dgv[2, dgv.Rows.Count - 1].Value = totalDesconto.ToString();
lblResultado.Text = "Total consumo com desconto: " + (totalConsumo - totalDesconto).ToString();

Persistence code

    CONEXAO.Open(); 
    MySqlCommand INSERT = new MySqlCommand("INSERT INTO consumo (casa, consumo)" + "VALUES ('" + casa + "','" + consumo + "')", CONEXAO);
    INSERT.Parameters.AddWithValue(casa, txtCasa.Text); 
    INSERT.Parameters.AddWithValue(consumo, txtConsumo.Text); 
    INSERT.ExecuteNonQuery(); 
    MessageBox.Show("O registro foi inserido com sucesso !");
    
asked by anonymous 31.10.2018 / 11:56

0 answers