示例#1
0
        public void UpdateRow(Af_Activo_fijo_CtaCble_Info info_det, decimal IdTransaccionSession)
        {
            Af_Activo_fijo_CtaCble_Info edited_info = get_list(IdTransaccionSession).Where(m => m.Secuencia == info_det.Secuencia).First();

            edited_info.IdActivoFijo   = info_det.IdActivoFijo;
            edited_info.IdCtaCble      = info_det.IdCtaCble;
            edited_info.IdDepartamento = info_det.IdDepartamento;
            edited_info.Porcentaje     = info_det.Porcentaje;
            edited_info.pc_Cuenta      = info_det.pc_Cuenta;
        }
示例#2
0
        public void AddRow(Af_Activo_fijo_CtaCble_Info info_det, decimal IdTransaccionSession)
        {
            List <Af_Activo_fijo_CtaCble_Info> list = get_list(IdTransaccionSession);

            info_det.Secuencia      = list.Count == 0 ? 1 : list.Max(q => q.Secuencia) + 1;
            info_det.IdDepartamento = info_det.IdDepartamento;
            info_det.IdCtaCble      = info_det.IdCtaCble;
            info_det.Porcentaje     = info_det.Porcentaje;
            info_det.pc_Cuenta      = info_det.pc_Cuenta;


            list.Add(info_det);
        }
示例#3
0
        public ActionResult EditingAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Af_Activo_fijo_CtaCble_Info info_det)
        {
            var cuenta = bus_plancta.get_info(Convert.ToInt32(SessionFixed.IdEmpresa), info_det.IdCtaCble);

            if (cuenta != null)
            {
                info_det.pc_Cuenta = cuenta.pc_Cuenta;
            }
            if (ModelState.IsValid)
            {
                List_det.AddRow(info_det, Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual));
            }
            Af_Activo_fijo_Info model = new Af_Activo_fijo_Info();

            model.LstDet = List_det.get_list(Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual));
            cargar_combos_Detalle();
            return(PartialView("_GridViewPartial_activo_fijo_ctacble", model));
        }
示例#4
0
        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(5));
                        var ini_depre = Convert.ToDateTime(reader.GetValue(15));
                        var info_empleado_custodio  = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(12))).FirstOrDefault();
                        var info_empleado_encargado = Lista_Empleado.get_list().Where(q => q.pe_cedulaRuc == Convert.ToString(reader.GetValue(13))).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(2))) ? null : Convert.ToString(reader.GetValue(2)),
                            Af_Nombre                = Convert.ToString(reader.GetValue(3)),
                            IdCategoriaAF            = Convert.ToInt32(reader.GetValue(4)),
                            IdActivoFijoTipo         = Convert.ToInt32(reader.GetValue(5)),
                            IdSucursal               = Convert.ToInt32(reader.GetValue(6)),
                            IdDepartamento           = Convert.ToInt32(reader.GetValue(7)),
                            IdCatalogo_Marca         = Convert.ToString(reader.GetValue(8)),
                            IdCatalogo_Modelo        = Convert.ToString(reader.GetValue(9)),
                            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(14)),
                            Af_fecha_ini_depre       = ini_depre,
                            Af_costo_compra          = Convert.ToDouble(reader.GetValue(16)),
                            Af_Depreciacion_acum     = Convert.ToDouble(reader.GetValue(17)),
                            Af_ValorSalvamento       = Convert.ToDouble(reader.GetValue(18)),
                            Af_NumSerie              = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(19))) ? null : Convert.ToString(reader.GetValue(19)),
                            Af_NumPlaca              = string.IsNullOrEmpty(Convert.ToString(reader.GetValue(20))) ? null : Convert.ToString(reader.GetValue(20)),
                            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,
                        };

                        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
            }
        }