Beispiel #1
0
 public ActionResult Nuevo(int IdEmpresa = 0)
 {
     #region Validar Session
     if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession))
     {
         return(RedirectToAction("Login", new { Area = "", Controller = "Account" }));
     }
     SessionFixed.IdTransaccionSession       = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString();
     SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession;
     #endregion
     in_parametro_Info i_param = bus_in_param.get_info(IdEmpresa);
     if (i_param == null)
     {
         return(RedirectToAction("Index"));
     }
     in_Ing_Egr_Inven_Info model = new in_Ing_Egr_Inven_Info
     {
         IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession),
         IdSucursal           = Convert.ToInt32(SessionFixed.IdSucursal),
         IdEmpresa            = IdEmpresa,
         cm_fecha             = DateTime.Now,
         signo             = "-",
         IdMovi_inven_tipo = i_param.P_IdMovi_inven_tipo_default_egr,
         IdMotivo_Inv      = i_param.IdMotivo_Inv_egreso
     };
     List_in_Ing_Egr_Inven_det.set_list(new List <in_Ing_Egr_Inven_det_Info>(), model.IdTransaccionSession);
     cargar_combos(model);
     return(View(model));
 }
        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
            }
        }