/// <summary> /// Metodo para agregar Los prestamos /// </summary> public void Agregar(prestamoEnc encabezado, DataGridView dtgListaDetalle) { using (TransactionScope scope = new TransactionScope()) { try { encabezadoDAL.AgregarPrestamoENC(encabezado); int numFila = dtgListaDetalle.RowCount - 1; for (int i = 0; i < numFila; i++) { prestamoDet detalle = new prestamoDet { CodPrestamo = encabezado.CodPrestamo, CodLibro = Convert.ToInt32(dtgListaDetalle.Rows[i].Cells[0].Value), cantidad = Convert.ToInt32(dtgListaDetalle.Rows[i].Cells[2].Value) }; new Cls_PrestamoDET().AgregarDetalle(detalle); } scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw ex; } } }
public void AgregarDetalle(prestamoDet detalle) { try { detalleDAL.AgregarPrestamoDET(detalle); } catch (Exception ex) { throw ex; } }
public void EliminarPrestamoDET(int pCodPrestamo, int pcodLibrp) { try { prestamoDET = miContexto.prestamoDet.First(prestamoDet => prestamoDet.CodPrestamo == pCodPrestamo); miContexto.prestamoDet.Remove(prestamoDET); miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
public void AgregarPrestamoDET(prestamoDet prestamoDET) { try { using (DB_BibliotecaEntities contexto = new DB_BibliotecaEntities()) { contexto.prestamoDet.Add(prestamoDET); contexto.SaveChanges(); } } catch (Exception ex) { throw ex; } }
///public prestamoDet ConsultarDet public void ModificarPresmoDET(prestamoDet pPrestamoDET) { try { var lista = from detalle in miContexto.prestamoDet where detalle.CodLibro == pPrestamoDET.CodLibro && detalle.CodPrestamo == pPrestamoDET.CodPrestamo select detalle; foreach (prestamoDet pres in lista) { pres.cantidad = pPrestamoDET.cantidad; } miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
private void btnModificar_Click(object sender, EventArgs e) { try { prestamoDet detalle = new prestamoDet { CodPrestamo = Convert.ToInt32(txtCodPrestamo.Text), CodLibro = Convert.ToInt32(txtCodLibro.Text), cantidad = Convert.ToInt32(txtCantidad.Value) }; new Cls_PrestamoDET().ModificarDetalle(detalle, dtgListaDetalle); MessageBox.Show("Prestamo modificado correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); EstadoInicial(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ModificarDetalle(prestamoDet detalle, DataGridView dtgListaDetalle) { try { int numFila = dtgListaDetalle.RowCount - 1; for (int i = 0; i < numFila; i++) { prestamoDet prestamoDEt = new prestamoDet { CodLibro = Convert.ToInt32(dtgListaDetalle.Rows[i].Cells[0].Value), cantidad = Convert.ToInt32(dtgListaDetalle.Rows[i].Cells[2].Value) }; detalleDAL.ModificarPresmoDET(prestamoDEt); } detalleDAL.ModificarPresmoDET(detalle); } catch (Exception ex) { throw ex; } }