using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Windows.Forms;

namespace AdvertsingProfitControl
{
    class AddRecord
    {
        private static string gConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=apcDatabase.accdb;Persist Security Info=False";

        public AddRecord()
        {
            //Get database location from DBLocation class
        }

        public int ExecuteQuery(string query)
        {
            int rowsAffected = -1;
            using (OleDbConnection conn = new OleDbConnection(gConnectionString))
            {
                try
                {
                    OleDbCommand queryCommand = new OleDbCommand(query, conn);
                    conn.Open();
                    rowsAffected = queryCommand.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error Writing to Database");
                }
            }

            return rowsAffected;
        }
    }
}
