Exemple #1
0
        public static Ingreso GetbyId(int id)
        {
            Ingreso c = new Ingreso();
            //creo el comando sql a utilizar
            SQLiteCommand cmd = new SQLiteCommand("SELECT id, idAtributoIngreso, fecha, idRevista, idProveedor, Cantidad from INGRESO where id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@id", id));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;
            //creo el datareader
            SQLiteDataReader obdr = cmd.ExecuteReader();// Devuelve algo por eso se llama data reader

            //recorro el datareader

            while (obdr.Read())
            {
                AtributosIngreso ti = pAtributosIngreso.GetById(obdr.GetInt32(1));
                Revista          r  = pRevista.GetById(obdr.GetInt32(3));
                Proveedor        p  = pProveedor.GetById(obdr.GetInt32(4));
                // p = new Marca(obdr.GetInt32(0), obdr.GetString(1));
                c.Id = obdr.GetInt32(0);
                c.Atributoingreso = ti;
                c.Fecha           = obdr.GetDateTime(2);
                c.Revista         = r;
                c.Proveedor       = p;
                c.Cantidad        = obdr.GetInt32(5);
            }
            return(c);
        }
        public static AtributosIngreso GetById(int id)
        {
            AtributosIngreso a = new AtributosIngreso();

            Conexion.OpenConnection();
            SQLiteCommand cmd = new SQLiteCommand("SELECT id, idFormaDePago, fechaInicial, fechaDeCierre, idMoneda, year, costo, costoEnvio, observaciones FROM ATRIBUTOSINGRESO WHERE id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@id", id));
            cmd.Connection = Conexion.Connection;
            SQLiteDataReader obdr = cmd.ExecuteReader();

            while (obdr.Read())
            {
                a.Id            = obdr.GetInt32(0);
                a.Formadepago   = pFormaDePago.GetById(obdr.GetInt32(1));
                a.Fechainicial  = obdr.GetDateTime(2);
                a.Fechacierre   = obdr.GetDateTime(3);
                a.Moneda        = pMoneda.GetById(obdr.GetInt32(4));
                a.Year          = obdr.GetDateTime(5);
                a.Costo         = obdr.GetDouble(6);
                a.Costoenvio    = obdr.GetDouble(7);
                a.Observaciones = obdr.GetString(8);
            }
            return(a);
        }
        public static void Delete(AtributosIngreso a)
        {
            SQLiteCommand cmd = new SQLiteCommand("DELETE FROM ATRIBUTOSINGRESO where id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@id", a.Id));
            cmd.Connection = Conexion.Connection;
            cmd.ExecuteNonQuery();
        }
Exemple #4
0
        public static void Save(Ingreso c, AtributosIngreso ti, Revista r, Proveedor p)
        {
            SQLiteCommand cmd = new SQLiteCommand("INSERT INTO INGRESO (idAtributoIngreso, Fecha, IdRevista, idProveedor, Cantidad) VALUES (@idti, @fecha, @idr, @idp, @cant);");

            cmd.Parameters.Add(new SQLiteParameter("@idti", ti.Id));
            cmd.Parameters.Add(new SQLiteParameter("@fecha", c.Fecha));
            cmd.Parameters.Add(new SQLiteParameter("@idr", r.Id));
            cmd.Parameters.Add(new SQLiteParameter("@idp", p.Id));
            cmd.Parameters.Add(new SQLiteParameter("@cant", c.Cantidad));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;

            cmd.ExecuteNonQuery();// no devuevlve nada :)
        }
        public static void Insert(AtributosIngreso a)
        {
            SQLiteCommand cmd = new SQLiteCommand("INSERT INTO ATRIBUTOSINGRESO(idFormaDePago, fechaInicial, fechaDeCierre, idMoneda, year, costo, costoEnvio, observaciones) VALUES (@idFormaDePago, @fechaInicial, @fechaDeCierre, @idMoneda, @year, @costo, @costoEnvio, @observaciones)");

            cmd.Parameters.Add(new SQLiteParameter("@idFormaDePago", a.Formadepago.Id));
            cmd.Parameters.Add(new SQLiteParameter("@fechaInicial", a.Fechainicial));
            cmd.Parameters.Add(new SQLiteParameter("@fechaDeCierre", a.Fechacierre));
            cmd.Parameters.Add(new SQLiteParameter("@idMoneda", a.Moneda.Id));
            cmd.Parameters.Add(new SQLiteParameter("@year", a.Year));
            cmd.Parameters.Add(new SQLiteParameter("@costo", a.Costo));
            cmd.Parameters.Add(new SQLiteParameter("@costoEnvio", a.Costoenvio));
            cmd.Parameters.Add(new SQLiteParameter("@observaciones", a.Observaciones));
            cmd.Connection = Conexion.Connection;
            cmd.ExecuteNonQuery();
        }
Exemple #6
0
        public static void Update(Ingreso c, AtributosIngreso ti, Revista r, Proveedor p)
        {
            SQLiteCommand cmd = new SQLiteCommand("UPDATE INGRESO SET idAtributoIngreso = @idti, Fecha = @fecha, idRevista = @idr, idProveedor = @idp, Cantidad = @cant where id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@id", c.Id));
            cmd.Parameters.Add(new SQLiteParameter("@idti", ti.Id));
            cmd.Parameters.Add(new SQLiteParameter("@fecha", c.Fecha));
            cmd.Parameters.Add(new SQLiteParameter("@idr", r.Id));
            cmd.Parameters.Add(new SQLiteParameter("@idp", p.Id));
            cmd.Parameters.Add(new SQLiteParameter("@cant", c.Cantidad));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;

            cmd.ExecuteNonQuery();// no devuevlve nada :)
        }
        public static void Update(AtributosIngreso a)
        {
            SQLiteCommand cmd = new SQLiteCommand("UPDATE ATRIBUTOSINGRESO SET idFormaDePago = @idFormaDePago, fechaInicial=@fechaInicial, fechaDeCierre=@fechaDeCierre, idMoneda=@idMoneda, year=@year, costo=@costo, costoEnvio=@costoEnvio, observaciones=@observaciones WHERE id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@idFormaDePago", a.Formadepago.Id));
            cmd.Parameters.Add(new SQLiteParameter("@fechaInicial", a.Fechainicial));
            cmd.Parameters.Add(new SQLiteParameter("@fechaDeCierre", a.Fechacierre));
            cmd.Parameters.Add(new SQLiteParameter("@idMoneda", a.Moneda.Id));
            cmd.Parameters.Add(new SQLiteParameter("@year", a.Year));
            cmd.Parameters.Add(new SQLiteParameter("@costo", a.Costo));
            cmd.Parameters.Add(new SQLiteParameter("@costoEnvio", a.Costoenvio));
            cmd.Parameters.Add(new SQLiteParameter("@observaciones", a.Observaciones));
            cmd.Parameters.Add(new SQLiteParameter("@id", a.Id));
            cmd.Connection = Conexion.Connection;
            cmd.ExecuteNonQuery();
        }
Exemple #8
0
        public static List <Ingreso> GetAll()
        {
            List <Ingreso> ingreso = new List <Ingreso>();
            //creo el comando sql a utiliza
            SQLiteCommand cmd = new SQLiteCommand("SELECT id, idAtributoIngreso, fecha, idRevista, idProveedor, Cantidad from INGRESO;");

            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;
            //creo el datareader
            SQLiteDataReader obdr = cmd.ExecuteReader();

            //recorro el datareader

            while (obdr.Read())
            {
                AtributosIngreso ti = pAtributosIngreso.GetById(obdr.GetInt32(1));
                Revista          r  = pRevista.GetById(obdr.GetInt32(3));
                Proveedor        p  = pProveedor.GetById(obdr.GetInt32(4));
                Ingreso          c  = new Ingreso(obdr.GetInt32(0), ti, obdr.GetDateTime(2), r, p, obdr.GetInt32(5));
                ingreso.Add(c);
            }
            return(ingreso);
        }
Exemple #9
0
        public static List <Ingreso> Buscar(string text)
        {
            List <Ingreso> ingreso = new List <Ingreso>();
            //creo el comando sql a utiliza
            SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM INGRESO WHERE fecha LIKE @texto + '%';");

            cmd.Parameters.Add(new SQLiteParameter("@texto", text));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;
            //creo el datareader
            SQLiteDataReader obdr = cmd.ExecuteReader();

            //recorro el datareader

            while (obdr.Read())
            {
                AtributosIngreso ti = pAtributosIngreso.GetById(obdr.GetInt32(1));
                Revista          r  = pRevista.GetById(obdr.GetInt32(3));
                Proveedor        p  = pProveedor.GetById(obdr.GetInt32(4));
                Ingreso          c  = new Ingreso(obdr.GetInt32(0), ti, obdr.GetDateTime(2), r, p, obdr.GetInt32(5));
                ingreso.Add(c);
            }
            return(ingreso);
        }