private void excluirVendaBtn_Click(object sender, EventArgs e) { try { if ((_codigoVenda != 0)) { if (MessageBox.Show("Deseja realmente excluir isto?", "Cuidado!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { DALVenda dALVenda = new DALVenda(); dALVenda.Excluir(_codigoVenda); consultaVendaGridView.DataSource = dALVenda.Pesquisar(); _codigoVenda = 0; MessageBox.Show("Venda excluída com sucesso!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Operação cancelada!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Tabela vazia ou venda não selecionada!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void adcCarrinhoVendaBtn_Click_1(object sender, EventArgs e) { DALVenda dALVenda = new DALVenda(); qtdValorVenda = Convert.ToDecimal(qtdVendaTbx.Text); Produto produto = dALVenda.getValorAndQtdProduto(modeloProdutoVendaCbx.Text); if (qtdValorVenda != 0) { if (qtdValorVenda <= produto.Quantidade) { valorTotalVendaTbx.Text = Convert.ToString(dALVenda.calculaPrecoVenda(precoAtualVenda, qtdValorVenda, produto.Preco)); precoAtualVenda = Convert.ToDecimal(valorTotalVendaTbx.Text); consultaCarrinhoVendaGridView.Rows.Add(produto.IdProduto, categoriaVendaCbx.Text, modeloProdutoVendaCbx.Text, qtdVendaTbx.Text, produto.Preco, produto.Quantidade); finalizaVendaBtn.Enabled = true; adcCarrinhoVendaBtn.Enabled = false; limpaCampos(); } else { MessageBox.Show("A quantidade escolhida é maior que contida no estoque Produto: " + modeloProdutoVendaCbx.Text + "/Quantidade: " + produto.Quantidade, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("A quantidade é inválida", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void comboBox1_DropDown_1(object sender, EventArgs e) { DALVenda dALVenda = new DALVenda(); modeloProdutoVendaCbx.DataSource = dALVenda.carregaComboBoxProduto(categoriaVendaCbx.Text); modeloProdutoVendaCbx.DisplayMember = "modelo"; }
private void modeloProdutoVendaCbx_SelectedIndexChanged_1(object sender, EventArgs e) { DALVenda dALVenda = new DALVenda(); Produto produto = dALVenda.getValorAndQtdProduto(modeloProdutoVendaCbx.Text); descricaoProdVendaTbx.Text = produto.Descricao; idProdutoVendaTbx.Text = Convert.ToString(produto.IdProduto); qtdVendaTbx.Enabled = true; qtdVendaTbx.Text = "0"; }
private void finalizaVendaBtn_Click_1(object sender, EventArgs e) { try { Venda venda = new Venda(); ValidarCamposVenda validarCamposVenda = new ValidarCamposVenda(); venda.NomeCliente = this.NomeCliente; venda.IdCliente = IdCliente; venda.ValorTotal = Convert.ToDecimal(valorTotalVendaTbx.Text); DALVenda dALVenda = new DALVenda(); dALVenda.Inserir(venda); for (int i = 0; i < (consultaCarrinhoVendaGridView.Rows.Count - 1); i++) { DataGridViewRow row = consultaCarrinhoVendaGridView.Rows[i]; venda.produtosVenda.Categoria = Convert.ToString(row.Cells["categoria"].Value); venda.produtosVenda.Modelo = Convert.ToString(row.Cells["modelo"].Value); venda.produtosVenda.QtdProduto = Convert.ToInt32(row.Cells["quantidade"].Value); venda.produtosVenda.Preco = Convert.ToDecimal(row.Cells["preco"].Value); _qtdProdutoEstoque = Convert.ToInt32(row.Cells["quantidade_estoque"].Value); _idProdutoEstoque = Convert.ToInt32(row.Cells["id_produtoEstoque"].Value); venda.produtosVenda.IdProduto = _idProdutoEstoque; _qtdAtualizadaEstoque = Convert.ToInt32(_qtdProdutoEstoque - venda.produtosVenda.QtdProduto); dALVenda.InserirProdutos(venda); dALVenda.AtualizarEstoque(_qtdAtualizadaEstoque, _idProdutoEstoque); } MessageBox.Show("Venda finalizada com sucesso!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); conn.Close(); Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void pesquisaVendaBtn_Click(object sender, EventArgs e) { try { DALVenda dALVenda = new DALVenda(); if (string.IsNullOrEmpty(cpfPesqVendaMskBx.Text)) { consultaVendaGridView.DataSource = dALVenda.PesquisarPorNomeCliente(nomeClientePesqTbx.Text); alterarNomesCulunasGridView(); } else if (string.IsNullOrEmpty(nomeClientePesqTbx.Text)) { consultaVendaGridView.DataSource = dALVenda.PesquisarPorCpf(cpfPesqVendaMskBx.Text); alterarNomesCulunasGridView(); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } }