Example #1
0
        public List <CategoriaRepuestos> listarCategorias()
        {
            //INSTANCIO LA LISTA
            List <CategoriaRepuestos> lista = new List <CategoriaRepuestos>();
            //DECLARO EL OBJETO
            CategoriaRepuestos aux;
            //INSTANCIO LA CONECCION A LA BASE
            AccesoDatos datos = new AccesoDatos();

            //TIRO LA QUERY
            datos.setearQuery("select nombre, id from CATEGORIAS_REPUESTOS where estado = 1");
            //EJECUTO EL LECTOR
            datos.ejecutarLector();

            //MIENTRAS EL LECTOR LEA, DEVULVE LOS DATOS (DEBE COINSIDIR CON LA QUERY)

            while (datos.lector.Read())
            {
                aux = new CategoriaRepuestos();

                aux.id     = Convert.ToInt32(datos.lector["id"]);
                aux.nombre = datos.lector["Nombre"].ToString();


                lista.Add(aux);
            }
            return(lista);
            //datos.cerrarConexion();
        }
        protected void btnCategoriaRepuesto_Click(object sender, EventArgs e)
        {
            CategoriaRepuestos         cr  = new CategoriaRepuestos();
            CategoriaRepuestosNegocios crn = new CategoriaRepuestosNegocios();

            if (string.IsNullOrEmpty(txtCategoriaRepuesto.Text))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('INGRESE ALGUNA CATEGORIA');window.location ='AgregarCateogtiasRepuestos.aspx';", true);
            }

            cr.nombre = txtCategoriaRepuesto.Text;

            crn.altaCategoriaRepuesto(cr);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('CATEGORIA DE REPUESTO AGREGADO');window.location ='AgregarCateogtiasRepuestos.aspx';", true);
        }
Example #3
0
        public bool altaCategoriaRepuesto(CategoriaRepuestos aux)
        {
            AccesoDatos data = new AccesoDatos();

            data.prepareStatement("INSERT INTO CATEGORIAS_REPUESTOS VALUES (@NOMBRE,1)");
            data.agregarParametro("@nombre", aux.nombre);
            data.ejecutarAccion();
            data.cerrarConexion();

            if (data.getAffectedRows() <= 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }