Example #1
0
        public void SaveToDatabase(MySqlConnection con)
        {
            ValidateDataBeforeSave();

            if (ID == 0)
            {
                // Insert
                string strCommandText = InsertCommand;

                using (MySqlCommand cmd = new MySqlCommand(strCommandText, con))
                {
                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.Read())
                        {
                            throw new Exception(@"Insert: 'SELECT LAST_INSERT_ID()' seems to have failed");
                        }

                        ID = reader.GetUInt32(0);
                    }
                }

                AdditionalInsertCode(con);
            }
            else
            {
                // Update
                MySqlUtils.ExecuteNonQuery(con, UpdateCommand);

                AdditionalUpdateCode(con);
            }
        }
Example #2
0
        private void DeleteFromDatabase(MySqlConnection con)
        {
            // Assert(FieldID > 0);
            string strCommandText = string.Format(@"DELETE FROM TargetFormFields WHERE FieldID={0};", FieldID);

            MySqlUtils.ExecuteNonQuery(con, strCommandText);
        }
Example #3
0
        private void UpdateInDatabase(MySqlConnection con)
        {
            // Assert(FieldID > 0);
            string strCommandText = string.Format(@"UPDATE TargetFormFields SET TargetID={0}, FieldName={1}, FieldValue={2} WHERE FieldID={3};",
                                                  TargetID,
                                                  MySqlUtils.RawStringToDatabaseString(FieldName),
                                                  MySqlUtils.RawStringToDatabaseString(FieldValue),
                                                  FieldID);

            MySqlUtils.ExecuteNonQuery(con, strCommandText);
        }
Example #4
0
        public void DeleteFromDatabase(MySqlConnection con)
        {
            if (ID == 0)
            {
                // This object's data has not yet been inserted into the database table; there is nothing to delete.
                return;
            }

            AdditionalDeleteCode(con);

            MySqlUtils.ExecuteNonQuery(con, DeleteCommand);
        }
Example #5
0
        public void DeleteFromDatabase(MySqlConnection con, UInt32 unTargetID)
        {
            string strCommandText = string.Format(@"DELETE FROM TargetFormFields WHERE TargetID={0};", unTargetID);

            MySqlUtils.ExecuteNonQuery(con, strCommandText);
        }
Example #6
0
        public void UpdateLastTargetLogID(uint unLogID, MySqlConnection con)
        {
            LastTargetLogID = unLogID;

            MySqlUtils.ExecuteNonQuery(con, UpdateLastTargetLogIDCommand);
        }
Example #7
0
        // **** Methods ****

        public void UpdateLastMonitoredAt(DateTime dt, MySqlConnection con)
        {
            LastMonitoredAt = dt;

            MySqlUtils.ExecuteNonQuery(con, UpdateLastMonitoredAtCommand);
        }