/*METODO ENCARGADO DE INSERTAR EL MAESTRO Y EL DETALLE DE LA FACTURA*/ public bool NuevaFactura(Entidad.Facturas f, List <Negocio.Datos_Factura_Detalle> dfd) { bool inserto = false; try { using (TransactionScope ts = new TransactionScope()) { this.InsertarFactura(f); Negocio.Factura_DetalleNegocio dc = new Factura_DetalleNegocio(); /*SE RECORRE CADA ELEMENTO DEL DETALLE A FACTURAR*/ foreach (var item in dfd) { Entidad.Factura_Detalle df = new Entidad.Factura_Detalle(); df.IdFactura = f.Id; df.IdProducto = item.IdProducto; df.Cantidad = item.Cantidad; df.Valor = item.Importe; df.FechaProceso = f.FechaProceso; df.UsuarioProceso = f.UsuarioProceso; dc.InsertarDetalle(df); } ts.Complete(); inserto = true; } } catch (Exception err) { throw(err); } return(inserto); }
/*METODO ENCARGADO DE INSERTAR EL DETALLE DE LA FACTURA*/ public int InsertarDetalle(Entidad.Factura_Detalle fd) { int inserto = 0; try { Datos.Factura_DetalleDatos dc = new Datos.Factura_DetalleDatos(); dc.InsertarDetalle(fd); inserto = 1; } catch (Exception err) { throw (err); } return(inserto); }
/*METODO ENCARGADO DE INSERTAR EL DETALLE DE LA FACTURA*/ public int InsertarDetalle(Entidad.Factura_Detalle fd) { int inserto = 0; Entidad.BD_EvaluacionEntities dc = null; try { dc = new Entidad.BD_EvaluacionEntities(); dc.Factura_Detalle.Add(fd); dc.SaveChanges(); inserto = 1; } catch (Exception err) { throw(err); } return(inserto); }