//boton agregar private void btnagregar_Click(object sender, EventArgs e) { //un try catch para prevenir errores try { if (txtnombre.Text != null && txtcargo.Text != null && txtsbruto.Text != null && txtisr.Text != null && txtss.Text != null && txtotro.Text != null && txtdeducciones.Text != null && txtsneto.Text != null) { //abre la conexion a la db operacion oper = new operacion(); //hace insert a tabla detalle nomina oper.ExecuteNonQuery("INSERT INTO detalle_nomina(nombre,cargo,sueldo_bruto,isr,ss,otro,total_deduccion,sueldo_neto) VALUES ('" + txtnombre.Text + "','" + txtcargo.Text + "','" + txtsbruto.Text + "','" + txtisr.Text + "','" + txtss.Text + "','" + txtotro.Text + "','" + txtdeducciones.Text + "','" + txtsneto.Text + "'); "); //mensaje para cuando se guardan los datos MessageBox.Show("Se almacenaron los datos", "Bien"); } else { //mensaje de error cuando no se almacenan los datos MessageBox.Show("Registro Fallido no guardado", "Error"); } } catch (SQLiteException ex) { ex.ToString(); } }
private void button1_Click(object sender, EventArgs e) { operacion oper = new operacion(); oper.ExecuteNonQuery("Update detalle_nomina set cargo='" + txtcargo.Text + "', sueldo_bruto='" + txtsbruto.Text + "', isr='" + txtisr.Text + "', ss='" + txtss.Text + "', otro='" + txtotro.Text + "', total_deduccion='" + txtdeducciones.Text + "', sueldo_neto='" + txtsneto.Text + "' where nombre='" + txtnombre.Text + "'"); MessageBox.Show("Se actualizo correctamente"); }
//boton eliminar private void btneliminar_Click(object sender, EventArgs e) { try { operacion oper = new operacion(); oper.ExecuteNonQuery("DELETE FROM detalle_nomina WHERE nombre LIKE '" + txtnombre.Text + "%' "); MessageBox.Show("Usuario eliminado exitosamente"); } catch (SQLiteException sqlEx) { MessageBox.Show(sqlEx.Message); } }