public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) { #region Variables List <in_Ing_Egr_Inven_det_Info> Lista_IngresoInventarioDet = new List <in_Ing_Egr_Inven_det_Info>(); in_Ing_Egr_Inven_det_List ListaIngresoInventario = new in_Ing_Egr_Inven_det_List(); in_Producto_Bus bus_producto = new in_Producto_Bus(); int cont = 0; decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual); int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); tb_sucursal_Bus bus_sucursal = new tb_sucursal_Bus(); #endregion Stream stream = new MemoryStream(e.UploadedFile.FileBytes); if (stream.Length > 0) { IExcelDataReader reader = null; reader = ExcelReaderFactory.CreateOpenXmlReader(stream); #region Ingreso Inventario var lst_producto = bus_producto.get_list(IdEmpresa, false); while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { var pr_codigo_producto = Convert.ToString(reader.GetValue(3)); var IdUnidadMedida = Convert.ToString(reader.GetValue(2)); var costo_total = Convert.ToDouble(reader.GetValue(6)); var cantidad = Convert.ToDouble(reader.GetValue(5)); var info_producto = lst_producto.Where(q => q.pr_codigo == pr_codigo_producto).FirstOrDefault(); if ((info_producto != null && info_producto.IdProducto != 0) && (costo_total > 0 && cantidad > 0)) { in_Ing_Egr_Inven_det_Info info_detalle = new in_Ing_Egr_Inven_det_Info { Secuencia = cont++, IdEmpresa = IdEmpresa, IdProducto = info_producto.IdProducto, pr_descripcion = info_producto.pr_descripcion, IdUnidadMedida_sinConversion = string.IsNullOrEmpty(IdUnidadMedida) ? info_producto.IdUnidadMedida_Consumo : IdUnidadMedida, dm_cantidad_sinConversion = cantidad, mv_costo_sinConversion = costo_total / cantidad, }; Lista_IngresoInventarioDet.Add(info_detalle); } } else { cont++; } } ListaIngresoInventario.set_list(Lista_IngresoInventarioDet, IdTransaccionSession); #endregion } }