using System;
using System.Data;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace HorseRacing
{
    public partial class Form1 : Form
    {
        private MySqlConnection conn;
        private string connectionString = "server=localhost;port=3306;username=root;password=root;database=HorseRacingDB";
        public MySqlConnection GetDBConnection()
        {
            return conn;
        }

        public string GetDBConnectionString()
        {
            return connectionString;
        }

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            conn = new MySqlConnection(connectionString);
            conn.Open();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            conn.Close();
        }

        private void ExecuteQuery(string query)
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand(query, conn);
                MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error executing query: " + ex.Message);
            }
        }

        // Button click event handler to open OwnerForm for data entry
        private void BtnAddOwner_Click(object sender, EventArgs e)
        {
            OwnerForm ownerForm = new OwnerForm(this);  // Create an instance of OwnerForm
            ownerForm.ShowDialog();  // Display the OwnerForm as a modal dialog
        }

        private void BtnAddHorses_Click(object sender, EventArgs e)
        {
            HorsesForm horsesForm = new HorsesForm(this);  // Create an instance of HorsesForm
            horsesForm.ShowDialog();
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            string query = "SELECT * FROM Owners " +
                           "WHERE OwnerID IN(" +
                           "SELECT OwnerID FROM Horses " +
                           "GROUP BY OwnerID " +
                           "HAVING COUNT(*) > 1)";
            ExecuteQuery(query);
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            string userInput = textBox2.Text;
            string query = "SELECT * FROM Jockeys " +
                           "WHERE Rating > " + userInput;
            ExecuteQuery(query);
        }

        private void Button3_Click(object sender, EventArgs e)
        {
            string startDate = textBox3.Text;
            string endDate = textBox4.Text;
            string query = "SELECT Races.RaceName, Results.Position, Horses.HorseName, Races.Location " +
                           "FROM Results " +
                           "JOIN Races ON Results.RaceID = Races.RaceID " +
                           "JOIN Horses ON Results.HorseID = Horses.HorseID " +
                           "WHERE Races.RaceDate BETWEEN '" + startDate + "’ AND '" +endDate + "'";
            ExecuteQuery(query);
        }

        private void Button4_Click(object sender, EventArgs e)
        {
            string userInput = textBox5.Text;
            string query = "SELECT Jockeys.JockeyName, SUM(CASE WHEN Results.Position = ‘I’ THEN 1 ELSE 0 END) AS FirstPlaceCount " +
                           "FROM Results " +
                           "JOIN Jockeys ON Results.JockeyID = Jockeys.JockeyID " +
                           "JOIN Races ON Results.RaceID = Races.RaceID " +
                           "WHERE Races.Location = '" + userInput + "' " +
                           "AND Races.RaceDate BETWEEN DATE_SUB(CURDATE(), INTERVAL 1 MONTH) AND CURDATE() " +
                           "GROUP BY Jockeys.JockeyID " +
                           "ORDER BY FirstPlaceCount DESC " +
                           "LIMIT 3";
            ExecuteQuery(query);
        }
    }
}

using System;
using System.Data;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace HorseRacing
{
    public partial class HorsesForm : Form
    {
        private MySqlConnection conn;
        private Form1 parentForm;
        private int selectedOwnerID;

        public HorsesForm(Form1 parentForm, int selectedOwnerID)
        {
            InitializeComponent();
            this.parentForm = parentForm;
            string connString = parentForm.GetDBConnectionString();
            conn = new MySqlConnection(connString);
            this.selectedOwnerID = selectedOwnerID;
        }

        //private void HorseForm_Load(object sender, EventArgs e)
        //{
        //    // Perform any additional initialization or data binding if needed
        //}

        private void BtnSave_Click(object sender, EventArgs e)
        {
            // Retrieve the selected OwnerID from the ComboBox
            int ownerID = Convert.ToInt32(cmbOwners.SelectedValue);
            string horseName = txtHorseName.Text;
            int age = Convert.ToInt32(txtAge.Text);
            string gender = cmbGender.SelectedItem.ToString();
            string breed = txtBreed.Text;

            string query = "INSERT INTO Horses (HorseName, Age, Gender, Breed, OwnerID) " +
                           "VALUES('" + horseName + "', " + age + ", '" +gender + "', '" + breed + "', '" + ownerID + "')";

            try
            {
                MySqlCommand cmd = new MySqlCommand(query, conn);
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                MessageBox.Show("Horse data saved successfully.");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error saving horse data: " + ex.Message);
            }
        }

        //private void cmbOwners_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //
        //}

        private void HorseForm_Load(object sender, EventArgs e)
        {
            // Populate ComboBox with Owner names
            string query = "SELECT OwnerID, OwnerName FROM Owners";
            MySqlCommand cmd = new MySqlCommand(query, conn);
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            adapter.Fill(dt);

            cmbOwners.DisplayMember = "OwnerName";
            cmbOwners.ValueMember = "OwnerID";
            cmbOwners.DataSource = dt;

            // Select the owner based on selectedOwnerID
            cmbOwners.SelectedValue = selectedOwnerID;
        }
    }
}
How to fix the error Severity Code Description Project File String Suppression status
Error CS7036 There is no argument corresponding to the required parameter 'selectedOwnerID' from 'HorsesForm.HorsesForm(Form1, int)'. HorseRacing E:\Users\Enot\source\repos\HorseRacing\Form1.cs 65 Active