public bool ExisteRegistroProductos(agregarproducto registro, bool buscar_id) { IDbConnection dbcon = this.Conectar (); IDbCommand dbcmd = dbcon.CreateCommand (); string sql; if (buscar_id) { sql = "SELECT codigobarra " + "FROM productos " + "WHERE codigobarra=" + registro.Codigobarra + ";"; dbcmd.CommandText = sql; } IDataReader reader = dbcmd.ExecuteReader(); bool existe = reader.Read(); // clean up reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; this.Desconectar(dbcon); return existe; }
public bool AgregarProductos(agregarproducto registro) { IDbConnection dbcon = this.Conectar(); IDbCommand dbcmd = dbcon.CreateCommand(); string sql = "INSERT INTO productos (codigobarra,nombre,precio_venta,nombre_familia,pesable,vigente) " + "VALUES ("+registro.Codigobarra+",'"+registro.Nombre+"','"+registro.Precioventa+"','"+registro.Familia+"','"+registro.Pesable+"','"+registro.Vigente+"');"; dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader(); // clean up dbcmd.Dispose(); dbcmd = null; this.Desconectar(dbcon); return false; }