0
I have a datagridview that is powered by a search in a database to carry out a sale but I can only sell one product at a time because the sales table cannot receive 2 or more products simultaneously we have already tried to separate the sales table into 2: itens_sale and sales, where sales stores the sales code, the payment method and the date, while itens_sell stores the products. When I finish the sale is only done the storage in the sales table (which is done by a Procedure) and in itens_sale nothing happens (storage here is carried out by table Adapter and data table) if you can help me I would be very grateful
follow the code of the checkout button
private void btnFinCompra_Click(object sender, EventArgs e)
{
try
{
int codigo = Convert.ToInt16(TAVendas.insereVenda(DateTime.Now, pagamento));
txtCodVenda.Text = codigo.ToString();
try
{
for(int cont = 0; cont<=dgvVenda.Rows.Count - 2; cont++)
{
DadosDataSet.tbitensvendaRow linha;
linha = (DadosDataSet.tbitensvendaRow)DTitens.NewRow();
linha.BeginEdit();
linha.codvenda = Convert.ToInt16(txtCodVenda.Text);
linha.codproduto = Convert.ToInt16(dgvVenda.Rows[cont].Cells["clmCodigo"].Value);
linha.nomecor = dgvVenda.Rows[cont].Cells["clmNomeCor"].Value.ToString();
linha.categoria = dgvVenda.Rows[cont].Cells["clmCategoria"].Value.ToString();
linha.subcategoria = dgvVenda.Rows[cont].Cells["clmSubCat"].Value.ToString();
linha.subcategoria2 = dgvVenda.Rows[cont].Cells["clmSubCat2"].Value.ToString();
linha.qtde = Convert.ToInt16(dgvVenda.Rows[cont].Cells["clmQtde"].Value);
linha.peso = Convert.ToDouble(dgvVenda.Rows[cont].Cells["clmPeso"].Value);
linha.marcatipo = dgvVenda.Rows[cont].Cells["clmMarcaTipo"].Value.ToString();
linha.precovenda = Convert.ToDouble(dgvVenda.Rows[cont].Cells["clmPreco"].Value);
linha.totalvenda = Convert.ToDouble(dgvVenda.Rows[cont].Cells["clmSubTotal"].Value);
linha.EndEdit();
DTitens.Rows.Add(linha);
}
TAitens.Update(DTitens);
MessageBox.Show("Venda realizada com sucesso", "Vendas", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Erro ao finalizar compra\n" + ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
TAVendas.excluirVenda(Convert.ToInt16(txtCodVenda.Text));
}
}
catch(Exception ex)
{
MessageBox.Show("Erro ao finalizar compra\n" + ex.Message, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
What is the error in catch?
– Leandro Angelo
It does not return error by catch, the system even makes the registration without errors however it does not store all the data in the database, stores only those that are assigned to stored Procedure, the data so datagridview I do not know where they go.
– Thiago Rodrigues