Exemplo n.º 1
0
 public string CadastroCartao(DadosCartao Cartao)
 {
     using (var connection = GetConnection())
     {
         connection.Open();
         string rpta = "";
         try
         {
             command.Connection  = connection;
             command.CommandText = "INSERT INTO tb_cartoes (id_bandeira, taxa_debito, taxa_credito) VALUES (@id_bandeira, @taxa_debito, @taxa_credito)";
             command.CommandType = CommandType.Text;
             command.Parameters.AddWithValue("@id_bandeira", Cartao.Bandeira);
             command.Parameters.AddWithValue("@taxa_debito", Cartao.TaxaDebito);
             command.Parameters.AddWithValue("@taxa_credito", Cartao.TaxaCredito);
             //command.Parameters.AddWithValue("@id_pagamento", Cartao.IdPagamento);
             rpta = command.ExecuteNonQuery() == 1 ? "OK" : "Falha ao cadastrar cartao";
             connection.Close();
         }
         catch (Exception ex)
         {
             rpta = ex.Message + ex.StackTrace;
         }
         return(rpta);
     }
 }
Exemplo n.º 2
0
 public bool Valida(DadosCartao Cartao)
 {
     using (var connection = GetConnection())
     {
         connection.Open();
         try
         {
             command.Connection  = connection;
             command.CommandText = "select * from tb_cartoes where id_bandeira = @id_bandeira";
             command.CommandType = CommandType.Text;
             command.Parameters.AddWithValue("@id_bandeira", Cartao.Bandeira);
             var result = command.ExecuteScalar();
             if (result != null)
             {
                 return(true);
             }
         }
         catch (Exception ex)
         {
         }
         return(false);
     }
 }
Exemplo n.º 3
0
 public string UpdateCartao(DadosCartao Cartao)
 {
     using (var connection = GetConnection())
     {
         connection.Open();
         string rpta = "";
         try
         {
             command.Connection  = connection;
             command.CommandText = "Update tb_cartoes SET taxa_debito=@taxa_debito, taxa_credito=@taxa_credito WHERE id_bandeira=@id_bandeira";
             command.CommandType = CommandType.Text;
             command.Parameters.AddWithValue("@id_bandeira", Cartao.Bandeira);
             command.Parameters.AddWithValue("@taxa_debito", Cartao.TaxaDebito);
             command.Parameters.AddWithValue("@taxa_credito", Cartao.TaxaCredito);
             //command.Parameters.AddWithValue("@id_pagamento", Cartao.IdPagamento);
             rpta = command.ExecuteNonQuery() == 1 ? "OK" : "Falha ao atualizar cartao";
         }
         catch (Exception ex)
         {
             rpta = ex.Message + ex.StackTrace;
         }
         return(rpta);
     }
 }