protected void excluirLinkButton_Click(object sender, EventArgs e) { LinkButton button = (LinkButton)sender; var x = button.CommandArgument; ItensDao.RemoverItem(int.Parse(x)); ListarItens(); }
private void ListarItens() { try { itensRepeater.DataSource = ItensDao.ListarItensPorPedido(pedidosDropDownList.SelectedValue); itensRepeater.DataBind(); } catch (Exception) { throw; } }
//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; } }
protected void pedidoDropDownList_SelectedIndexChanged(object sender, EventArgs e) { try { string numeroPedido = pedidoDropDownList.SelectedValue; itensRepeater.DataSource = ItensDao.ListarItensPorPedido(numeroPedido); itensRepeater.DataBind(); } catch (Exception) { throw; } }
protected void pagamentoButton_Click(object sender, EventArgs e) { try { //Obtendo o numero do pedido string numPedido = pedidoDropDowList.SelectedValue; //o valor total de itens para o pedido selecionado double totalPedido = ItensDao.ListarItensPorPedidos(numPedido).Sum(p => p.ValorTotalItem); //Obtendo o numero do cartao string cartao = cartaoTextBox.Text; //instanciando a classe pagamento contract obtida atrves do serviço 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("Numero de cartão não encontrado"); case 2: throw new Exception("O pedido ja foi está pago"); case 3: throw new Exception("Limite insuficiente"); default: break; } 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; } }
protected void excluirLinkButton_Click(object sender, EventArgs e) { try { var x = ((LinkButton)sender).CommandArgument; ItensDao.RemoverItem(int.Parse(x)); ListarItens(); } catch (Exception) { throw; } }
protected void pagamentoButton_Click(object sender, EventArgs e) { try { //obtendo o numero do pedido string numPedido = pedidosDropDownList.SelectedValue; //obtendo o total de itens para o pedido selecionado double totalPedido = ItensDao.ListarItensPorPedido(numPedido) .Sum(p => p.ValorTotalItem); //obtendo o numero do cartão string cartao = cartaoTextBox.Text; //instanciando a classe PagamentoContract obtida através //do serviço ServiceProxy.PagamentoContract pagamento = new ServiceProxy.PagamentoContract(); pagamento.NumeroCartao = cartao; pagamento.NumeroPedido = numPedido; pagamento.Valor = totalPedido; //instanciando a classe ServicePagamentoCliente, obtida //através 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; } }
protected void enviarButton_Click(object sender, EventArgs e) { try { Item item = new Item(); item.IdPedido = int.Parse(pedidosDropDownList.SelectedValue); item.IdProduto = int.Parse(produtosDropDownList.SelectedValue); item.Quantidade = double.Parse(quantidadeTextBox.Text); ItensDao.IncluirItem(item); mensagemLabel.CssClass = "alert alert-success"; mensagemLabel.Text = "Item incluido com sucesso"; } catch (Exception ex) { mensagemLabel.CssClass = "alert alert-success"; mensagemLabel.Text = ex.Message; } }
protected void excluirLinkButton_Click(object sender, EventArgs e) { var x = ((LinkButton)sender).CommandArgument; ItensDao.removerItem(int.Parse(x)); }