public static bool Guardar(Prestamos prestamos) { using (var context = new Respository <Prestamos>()) { try { if (Buscar(p => p.PrestamoId == prestamos.PrestamoId) == null) { return(context.Guardar(prestamos)); } else { return(context.Modificar(prestamos)); } } catch (Exception) { throw; } } }
private void prestamoConsultabutton_Click(object sender, EventArgs e) { Prestamos prestamo = new Prestamos(); DataTable data = new DataTable(); string condicion; if (prestamocomboBox.SelectedIndex == 0) { if (prestamotextBox.Text.Trim().Length == 0) { condicion = "1=1 "; } else { int id; int.TryParse(prestamotextBox.Text, out id); condicion = "PrestamoId= " + id.ToString(); } data = prestamo.Listado("ClienteId,RutaId,SemanaNo,ValorCuota,Monto,Cuota", condicion, ""); PrestamodataGridView.DataSource = data; } if (prestamocomboBox.SelectedIndex == 1) { if (prestamotextBox.Text.Trim().Length == 1) { condicion = "2=2 "; } else { int id; int.TryParse(prestamotextBox.Text, out id); condicion = " Monto= " + id.ToString(); } data = prestamo.Listado("ClienteId,RutaId,SemanaNo,ValorCuota,Monto,Cuota", condicion, ""); PrestamodataGridView.DataSource = data; } }