public async Task <IActionResult> Edit(int id, [Bind("idTipoIngreso,nombre,estado")] TipoIngreso tipoIngreso)
        {
            if (id != tipoIngreso.idTipoIngreso)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tipoIngreso);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TipoIngresoExists(tipoIngreso.idTipoIngreso))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipoIngreso));
        }
Ejemplo n.º 2
0
        public static void Save(TipoIngreso c)
        {
            SQLiteCommand cmd = new SQLiteCommand("INSERT INTO TIPOINGRESO (Nombre) VALUES (@Nombre);");

            cmd.Parameters.Add(new SQLiteParameter("@Nombre", c.Nombre));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;

            cmd.ExecuteNonQuery();// no devuevlve nada :)
        }
        public async Task <IActionResult> Create([Bind("idTipoIngreso,nombre,estado")] TipoIngreso tipoIngreso)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tipoIngreso);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipoIngreso));
        }
Ejemplo n.º 4
0
        public static void Delete(TipoIngreso c)
        {
            SQLiteCommand cmd = new SQLiteCommand("DELETE FROM TIPOINGRESO where id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@id", c.Id));

            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;

            cmd.ExecuteNonQuery();// no devuevlve nada :)
        }
Ejemplo n.º 5
0
        public static void Update(TipoIngreso c)
        {
            SQLiteCommand cmd = new SQLiteCommand("UPDATE TIPOINGRESO SET Nombre = @Nombre where id = @id;");

            cmd.Parameters.Add(new SQLiteParameter("@Nombre", c.Nombre));
            cmd.Parameters.Add(new SQLiteParameter("@id", c.Id));
            //asigno la conexion al comando
            cmd.Connection = Conexion.Connection;

            cmd.ExecuteNonQuery();// no devuevlve nada :)
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Nombre,PorcentajeSalario,Estado,MontoFijo")] TipoIngreso tipoIngreso)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tipoIngreso);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tipoIngreso));
        }
Ejemplo n.º 7
0
 public frmEditarTipoIngreso(TipoIngreso tp)
 {
     InitializeComponent();
     if (tp == null)
     {
         tipoIngresoBindingSource.DataSource = new Ingreso();
     }
     else
     {
         //cbPaises.SelectedValue = 0;
         tipoIngresoBindingSource.DataSource = tp;
     }
 }
Ejemplo n.º 8
0
        private void btAceptar_Click(object sender, EventArgs e)
        {
            TipoIngreso i = (TipoIngreso)tipoIngresoBindingSource.DataSource;

            if (i.Id == 0)
            {
                pTipoIngreso.Save(i);
            }
            else
            {
                pTipoIngreso.Update(i);
            }
            Close();
        }
Ejemplo n.º 9
0
        public static List <TipoIngreso> GetAll()
        {
            List <TipoIngreso> list = new List <TipoIngreso>();
            //creo el comando sql a utilizar
            SQLiteCommand cmd = new SQLiteCommand("SELECT id, Nombre from TIPOINGRESO;");

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

            //recorro el datareader

            while (obdr.Read())
            {
                TipoIngreso c = new TipoIngreso(obdr.GetInt32(0), obdr.GetString(1));
                list.Add(c);
            }
            return(list);
        }
Ejemplo n.º 10
0
        public static List <TipoIngreso> Buscar(string text)
        {
            List <TipoIngreso> list = new List <TipoIngreso>();
            //creo el comando sql a utilizar
            SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM TIPOINGRESO WHERE nombre 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())
            {
                TipoIngreso c = new TipoIngreso(obdr.GetInt32(0), obdr.GetString(1));
                list.Add(c);
            }
            return(list);
        }
Ejemplo n.º 11
0
        public static TipoIngreso GetbyId(int id)
        {
            TipoIngreso c = new TipoIngreso();
            //creo el comando sql a utilizar
            SQLiteCommand cmd = new SQLiteCommand("SELECT id, Nombre from TIPOINGRESO 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())
            {
                // p = new Marca(obdr.GetInt32(0), obdr.GetString(1));
                c.Id     = obdr.GetInt32(0);
                c.Nombre = obdr.GetString(1);
            }
            return(c);
        }
Ejemplo n.º 12
0
 private void prepararComboBoxTipoIngresoSeleccionado(TipoIngreso tipoIngreso)
 {
     cmbTipoIngreso.SelectedItem = tipoIngreso.nombre;
 }