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 !");