示例#1
0
 public DataTable findRubrosByIdModelo(Int64 modelo_id)
 {
     return(_queryExecuter.ExecuteQuery("SELECT * FROM rubro WHERE activo=true and tipo_id = " +
                                        TipoRubroCuentas +
                                        " AND id_modelo_neg = " +
                                        modelo_id));
 }
示例#2
0
 public Boolean existePeridodoActivo(int anio, Int64 idTipoProforma, Int64 idTipoCaptura)
 {
     return(_queryExecuter
            .ExecuteQuery(
                "select distinct anio_periodo from periodo where activo = true and estatus = 'true' and tipo_captura_id = " +
                idTipoCaptura + " and tipo_proforma_id = " + idTipoProforma + " and anio_periodo=" + anio)
            .Rows.Count > 0);
 }
        public IEnumerable <Proyecto> GetAllProyectos()
        {
            string cadena = " select * from proyecto "
                            + "  where  activo  = true order by id desc";

            try
            {
                List <Proyecto> lstProyecto = new List <Proyecto>();

                {
                    NpgsqlCommand cmd = new NpgsqlCommand(cadena, con);
                    con.Open();
                    NpgsqlDataReader rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        Proyecto proyecto = new Proyecto();

                        proyecto.id                 = Convert.ToInt64(rdr["id"]);
                        proyecto.desc_id            = rdr["desc_id"].ToString().Trim();
                        proyecto.nombre             = rdr["nombre"].ToString().Trim();
                        proyecto.activo             = Convert.ToBoolean(rdr["activo"]);
                        proyecto.responsable        = rdr["responsable"].ToString().Trim();
                        proyecto.estatus            = rdr["estatus"].ToString().Trim();
                        proyecto.fecha_modificacion = Convert.ToDateTime(rdr["fecha_modificacion"]);

                        DataTable dataTable = _queryExecuter.ExecuteQuery(
                            "select e.desc_id from empresa_proyecto empr join empresa e on empr.empresa_id = e.id " +
                            " where empr.activo=true and e.activo=true and  empr.proyecto_id=@id",
                            new NpgsqlParameter("@id", proyecto.id));
                        String desIdsEmpresas = "";
                        foreach (DataRow row in dataTable.Rows)
                        {
                            desIdsEmpresas += row["desc_id"] + " ";
                        }

                        proyecto.idsempresas = desIdsEmpresas;

                        lstProyecto.Add(proyecto);
                    }
                    con.Close();
                }

                return(lstProyecto);
            }
            catch
            {
                con.Close();
                throw;
            }
            finally
            {
                con.Close();
            }
        }
示例#4
0
        public byte[] buildReport(ReportesRequest request)
        {
            string    queryReporte    = _queryExecuter.ExecuteQueryUniqueresult("select contenido from reportes where id=" + request.idReporte)["contenido"].ToString();
            DataTable dataTableParams = _queryExecuter.ExecuteQuery("select * from reportes_parametros where id_reporte=" + request.idReporte);
            Dictionary <string, string> claveTipoParam = new Dictionary <string, string>();

            foreach (DataRow parametroRow in dataTableParams.Rows)
            {
                claveTipoParam.Add(parametroRow["clave"].ToString(), parametroRow["tipo"].ToString());
            }
            foreach (var parametro in request.parametros)
            {
                string claveParametro = parametro.Key;
                string valorParametro = parametro.Value;

                if (claveTipoParam[claveParametro].Equals("text") || claveTipoParam[claveParametro].Equals("date"))
                {
                    if (valorParametro.Trim().Length == 0)
                    {
                        valorParametro = "null";
                    }
                    else
                    {
                        valorParametro = $"'{valorParametro}'";
                    }
                }
                else
                {
                    if (valorParametro.Trim().Length == 0)
                    {
                        valorParametro = "null";
                    }
                }


                queryReporte = queryReporte.Replace($"${claveParametro}", $"{valorParametro}");
            }

            DataTable dataTable = _queryExecuter.ExecuteQuery(queryReporte);
            var       package   = new ExcelPackage();
            var       workSheet = package.Workbook.Worksheets.Add("Reporte");

            workSheet.Cells["A1"].LoadFromDataTable(dataTable, true);
            ExcelRange rowEncabezado = workSheet.Cells[1, 1, 1, workSheet.Dimension.End.Column];

            rowEncabezado.Style.Font.Color.SetColor(Color.White);
            rowEncabezado.Style.Font.Bold        = true;
            rowEncabezado.Style.Fill.PatternType = ExcelFillStyle.Solid;
            rowEncabezado.Style.Fill.BackgroundColor.SetColor(Color.Blue);
            workSheet.Cells[workSheet.Dimension.Address].AutoFitColumns();
            return(package.GetAsByteArray());
        }
示例#5
0
        public List <Empresa> GetAllEmpresas()
        {
            //string cadena = "select *from empresa where  activo = " + true;
            string cadena = "select id,activo,nombre,abrev,bd_name," +
                            //"contrasenia_etl," +
                            "desc_id,etl,fec_modif,host,puerto_compania,usuario_etl,moneda_id from empresa where activo = true order by id desc";
            DataTable      dataTable  = _queryExecuter.ExecuteQuery(cadena);
            List <Empresa> lstempresa = new List <Empresa>();

            foreach (DataRow rdr in dataTable.Rows)
            {
                Empresa empresa = new Empresa();
                empresa.id      = Convert.ToInt32(rdr["id"]);
                empresa.desc_id = rdr["desc_id"].ToString().Trim();
                empresa.activo  = Convert.ToBoolean(rdr["activo"]);
                empresa.nombre  = rdr["nombre"].ToString().Trim();
                empresa.abrev   = rdr["abrev"].ToString().Trim();
                empresa.bd_name = rdr["bd_name"].ToString().Trim();
                //empresa.contrasenia_etl = rdr["contrasenia_etl"].ToString().Trim();
                empresa.etl             = Convert.ToBoolean(rdr["etl"]);
                empresa.fec_modif       = Convert.ToDateTime(rdr["fec_modif"]);
                empresa.host            = rdr["host"].ToString().Trim();
                empresa.puerto_compania = Convert.ToInt32(rdr["puerto_compania"]);
                empresa.usuario_etl     = rdr["usuario_etl"].ToString().Trim();
                empresa.moneda_id       = Convert.ToInt32(rdr["moneda_id"]);
                lstempresa.Add(empresa);
            }
            return(lstempresa);
        }
示例#6
0
        public List <ModeloUnidadNegocio> findAll()
        {
            DataTable dataTable =
                _queryExecuter.ExecuteQuery("select id_unidad,id_modelo,activo from modelo_unidad where activo=true ");
            List <ModeloUnidadNegocio> modeloUnidadNegocios = new List <ModeloUnidadNegocio>();

            foreach (DataRow rdr in dataTable.Rows)
            {
                ModeloUnidadNegocio modeloUnidadNegocio = new ModeloUnidadNegocio();
                modeloUnidadNegocio.idModelo = Convert.ToInt64(rdr["id_modelo"]);
                modeloUnidadNegocio.idUnidad = Convert.ToInt64(rdr["id_unidad"]);
                modeloUnidadNegocio.activo   = Convert.ToBoolean(rdr["activo"]);
                modeloUnidadNegocios.Add(modeloUnidadNegocio);
            }
            return(modeloUnidadNegocios);
        }
        public IEnumerable <RelacionRol> GetAllRelacionRol()
        {
            string query =
                " select relrol.*,cr.str_nombre_rol as nombrerol" +
                " from tab_relacion_rol relrol join cat_rol cr on relrol.idrol = cr.int_idrol_p" +
                " where relrol.estatus_logico = true" +
                " order by relrol.id, relrol.pantalla, relrol.permiso";

            List <RelacionRol> lstRelacionRol = new List <RelacionRol>();

            foreach (DataRow rdr in _queryExecuter.ExecuteQuery(query).Rows)
            {
                RelacionRol relacionRol = new RelacionRol();
                relacionRol.id        = Convert.ToInt32(rdr["id"]);
                relacionRol.idRol     = Convert.ToInt32(rdr["idrol"]);
                relacionRol.nombreRol = Convert.ToString(rdr["nombrerol"]);
                relacionRol.estatus   = Convert.ToBoolean(rdr["estatus_logico"]);
                relacionRol.fecModif  = Convert.ToDateTime(rdr["fec_modif"]);
                relacionRol.permiso   = Convert.ToString(rdr["permiso"]);
                relacionRol.pantalla  = Convert.ToString(rdr["pantalla"]);
                lstRelacionRol.Add(relacionRol);
            }

            return(lstRelacionRol);
        }
        public List <UnidadNegocio> GetAllUnidadNegocioWithModelo()
        {
            List <UnidadNegocio> lstUnidadNegocio = new List <UnidadNegocio>();
            DataTable            dataTable        = queryExecuter.ExecuteQuery("select distinct un.* " +
                                                                               " from unidad_negocio un " +
                                                                               "    join modelo_unidad mu on un.id = mu.id_unidad and mu.activo = true " +
                                                                               " join modelo_negocio mn on mu.id_modelo = mn.id and mn.activo = true " +
                                                                               " join centro_costo cc on mn.id = cc.modelo_negocio_id and cc.activo=true " +
                                                                               " where un.activo = true");

            foreach (DataRow rdr in dataTable.Rows)
            {
                UnidadNegocio unidadNegocio = new UnidadNegocio();
                unidadNegocio.id          = Convert.ToInt64(rdr["id"]);
                unidadNegocio.descripcion = (rdr["descripcion"]).ToString();
                lstUnidadNegocio.Add(unidadNegocio);
            }

            return(lstUnidadNegocio);
        }
        public int Update(string id, Modelo_Negocio modeloNegocio)
        {
            Object agrupador =
                _queryExecuter.ExecuteQueryUniqueresult("select agrupador from modelo_negocio where id=@id",
                                                        new NpgsqlParameter("@id", Convert.ToInt64(id)))["agrupador"];

            DataTable dataTable = _queryExecuter.ExecuteQuery(
                "select mn.id from modelo_negocio mn" +
                " where mn.activo=true and mn.agrupador=@agrupador",
                new NpgsqlParameter("@agrupador", agrupador.ToString()));

            int co = 0;

            foreach (DataRow modeloIdRow in dataTable.Rows)
            {
                Int64 modeloId = Convert.ToInt64(modeloIdRow["id"]);
                co += UpdateModelo(modeloId, modeloNegocio);
            }

            return(co);
        }
示例#10
0
        public Dictionary <string, string> configCrons()
        {
            DataTable dataTable             = _queryExecuter.ExecuteQuery("select clave,cron_expresion from programacion_proceso");
            Dictionary <string, string> res = new Dictionary <string, string>();

            foreach (DataRow rdr in dataTable.Rows)
            {
                res.Add(rdr["clave"].ToString(), rdr["cron_expresion"].ToString());
            }

            return(res);
        }
        public List <ProgramacionProceso> GetAll()
        {
            string cadena = "select clave,descripcion,cron_expresion,id_usuario from programacion_proceso";
            List <ProgramacionProceso> programacionProcesos = new List <ProgramacionProceso>();

            {
                DataTable dataTable = _queryExecuter.ExecuteQuery(cadena);
                foreach (DataRow row in dataTable.Rows)
                {
                    programacionProcesos.Add(transform(row));
                }
            }
            return(programacionProcesos);
        }
示例#12
0
        public List <RelacionUsrEmprUniCentro> findAll()
        {
            List <RelacionUsrEmprUniCentro> result = new List <RelacionUsrEmprUniCentro>();
            DataTable dataTable = _queryExecuter.ExecuteQuery(
                "select rel.*," +
                " usr.user_name," +
                " '(' || emp.desc_id || ')' || emp.nombre as empresa," +
                " un.descripcion                          as unidad," +
                " '(' || cc.desc_id || ')' || cc.nombre   as centro" +
                " from relacion_usr_emp_uni_cc rel" +
                " join tab_usuario usr on usr.id = rel.id_usuario" +
                " join empresa emp on emp.id = rel.id_empresa" +
                " join unidad_negocio un on un.id = rel.id_unidad" +
                " join centro_costo cc on cc.id = rel.id_centrocosto" +
                " where rel.activo = true");

            foreach (DataRow row in dataTable.Rows)
            {
                result.Add(transform(row));
            }

            return(result);
        }
        public void ResetDatabase()
        {
            // Get the current directory
            string directory = Directory.GetCurrentDirectory();
            // Set the correct path to the file
            int    index = directory.IndexOf("ProjectSCAM.Tests");
            string path  = directory.Remove(index) + "\\ProjectSCAM.Tests\\Logic\\DB_SQL.txt";

            if (File.Exists(path))
            {
                // Read the file
                string query = File.ReadAllText(path);
                // Execute the query
                bool success = exe.ExecuteQuery(query);
                // Check
                Assert.IsTrue(success);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
示例#14
0
        public List <ProformaDetalle> GetProformaDetalle(Int64 idProforma)
        {
            string consulta = "";

            consulta += " select ";
            consulta += "   det.id, det.id_proforma, det.rubro_id, rub.nombre as nombre_rubro,rub.hijos,rub.aritmetica, rub.clave,rub.es_total_ingresos,";
            consulta += "   coalesce(ejercicio_resultado, 0) as ejercicio_resultado, ";
            consulta += "   coalesce(enero_monto_resultado, 0) as enero_monto_resultado, ";
            consulta += "   coalesce(febrero_monto_resultado, 0) as febrero_monto_resultado, ";
            consulta += "   coalesce(marzo_monto_resultado, 0) as marzo_monto_resultado, ";
            consulta += "   coalesce(abril_monto_resultado, 0) as abril_monto_resultado, ";
            consulta += "   coalesce(mayo_monto_resultado, 0) as mayo_monto_resultado, ";
            consulta += "   coalesce(junio_monto_resultado, 0) as junio_monto_resultado, ";
            consulta += "   coalesce(julio_monto_resultado, 0) as julio_monto_resultado, ";
            consulta += "   coalesce(agosto_monto_resultado, 0) as agosto_monto_resultado, ";
            consulta += "   coalesce(septiembre_monto_resultado, 0) as septiembre_monto_resultado, ";
            consulta += "   coalesce(octubre_monto_resultado, 0) as octubre_monto_resultado, ";
            consulta += "   coalesce(noviembre_monto_resultado, 0) as noviembre_monto_resultado, ";
            consulta += "   coalesce(diciembre_monto_resultado, 0) as diciembre_monto_resultado, ";
            consulta += "   coalesce(total_resultado, 0) as total_resultado, ";
            consulta += "   coalesce(acumulado_resultado, 0) as acumulado_resultado, ";
            consulta += "   coalesce(valor_tipo_cambio_resultado, 0) as valor_tipo_cambio_resultado ";
            consulta += " from proforma_detalle det ";
            consulta += " inner join rubro rub on det.rubro_id = rub.id ";
            consulta += " where id_proforma = " + idProforma;
            consulta += " and det.activo = 'true' ";


            List <ProformaDetalle> lstProformaDetalle = new List <ProformaDetalle>();

            DataTable dataTable = _queryExecuter.ExecuteQuery(consulta.Trim());

            foreach (DataRow rdr in dataTable.Rows)
            {
                ProformaDetalle proforma_detalle = new ProformaDetalle();
                proforma_detalle.id                          = ToInt64(rdr["id"]);
                proforma_detalle.id_proforma                 = ToInt64(rdr["id_proforma"]);
                proforma_detalle.rubro_id                    = ToInt64(rdr["rubro_id"]);
                proforma_detalle.nombre_rubro                = Convert.ToString(rdr["nombre_rubro"]);
                proforma_detalle.aritmetica                  = Convert.ToString(rdr["aritmetica"]);
                proforma_detalle.es_total_ingresos           = ToBoolean(rdr["es_total_ingresos"]);
                proforma_detalle.ejercicio_resultado         = ToDouble(rdr["ejercicio_resultado"]);
                proforma_detalle.enero_monto_resultado       = ToDouble(rdr["enero_monto_resultado"]);
                proforma_detalle.febrero_monto_resultado     = ToDouble(rdr["febrero_monto_resultado"]);
                proforma_detalle.marzo_monto_resultado       = ToDouble(rdr["marzo_monto_resultado"]);
                proforma_detalle.abril_monto_resultado       = ToDouble(rdr["abril_monto_resultado"]);
                proforma_detalle.mayo_monto_resultado        = ToDouble(rdr["mayo_monto_resultado"]);
                proforma_detalle.junio_monto_resultado       = ToDouble(rdr["junio_monto_resultado"]);
                proforma_detalle.julio_monto_resultado       = ToDouble(rdr["julio_monto_resultado"]);
                proforma_detalle.agosto_monto_resultado      = ToDouble(rdr["agosto_monto_resultado"]);
                proforma_detalle.septiembre_monto_resultado  = ToDouble(rdr["septiembre_monto_resultado"]);
                proforma_detalle.octubre_monto_resultado     = ToDouble(rdr["octubre_monto_resultado"]);
                proforma_detalle.noviembre_monto_resultado   = ToDouble(rdr["noviembre_monto_resultado"]);
                proforma_detalle.diciembre_monto_resultado   = ToDouble(rdr["diciembre_monto_resultado"]);
                proforma_detalle.total_resultado             = ToDouble(rdr["total_resultado"]);
                proforma_detalle.acumulado_resultado         = ToDouble(rdr["acumulado_resultado"]);
                proforma_detalle.valor_tipo_cambio_resultado = ToDouble(rdr["valor_tipo_cambio_resultado"]);
                //proforma_detalle.activo = ToBoolean(rdr["activo"]);
                proforma_detalle.hijos       = rdr["hijos"].ToString();
                proforma_detalle.clave_rubro = rdr["clave"].ToString();

                lstProformaDetalle.Add(proforma_detalle);
            }

            Proforma pro = _proformaDataAccessLayer.GetProforma(idProforma);
            Boolean  hayPeriodoActivo =
                _profHelper.existePeridodoActivo(pro.anio, pro.tipo_proforma_id, pro.tipo_captura_id);

            Int64 idEmpresa =
                ToInt64(_queryExecuter.ExecuteQueryUniqueresult(
                            "select empresa_id from centro_costo where id =" + pro.centro_costo_id)["empresa_id"]);

            List <ProformaDetalle> detallesAniosPosteriores = GetEjercicioPosterior(pro.anio, pro.centro_costo_id,
                                                                                    pro.modelo_negocio_id, pro.tipo_captura_id, pro.tipo_proforma_id);

            lstProformaDetalle.ForEach(detalle =>
            {
                detalle.editable          = hayPeriodoActivo;
                detalle.mes_inicio        = _profHelper.getMesInicio(pro.tipo_proforma_id);
                detalle.modelo_negocio_id = pro.modelo_negocio_id;
                detalle.anio             = pro.anio;
                detalle.centro_costo_id  = pro.centro_costo_id;
                detalle.tipo_proforma_id = pro.tipo_proforma_id;
                detalle.tipo_captura_id  = pro.tipo_captura_id;
                detalle.empresa_id       = idEmpresa;
                detalle.unidad_id        = pro.unidad_id;
                detallesAniosPosteriores.ForEach(posterior =>
                {
                    if (detalle.rubro_id == posterior.rubro_id)
                    {
                        detalle.anios_posteriores_resultado = posterior.anios_posteriores_resultado;
                    }
                });
            });

            return(_profHelper.reorderConceptos(lstProformaDetalle));
        }
        public int update(string id, CentroCostos centroCostos)
        {
            String updateSegmentModelo = "";

            if (centroCostos.modelo_negocio_id > 0)
            {
                DataTable dataTable =
                    _queryExecuter.ExecuteQuery("select agrupador from modelo_negocio where id=" +
                                                centroCostos.modelo_negocio_id);
                Object agrupador = dataTable.Rows[0]["agrupador"];
                dataTable = _queryExecuter.ExecuteQuery(
                    "select mn.id,mn.tipo_captura_id  from modelo_negocio mn" +
                    " where mn.activo=true and mn.agrupador='" + agrupador + "'");
                foreach (DataRow modeloIdRow in dataTable.Rows)
                {
                    Int64 modeloId      = Convert.ToInt64(modeloIdRow["id"]);
                    Int64 tipocapturaId = Convert.ToInt64(modeloIdRow["tipo_captura_id"]);
                    if (tipocapturaId == TipoCapturaContable)
                    {
                        updateSegmentModelo += " modelo_negocio_id=" + modeloId + ",";
                    }
                    else if (tipocapturaId == TipoCapturaFlujo)
                    {
                        updateSegmentModelo += "modelo_negocio_flujo_id=" + modeloId + ",";
                    }
                }
            }

            string update = " update  centro_costo set " +
                            updateSegmentModelo +
                            " tipo = @tipo  ," +
                            " desc_id = @desc_id ," +
                            " nombre  =  @nombre ," +
                            " categoria =  @categoria ," +
                            " estatus =   @estatus ," +
                            " gerente =  @gerente ," +
                            " empresa_id =  @empresa_id ," +
                            " fecha_modificacion =  @fecha_modificacion ," +
                            " porcentaje =  @porcentaje ," +
                            " proyeccion =  @proyeccion " +
                            " where id = " + id;


            {
                try
                {
                    NpgsqlCommand cmd = new NpgsqlCommand(update, con);

                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@tipo", Value = centroCostos.tipo
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@desc_id", Value = centroCostos.desc_id
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@nombre", Value = centroCostos.nombre
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@categoria", Value = centroCostos.categoria
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@estatus", Value = centroCostos.estatus
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@gerente", Value = centroCostos.gerente
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer, ParameterName = "@empresa_id", Value = centroCostos.empresa_id
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Date, ParameterName = "@fecha_modificacion", Value = DateTime.Now
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Double, ParameterName = "@porcentaje", Value = centroCostos.porcentaje / 100
                    });
                    cmd.Parameters.Add(new NpgsqlParameter()
                    {
                        NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text, ParameterName = "@proyeccion", Value = centroCostos.proyeccion
                    });

                    con.Open();
                    int cantFilas = cmd.ExecuteNonQuery();
                    con.Close();
                    return(cantFilas);
                }
                catch
                {
                    con.Close();
                    throw;
                }
            }
        }
 protected virtual CellSetData GetDescription(String query)
 {
     System.Diagnostics.Trace.TraceInformation("Ranet.Olap.Core.Providers.OlapProvider execute MDX query: {0} \r\n", query);
     return(QueryExecuter.ExecuteQuery(query));
 }