Example #1
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *   \fn            Insert
         *   \brief         this method will be able to insert into any table that using the corresponding
         *                  ParentTable
         *   \param[in]     ParentTable input
         *   \param[out]    none
         *   \return        bool
         * ---------------------------------------------------------------------------------------------------- */
        public static bool Insert(ParentTable input)
        {
            try
            {
                //get the insert statement
                string query = input.GetInsertStatment();

                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, connection);

                //Execute command
                if (cmd.ExecuteNonQuery() > 0)
                {
                    TMSBackup.WriteQueryToCurrentFile(new TMSBackupQuery(query));
                }

                TMSLogger.LogIt(" | " + "SQL.cs" + " | " + "SQL" + " | " + "Insert" + " | " + "Confirmation" + " | " + "Data inserted into SQL database" + " | ");
                return(true);
            }
            catch (Exception e)
            {
                //logit
                TMSLogger.LogIt(" | " + "SQL.cs" + " | " + "SQL" + " | " + "Insert" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
                return(false);
            }
        }