예제 #1
0
        protected void enviarButton_Click(object sender, EventArgs e)
        {
            try
            {
                string numeroPedido = (pedidoDropDownList.SelectedValue).ToString();
                double totalPedido  = ItensDao.ListarItensPorPedido(numeroPedido).Sum(p => p.ValorTotalItem);
                string NumeroCartao = cartaoTextBox.Text;

                PagamentoContract pagamento = new PagamentoContract();
                pagamento.NumeroCartao = NumeroCartao;
                pagamento.NumeroPedido = numeroPedido;
                pagamento.Valor        = totalPedido;

                ServicePagamentosClient service = new ServicePagamentosClient();
                int resposta = service.EfetuarPagamento(pagamento);
                switch (resposta)
                {
                case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void pagamentoButton_Click(object sender, EventArgs e)
        {
            try
            {
                string numPedido   = pedidosDropDownList.SelectedValue;
                double totalPedido = ItensDao.ListarItensPorPedido(numPedido).Sum(p => p.ValorTotalItem);
                string cartao      = cartaoTextBox.Text;

                ServiceProxy.PagamentoContract pagamento = new ServiceProxy.PagamentoContract();
                pagamento.NumeroCartao = cartao;
                pagamento.NumeroPedido = numPedido;
                pagamento.Valor        = totalPedido;

                ServiceProxy.ServicePagamentosClient service = new ServiceProxy.ServicePagamentosClient();

                int resposta = service.EfetuarPagamento(pagamento);

                switch (resposta)
                {
                case 1: throw new Exception("Este cartão não existe");

                case 2: throw new Exception("Este pedido já foi pago");

                case 3: throw new Exception("Limite excedido");
                }
                mensagemLabel.CssClass = "text text-success";
                mensagemLabel.Text     = "Pedido <strong>" + numPedido + "</strong> pago com sucesso";
            }
            catch (Exception ex)
            {
                mensagemLabel.CssClass = "text text-danger";
                mensagemLabel.Text     = ex.Message;
            }
        }
예제 #3
0
        //método para listar os itens atualizados de um pedido
        private void ListarItens()
        {
            string numeroPedido = pedidosDropDownList1.SelectedValue;

            itensRepeater.DataSource = ItensDao.ListarItensPorPedido(numeroPedido);
            itensRepeater.DataBind();
        }
 private void ListarItens()
 {
     try
     {
         itensRepeater.DataSource = ItensDao.ListarItensPorPedido(pedidosDropDownList.SelectedValue);
         itensRepeater.DataBind();
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #5
0
 //Método para listar os itens atualizados de um pedido
 private void ListarItens()
 {
     try
     {
         string numeroPedido = pedidosDropDownList.SelectedValue;
         itensRepeater.DataSource = ItensDao.ListarItensPorPedido(numeroPedido);
         itensRepeater.DataBind();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #6
0
 protected void pedidoDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         string numeroPedido = pedidoDropDownList.SelectedValue;
         itensRepeater.DataSource = ItensDao.ListarItensPorPedido(numeroPedido);
         itensRepeater.DataBind();
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #7
0
        protected void pagamentoButton_Click(object sender, EventArgs e)
        {
            try
            {
                //obtendo o numero do pedido

                string numPedido = pedidosDropDownList.SelectedValue;

                //obtendo o toral de itens para o pedido selecionado
                double totalPedido = ItensDao.ListarItensPorPedido(numPedido)
                                     .Sum(p => p.ValorTotalItem);


                // obtendo o numero do cartpa
                string cartao = cartaoTextBox.Text;

                //instanciando a classe pagamento contract obtida atraves do serviço
                ServiceProxy.PagamentoContract pagamento =
                    new ServiceProxy.PagamentoContract();

                pagamento.NumeroCartao = cartao;
                pagamento.NumeroPedido = numPedido;
                pagamento.Valor        = totalPedido;

                //instanciando a classe Service Pagamento cliente, obtida atraves do webservice
                ServiceProxy.ServicePagamentosClient service =
                    new ServiceProxy.ServicePagamentosClient();

                int resposta = service.EfetuarPagamento(pagamento);


                switch (resposta)
                {
                case 1: throw new Exception("Este cartão não existe");

                case 2: throw new Exception("Este pedido já foi pago");

                case 3: throw new Exception("Não há limite no cartão");
                }

                mensagemLabel.CssClass = "text text-success";
                mensagemLabel.Text     = "Pedido <strong>" + numPedido +
                                         "</strong> pago com sucesso";
            }
            catch (Exception ex)
            {
                mensagemLabel.CssClass = "text text-danger";
                mensagemLabel.Text     = ex.Message;
            }
        }