예제 #1
0
        public static CuentaCorriente Buscar(int pNumCta)
        {
            SqlConnection   _cnn    = new SqlConnection(Conexion.Cnn);
            CuentaCorriente _unaCta = null;

            SqlCommand _comando = new SqlCommand("CuentaCorrienteBuscar", _cnn);

            _comando.CommandType = System.Data.CommandType.StoredProcedure;
            _comando.Parameters.AddWithValue("@NumCta", pNumCta);

            try
            {
                _cnn.Open();
                SqlDataReader _lector = _comando.ExecuteReader();
                if (_lector.HasRows)
                {
                    _lector.Read();
                    _unaCta = new CuentaCorriente((int)_lector["NumCta"], (PersistenciaCliente.ClienteBuscar((int)_lector["CICli"])), Convert.ToDouble(_lector["SaldoCta"]), Convert.ToDouble(_lector["MinimoCta"]));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_unaCta);
        }
예제 #2
0
        public static List <CuentaCorriente> CuentaCorrienteListado()
        {
            SqlConnection          _cnn    = new SqlConnection(Conexion.Cnn);
            CuentaCorriente        _unaCta = null;
            List <CuentaCorriente> _lista  = new List <CuentaCorriente>();

            SqlCommand _comando = new SqlCommand("CuentaCorrienteListado", _cnn);

            _comando.CommandType = System.Data.CommandType.StoredProcedure;

            try
            {
                _cnn.Open();
                SqlDataReader _lector = _comando.ExecuteReader();
                if (_lector.HasRows)
                {
                    while (_lector.Read())
                    {
                        _unaCta = new CuentaCorriente((int)_lector["NumCta"], (PersistenciaCliente.ClienteBuscar((int)_lector["CICli"])), Convert.ToDouble(_lector["SaldoCta"]), Convert.ToDouble(_lector["MinimoCta"]));
                        _lista.Add(_unaCta);
                    }
                }
                _lector.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_lista);
        }