예제 #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);
            }
        }
예제 #2
0
        // METHOD HEADER COMMENT -------------------------------------------------------------------------------

        /**
         *   \fn          GenericFunction
         *   \brief       This method will be called if for a generic query
         *   \param[in]   string Query
         *   \param[out]  none
         *   \return      bool
         * ---------------------------------------------------------------------------------------------------- */
        public static bool GenericFunction(string Query)
        {
            try
            {
                //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" + " | " + "GenericFunction" + " | " + "Confirmation" + " | " + "Query executed successfully" + " | ");
                return(true);
            }
            catch (Exception e)
            {
                TMSLogger.LogIt(" | " + "SQL.cs" + " | " + "SQL" + " | " + "GenericFunction" + " | " + e.GetType().ToString() + " | " + e.Message + " | ");
                return(false);
            }
        }