private void AddButton_Click(object sender, EventArgs e)
        {
            const string errorMessage = "An item with this product code already exists.\n\nPlease enter a different product code.";

            _connection = DB_Connect.connect();
            _connection.Open();

            if (IfProductExists(_connection, PCTextBox.Text))
            {
                MessageBox.Show(errorMessage);
                PCTextBox.Clear();
                PCTextBox.Focus();
            }
            else
            {
                var sqlQuery = @"INSERT INTO[Products] ([ProductCode], [ProductName], [ProductSupplier], [ProductSupplierCode], [ProductPrice], [ProductStock]) VALUES
                      ('" + PCTextBox.Text + "', '" + PNTextBox.Text + "', '" + SNTextBox.Text + "', '" + SCTextBox.Text + "', '" + PriceTextBox.Text + "', '" + StockTextBox.Text + "')";
                _command = new SqlCommand(sqlQuery, _connection);
                _command.ExecuteNonQuery();
                ClearText();
                PCTextBox.Focus();
            }

            _connection.Close();
            LoadData();
        }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            const string errorMessage = "An item with this product code doesn't exist.\n\nPlease enter a different product code.";

            _connection = DB_Connect.connect();
            _connection.Open();

            if (IfProductExists(_connection, PCTextBox.Text))
            {
                var sqlQuery = @"UPDATE[Products] SET[ProductName] = '" + PNTextBox.Text + "', [ProductSupplier] = '" + SNTextBox.Text + "' , [ProductSupplierCode] = '" + SCTextBox.Text + "', [ProductPrice] = '" + PriceTextBox.Text + "', [ProductStock] = '" + StockTextBox.Text + "' WHERE[ProductCode] = '" + PCTextBox.Text + "'";
                ClearText();
                PCTextBox.Focus();
                _command = new SqlCommand(sqlQuery, _connection);
                _command.ExecuteNonQuery();
            }
            else
            {
                MessageBox.Show(errorMessage);
                PCTextBox.Clear();
                PCTextBox.Focus();
            }

            _connection.Close();
            LoadData();
        }
 private void ClearText()
 {
     PCTextBox.Clear();
     PNTextBox.Clear();
     SNTextBox.Clear();
     SCTextBox.Clear();
     PriceTextBox.Clear();
     StockTextBox.Clear();
 }