SqliteRunIntervalType.SelectRunIntervalTypesNew C# (CSharp) Method

SelectRunIntervalTypesNew() public static method

public static SelectRunIntervalTypesNew ( string allRunsName, bool onlyName ) : List
allRunsName string
onlyName bool
return List
    public static List<object> SelectRunIntervalTypesNew(string allRunsName, bool onlyName)
    {
        Sqlite.Open();
        dbcmd.CommandText = "SELECT * " +
            " FROM " + Constants.RunIntervalTypeTable +
            " ORDER BY uniqueID";

        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        List<object> types = new List<object>();

        SelectRunITypes type;
        if(allRunsName != "") {
            type = new SelectRunITypes(allRunsName);
            types.Add(type);
        }

        while(reader.Read()) {
            if(onlyName) {
                type = new SelectRunITypes(reader[1].ToString());
            } else {
                type = new SelectRunITypes(
                        Convert.ToInt32(reader[0]), 	//uniqueID
                        reader[1].ToString(),		//nameEnglish
                        Convert.ToDouble(Util.ChangeDecimalSeparator(reader[2].ToString())), 	//distance
                        Util.IntToBool(Convert.ToInt32(reader[3].ToString())), 	//tracksLimited
                        Convert.ToInt32(reader[4].ToString()), 			//fixedValue
                        Util.IntToBool(Convert.ToInt32(reader[5].ToString())), 	//unlimited
                        reader[6].ToString(),					//description
                        Util.ChangeDecimalSeparator(reader[7].ToString())	//distancesString
                        );
            }
            types.Add(type);
        }

        reader.Close();
        Sqlite.Close();

        return types;
    }

Usage Example

Example #1
0
    private void createTreeView_runs_interval_sprint(Gtk.TreeView tv)
    {
        LogB.Information("SPRINT create START");
        UtilGtk.RemoveColumns(tv);
        button_sprint.Sensitive            = false;
        image_sprint.Sensitive             = false;
        button_sprint_save_image.Sensitive = false;

        tv.HeadersVisible = true;

        int count = 0;

        tv.AppendColumn(Catalog.GetString("Type"), new CellRendererText(), "text", count++);
        tv.AppendColumn("ID", new CellRendererText(), "text", count++);
        tv.AppendColumn(Catalog.GetString("Distances"), new CellRendererText(), "text", count++);
        tv.AppendColumn(Catalog.GetString("Split times"), new CellRendererText(), "text", count++);
        tv.AppendColumn(Catalog.GetString("Total time"), new CellRendererText(), "text", count++);

        storeSprint = new TreeStore(
            typeof(string), typeof(string), typeof(string),
            typeof(string), typeof(string));
        tv.Model = storeSprint;

        if (currentSession == null || currentPerson == null)
        {
            return;
        }

        tv.Selection.Changed -= onTreeviewSprintSelectionEntry;
        tv.Selection.Changed += onTreeviewSprintSelectionEntry;

        List <object> runITypes = SqliteRunIntervalType.SelectRunIntervalTypesNew("", false);

        string [] runsArray = SqliteRunInterval.SelectRuns(
            false, currentSession.UniqueID, currentPerson.UniqueID, "");

        foreach (string line in runsArray)
        {
            //[] lineSplit has run params
            string [] lineSplit = line.Split(new char[] { ':' });

            //get intervalTimes
            string intervalTimesString = lineSplit[8];

            string positions = getSprintPositions(
                Convert.ToDouble(lineSplit[7]),                         //distanceInterval. == -1 means variable distances
                intervalTimesString,
                runIntervalTypeDistances(lineSplit[4], runITypes)       //distancesString
                );
            if (positions == "")
            {
                continue;
            }

            string splitTimes = getSplitTimes(intervalTimesString);

            string [] lineParams =
            {
                lineSplit[4],
                lineSplit[1],
                positions,
                splitTimes,
                Util.TrimDecimals(lineSplit[6], preferences.digitsNumber)
            };
            storeSprint.AppendValues(lineParams);
        }
        LogB.Information("SPRINT create END");
    }
All Usage Examples Of SqliteRunIntervalType::SelectRunIntervalTypesNew