/// <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 prestamoEnc ConsultarEncabezadp(int codPrestamo, DataGridView dtgListaDetalle) { using (TransactionScope scope = new TransactionScope()) { try { Array Lista = new Cls_PrestamoDET().ListaDetalle(codPrestamo); Libros lib; foreach (prestamoDet per in Lista) { lib = new Cls_Libros().ConsultarLibro(per.CodLibro); dtgListaDetalle.Rows.Add(per.CodLibro, lib.Titulo, per.cantidad); } prestamoEnc enc = encabezadoDAL.ConsultarPrestamoENC(codPrestamo); scope.Complete(); return(enc); } catch (Exception ex) { scope.Dispose(); throw ex; } } }
public void ModificarEncabezado(prestamoEnc encabezado) { try { encabezadoDAL.ModificarPresmoENC(encabezado); } catch (Exception ex) { throw ex; } }
public void AgregarEncabezado(prestamoEnc encabezado) { try { encabezadoDAL.AgregarPrestamoENC(encabezado); } catch (Exception ex) { throw ex; } }
public void EliminarPrestamoENC(int pCodPrestamo) { try { prestamoENC = miContexto.prestamoEnc.First(prestamoEnc => prestamoEnc.CodPrestamo == pCodPrestamo); miContexto.prestamoEnc.Remove(prestamoENC); miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
public void ModificarPresmoENC(prestamoEnc pPrestamoENC) { try { prestamoENC = ConsultarPrestamoENC(pPrestamoENC.CodPrestamo); prestamoENC.fechaPrestamo = pPrestamoENC.fechaPrestamo; prestamoENC.fechaDevoluvion = pPrestamoENC.fechaDevoluvion; miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
public void AgregarPrestamoENC(prestamoEnc prestamoENC) { try { using (DB_BibliotecaEntities contexto = new DB_BibliotecaEntities()) { contexto.prestamoEnc.Add(prestamoENC); contexto.SaveChanges(); } } catch (Exception ex) { throw ex; } }
private void btnAgregar_Click(object sender, EventArgs e) { try { prestamoEnc encabezado = new prestamoEnc { cedula = txtCed.Text, fechaPrestamo = Convert.ToDateTime(dtpPrestamo.Text), fechaDevoluvion = Convert.ToDateTime(dtpDevolucion.Text) }; new Cls_PrestamoENC().Agregar(encabezado, dtgListaDetalle); MessageBox.Show("Prestamo guardado correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }