public bool updateSensor(Sensor sensor, string sid)
        {
            string SID, Name, Description, Settings;
            int    id = getIDbySID(sid);

            int count = (int)executeScalar("SELECT COUNT(*) FROM Sensors WHERE ID=" + id);

            if (count == 0)
            {
                return(false);
            }

            SID         = qouted(sensor.SID);
            Name        = qouted(sensor.Name);
            Description = sensor.Description == null ? "NULL" : qouted(sensor.Description);
            Settings    = "'" + ServiceFunctions.serializeProperties(sensor.Settings) + "'";

            string query = "UPDATE SENSORS SET [SID]=" + SID + ", [Name]=" + Name + ", Description=" + Description + ", Settings=" + Settings + " WHERE ID=" + id;

            try
            {
                int res = executeNonQuery(query);
                sensorList = getSensorList();
                return(res > 0);
            }
            catch (Exception ex)
            {
                sensorList = getSensorList();
                throw ex;
            }
        }
        public bool insertSensor(Sensor sensor)
        {
            string SID, Name, Description, Settings;

            int count = (int)executeScalar("SELECT COUNT(*) FROM Sensors WHERE SID='" + sensor.SID + "'");

            if (count > 0)
            {
                return(false);
            }

            SID         = "'" + sensor.SID + "'";
            Name        = "'" + sensor.Name + "'";
            Description = sensor.Description == null ? "NULL" : "'" + sensor.Description + "'";
            Settings    = "'" + ServiceFunctions.serializeProperties(sensor.Settings) + "'";

            string query = "INSERT INTO SENSORS (SID, [Name], Description, Settings) VALUES (" + SID + ", " + Name + ", " + Description + ", " + Settings + ")";

            try
            {
                int res = executeNonQuery(query);
                sensorList = getSensorList();
                return(res > 0);
            }
            catch (Exception ex)
            {
                sensorList = getSensorList();
                throw ex;
            }
        }