Ejemplo n.º 1
0
    public static List <ForceSensorRFD> SelectAll(bool dbconOpened)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "SELECT * FROM " + table + " WHERE code != \"I\"";
        LogB.SQL(dbcmd.CommandText.ToString());
        dbcmd.ExecuteNonQuery();

        SqliteDataReader reader = dbcmd.ExecuteReader();

        List <ForceSensorRFD> l = new List <ForceSensorRFD>();

        while (reader.Read())
        {
            ForceSensorRFD rfd = new ForceSensorRFD(
                reader[0].ToString(),                                                   //code
                Util.IntToBool(Convert.ToInt32(reader[1])),                             //active
                (ForceSensorRFD.Functions)Enum.Parse(
                    typeof(ForceSensorRFD.Functions), reader[2].ToString()),            //function
                (ForceSensorRFD.Types)Enum.Parse(
                    typeof(ForceSensorRFD.Types), reader[3].ToString()),                //type
                Convert.ToInt32(reader[4]),                                             //num1
                Convert.ToInt32(reader[5])                                              //num2
                );
            l.Add(rfd);
        }

        reader.Close();
        closeIfNeeded(dbconOpened);

        return(l);
    }
Ejemplo n.º 2
0
    public static void Insert(bool dbconOpened, ForceSensorRFD rfd)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "INSERT INTO " + table +
                            " (code, active, function, type, num1, num2) VALUES (" + rfd.ToSQLInsertString() + ")";

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

        closeIfNeeded(dbconOpened);
    }
Ejemplo n.º 3
0
    public bool Changed(ForceSensorRFD newRFD)
    {
        if (
            code == newRFD.code && active == newRFD.active &&
            function == newRFD.function && type == newRFD.type &&
            num1 == newRFD.num1 && num2 == newRFD.num2)
        {
            return(false);
        }

        return(true);
    }
Ejemplo n.º 4
0
    public static void Update(bool dbconOpened, ForceSensorRFD rfd)
    {
        openIfNeeded(dbconOpened);

        dbcmd.CommandText = "UPDATE " + table + " SET " +
                            " active = " + Util.BoolToInt(rfd.active).ToString() + "," +
                            " function = \"" + rfd.function.ToString() + "\"" + "," +
                            " type = \"" + rfd.type.ToString() + "\"" + "," +
                            " num1 = " + rfd.num1.ToString() + "," +
                            " num2 = " + rfd.num2.ToString() +
                            " WHERE code = \"" + rfd.code + "\"";

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

        closeIfNeeded(dbconOpened);
    }