/// <summary>
        /// Clicking on Row within the grid, populates the data in the controls places on the form from the Grid.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnDeletePkg_Click_1(object sender, EventArgs e)
        {
            Package pkgObj = new Package();

            try
            {
                if (txtPackageId.Text != "")
                {
                    pkgObj.PackageId = Convert.ToInt32(txtPackageId.Text);
                    PutPackageData(pkgObj);
                    var packageCount = PackageDB.CheckBeforeDelete(pkgObj.PackageId);
                    if (packageCount > 0)
                    {
                        MessageBox.Show("Can't Delete Package. Please delete dependent tables first");
                    }
                    else
                    {
                        DialogResult result = MessageBox.Show("Are you sure you want to delete this item from database?\n" +
                                                              "Delete action cannot be undone.", "Confirm deletion", MessageBoxButtons.OKCancel);

                        if (result.ToString() == "OK")
                        {
                            bool success = PackageDB.PackageDelete(pkgObj);
                            if (success)
                            {
                                MessageBox.Show("Package has been Deleted");
                            }
                        }
                    }



                    Refresh();

                    packages = PackageDB.DisplayPackagesInGrid();
                    packageDataGridView.DataSource = packages; //packages is the list to hold the list of packages
                }
                else
                {
                    MessageBox.Show("Please select the recprd to delete from the grid", "Select Error");
                }
            }

            catch (Exception ex)
            {
                //MessageBox.Show(ex.GetType().ToString() + ex.Message);
                MessageBox.Show("Can't delete the record now as it is beeing accessed by someone else", "Delete Error");
            }
        }