コード例 #1
0
        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");
            }
        }
コード例 #2
0
 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();
 }
コード例 #3
0
 private void btnSairCliente_Click(object sender, EventArgs e)
 {
     this.clienteSalvo      = null;
     pbFotoCliente.Image    = null;
     pbFotoProduto.Image    = null;
     txtUsuario.Text        = "";
     txtSenha.Text          = "";
     dgvCarrinho.DataSource = new List <CAMADAS.MODEL.Carrinho>();
     zerarProduto();
     habilitarCliente(false);
 }
コード例 #4
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            CAMADAS.BLL.ClienteBLL       bllCli            = new CAMADAS.BLL.ClienteBLL();
            List <CAMADAS.MODEL.Cliente> clienteRecuperado = bllCli.SelectByUsuarioAndSenha(txtUsuario.Text, txtSenha.Text);

            if (clienteRecuperado == null)
            {
            }
            else if (clienteRecuperado.Count > 0)
            {
                this.clienteSalvo = clienteRecuperado[0];
                this.setarClienteNovoVisual();
                recarregarTabelaCarrinho();
                recarregarTabelaComprasRealizadas();
                habilitarCliente(true);
            }
            else
            {
                MessageBox.Show("Usuário não encontrado");
            }
        }
コード例 #5
0
        private void BtnInserir_Click(object sender, EventArgs e)
        {
            CAMADAS.MODEL.Cliente cliente = new CAMADAS.MODEL.Cliente();
            cliente.nome        = txtNome.Text;
            cliente.cpf         = txtCPF.Text;
            cliente.telefone    = txtTelefone.Text;
            cliente.dt_nasc     = dtpDt_Nasc.Value;
            cliente.endereco    = txtEndereco.Text;
            cliente.numero      = Convert.ToInt32(txtNumero.Text);
            cliente.complemento = txtComplemento.Text;
            cliente.bairro      = txtBairro.Text;
            cliente.cep         = Convert.ToInt32(txtCEP.Text);
            cliente.idCidade    = Convert.ToInt32(cmbCidade.SelectedValue.ToString());

            CAMADAS.DAL.Cliente dalCli = new CAMADAS.DAL.Cliente();
            dalCli.Inserir(cliente);

            //dgvClientes.DataSource = "";
            dgvClientes.Refresh();
            dgvClientes.DataSource = dalCli.Select();

            limparCampos();
        }
コード例 #6
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);
        }