public static string SELECT_BY_RANGO(ExpedientInfo from, ExpedientInfo till)
        {
            QueryConditions conditions = new QueryConditions();

            return
                (Expedient.FIELDS(conditions) +
                 Expedient.JOIN(conditions) +
                 Expedient.WHERE(conditions) + @"
			    AND E.""CODIGO"" BETWEEN '"             + from.Codigo + "' AND '" + till.Codigo + "'" + @"
			ORDER BY E.""CODIGO"""            );
        }
        public static string SELECT_SIN_FOMENTO(ETipoExpediente expedientType)
        {
            string lf = nHManager.Instance.GetSQLTable(typeof(moleQule.Store.Data.LineaFomentoRecord));

            QueryConditions conditions = new QueryConditions();

            string query = Expedient.FIELDS(conditions) +
                           Expedient.JOIN(conditions) +
                           Expedient.WHERE(conditions) +
                           " AND E.\"OID\" NOT IN (SELECT LF.\"OID_EXPEDIENTE\"" +
                           "							FROM "+ lf + " AS LF " +
                           "							GROUP BY \"OID_EXPEDIENTE\")"+
                           " AND \"TIPO_EXPEDIENTE\" = " + ((long)expedientType).ToString();

            query += " ORDER BY E.\"CODIGO\"";

            return(query);
        }
        public static string SELECT_BY_TYPE(ETipoExpediente expedientType)
        {
            QueryConditions conditions = new QueryConditions();

            string query =
                Expedient.FIELDS(conditions) +
                Expedient.JOIN(conditions) +
                Expedient.WHERE(conditions);

            if (expedientType != ETipoExpediente.Todos)
            {
                query += " AND E.\"TIPO_EXPEDIENTE\" = " + (long)expedientType;
            }

            query += " ORDER BY E.\"CODIGO\"";

            return(query);
        }
        public static string SELECT(QueryConditions conditions, ExpedientInfo from, ExpedientInfo till)
        {
            string query = string.Empty;

            query = Expedient.FIELDS(conditions) +
                    Expedient.JOIN(conditions) +
                    Expedient.WHERE(conditions);

            if (from != null)
            {
                query += " AND E.\"CODIGO\" >='" + from.Codigo + "'";
            }

            if (till != null)
            {
                query += " AND E.\"CODIGO\" <='" + till.Codigo + "'";
            }

            query += " ORDER BY E.\"CODIGO\"";

            return(query);
        }
        public static string SELECT_FOMENTO(string cod_aduanero,
                                            NavieraInfo naviera,
                                            PuertoInfo p_origen,
                                            PuertoInfo p_destino,
                                            DateTime from,
                                            DateTime till)
        {
            QueryConditions conditions = new QueryConditions();

            string query = Expedient.FIELDS(conditions) +
                           Expedient.JOIN(conditions) +
                           Expedient.WHERE(conditions) +
                           " AND E.\"FECHA_CONOCIMIENTO\" >= '" + from.ToString("MM/dd/yyyy") + "'" +
                           " AND E.\"FECHA_CONOCIMIENTO\" <= '" + till.ToString("MM/dd/yyyy") + "'";

            if (cod_aduanero != string.Empty)
            {
                query += " AND E.\"CODIGO_ARTICULO\" = '" + cod_aduanero + "'";
            }
            if (naviera != null)
            {
                query += " AND E.\"OID_NAVIERA\" = " + naviera.Oid;
            }
            if (p_origen != null)
            {
                query += " AND E.\"PUERTO_ORIGEN\" = '" + p_origen.Valor + "'";
            }
            if (p_destino != null)
            {
                query += " AND E.\"PUERTO_DESTINO\" = '" + p_destino.Valor + "'";
            }

            query += " ORDER BY E.\"CODIGO\"";

            return(query);
        }
        public static string SELECT_BY_ACREEDOR(ETipoAcreedor expedientType, long oid)
        {
            string tabla = nHManager.Instance.GetSQLTable(typeof(moleQule.Store.Data.ExpedientRecord));

            QueryConditions conditions = new QueryConditions();

            string query =
                Expedient.FIELDS(conditions) +
                Expedient.JOIN(conditions) +
                Expedient.WHERE(conditions);

            switch (expedientType)
            {
            case ETipoAcreedor.Despachante:
                query = " AND \"OID_DESPACHANTE\" = " + oid;
                break;

            case ETipoAcreedor.Naviera:
                query = " AND \"OID_NAVIERA\" = " + oid;
                break;

            case ETipoAcreedor.Proveedor:
                query = " AND \"OID_PROVEEDOR\" = " + oid;
                break;

            case ETipoAcreedor.TransportistaOrigen:
                query = " AND \"OID_TRANS_ORIGEN\" = " + oid;
                break;

            case ETipoAcreedor.TransportistaDestino:
                query = " AND \"OID_TRANS_DESTINO\" = " + oid;
                break;
            }

            return(query);
        }