예제 #1
0
        public Tarjeta(int codigo)
        {
            Tarjeta tarjeta = LeerTarjeta(codigo);

            if (!(tarjeta == null))
            {
                Nombre           = tarjeta.Nombre;
                Descripcion      = tarjeta.Descripcion;
                Fecha            = tarjeta.Fecha;
                Tipo             = tarjeta.Tipo;
                Numero           = tarjeta.Numero;
                CVV              = tarjeta.CVV;
                NombreImpreso    = tarjeta.NombreImpreso;
                FechaVencimiento = tarjeta.FechaVencimiento;
            }
        }
예제 #2
0
        public Tarjeta LeerTarjeta(int codigo)
        {
            int      clave            = 0;
            string   tipo             = null;
            int      numero           = 0;
            int      cvv              = 0;
            string   nombreImpreso    = null;
            DateTime fechaVencimiento = new DateTime();

            try
            {
                Conexion.Open();

                string Comando = "SELECT * FROM tarjeta WHERE mp_codigo = @codigo";
                Script = new NpgsqlCommand(Comando, Conexion);

                Script.Parameters.AddWithValue("codigo", codigo);

                Reader = Script.ExecuteReader();

                if (Reader.Read())
                {
                    clave            = ReadInt(0);
                    tipo             = ReadString(1);
                    numero           = ReadInt(2);
                    cvv              = ReadInt(3);
                    nombreImpreso    = ReadString(4);
                    fechaVencimiento = ReadDate(5);
                }

                Conexion.Close();
            }
            catch (Exception e)
            {
                try
                {
                    Conexion.Close();
                }
                catch (Exception f)
                {
                }
                return(null);
            }
            Tarjeta tarjeta = new Tarjeta(clave, tipo, numero, cvv, nombreImpreso, fechaVencimiento);

            return(tarjeta);
        }