public void Insert(ContaBancariaEntity contaBancaria) { try { OpenConnection(); using (cmd = new SqlCommand("", con)) { cmd.CommandText = "fin.UP_CONTA_BANCARIA_CADASTRAR"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@NOME", SqlDbType.VarChar, 100)).Value = contaBancaria.Nome; cmd.Parameters.Add(new SqlParameter("@BANCO", SqlDbType.VarChar, 100)).Value = contaBancaria.Banco; cmd.Parameters.Add(new SqlParameter("@AGENCIA", SqlDbType.VarChar, 4)).Value = contaBancaria.Agencia; cmd.Parameters.Add(new SqlParameter("@DIGITO_AGENCIA", SqlDbType.VarChar, 1)).Value = contaBancaria.DigitoAgencia; cmd.Parameters.Add(new SqlParameter("@CONTA", SqlDbType.VarChar, 10)).Value = contaBancaria.Conta; cmd.Parameters.Add(new SqlParameter("@DIGITO_CONTA", SqlDbType.VarChar, 1)).Value = contaBancaria.DigitoConta; cmd.Parameters.Add(new SqlParameter("@SALDO", SqlDbType.Money)).Value = contaBancaria.Saldo; cmd.ExecuteNonQuery(); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { CloseConnection(); } }
public void IncluirContaBancaria(ContaBancariaEntity entity) { if (entity != null) { if (this.Lista == null) { this.Lista = new List <ContaBancariaEntity>(); } this.Lista.Add(entity); } }
public ContaBancariaEntity GetById(int id) { try { OpenConnection(); using (cmd = new SqlCommand("", con)) { cmd.CommandText = "fin.UP_CONTA_BANCARIA_BUSCAR"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id; dr = cmd.ExecuteReader(); ContaBancariaEntity contaBancaria = null; if (dr.Read()) { contaBancaria = new ContaBancariaEntity() { Id = Convert.ToInt32(dr["ID"]), Nome = Convert.ToString(dr["NOME"]), Ativo = Convert.ToBoolean(dr["ATIVO"]), Banco = Convert.ToString(dr["BANCO"]), Agencia = Convert.ToString(dr["AGENCIA"]), DigitoAgencia = Convert.ToString(dr["DIGITO_AGENCIA"]), Conta = Convert.ToString(dr["CONTA"]), DigitoConta = Convert.ToString(dr["DIGITO_CONTA"]), Saldo = Convert.ToDecimal(dr["SALDO"]) }; } return(contaBancaria); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { CloseConnection(); } }
public void Update(ContaBancariaEntity contaBancaria) => new ContaBancariaRepository().Update(contaBancaria);
public void Insert(ContaBancariaEntity contaBancaria) => new ContaBancariaRepository().Insert(contaBancaria);