Example #1
0
        private void XCONTA_Rpt007_frm_Load(object sender, EventArgs e)
        {
            try
            {
                ct_Plancta_nivel_Bus         BusNivel    = new ct_Plancta_nivel_Bus();
                List <ct_Plancta_nivel_Info> listNiveles = new List <ct_Plancta_nivel_Info>();

                ct_Centro_costo_Bus         BusCentro  = new ct_Centro_costo_Bus();
                List <ct_Centro_costo_Info> listCentro = new List <ct_Centro_costo_Info>();
                listCentro = BusCentro.Get_list_Centro_Costo_cuentas_de_movimiento(param.IdEmpresa, ref msg);

                cmb_centro_costo.Properties.DisplayMember = "Centro_costo";
                cmb_centro_costo.Properties.ValueMember   = "IdCentroCosto";
                cmb_centro_costo.Properties.DataSource    = listCentro;
                uCct_Pto_Cargo_Grupo.Cargar_combos();


                //listNiveles = BusNivel.Get_list_Plancta_nivel(param.IdEmpresa);

                //cmb_nivel.DisplayMember = "IdNivelCta";
                //cmb_nivel.ValueMember = "IdNivelCta";
                //cmb_nivel.DataSource = listNiveles;
                //cmb_nivel.SelectedValue = 3;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.Message, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private Boolean Grabacion_Niveles(List <ct_Plancta_Info> lista)
        {
            Boolean respuesta = false;

            try
            {
                ct_Plancta_nivel_Bus         BusNivel    = new ct_Plancta_nivel_Bus();
                List <ct_Plancta_nivel_Info> ListNiveles = new List <ct_Plancta_nivel_Info>();


                var results = from p in lista
                              group new { p.IdEmpresa, p.IdNivelCta, num_digitos = p.IdCtaCble.Length } by p into grupo
                orderby grupo.Key
                select grupo;

                foreach (var item in results)
                {
                    ct_Plancta_nivel_Info Info = new ct_Plancta_nivel_Info();
                    Info.IdEmpresa      = item.Key.IdEmpresa;
                    Info.IdNivelCta     = item.Key.IdNivelCta;
                    Info.nv_Descripcion = "Nivel " + item.Key.IdNivelCta;
                    Info.nv_NumDigitos  = 0;

                    //ListNiveles.Add(Info);
                }



                for (int i = ListNiveles.Count(); i < 0; i--)
                {
                }


                respuesta = BusNivel.GrabarDB(ListNiveles);

                return(respuesta);
            }
            catch (Exception ex)
            {
                lblMensaje.Text    = "Error al cargar " + ex.ToString();
                lblMensaje.Visible = true;
                return(respuesta);
            }
        }
Example #3
0
        void carga_combos()
        {
            try
            {
                string msg = "";

                uCct_Pto_Cargo_Grupo.Cargar_combos();

                ct_Plancta_nivel_Bus         BusNivel    = new ct_Plancta_nivel_Bus();
                List <ct_Plancta_nivel_Info> listNiveles = new List <ct_Plancta_nivel_Info>();

                listPeriodo = busPeriodo.Get_List_PeriodoCombo(param.IdEmpresa, ref msg);
                cmb_Periodo.Properties.DataSource    = listPeriodo;
                cmb_Periodo.Properties.ValueMember   = "IdPeriodo";
                cmb_Periodo.Properties.DisplayMember = "nom_periodo";

                listNiveles = BusNivel.Get_list_Plancta_nivel(param.IdEmpresa);

                cmb_nivel.DisplayMember = "IdNivelCta";
                cmb_nivel.ValueMember   = "IdNivelCta";
                cmb_nivel.DataSource    = listNiveles;
                cmb_nivel.SelectedValue = 3;

                ct_Centro_costo_Bus         BusCentro  = new ct_Centro_costo_Bus();
                List <ct_Centro_costo_Info> listCentro = new List <ct_Centro_costo_Info>();
                listCentro = BusCentro.Get_list_Centro_Costo_cuentas_de_movimiento(param.IdEmpresa, ref msg);

                cmb_centro_costo.Properties.DisplayMember = "Centro_costo";
                cmb_centro_costo.Properties.ValueMember   = "IdCentroCosto";
                cmb_centro_costo.Properties.DataSource    = listCentro;

                cmb_Mostrar_a.SelectedItem = "Mes actual";
                cmb_nivel.SelectedIndex    = 5;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        private void cargar_combos()
        {
            try
            {
                ct_Periodo_Bus         BusPeriodo  = new ct_Periodo_Bus();
                List <ct_Periodo_Info> ListPeriodo = new List <ct_Periodo_Info>();
                int anio_actual = DateTime.Now.Year;


                ListPeriodo = BusPeriodo.Get_List_Periodo(param.IdEmpresa, ref MensajeError);

                foreach (var itemPeriodo in ListPeriodo)
                {
                    if (anio_actual == itemPeriodo.IdanioFiscal)
                    {
                        chkList_Periodos.Items.Add(itemPeriodo, itemPeriodo.nom_periodo, CheckState.Checked, true);
                    }
                    else
                    {
                        chkList_Periodos.Items.Add(itemPeriodo, itemPeriodo.nom_periodo, CheckState.Unchecked, true);
                    }
                }
                ct_Plancta_nivel_Bus         BusNivel  = new ct_Plancta_nivel_Bus();
                List <ct_Plancta_nivel_Info> listNivel = new List <ct_Plancta_nivel_Info>();
                listNivel            = BusNivel.Get_list_Plancta_nivel(param.IdEmpresa);
                cmb_nivel.DataSource = listNivel;

                cmb_nivel.DisplayMember = "IdNivelCta";
                cmb_nivel.ValueMember   = "IdNivelCta";
                cmb_nivel.SelectedValue = 5;
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
                MessageBox.Show(ex.Message, param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private Boolean Proceso_Grabacion()
        {
            Boolean respuesta   = false;
            int     c           = 1;
            int     Total_Reg   = 0;
            string  IdCta       = "";
            string  IdCta_Padre = "";
            string  Nom_cta     = "";

            BindingList <cl_estado_grabacion> ListEstadoGrabacion = new BindingList <cl_estado_grabacion>();

            try
            {
                string MensajeLog     = "Ingreso Exitoso.";
                string MensajeWarning = "";
                string listaLog       = "";
                this.rtbLog.Text = "";
                bool B_Proceso_anulacion = true;
                lblMensaje.Text    = "";
                lblMensaje.Visible = false;

                gridControlProceGrabado.DataSource = ListEstadoGrabacion;


                if (treeListPlanCta.DataSource != null)
                {
                    if (rgImportar.SelectedIndex == 0)
                    {
                        MensajeWarning = "Atención esta a punto de eliminar toda la información actual, y reemplazarla con la nueva. Está seguro de continuar?";
                    }
                    else
                    {
                        MensajeWarning = "Atención esta a punto de proceder. Está seguro de continuar?";
                    }
                    lblmsg3.Visible = true;


                    if (MessageBox.Show(MensajeWarning, "SISTEMAS", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                    {
                        if (rgImportar.SelectedIndex == 0)
                        {
                            splashScreenManager.ShowWaitForm();


                            B_Proceso_anulacion = _PlanCtaBus.EliminarDB(param.IdEmpresa, ref MensajeError);

                            if (B_Proceso_anulacion)
                            {
                                ListEstadoGrabacion.Add(new cl_estado_grabacion(0, "", "Eliminado Plan de cuenta", "", "OK", "Eliminado Ok"));
                                gridControlProceGrabado.Refresh();
                            }


                            splashScreenManager.CloseWaitForm();
                        }


                        if (B_Proceso_anulacion == true)
                        {
                            splashScreenManager.ShowWaitForm();


                            Total_Reg            = _ListPlanCtaInfo.Count();
                            progressBar.Maximum  = Total_Reg;
                            progressBar.Minimum  = 1;
                            progressBar.Step     = 1;
                            lblNumRegistros.Text = "0 registros de " + Total_Reg;
                            c = 1;

                            ct_Plancta_nivel_Bus         BusPlan_nivel    = new ct_Plancta_nivel_Bus();
                            List <ct_Plancta_nivel_Info> list_niveles     = new List <ct_Plancta_nivel_Info>();
                            List <ct_Plancta_nivel_Info> list_niveles_Aux = new List <ct_Plancta_nivel_Info>();



                            var QNiveles = from Cb in _ListPlanCtaInfo
                                           orderby Cb.IdNivelCta descending
                                           group Cb by new { Cb.IdEmpresa, Cb.IdNivelCta, Cb.IdCtaCble.Length }
                            into grouping
                                select new { grouping.Key };

                            if (QNiveles.Count() > 0)
                            {
                                foreach (var item in QNiveles)
                                {
                                    ct_Plancta_nivel_Info InfoPlan_nivel = new ct_Plancta_nivel_Info();
                                    InfoPlan_nivel.IdEmpresa      = item.Key.IdEmpresa;
                                    InfoPlan_nivel.IdNivelCta     = item.Key.IdNivelCta;
                                    InfoPlan_nivel.nv_Descripcion = "Nivel " + item.Key.IdNivelCta;;
                                    InfoPlan_nivel.nv_NumDigitos  = item.Key.Length;
                                    InfoPlan_nivel.Estado         = "A";
                                    list_niveles_Aux.Add(InfoPlan_nivel);
                                }
                            }

                            // recorre desde el nivel mas grande hasta el nivel mas pequeño
                            foreach (var item in list_niveles_Aux)
                            {
                                int num_Digito_x_Nivel_Actual   = 0;
                                int num_Digito_x_Nivel_Anterior = 0;

                                ct_Plancta_nivel_Info InfoPlan_nivel_Anterior = list_niveles_Aux.FirstOrDefault(v => v.IdNivelCta == item.IdNivelCta - 1);

                                num_Digito_x_Nivel_Anterior = (InfoPlan_nivel_Anterior == null) ? 0 : InfoPlan_nivel_Anterior.nv_NumDigitos;
                                num_Digito_x_Nivel_Actual   = item.nv_NumDigitos - num_Digito_x_Nivel_Anterior;

                                ct_Plancta_nivel_Info InfoPlan_nivel = new ct_Plancta_nivel_Info();
                                InfoPlan_nivel.IdEmpresa      = item.IdEmpresa;
                                InfoPlan_nivel.IdNivelCta     = item.IdNivelCta;
                                InfoPlan_nivel.nv_Descripcion = item.nv_Descripcion;
                                InfoPlan_nivel.nv_NumDigitos  = num_Digito_x_Nivel_Actual;
                                InfoPlan_nivel.Estado         = "A";
                                list_niveles.Add(InfoPlan_nivel);
                            }

                            //BusPlan_nivel.EliminarDB(param.IdEmpresa);
                            BusPlan_nivel.GrabarDB(list_niveles);


                            foreach (ct_Plancta_Info item in _ListPlanCtaInfo)
                            {
                                IdCta          = item.IdCtaCble;
                                Nom_cta        = item.pc_Cuenta;
                                IdCta_Padre    = item.IdCtaCblePadre;
                                item.IdUsuario = "migrado2";

                                respuesta = _PlanCtaBus.GrabarDB(item, ref MensajeError);
                                if (respuesta)
                                {
                                    ListEstadoGrabacion.Add(new cl_estado_grabacion(c, item.IdCtaCble, item.pc_Cuenta, IdCta_Padre, "OK", "Migrado Ok"));
                                    gridControlProceGrabado.Refresh();
                                    progressBar.Value    = c;
                                    lblNumRegistros.Text = c + " registros de " + Total_Reg;
                                    progressBar.Refresh();
                                    Application.DoEvents();
                                }

                                c++;
                            }

                            if (listaLog != "")
                            {
                                MensajeLog += " pero con errores:" + "\n" + listaLog + MensajeError;
                            }
                        }
                    }
                    else
                    {
                        MensajeLog = "No se efectuó la operación. Operación cancelada por el usuario.";
                    }
                    lblmsg3.Visible = false;
                }
                else
                {
                    MensajeLog = "No existen Datos para importación.";
                }
                this.rtbLog.Text = MensajeLog;


                splashScreenManager.CloseWaitForm();

                return(respuesta);
            }
            catch (Exception ex)
            {
                splashScreenManager.CloseWaitForm();
                ListEstadoGrabacion.Add(new cl_estado_grabacion(c++, IdCta, Nom_cta, IdCta_Padre, "ERROR", "No Migrado:" + ex.ToString()));
                gridControlProceGrabado.Refresh();
                lblMensaje.Text    = "Error al cargar " + ex.ToString();
                lblMensaje.Visible = true;
                return(respuesta);
            }
        }
Example #6
0
        public List <XCONTA_Rpt022_Info> consultar_data(int IdEmpresa, DateTime FechaIni, DateTime FechaFin, string IdCentroCosto, int IdNivel_a_mostrar
                                                        , int IdPunto_cargo_grupo
                                                        , int IdPunto_cargo
                                                        , bool Mostrar_reg_Cero
                                                        , bool MostrarCC, bool Considerar_Asiento_cierre_anual, string IdUsuario, ref String MensajeError)
        {
            try
            {
                List <XCONTA_Rpt022_Info> listadedatos = new List <XCONTA_Rpt022_Info>();

                FechaIni = Convert.ToDateTime(FechaIni.ToShortDateString());
                FechaFin = Convert.ToDateTime(FechaFin.ToShortDateString());

                using (EntitiesContabilidadRptGeneral BalanceGeneral = new EntitiesContabilidadRptGeneral())
                {
                    BalanceGeneral.SetCommandTimeOut(30000);//timeout 3 minutos

                    IList <spCON_Mayorizar_x_fecha_corte_Result> listBalance =
                        BalanceGeneral.spCON_Mayorizar_x_fecha_corte(IdEmpresa, FechaIni, FechaFin, IdCentroCosto, IdPunto_cargo_grupo, IdPunto_cargo, Mostrar_reg_Cero, MostrarCC, Considerar_Asiento_cierre_anual, IdUsuario).Where(v => v.gc_estado_financiero == "BG" && v.IdNivelCta <= IdNivel_a_mostrar).ToList();

                    ct_Plancta_nivel_Info info_nivel_2 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_3 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_4 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_5 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_6 = new ct_Plancta_nivel_Info();

                    ct_Plancta_nivel_Bus bus_nivel = new ct_Plancta_nivel_Bus();
                    info_nivel_2 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 2);
                    info_nivel_3 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 3);
                    info_nivel_4 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 4);
                    info_nivel_5 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 5);
                    info_nivel_6 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 6);


                    List <ct_Plancta_Info> lst_nivel_2 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_3 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_4 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_5 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_6 = new List <ct_Plancta_Info>();

                    ct_Plancta_Bus bus_plancta = new ct_Plancta_Bus();
                    lst_nivel_2 = bus_plancta.Get_List_Plancta(IdEmpresa, 2);
                    lst_nivel_3 = bus_plancta.Get_List_Plancta(IdEmpresa, 3);
                    lst_nivel_4 = bus_plancta.Get_List_Plancta(IdEmpresa, 4);
                    lst_nivel_5 = bus_plancta.Get_List_Plancta(IdEmpresa, 5);
                    lst_nivel_6 = bus_plancta.Get_List_Plancta(IdEmpresa, 6);

                    foreach (var item in listBalance)
                    {
                        if (item.IdNivelCta == IdNivel_a_mostrar)
                        {
                            XCONTA_Rpt022_Info itemInfo = new XCONTA_Rpt022_Info();
                            itemInfo.IdEmpresa            = item.IdEmpresa;
                            itemInfo.IdCtaCble            = item.IdCtaCble;
                            itemInfo.nom_cuenta           = item.nom_cuenta;
                            itemInfo.IdNivelCta           = item.IdNivelCta;
                            itemInfo.IdCtaCblePadre       = item.IdCtaCblePadre;
                            itemInfo.GrupoCble            = item.GrupoCble;
                            itemInfo.OrderGrupoCble       = Convert.ToInt32(item.OrderGrupoCble);
                            itemInfo.gc_estado_financiero = item.gc_estado_financiero;
                            itemInfo.Saldo_Inicial        = item.Saldo_Inicial;
                            itemInfo.Debito_Mes           = item.Debito_Mes;
                            itemInfo.Credito_Mes          = item.Credito_Mes;
                            itemInfo.Saldo = item.Saldo;
                            itemInfo.Saldo_inicial_x_Movi = item.Saldo_inicial_x_Movi;
                            itemInfo.Debito_Mes_x_Movi    = item.Debito_Mes_x_Movi;
                            itemInfo.Credito_Mes_x_Movi   = item.Credito_Mes_x_Movi;
                            itemInfo.Saldo_x_Movi         = item.Saldo_x_Movi;
                            itemInfo.pc_EsMovimiento      = item.pc_EsMovimiento;
                            itemInfo.nom_cuenta2          = item.IdCtaCble + " - " + item.nom_cuenta;
                            itemInfo.nom_cuenta           = item.nom_cuenta;
                            itemInfo.IdPuntoCargo         = item.IdPunto_cargo;
                            itemInfo.IdPuntoCargo_Grupo   = item.IdPunto_cargo_grupo;
                            itemInfo.IdCentroCosto        = item.IdCentroCosto;
                            itemInfo.nom_PuntoCargo       = item.nom_punto_cargo;
                            itemInfo.nom_PuntoCargo_Grupo = item.nom_punto_cargo_grupo;
                            itemInfo.nom_CentroCosto      = item.nom_centro_costo;
                            itemInfo.nom_empresa          = item.nom_empresa;


                            try
                            {
                                //Nivel 2
                                itemInfo.IdCtaCble_nivel2 = item.IdCtaCble.Length > info_nivel_2.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_2.nv_NumDigitos_total)) : null;
                                if (itemInfo.IdCtaCble_nivel2 != null)
                                {
                                    itemInfo.pc_cuenta_nivel2 = lst_nivel_2.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel2).pc_Cuenta;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                //Nivel 3
                                itemInfo.IdCtaCble_nivel3 = item.IdCtaCble.Length > info_nivel_3.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_3.nv_NumDigitos_total)) : null;
                                if (itemInfo.IdCtaCble_nivel3 != null)
                                {
                                    itemInfo.pc_cuenta_nivel3 = lst_nivel_3.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel3).pc_Cuenta;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                //Nivel 4
                                itemInfo.IdCtaCble_nivel4 = item.IdCtaCble.Length > info_nivel_4.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_4.nv_NumDigitos_total)) : null;
                                if (itemInfo.IdCtaCble_nivel4 != null)
                                {
                                    itemInfo.pc_cuenta_nivel4 = lst_nivel_4.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel4).pc_Cuenta;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                //Nivel 5
                                itemInfo.IdCtaCble_nivel5 = item.IdCtaCble.Length > info_nivel_5.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_5.nv_NumDigitos_total)) : null;
                                if (itemInfo.IdCtaCble_nivel5 != null)
                                {
                                    itemInfo.pc_cuenta_nivel5 = lst_nivel_5.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel5).pc_Cuenta;
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                            try
                            {
                                //Nivel 6
                                itemInfo.IdCtaCble_nivel6 = item.IdCtaCble.Length > info_nivel_6.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_6.nv_NumDigitos_total)) : null;
                                if (itemInfo.IdCtaCble_nivel6 != null)
                                {
                                    itemInfo.pc_cuenta_nivel6 = lst_nivel_6.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel6).pc_Cuenta;
                                }
                            }
                            catch (Exception ex)
                            {
                            }


                            listadedatos.Add(itemInfo);
                        }
                    }
                }
                return(listadedatos.OrderBy(Q => Q.IdCtaCble).ToList());
            }
            catch (Exception ex)
            {
                string mensaje = "";
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }
Example #7
0
        public List <XCONTA_NATU_Rpt004_Info> consultar_data(int IdEmpresa, DateTime FechaIni, DateTime FechaFin, string IdCentroCosto, int IdNivel_a_mostrar
                                                             , int IdPunto_cargo_grupo
                                                             , int IdPunto_cargo
                                                             , bool Mostrar_reg_en_cero
                                                             , bool MostrarCC, bool Considerar_Asiento_cierre_anual, string IdUsuario, ref String MensajeError)
        {
            try
            {
                List <XCONTA_NATU_Rpt004_Info> listadedatos = new List <XCONTA_NATU_Rpt004_Info>();
                FechaIni = Convert.ToDateTime(FechaIni.ToShortDateString());
                FechaFin = Convert.ToDateTime(FechaFin.ToShortDateString());


                using (EntitiesDBConta Estado_Resultado = new EntitiesDBConta())
                {
                    Estado_Resultado.SetCommandTimeOut(30000);//timeout 3 minutos

                    //IList<spCON_Mayorizar_x_fecha_corte_Result> listBalance =
                    IEnumerable <spCON_Mayorizar_x_fecha_corte_Result> listBalance = from q in Estado_Resultado.spCON_Mayorizar_x_fecha_corte(IdEmpresa, FechaIni, FechaFin, IdCentroCosto, IdPunto_cargo_grupo, IdPunto_cargo, Mostrar_reg_en_cero, MostrarCC, Considerar_Asiento_cierre_anual, IdUsuario)
                                                                                     select q;


                    var Querry_x_UTILIDAD = from C in listBalance
                                            where C.CtaUtilidad == true
                                            select C;


                    var Querry_x_ER = from C in listBalance
                                      where C.gc_estado_financiero == "ER" &&
                                      C.IdNivelCta <= IdNivel_a_mostrar
                                      select C;

                    ct_Plancta_nivel_Info info_nivel_2 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_3 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_4 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_5 = new ct_Plancta_nivel_Info();
                    ct_Plancta_nivel_Info info_nivel_6 = new ct_Plancta_nivel_Info();

                    ct_Plancta_nivel_Bus bus_nivel = new ct_Plancta_nivel_Bus();
                    info_nivel_2 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 2);
                    info_nivel_3 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 3);
                    info_nivel_4 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 4);
                    info_nivel_5 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 5);
                    info_nivel_6 = bus_nivel.Get_info_plancta_nivel(IdEmpresa, 6);


                    List <ct_Plancta_Info> lst_nivel_2 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_3 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_4 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_5 = new List <ct_Plancta_Info>();
                    List <ct_Plancta_Info> lst_nivel_6 = new List <ct_Plancta_Info>();

                    ct_Plancta_Bus bus_plancta = new ct_Plancta_Bus();
                    lst_nivel_2 = bus_plancta.Get_List_Plancta(IdEmpresa, 2);
                    lst_nivel_3 = bus_plancta.Get_List_Plancta(IdEmpresa, 3);
                    lst_nivel_4 = bus_plancta.Get_List_Plancta(IdEmpresa, 4);
                    lst_nivel_5 = bus_plancta.Get_List_Plancta(IdEmpresa, 5);
                    lst_nivel_6 = bus_plancta.Get_List_Plancta(IdEmpresa, 6);

                    foreach (var item in Querry_x_ER)
                    {
                        if (item.IdNivelCta == IdNivel_a_mostrar)
                        {
                            XCONTA_NATU_Rpt004_Info itemInfo = new XCONTA_NATU_Rpt004_Info();
                            itemInfo.IdEmpresa            = item.IdEmpresa;
                            itemInfo.IdCtaCble            = item.IdCtaCble;
                            itemInfo.nom_cuenta           = item.nom_cuenta;
                            itemInfo.nom_cuenta2          = item.IdCtaCble + " " + item.nom_cuenta;
                            itemInfo.IdNivelCta           = item.IdNivelCta;
                            itemInfo.IdCtaCblePadre       = item.IdCtaCblePadre;
                            itemInfo.GrupoCble            = item.GrupoCble;
                            itemInfo.OrderGrupoCble       = Convert.ToInt32(item.OrderGrupoCble);
                            itemInfo.gc_estado_financiero = item.gc_estado_financiero;


                            itemInfo.Saldo_Inicial = item.Saldo_Inicial;
                            itemInfo.Debito_Mes    = item.Debito_Mes;
                            itemInfo.Credito_Mes   = item.Credito_Mes;
                            itemInfo.Saldo         = item.Saldo;

                            itemInfo.Saldo_inicial_x_Movi = item.Saldo_inicial_x_Movi;
                            itemInfo.Debito_Mes_x_Movi    = item.Debito_Mes_x_Movi;
                            itemInfo.Credito_Mes_x_Movi   = item.Credito_Mes_x_Movi;
                            itemInfo.Saldo_x_Movi         = item.Saldo_x_Movi;



                            itemInfo.pc_EsMovimiento = item.pc_EsMovimiento;
                            //itemInfo.GrupoCble = item.OrderGrupoCble + " " + item.GrupoCble;
                            itemInfo.gc_signo_operacion = item.gc_signo_operacion;


                            itemInfo.IdPuntoCargo         = item.IdPunto_cargo;
                            itemInfo.IdPuntoCargo_Grupo   = item.IdPunto_cargo_grupo;
                            itemInfo.IdCentroCosto        = item.IdCentroCosto;
                            itemInfo.nom_PuntoCargo       = item.nom_punto_cargo;
                            itemInfo.nom_PuntoCargo_Grupo = item.nom_punto_cargo_grupo;
                            itemInfo.nom_CentroCosto      = item.nom_centro_costo;
                            itemInfo.nom_empresa          = item.nom_empresa;

                            itemInfo.IdGrupo_Mayor     = item.IdGrupo_Mayor;
                            itemInfo.nom_grupo_mayor   = item.nom_grupo_mayor;
                            itemInfo.order_grupo_mayor = item.order_grupo_mayor;

                            //Nivel 2
                            itemInfo.IdCtaCble_nivel2 = item.IdCtaCble.Length > info_nivel_2.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_2.nv_NumDigitos_total)) : null;
                            if (itemInfo.IdCtaCble_nivel2 != null)
                            {
                                itemInfo.pc_cuenta_nivel2 = lst_nivel_2.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel2).pc_Cuenta;
                            }
                            //Nivel 3
                            itemInfo.IdCtaCble_nivel3 = item.IdCtaCble.Length > info_nivel_3.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_3.nv_NumDigitos_total)) : null;
                            if (itemInfo.IdCtaCble_nivel3 != null)
                            {
                                itemInfo.pc_cuenta_nivel3 = lst_nivel_3.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel3).pc_Cuenta;
                            }
                            //Nivel 4
                            itemInfo.IdCtaCble_nivel4 = item.IdCtaCble.Length > info_nivel_4.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_4.nv_NumDigitos_total)) : null;
                            if (itemInfo.IdCtaCble_nivel4 != null)
                            {
                                itemInfo.pc_cuenta_nivel4 = lst_nivel_4.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel4).pc_Cuenta;
                            }
                            //Nivel 5
                            itemInfo.IdCtaCble_nivel5 = item.IdCtaCble.Length > info_nivel_5.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_5.nv_NumDigitos_total)) : null;
                            if (itemInfo.IdCtaCble_nivel5 != null)
                            {
                                itemInfo.pc_cuenta_nivel5 = lst_nivel_5.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel5).pc_Cuenta;
                            }
                            //Nivel 6
                            itemInfo.IdCtaCble_nivel6 = item.IdCtaCble.Length > info_nivel_6.nv_NumDigitos_total ? itemInfo.IdCtaCble.Substring(0, Convert.ToInt32(info_nivel_6.nv_NumDigitos_total)) : null;
                            if (itemInfo.IdCtaCble_nivel6 != null)
                            {
                                itemInfo.pc_cuenta_nivel6 = lst_nivel_6.FirstOrDefault(q => q.IdCtaCble == itemInfo.IdCtaCble_nivel6).pc_Cuenta;
                            }

                            listadedatos.Add(itemInfo);
                        }
                    }
                }
                return(listadedatos);
            }
            catch (Exception ex)
            {
                string mensaje = "";
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "",
                                                                                          "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString();
                throw new Exception(ex.ToString());
            }
        }