/// <summary> /// /// </summary> /// <param name="idFactura"></param> /// <returns></returns> public static List<negociosDetalleFacturaCliente> fnlstObtenerListaDetallesFactura(int idFactura) { //IDDETALLEFACTURACLIENTE,IDPRODUCTO,PRECIO,CANTIDAD DataTable dtLocal = negociosAdaptadores.gBuscarDetalleFactura.GetData(idFactura); List<negociosDetalleFacturaCliente> lst = new List<negociosDetalleFacturaCliente>(); object[] objInstancia; for (int i = 0; i < dtLocal.Rows.Count; i++) { objInstancia = dtLocal.Rows[i].ItemArray; negociosDetalleFacturaCliente temporal = new negociosDetalleFacturaCliente(); temporal.giIdEncabezadoFacturaCliente = idFactura; temporal.giIdDetalleFacturaCliente = (Convert.ToInt32(objInstancia[0])); temporal.gshIdProducto = (short)(Convert.ToInt32(objInstancia[1])); temporal.gdecPrecio = (Convert.ToDecimal(objInstancia[2])); temporal.gduCantidad = (Convert.ToDouble(objInstancia[3])); temporal.gdecMonto = temporal.gdecPrecio * (Convert.ToDecimal(temporal.gduCantidad)); lst.Add(temporal); } return lst; }
/// <summary> /// Función para agregar un producto a la factura. Ésta función no se encarga de descargar el producto de la bodega /// </summary> /// <param name="lndfcProducto">negociosDetalleFacturaCliente: la especificación de precio y cantidad de producto comprado</param> public void fnvdAgregarProducto(negociosDetalleFacturaCliente lndfcProducto) { int index = -1; this.gdecTotal+=(lndfcProducto.getPrecio()*Convert.ToDecimal(lndfcProducto.getCantidad())); this.gdecSubTotal = this.gdecTotal - Convert.ToDecimal(this.gduDescuento); for (int i = 0; i < this.glstListaDetalleFactura.Count; i++ ) { if (glstListaDetalleFactura[i].getIdProducto() == lndfcProducto.getIdProducto()) { index = i; break; } } if (index > -1) { glstListaDetalleFactura[index].fnvAumentarCantidad(lndfcProducto.getCantidad()); } else glstListaDetalleFactura.Add(lndfcProducto); }