public List <EntidadesCompartidas.Cuenta> ListaCuentasDeCliente(EntidadesCompartidas.Cliente pCLiente)
        {
            SqlConnection _cnn    = new SqlConnection(Conexion.Cnn);
            Cuenta        _unaCta = null;
            List <Cuenta> _lista  = new List <Cuenta>();

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

            _comando.CommandType = System.Data.CommandType.StoredProcedure;
            _comando.Parameters.AddWithValue("@NumCli", pCLiente.NumCli);

            try
            {
                _cnn.Open();
                SqlDataReader _lector = _comando.ExecuteReader();
                if (_lector.HasRows)
                {
                    while (_lector.Read())
                    {
                        _unaCta = new Cuenta((int)_lector["NumCta"], (PersistenciaCliente.GetInstancia().Buscar((int)_lector["NumCli"])), Convert.ToDouble(_lector["SaldoCta"]));
                        _lista.Add(_unaCta);
                    }
                }
                _lector.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_lista);
        }
Example #2
0
        public CuentaCorriente Buscar(int pNumCta)
        {
            SqlConnection   _cnn    = new SqlConnection(Conexion.Cnn);
            CuentaCorriente _unaCta = null;

            SqlCommand _comando = new SqlCommand("BuscarCuentaCorriente", _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.GetInstancia().Buscar((int)_lector["NumCli"])), Convert.ToDouble(_lector["SaldoCta"]), Convert.ToDouble(_lector["MinimoCta"]));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_unaCta);
        }
Example #3
0
        public List <CuentaCorriente> Listado()
        {
            SqlConnection          _cnn    = new SqlConnection(Conexion.Cnn);
            CuentaCorriente        _unaCta = null;
            List <CuentaCorriente> _lista  = new List <CuentaCorriente>();

            SqlCommand _comando = new SqlCommand("ListadoCuentaCorriente", _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.GetInstancia().Buscar((int)_lector["NumCli"])), 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);
        }
Example #4
0
        public static List <Reserva> ListadoCliente(string nombre_cliente)
        {
            List <Reserva> resp = new List <Reserva>();
            SqlConnection  cnn  = new SqlConnection(BaseDeDatos.CONEXION);
            SqlCommand     cmd  = new SqlCommand("reservasActivasCliente", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@nombre", nombre_cliente);
            try
            {
                cnn.Open();
                SqlDataReader lector = cmd.ExecuteReader();
                while (lector.Read())
                {
                    Cliente cli = PersistenciaCliente.BuscarCliente((string)lector["nombre_cli"]);

                    Habitacion hab = PersistenciaHabitacion.ObtenerHabitacion((string)lector["nombre_hotel"], (int)lector["numero_hab"]);
                    Reserva    r   = new Reserva((int)lector["numero"], (DateTime)lector["fecha_inicio"], (DateTime)lector["fecha_final"], (string)lector["estado_reserva"],
                                                 cli, hab);

                    resp.Add(r);
                }
                lector.Close();
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { cnn.Close(); }
            return(resp);
        }
Example #5
0
        public static List <CuentaCAhorro> CuentaCAhorroListado()
        {
            SqlConnection        _cnn    = new SqlConnection(Conexion.Cnn);
            CuentaCAhorro        _unaCta = null;
            List <CuentaCAhorro> _lista  = new List <CuentaCAhorro>();

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

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

            try
            {
                _cnn.Open();
                SqlDataReader _lector = _comando.ExecuteReader();
                if (_lector.HasRows)
                {
                    while (_lector.Read())
                    {
                        _unaCta = new CuentaCAhorro((int)_lector["NumCta"], PersistenciaCliente.ClienteBuscar((int)_lector["CICli"]), Convert.ToDouble(_lector["SaldoCta"]), (int)_lector["MovsCta"], Convert.ToDouble(_lector["CostoMovCta"]));
                        _lista.Add(_unaCta);
                    }
                }
                _lector.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_lista);
        }
 public static PersistenciaCliente GetInstancia()
 {
     if (_instancia == null)
     {
         _instancia = new PersistenciaCliente();
     }
     return(_instancia);
 }
Example #7
0
        //LISTAR PEDIDOS GENERADOS O ENVIADOS
        public List <Pedido> ListarPedidoGeneradoOEnviado()
        {
            //GET CONNECTION STRING
            SqlConnection connection = new SqlConnection(Conexion.ConnectionString);

            //STORED PROCEDURE
            SqlCommand Command = new SqlCommand("ListarPedidoGeneradoOEnviado", connection);

            Command.CommandType = CommandType.StoredProcedure;

            //READER
            SqlDataReader Reader;

            //PREPARAR VARIABLES
            PersistenciaCliente     persistenciaCliente     = new PersistenciaCliente();
            PersistenciaMedicamento persistenciaMedicamento = new PersistenciaMedicamento();
            int           Numero;
            Cliente       cliente = null;
            int           Cantidad;
            string        Estado;
            Medicamento   medicamento = null;
            int           MedicamentoCodigo;
            string        MedicamentoFarmacia;
            List <Pedido> List = new List <Pedido>();

            try
            {
                connection.Open();
                Reader = Command.ExecuteReader();
                while (Reader.Read())
                {
                    Numero              = (int)Reader["Numero"];
                    Estado              = (string)Reader["Estado"];
                    Cantidad            = (int)Reader["CantidadMedicamento"];
                    MedicamentoCodigo   = (int)Reader["MedicamentoCodigo"];
                    MedicamentoFarmacia = (string)Reader["MedicamentoFarmaceutica"];
                    medicamento         = persistenciaMedicamento.BuscarMedicamento(MedicamentoCodigo, MedicamentoFarmacia);
                    cliente             = persistenciaCliente.BuscarCliente((string)Reader["Cliente"]);
                    Pedido pedido = new Pedido(Numero, cliente, medicamento, Cantidad, Estado);
                    List.Add(pedido);
                }
                Reader.Close();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error en la base de datos: " + ex.Message);
            }
            finally
            {
                connection.Close();
            }
            return(List);
        }
        public static List <Credito> ListarCreditoCliente(int oci)
        {
            int      oNroT;
            Boolean  oPersonalizada;
            DateTime oFechaVen;
            Cliente  Cli;

            int    oLimite;
            string oCategoria;

            List <Credito> oListadoTarjetasCredito = new List <Credito>();
            SqlDataReader  oReader;

            SqlConnection oConexion = new SqlConnection(CONEXION.STR);
            SqlCommand    oComando  = new SqlCommand("exec sp_ListarTarjetaCredito " + oci, oConexion);



            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();

                if (oReader.HasRows)

                {
                    while (oReader.Read())
                    {
                        oNroT          = Convert.ToInt32((int)oReader["NroT"]);
                        oFechaVen      = (DateTime)oReader["FechaVencimiento"];
                        Cli            = PersistenciaCliente.Buscar(Convert.ToInt32((int)oReader["CI"]));
                        oPersonalizada = (bool)oReader["Personalizada"];
                        oLimite        = Convert.ToInt32((int)oReader["Limite"]);
                        oCategoria     = (string)oReader["Categoria"];

                        Credito c = new Credito(oNroT, Cli, oFechaVen, oPersonalizada, oLimite, oCategoria);
                        oListadoTarjetasCredito.Add(c);
                    }
                }

                oReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }
            return(oListadoTarjetasCredito);
        }
Example #9
0
        internal List <Visita> ListaVisitas(string rutEmpresa)
        {
            SqlConnection conexion  = null;
            SqlDataReader drVisitas = null;

            try
            {
                conexion = new SqlConnection(Conexion.Cnn);

                SqlCommand cmdListarVisitas = new SqlCommand("VisitasDeEmpresa", conexion);
                cmdListarVisitas.CommandType = CommandType.StoredProcedure;

                cmdListarVisitas.Parameters.AddWithValue("@rut", rutEmpresa);

                conexion.Open();

                drVisitas = cmdListarVisitas.ExecuteReader();

                List <Visita> visitas = new List <Visita>();

                if (drVisitas.HasRows)
                {
                    while (drVisitas.Read())
                    {
                        Cliente cliente = PersistenciaCliente.GetInstancia().BuscarCliente(Convert.ToInt32(drVisitas["CICliente"]));
                        Visita  visita  = new Visita(cliente, (DateTime)drVisitas["FechaHora"], Convert.ToBoolean(drVisitas["VisitaAceptada"]));

                        visitas.Add(visita);
                    }
                }

                return(visitas);
            }

            catch (Exception ex)
            {
                throw new Exception("Error de DB: " + ex.Message);
            }

            finally
            {
                if (drVisitas != null)
                {
                    drVisitas.Close();
                }

                if (conexion != null)
                {
                    conexion.Close();
                }
            }
        }
        public static List <Tarjeta> ListarVencidasCredito()
        {
            int      oNroT;
            Boolean  oPersonalizada;
            DateTime oFechaVen;
            Cliente  Cli;
            int      oLimite;
            string   oCategoria;

            List <Tarjeta> oListadoTarjetasVencidas = new List <Tarjeta>();
            Credito        c;

            SqlDataReader oReader;


            SqlConnection oConexion = new SqlConnection(CONEXION.STR);
            SqlCommand    oComando  = new SqlCommand("sp_ListarTarjetasCreditoVencidas", oConexion);

            oComando.CommandType = CommandType.StoredProcedure;

            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();


                while (oReader.Read())
                {
                    oNroT          = Convert.ToInt32((int)oReader["NroT"]);
                    Cli            = PersistenciaCliente.Buscar(Convert.ToInt32((int)oReader["CI"]));
                    oFechaVen      = Convert.ToDateTime((DateTime)oReader["FechaVencimiento"]);
                    oPersonalizada = (bool)oReader["Personalizada"];
                    oLimite        = Convert.ToInt32((int)oReader["Limite"]);
                    oCategoria     = (string)oReader["Categoria"];


                    c = new Credito(oNroT, Cli, oFechaVen, oPersonalizada, oLimite, oCategoria);
                    oListadoTarjetasVencidas.Add(c);
                }

                oReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }
            return(oListadoTarjetasVencidas);
        }
        public static List <Tarjeta> ListarVencidasDebito()
        {
            int      oNroT;
            Boolean  oPersonalizada;
            DateTime oFechaVen;
            Cliente  Cli;
            double   oSaldo;
            int      oCantC;

            List <Tarjeta> oListadoTarjetasVencidas = new List <Tarjeta>();
            Debito         d;

            SqlDataReader oReader;


            SqlConnection oConexion = new SqlConnection(CONEXION.STR);
            SqlCommand    oComando  = new SqlCommand("sp_ListarTarjetasDebitoVencidas", oConexion);

            oComando.CommandType = CommandType.StoredProcedure;

            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();


                while (oReader.Read())
                {
                    oNroT          = Convert.ToInt32((int)oReader["NroT"]);
                    Cli            = PersistenciaCliente.Buscar(Convert.ToInt32((int)oReader["CI"]));
                    oFechaVen      = Convert.ToDateTime((DateTime)oReader["FechaVencimiento"]);
                    oPersonalizada = (bool)oReader["Personalizada"];
                    oSaldo         = Convert.ToDouble((double)oReader["Saldo"]);
                    oCantC         = Convert.ToInt32((int)oReader["CantCuentas"]);


                    d = new Debito(oNroT, Cli, oFechaVen, oPersonalizada, oSaldo, oCantC);
                    oListadoTarjetasVencidas.Add(d);
                }

                oReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }
            return(oListadoTarjetasVencidas);
        }
Example #12
0
 //Pre: c != null.
 //Post: Si c existe lo busca y lo devuelve, en otro caso no hace nada y devuelve null.
 public static Cliente Buscar(Cliente c)
 {
     ;
     if (BDCliente.SELECTCliente(new ClienteDato(c.Dni)) != null)
     {
         ClienteDato dato = BDCliente.SELECTCliente(new ClienteDato(c.Dni));
         return(new Cliente(dato.Dni, dato.Nombre, dato.Telefono, PersistenciaCliente.CambioACategoria(dato.Valor)));
     }
     else
     {
         return(null);
     }
 }
        public static Pedido BuscarPorNumero(int oNum)
        {
            Int64  rucMedicamento;
            int    codMedicamento, cantidad, estado;
            string oCliente;

            Pedido        oPed = null;
            SqlDataReader oReader;

            SqlConnection oConexion = new SqlConnection(Conexion.STR);
            SqlCommand    oComando  = new SqlCommand("BuscarPedidoXNumero", oConexion);

            oComando.CommandType = CommandType.StoredProcedure;

            oComando.Parameters.AddWithValue("@numero", oNum);

            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();

                if (oReader.HasRows)
                {
                    if (oReader.Read())
                    {
                        oCliente       = (string)oReader["cliente"];
                        rucMedicamento = (Int64)oReader["rucMedicamento"];
                        codMedicamento = (int)oReader["codMedicamento"];
                        cantidad       = (int)oReader["cantidad"];
                        estado         = (int)oReader["estado"];

                        Cliente     cliente = PersistenciaCliente.Buscar(oCliente);
                        Medicamento oMed    = PersistenciaMedicamento.Buscar(rucMedicamento, codMedicamento);

                        oPed = new Pedido(oNum, cantidad, estado, cliente, oMed);
                    }
                }
                oReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }

            return(oPed);
        }
Example #14
0
        public static List <Reserva> ListarPorHabitacion(Habitacion hab, string filtro)
        {
            List <Reserva> lstRes = new List <Reserva>();
            SqlConnection  cnn    = new SqlConnection(BaseDeDatos.CONEXION);

            SqlCommand cmd = new SqlCommand("listadoReservasCronologica", cnn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@numeroHab", Convert.ToInt32(hab.Numero));
            cmd.Parameters.AddWithValue("@nombreHotel", hab.Hotel.Nombre);
            cmd.Parameters.AddWithValue("@filtro", filtro);

            SqlParameter prmRetorno = new SqlParameter();

            prmRetorno.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(prmRetorno);

            try
            {
                cnn.Open();
                SqlDataReader lector = cmd.ExecuteReader();
                if (prmRetorno.Value != null)
                {
                    int resp = (int)prmRetorno.Value;
                    if (resp == -1)
                    {
                        throw new Exception("No existen reservas para esta habitación con el filtro seleccionado.");
                    }
                }

                while (lector.Read())
                {
                    Cliente    cliente    = PersistenciaCliente.BuscarCliente((string)lector["nombre_cli"]);
                    Habitacion habitacion = PersistenciaHabitacion.ObtenerHabitacion((string)lector["nombre_hotel"], (int)lector["numero_hab"]);
                    Reserva    reserva    = new Reserva(
                        (int)lector["numero"],
                        (DateTime)lector["fecha_inicio"],
                        (DateTime)lector["fecha_final"],
                        (string)lector["estado_reserva"],
                        cliente,
                        habitacion);
                    lstRes.Add(reserva);
                }
            }
            catch (Exception ex)
            { throw ex; }
            finally
            { cnn.Close(); }
            return(lstRes);
        }
Example #15
0
        //GET PEDIDO
        public Pedido BuscarPedido(int Numero)
        {
            //GET CONNECTION STRING
            SqlConnection connection = new SqlConnection(Conexion.ConnectionString);

            //STORED PROCEDURE
            SqlCommand sp = new SqlCommand("BuscarPedido", connection);

            sp.CommandType = CommandType.StoredProcedure;

            //PARAMETROS
            sp.Parameters.AddWithValue("@Numero", Numero);

            //READER
            SqlDataReader reader;

            //PREPARAR VARIABLES
            PersistenciaCliente     persistenciaCliente     = new PersistenciaCliente();
            PersistenciaMedicamento persistenciaMedicamento = new PersistenciaMedicamento();
            Cliente     cliente;
            Medicamento medicamento;
            Pedido      pedido;
            int         Cantidad;
            string      Estado;

            try
            {
                connection.Open();
                reader = sp.ExecuteReader();

                if (reader.Read())
                {
                    cliente     = persistenciaCliente.BuscarCliente((string)reader["Cliente"]);
                    medicamento = persistenciaMedicamento.BuscarMedicamento((int)reader["MedicamentoCodigo"], (string)reader["MedicamentoFarmaceutica"]);
                    Cantidad    = (int)reader["CantidadMedicamento"];
                    Estado      = (string)reader["Estado"];
                    pedido      = new Pedido(Numero, cliente, medicamento, Cantidad, Estado);
                    reader.Close();
                }
                else
                {
                    return(null);
                }

                return(pedido);
            }
            catch { throw; }

            finally { connection.Close(); }
        }
        public static List <Debito> ListarDebitoCliente(int oci)
        {
            int      oNroT;
            Boolean  oPersonalizada;
            DateTime oFechaVen;
            Cliente  Cli;

            Double oSaldo;
            int    oCantCuentas;

            List <Debito> oListadoTarjetasDebito = new List <Debito>();
            SqlDataReader oReader;

            SqlConnection oConexion = new SqlConnection(CONEXION.STR);
            SqlCommand    oComando  = new SqlCommand("exec sp_ListarTarjetaDebito " + oci, oConexion);



            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();
                if (oReader.HasRows)
                {
                    while (oReader.Read())
                    {
                        oNroT          = Convert.ToInt32((int)oReader["NroT"]);
                        oFechaVen      = (DateTime)oReader["FechaVencimiento"];
                        Cli            = PersistenciaCliente.Buscar(Convert.ToInt32((int)oReader["CI"]));
                        oPersonalizada = (bool)oReader["Personalizada"];
                        oSaldo         = Convert.ToDouble((Double)oReader["Saldo"]);
                        oCantCuentas   = Convert.ToInt32((int)oReader["CantCuentas"]);

                        Debito d = new Debito(oNroT, Cli, oFechaVen, oPersonalizada, oSaldo, oCantCuentas);
                        oListadoTarjetasDebito.Add(d);
                    }
                }
                oReader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }
            return(oListadoTarjetasDebito);
        }
Example #17
0
        public static List <Alquiler> Listar_Alquileres_Por_Vehiculo(Vehiculo V)
        {
            List <Alquiler> Listado = new List <Alquiler>();;
            SqlDataReader   oReader;

            SqlConnection oConexion = new SqlConnection(Conexion.STR);
            SqlCommand    oComando  = new SqlCommand("Listado_Alquileres_Por_Vehiculo", oConexion);

            oComando.CommandType = CommandType.StoredProcedure;
            oComando.Parameters.AddWithValue("@vehiculo", V.Matricula);

            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();

                if (oReader.HasRows)
                {
                    while (oReader.Read())
                    {
                        Alquiler A = new Alquiler(PersistenciaCliente.Buscar(Convert.ToInt32(oReader["cliente"])),
                                                  PersistenciaVehiculo.Buscar(oReader["vehiculo"].ToString()),
                                                  Convert.ToDateTime(oReader["fechainicio"]),
                                                  Convert.ToDateTime(oReader["fechafin"]),
                                                  Convert.ToInt32(oReader["costo"]), false);

                        Listado.Add(A);
                    }
                }

                oReader.Close();
            }

            catch (Exception ex)
            {
                throw new ApplicationException("Problemas con la base de datos:" + ex.Message);
            }
            finally
            {
                oConexion.Close();
            }

            return(Listado);
        }
        public static List <Pedido> ListarEntregados(Medicamento m)
        {
            List <Pedido> lista = new List <Pedido>();
            SqlConnection cn    = new SqlConnection(Conexion.str);
            SqlCommand    cmd   = new SqlCommand("listarpedidosentregados", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("codigo", m.Codigo);
            cmd.Parameters.AddWithValue("ruc", m.Proveedor.Ruc);
            SqlDataReader reader;

            try
            {
                cn.Open();
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        int     codigo   = (int)reader["numero"];
                        string  usuario  = (string)reader["nombreusuario"];
                        int     articulo = (int)reader["codigo"];
                        int     ruc      = (int)reader["ruc"];
                        int     cantidad = (int)reader["cantidad"];
                        string  estado   = (string)reader["estado"];
                        Cliente c        = PersistenciaCliente.Buscar(usuario);
                        Pedido  p        = new Pedido(codigo, c, m, cantidad, estado);
                        lista.Add(p);
                    }
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cn.Close();
            }
            return(lista);
        }
        public static Pedido Buscar(int numero)
        {
            Pedido        p   = null;
            SqlConnection cn  = new SqlConnection(Conexion.str);
            SqlCommand    cmd = new SqlCommand("buscarpedido", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("numero", numero);
            SqlDataReader reader;

            try
            {
                cn.Open();
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    int         codigo   = (int)reader["numero"];
                    string      usuario  = (string)reader["nombreusuario"];
                    int         ruc      = (int)reader["ruc"];
                    int         cantidad = (int)reader["cantidad"];
                    string      estado   = (string)reader["estado"];
                    Cliente     c        = PersistenciaCliente.Buscar(usuario);
                    Medicamento m        = PersistenciaMedicamento.Buscar(codigo, ruc);
                    p = new Pedido(codigo, c, m, cantidad, estado);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cn.Close();
            }
            return(p);
        }
Example #20
0
        public static List <Cliente> ListarComprasXCliente()
        {
            Cliente        oCli;
            List <Cliente> oListaCxC = new List <Cliente>();
            SqlDataReader  oReader;

            SqlConnection oConexion = new SqlConnection(Conexion.STR);
            SqlCommand    oComando  = new SqlCommand("sp_TotalComprasXCliente", oConexion);

            try
            {
                oConexion.Open();
                oReader = oComando.ExecuteReader();

                if (oReader.HasRows)
                {
                    while (oReader.Read())
                    {
                        int CI = (int)oReader["ci"];
                        oCli = PersistenciaCliente.BuscarCliente(CI);

                        Cliente _Cli = new Cliente(CI, (string)oReader["nombre"], (string)oReader["apellido"], (int)oReader["numTel"]);

                        oListaCxC.Add(_Cli);
                    }

                    oReader.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConexion.Close();
            }

            return(oListaCxC);
        }
Example #21
0
 //Pre: c != null. c no existe.
 //Post: Añade c
 public static void Añadir(Cliente c)
 {
     BDCliente.INSERTCliente(new ClienteDato(c.Dni, c.Nombre, c.Telefono, PersistenciaCliente.CambioACategoriaDato(c.Valor)));
 }
Example #22
0
 public static IPersistenciaCliente GetPersistenciaCliente()
 {
     return(PersistenciaCliente.GetInstancia());
 }
Example #23
0
 //Pre: c != null. c no existe.
 //Post: Modifica c.
 public static void Modificar(Cliente c)
 {
     BDCliente.UPDATECliente(new ClienteDato(c.Dni, c.Nombre, c.Telefono, PersistenciaCliente.CambioACategoriaDato(c.Valor)));
 }
Example #24
0
        public List <EntidadesCompartidas.Prestamo> ListoPrestamos()
        {
            SqlConnection   _cnn        = new SqlConnection(Conexion.Cnn);
            Prestamo        _unPrestamo = null;
            List <Prestamo> _lista      = new List <Prestamo>();

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

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

            try
            {
                _cnn.Open();
                SqlDataReader _lector = _comando.ExecuteReader();
                if (_lector.HasRows)
                {
                    while (_lector.Read())
                    {
                        _unPrestamo = new Prestamo(Convert.ToInt32(_lector["IdPres"]), PersistenciaCliente.GetInstancia().Buscar(Convert.ToInt32(_lector["NumCli"])), Convert.ToDateTime(_lector["FechaPres"]), Convert.ToDouble(_lector["MontoPres"]), Convert.ToBoolean(_lector["AprobadoPres"]));
                        _lista.Add(_unPrestamo);
                    }
                }
                _lector.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _cnn.Close();
            }
            return(_lista);
        }