SQLBuildQueryString() 공개 정적인 메소드

public static SQLBuildQueryString ( string tableName, string test, string variable, int sex, string ageInterval, int countryID, int sportID, int speciallityID, int levelID, int evaluatorID ) : string
tableName string
test string
variable string
sex int
ageInterval string
countryID int
sportID int
speciallityID int
levelID int
evaluatorID int
리턴 string
    public string Query(string tableName, string test, string variable,
                        int sex, string ageInterval,
                        int countryID, int sportID, int speciallityID, int levelID, int evaluatorID)
    {
        string str = Sqlite.SQLBuildQueryString(tableName, test, variable,
                                                sex, ageInterval,
                                                countryID, sportID, speciallityID, levelID, evaluatorID
                                                );

        return(SqliteServer.Query(str));
    }
예제 #2
0
    string sqlBuildSelect(bool performQuery)
    {
        string testType  = UtilGtk.ComboGetActive(combo_test_types);
        string tableName = "";

        if (testType == Catalog.GetString(Constants.JumpSimpleName))
        {
            tableName = Constants.JumpTable;
        }
        else if (testType == Catalog.GetString(Constants.JumpReactiveName))
        {
            tableName = Constants.JumpRjTable;
        }
        else if (testType == Catalog.GetString(Constants.RunSimpleName))
        {
            tableName = Constants.RunTable;
        }
        else
        {
            new DialogMessage(Constants.MessageTypes.WARNING, "Problem on sqlBuildSelect");
            return("");
        }

        string strVariable = UtilGtk.ComboGetActive(combo_variables);

        if (strVariable == Constants.DjIndexFormula)
        {
            strVariable = Constants.DjIndexFormulaOnly;
        }
        else if (strVariable == Constants.QIndexFormula)
        {
            strVariable = Constants.QIndexFormulaOnly;
        }
        else if (strVariable == Catalog.GetString("Average Index"))
        {
            strVariable = Constants.RjIndexFormulaOnly;
        }
        else if (strVariable == Constants.RJPotencyBoscoFormula)
        {
            strVariable = Constants.RJPotencyBoscoFormulaOnly;
        }

        /*
         * as in server maybe Catalog locale is different than in client
         * we cannot pass a localized "Any" hoping that will match server.
         * then if it's any, pass "" (if string) or corresponding undefined ID (if int)
         */

        int sexID = Constants.AnyID;

        if (UtilGtk.ComboGetActive(combo_sexes) == Catalog.GetString(Constants.Males))
        {
            sexID = Constants.MaleID;
        }
        else if (UtilGtk.ComboGetActive(combo_sexes) == Catalog.GetString(Constants.Females))
        {
            sexID = Constants.FemaleID;
        }

        /*
         * ageInterval can be:
         * "" -> any ages
         * ">=|30" -> higher or equal than 30
         * ">=|30|< |40" -> higher or equal than 30 and lower than 40
         */

        string ageInterval = "";
        string age1        = UtilGtk.ComboGetActive(combo_ages1);

        if (age1 != "" && age1 != Catalog.GetString(Constants.Any))
        {
            ageInterval  = age1.Substring(0, 2);           //get the code
            ageInterval += ":" + spin_ages1.Value.ToString();

            string age2 = UtilGtk.ComboGetActive(combo_ages2);
            if (age2 != "" && age2 != Catalog.GetString(Constants.Any))
            {
                ageInterval += ":" + age2.Substring(0, 2);                //get the code
                ageInterval += ":" + spin_ages2.Value.ToString();
            }
        }

        try {
            string sqlString = Sqlite.SQLBuildQueryString(
                tableName,
                UtilGtk.ComboGetActive(combo_tests),
                strVariable,
                sexID,
                ageInterval,
                Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries)),
                Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports)),
                Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
                Util.FetchID(UtilGtk.ComboGetActive(combo_levels)),
                Util.FetchID(UtilGtk.ComboGetActive(combo_evaluators))
                );

            if (performQuery)
            {
                ChronojumpServer myServer = new ChronojumpServer();
                myServer.ConnectDatabase();
                string result = myServer.Query(
                    tableName,
                    UtilGtk.ComboGetActive(combo_tests),
                    strVariable,
                    sexID,
                    ageInterval,
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_countries), countries)),
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports)),
                    Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_speciallities), speciallities)),
                    Util.FetchID(UtilGtk.ComboGetActive(combo_levels)),
                    Util.FetchID(UtilGtk.ComboGetActive(combo_evaluators))
                    );
                myServer.DisConnectDatabase();

                string [] resultFull = result.Split(new char[] { ':' });
                label_results_num.Text = resultFull[0];

                printUnits(resultFull[0]);

                if (resultFull[0] == "0")
                {
                    label_results_avg.Text = "-";
                }
                else
                {
                    label_results_avg.Text = Util.TrimDecimals(
                        Util.ChangeDecimalSeparator(resultFull[1]), pDN);
                }
            }

            return(sqlString);
        } catch {
            //fix problem on changing continent that updates country and two signals come
            //also on run (maybe because there's no data)
            label_results_num.Text = "0";
            label_results_avg.Text = "-";
            printUnits("0");
            return("");
        }
    }