SqlitePerson.Select C# (CSharp) Method

Select() public static method

public static Select ( bool dbconOpened, int uniqueID ) : Person,
dbconOpened bool
uniqueID int
return Person,
    public static Person Select(bool dbconOpened, int uniqueID)
    {
        if(! dbconOpened)
            Sqlite.Open();

        dbcmd.CommandText = "SELECT * FROM " + Constants.PersonTable + " WHERE uniqueID == " + uniqueID;

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

        SqliteDataReader reader;
        reader = dbcmd.ExecuteReader();

        Person p = new Person(-1);
        if(reader.Read()) {
            p = new Person(
                    Convert.ToInt32(reader[0].ToString()), //uniqueID
                    reader[1].ToString(), 			//name
                    reader[2].ToString(), 			//sex
                    UtilDate.FromSql(reader[3].ToString()),//dateBorn
                    Convert.ToInt32(reader[4].ToString()), //race
                    Convert.ToInt32(reader[5].ToString()), //countryID
                    reader[6].ToString(), 			//description
                    Convert.ToInt32(reader[9].ToString()) //serverUniqueID
                    );
        }
        reader.Close();
        if(! dbconOpened)
            Sqlite.Close();

        return p;
    }

Same methods

SqlitePerson::Select ( int uniqueID ) : Person,

Usage Example

Exemplo n.º 1
0
    private Person personDeserialize(string strPerson)
    {
        JsonValue jsonPerson = JsonValue.Parse(strPerson);

        Int32  id     = jsonPerson ["id"];
        string player = jsonPerson ["name"];
        double weight = jsonPerson ["weight"];
        double height = jsonPerson ["height"];
        string rfid   = jsonPerson ["rfid"];
        string image  = jsonPerson ["imageName"];

        LastPersonByRFIDHeight   = height;
        LastPersonByRFIDWeight   = weight;
        LastPersonByRFIDImageURL = image;

        Person personTemp = SqlitePerson.Select(false, id);

        /*
         * if personTemp == -1, need to insert this person
         * LastPersonWasInserted will be used:
         *  to insert person at person.cs
         *  to know if (it's new person or RFID changed) at gui/networks.cs
         */
        LastPersonWasInserted = (personTemp.UniqueID == -1);

        return(new Person(LastPersonWasInserted, id, player, rfid));
    }