private void btnAdicionarCarrinho_Click(object sender, EventArgs e)
        {
            CAMADAS.MODEL.Carrinho carrinho = new CAMADAS.MODEL.Carrinho();

            carrinho.idCliente = clienteSalvo.id;
            carrinho.idProduto = Convert.ToInt32(lblIdProduto.Text);
            if (txtQuantidadeProduto.Text.Equals("") || txtQuantidadeProduto.Text.Equals("0"))
            {
                MessageBox.Show("Quantidade inválida");
                return;
            }
            carrinho.quantidade = Convert.ToInt32(txtQuantidadeProduto.Text);
            carrinho.total      = Convert.ToSingle(txtPrecoProduto.Text) * carrinho.quantidade;
            if (!lblIdProduto.Text.Equals("-1"))
            {
                CAMADAS.BLL.CompraBLL  bllCompra = new CAMADAS.BLL.CompraBLL();
                CAMADAS.BLL.ClienteBLL bllCli    = new CAMADAS.BLL.ClienteBLL();
                bllCompra.adicionarAoCarrinho(carrinho);
                clienteSalvo = bllCli.SelectById(clienteSalvo.id)[0];
                zerarProduto();
                setarClienteNovoVisual();
                recarregarTabelaCarrinho();
                recarregarTabelaProduto();
            }
            else
            {
                MessageBox.Show("Selecione um produto");
            }
        }
Beispiel #2
0
        public static void  relatorioVendas()
        {
            CAMADAS.BLL.CompraBLL bllCompra = new CAMADAS.BLL.CompraBLL();
            List <CAMADAS.MODEL.RegistroCompra> lstVenda = new List <CAMADAS.MODEL.RegistroCompra>();

            lstVenda = bllCompra.SelectAllRegistroCompra();
            string       pasta   = Funcoes.diretorioPasta();
            string       arquivo = pasta + @"\RelatoriosVenda.html";
            StreamWriter sw      = new StreamWriter(arquivo);

            using (sw)
            {
                sw.WriteLine("<!DOCTYPE html>");
                sw.WriteLine("<HTML lang = 'pt - br'>");
                sw.WriteLine("<HEAD>");
                sw.WriteLine("<META http-equiv = 'Content-Type' content='text/css; text='text/css' charset=utf-8'/");
                sw.WriteLine("<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>");
                sw.WriteLine("<title> Relatorio de Vendas </title>");
                sw.WriteLine("</HEAD>");
                sw.WriteLine("<BODY>");
                sw.WriteLine("<h1> Relatorio de Venda </h1> <hr> <br>");
                sw.WriteLine("<table class='table table-striped' width=100% border='2px' align='center'>");
                sw.WriteLine("<tr>");
                sw.WriteLine("<th> ID </th>");
                sw.WriteLine("<th> ID-CLIENTE </th>");
                sw.WriteLine("<th> DATA </th>");
                sw.WriteLine("<th> TOTAL </th>");
                sw.WriteLine("</tr>");
                int   cont  = 0;
                float total = 0;
                foreach (CAMADAS.MODEL.RegistroCompra registro in lstVenda)
                {
                    sw.WriteLine("<tr align='center'>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(registro.id);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(registro.idCliente);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(registro.data);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(string.Format("{0:C2}", registro.totalPago));
                    sw.WriteLine("</td>");
                    sw.WriteLine("</tr>");
                    cont++;
                    total += registro.totalPago;
                }
                sw.WriteLine("</table> <br> <hr>");
                sw.WriteLine("<h2> Quantidade de Vendas: {0}", cont);
                sw.WriteLine("<h2> Valor total de vendas: {0}", string.Format("{0:C2}", total));
                sw.WriteLine("</h2>");
                sw.WriteLine("</BODY>");
                sw.WriteLine("</HTML>");
            }
            System.Diagnostics.Process.Start(arquivo);
        }
 private void btnFinalizarCompra_Click(object sender, EventArgs e)
 {
     CAMADAS.BLL.CompraBLL bllComp = new CAMADAS.BLL.CompraBLL();
     bllComp.finalizarCompra(this.clienteSalvo.id);
     recarregarTabelaCarrinho();
     recarregarTabelaProduto();
     recarregarTabelaComprasRealizadas();
     zerarProduto();
 }
 private void btnCancelarCompra_Click(object sender, EventArgs e)
 {
     CAMADAS.BLL.CompraBLL  bllComp = new CAMADAS.BLL.CompraBLL();
     CAMADAS.BLL.ClienteBLL bllCli  = new CAMADAS.BLL.ClienteBLL();
     bllComp.deletarCarrinhoCliente(this.clienteSalvo.id);
     recarregarTabelaCarrinho();
     recarregarTabelaProduto();
     zerarProduto();
     this.clienteSalvo = bllCli.SelectById(this.clienteSalvo.id)[0];
     setarClienteNovoVisual();
 }
 private void recarregarTabelaComprasRealizadas()
 {
     if (clienteSalvo != null)
     {
         CAMADAS.BLL.CompraBLL bllCompra = new CAMADAS.BLL.CompraBLL();
         dgvComprasRealizadas.DataSource = bllCompra.SelectRegistroCompraByIdCliente(this.clienteSalvo.id);
     }
     else
     {
         MessageBox.Show("Erro, logue novamente");
     }
 }
 private void recarregarTabelaCarrinho()
 {
     if (clienteSalvo != null)
     {
         CAMADAS.BLL.CompraBLL bllCompra = new CAMADAS.BLL.CompraBLL();
         dgvCarrinho.DataSource = bllCompra.SelectCarrinhoByCliente(this.clienteSalvo.id);
     }
     else
     {
         MessageBox.Show("Erro, logue novamente");
     }
 }
Beispiel #7
0
        public static void relatorioVendaDetalhada(int registro, int idCliente)
        {
            CAMADAS.BLL.CompraBLL       bllCompra = new CAMADAS.BLL.CompraBLL();
            CAMADAS.BLL.ClienteBLL      bllCli    = new CAMADAS.BLL.ClienteBLL();
            List <CAMADAS.MODEL.Compra> lstVendaD = new List <CAMADAS.MODEL.Compra>();

            CAMADAS.MODEL.RegistroCompra registroCompra = bllCompra.SelectRegistroCompraById(registro)[0];
            lstVendaD = bllCompra.SelectComprasRealizadasByIdRegistro(registro);
            CAMADAS.MODEL.Cliente cliente = bllCli.SelectById(idCliente)[0];

            string       pasta   = Funcoes.diretorioPasta();
            string       arquivo = pasta + @"\RelatoriosVendaDetalhada-" + registro + ".html";
            StreamWriter sw      = new StreamWriter(arquivo);

            using (sw)
            {
                sw.WriteLine("<!DOCTYPE html>");
                sw.WriteLine("<HTML lang = 'pt - br'>");
                sw.WriteLine("<HEAD>");
                sw.WriteLine("<META http-equiv = 'Content-Type' content='text/css; text='text/css' charset=utf-8'/");
                sw.WriteLine("<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous'>");
                sw.WriteLine("<title> Relatorio de Vendas </title>");
                sw.WriteLine("</HEAD>");
                sw.WriteLine("<BODY>");
                sw.WriteLine("<h1> Relatorio de Venda, " + registroCompra.data.ToString() + "</h1> <hr> <br>");
                sw.WriteLine("<h1> Cliente: " + cliente.nome + "</h1> <hr> <br>");
                sw.WriteLine("<table class='table table-striped' width=100% border='2px' align='center'>");
                sw.WriteLine("<tr>");
                sw.WriteLine("<th> ID </th>");
                sw.WriteLine("<th> ID-PRODUTO </th>");
                sw.WriteLine("<th> QUANTIDADE </th>");
                sw.WriteLine("<th> TOTAL </th>");
                sw.WriteLine("</tr>");
                int cont = 0;
                foreach (CAMADAS.MODEL.Compra compra in lstVendaD)
                {
                    sw.WriteLine("<tr align='center'>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(compra.id);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(compra.idProduto);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(compra.quantidade);
                    sw.WriteLine("</td>");
                    sw.WriteLine("<td>");
                    sw.WriteLine(string.Format("{0:C2}", compra.total));
                    sw.WriteLine("</td>");
                    sw.WriteLine("</tr>");
                    cont++;
                }
                sw.WriteLine("</table> <br> <hr>");
                sw.WriteLine("<h2> Quantidade de Vendas: {0}", cont);
                sw.WriteLine("<h2> Valor total da venda: {0}", string.Format("{0:C2}", registroCompra.totalPago));
                sw.WriteLine("</h2>");
                sw.WriteLine("</BODY>");
                sw.WriteLine("</HTML>");
            }
            System.Diagnostics.Process.Start(arquivo);
        }