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)); }
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)); }
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 :) }
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 :) }
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)); }
public frmEditarTipoIngreso(TipoIngreso tp) { InitializeComponent(); if (tp == null) { tipoIngresoBindingSource.DataSource = new Ingreso(); } else { //cbPaises.SelectedValue = 0; tipoIngresoBindingSource.DataSource = tp; } }
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(); }
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); }
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); }
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); }
private void prepararComboBoxTipoIngresoSeleccionado(TipoIngreso tipoIngreso) { cmbTipoIngreso.SelectedItem = tipoIngreso.nombre; }