public ActionResult GridViewPartial_tipoactivo(bool Nuevo = false) { ViewBag.Nuevo = Nuevo; SessionFixed.IdTransaccionSessionActual = Request.Params["TransaccionFixed"] != null ? Request.Params["TransaccionFixed"].ToString() : SessionFixed.IdTransaccionSessionActual; var model = Lista_TipoAF.get_list(Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual)); return(PartialView("_GridViewPartial_tipoactivo", model)); }
public ActionResult Importar(Af_Activo_fijo_Info model) { try { var Lista_Tipo = ListaTipo.get_list(model.IdTransaccionSession); var Lista_Categoria = ListaCategoria.get_list(model.IdTransaccionSession); var Lista_Departamento = ListaDepartamento.get_list(model.IdTransaccionSession); var Lista_Area = ListaAreaAF.get_list(model.IdTransaccionSession); var Lista_Catalogo = ListaCatalogo.get_list(model.IdTransaccionSession); var Lista_ActivoFijo = ListaActivoFijo.get_list(model.IdTransaccionSession); var ListaModelo = ListaModeloAF.get_list(model.IdTransaccionSession); var ListaMarca = ListaMarcaAF.get_list(model.IdTransaccionSession); //var Lista_ActivoFijo_CtaCble = List_det.get_list(model.IdTransaccionSession); //foreach (var item in Lista_ActivoFijo) //{ //item.LstDet = Lista_ActivoFijo_CtaCble.Where(q => q.IdActivoFijo == item.IdActivoFijo).ToList(); ////var secuencia = 1; ////foreach (var item2 in item.LstDet) ////{ //// item2.Secuencia = secuencia++; ////} //} if (!bus_activo.guardarDB_importacion(Lista_Tipo, Lista_Categoria, Lista_Departamento, Lista_Area, Lista_Catalogo, ListaModelo, ListaMarca, Lista_ActivoFijo)) { ViewBag.mensaje = "Error al importar el archivo"; return(View(model)); } } catch (Exception ex) { ViewBag.error = ex.Message.ToString(); return(View(model)); } return(RedirectToAction("Index")); }
public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) { #region Variables ro_empleado_Bus bus_empleado = new ro_empleado_Bus(); Af_Activo_fijo_tipo_Bus bus_tipo = new Af_Activo_fijo_tipo_Bus(); Af_Activo_fijo_tipo_List ListaTipo = new Af_Activo_fijo_tipo_List(); List <Af_Activo_fijo_tipo_Info> Lista_Tipo = new List <Af_Activo_fijo_tipo_Info>(); Af_Activo_fijo_Categoria_List ListaCategoria = new Af_Activo_fijo_Categoria_List(); List <Af_Activo_fijo_Categoria_Info> Lista_Categoria = new List <Af_Activo_fijo_Categoria_Info>(); Af_Departamento_List ListaDepartamento = new Af_Departamento_List(); List <Af_Departamento_Info> Lista_Departamento = new List <Af_Departamento_Info>(); Af_Catalogo_List ListaCatalogo = new Af_Catalogo_List(); List <Af_Catalogo_Info> Lista_Catalogo = new List <Af_Catalogo_Info>(); Af_Activo_fijo_List ListaActivoFijo = new Af_Activo_fijo_List(); List <Af_Activo_fijo_Info> Lista_ActivoFijo = new List <Af_Activo_fijo_Info>(); //Af_Activo_fijo_CtaCble_List ListaActivoFijoCtaCble = new Af_Activo_fijo_CtaCble_List(); List <Af_Activo_fijo_CtaCble_Info> Lista_ActivoFijoCtaCble = new List <Af_Activo_fijo_CtaCble_Info>(); int cont = 0; decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual); int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); #endregion Stream stream = new MemoryStream(e.UploadedFile.FileBytes); if (stream.Length > 0) { IExcelDataReader reader = null; reader = ExcelReaderFactory.CreateOpenXmlReader(stream); #region Tipo while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { Af_Activo_fijo_tipo_Info info = new Af_Activo_fijo_tipo_Info { IdEmpresa = IdEmpresa, IdActivoFijoTipo = Convert.ToInt32(reader.GetValue(0)), CodActivoFijo = reader.GetString(1), Af_Descripcion = reader.GetString(2), Af_Porcentaje_depre = Convert.ToDouble(reader.GetValue(3)), Af_anio_depreciacion = Convert.ToInt32(reader.GetValue(4)), IdCtaCble_Activo = Convert.ToString(reader.GetValue(6)), IdCtaCble_Dep_Acum = Convert.ToString(reader.GetValue(7)), IdCtaCble_Gastos_Depre = Convert.ToString(reader.GetValue(8)), Se_Deprecia = reader.GetString(5) == "SI" ? true : false, IdCtaCble_CostoVenta = Convert.ToString(reader.GetValue(9)), IdCtaCble_Mejora = Convert.ToString(reader.GetValue(10)), IdCtaCble_Baja = Convert.ToString(reader.GetValue(11)), IdCtaCble_Retiro = Convert.ToString(reader.GetValue(12)), IdUsuario = SessionFixed.IdUsuario }; Lista_Tipo.Add(info); } else { cont++; } } ListaTipo.set_list(Lista_Tipo, IdTransaccionSession); #endregion cont = 0; //Para avanzar a la siguiente hoja de excel reader.NextResult(); #region Categoria while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { Af_Activo_fijo_Categoria_Info info = new Af_Activo_fijo_Categoria_Info { IdEmpresa = IdEmpresa, IdCategoriaAF = Convert.ToInt32(reader.GetValue(0)), IdActivoFijoTipo = Convert.ToInt32(reader.GetValue(1)), CodCategoriaAF = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(2))) ? null : Convert.ToString(reader.GetValue(2)), Descripcion = Convert.ToString(reader.GetValue(3)), IdUsuario = SessionFixed.IdUsuario }; Lista_Categoria.Add(info); } else { cont++; } } ListaCategoria.set_list(Lista_Categoria, IdTransaccionSession); #endregion cont = 0; reader.NextResult(); #region Departamento while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { Af_Departamento_Info info = new Af_Departamento_Info { IdEmpresa = IdEmpresa, IdDepartamento = Convert.ToInt32(reader.GetValue(0)), Descripcion = Convert.ToString(reader.GetValue(1)), IdUsuarioCreacion = SessionFixed.IdUsuario }; Lista_Departamento.Add(info); } else { cont++; } } ListaDepartamento.set_list(Lista_Departamento, IdTransaccionSession); #endregion cont = 0; reader.NextResult(); #region Catalogo while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { Af_Catalogo_Info info = new Af_Catalogo_Info { IdCatalogo = Convert.ToString(reader.GetValue(0)), IdTipoCatalogo = Convert.ToString(reader.GetValue(1)), Descripcion = Convert.ToString(reader.GetValue(2)), IdUsuario = SessionFixed.IdUsuario }; info.IdCatalogo = info.IdCatalogo.Trim(); info.IdTipoCatalogo = info.IdTipoCatalogo.Trim(); Lista_Catalogo.Add(info); } else { cont++; } } ListaCatalogo.set_list(Lista_Catalogo, IdTransaccionSession); #endregion cont = 0; reader.NextResult(); #region ActivoFijo var ListaEmpleado = bus_empleado.get_list_combo(IdEmpresa); ro_empleado_info_list Lista_Empleado = new ro_empleado_info_list(); Lista_Empleado.set_list(ListaEmpleado); while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { var IdTipo = Convert.ToInt32(reader.GetValue(3)); var ini_depre = Convert.ToDateTime(reader.GetValue(13)); var info_empleado_custodio = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(23))).FirstOrDefault(); var info_empleado_encargado = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(22))).FirstOrDefault(); var info_tipo_activofijo = ListaTipo.get_list(IdTransaccionSession).Where(q => q.IdActivoFijoTipo == IdTipo).FirstOrDefault(); Af_Activo_fijo_Info info = new Af_Activo_fijo_Info { IdEmpresa = IdEmpresa, IdUsuario = SessionFixed.IdUsuario, IdActivoFijo = Convert.ToInt32(reader.GetValue(0)), CodActivoFijo = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(1))) ? null : Convert.ToString(reader.GetValue(1)), Af_Codigo_Barra = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(24))) ? null : Convert.ToString(reader.GetValue(24)), Af_Nombre = Convert.ToString(reader.GetValue(2)), IdCategoriaAF = Convert.ToInt32(reader.GetValue(4)), IdActivoFijoTipo = Convert.ToInt32(reader.GetValue(3)), IdSucursal = Convert.ToInt32(reader.GetValue(5)), IdDepartamento = Convert.ToInt32(reader.GetValue(6)), IdCatalogo_Marca = Convert.ToString(reader.GetValue(7)), IdCatalogo_Modelo = Convert.ToString(reader.GetValue(8)), IdCatalogo_Color = Convert.ToString(reader.GetValue(10)), IdTipoCatalogo_Ubicacion = Convert.ToString(reader.GetValue(11)), IdEmpleadoCustodio = info_empleado_custodio.IdEmpleado, IdEmpleadoEncargado = info_empleado_encargado.IdEmpleado, Af_fecha_compra = Convert.ToDateTime(reader.GetValue(12)), Af_fecha_ini_depre = ini_depre, Af_costo_compra = Convert.ToDouble(reader.GetValue(15)), Af_Depreciacion_acum = Convert.ToDouble(reader.GetValue(16)), Af_ValorSalvamento = Convert.ToDouble(reader.GetValue(25)), Af_NumSerie = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(9))) ? null : Convert.ToString(reader.GetValue(9)), Af_NumPlaca = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(21))) ? null : Convert.ToString(reader.GetValue(21)), Estado_Proceso = "TIP_ESTADO_AF_ACTIVO", Af_fecha_fin_depre = ini_depre.AddYears(info_tipo_activofijo.Af_anio_depreciacion), Af_Meses_depreciar = (info_tipo_activofijo.Af_anio_depreciacion * 12), Af_porcentaje_deprec = info_tipo_activofijo.Af_Porcentaje_depre, Af_Vida_Util = info_tipo_activofijo.Af_anio_depreciacion, Af_observacion = Convert.ToString(reader.GetValue(20)), Cantidad = Convert.ToInt32(reader.GetValue(26)) }; Lista_ActivoFijo.Add(info); } else { cont++; } } ListaActivoFijo.set_list(Lista_ActivoFijo, IdTransaccionSession); #endregion cont = 0; reader.NextResult(); #region ActivoFijo_CtaCble //while (reader.Read()) //{ // if (!reader.IsDBNull(0) && cont > 0) // { // Af_Activo_fijo_CtaCble_Info info = new Af_Activo_fijo_CtaCble_Info // { // IdEmpresa = IdEmpresa, // IdActivoFijo = Convert.ToInt32(reader.GetValue(0)), // IdDepartamento = Convert.ToInt32(reader.GetValue(1)), // IdCtaCble = Convert.ToString(reader.GetValue(2)), // Porcentaje = Convert.ToDouble(reader.GetValue(3)) // }; // Lista_ActivoFijoCtaCble.Add(info); // } // else // cont++; //} //ListaActivoFijoCtaCble.set_list(Lista_ActivoFijoCtaCble, IdTransaccionSession); #endregion } }