private void grdRemoveMember_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //try catch block to catch InvalidCastException when the user clicks on an empty row of the table.
            try
            {
                //Get ID from first column of selected rom and store it as variable gridID
                int gridID = Convert.ToInt32(grdRemoveMember.Rows[grdRemoveMember.CurrentCell.RowIndex].Cells[0].Value);

                //Retrieve Member Details
                Members singleMember = new Members();
                singleMember.getSingleMember(gridID);

                //load Member details onto form
                txtRemoveId.Text        = singleMember.getMemberID().ToString();
                txtRemoveFirstName.Text = singleMember.getFirstName().ToString();
                txtRemoveLastName.Text  = singleMember.getLastName().ToString();
                txtRemoveStreet.Text    = singleMember.getStreet().ToString();
                txtRemoveTown.Text      = singleMember.getTown().ToString();
                cboRemoveCounty.Text    = singleMember.getCounty().ToString();
                txtRemoveNumber.Text    = singleMember.getMobile().ToString();
                txtRemoveEmail.Text     = singleMember.getEmail().ToString();
                cboRemoveStatus.Text    = singleMember.getMemberStatus().ToString();
                cboRemoveType.Text      = singleMember.getTypeID().ToString();
                txtRemovePaid.Text      = singleMember.getPaid().ToString();
            } catch (System.InvalidCastException)
            {
                MessageBox.Show("Please select a member by clicking on their row in the table", "Empty Row Selected");
            }
        }
Exemple #2
0
        private void grdUpdateMembers_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Get ID from first column of selected rom and store it as variable gridID
            int gridID = Convert.ToInt32(grdUpdateMembers.Rows[grdUpdateMembers.CurrentCell.RowIndex].Cells[0].Value);

            //Retrieve Member Details
            Members singleMember = new Members();

            singleMember.getSingleMember(gridID);

            //load Member details onto form
            txtUpdateId.Text        = singleMember.getMemberID().ToString();
            txtUpdateFirstName.Text = singleMember.getFirstName().ToString();
            txtUpdateLastName.Text  = singleMember.getLastName().ToString();
            txtUpdateStreet.Text    = singleMember.getStreet().ToString();
            txtUpdateTown.Text      = singleMember.getTown().ToString();
            cboUpdateCounty.Text    = singleMember.getCounty().ToString();
            txtUpdateNumber.Text    = singleMember.getMobile().ToString();
            txtUpdateEmail.Text     = singleMember.getEmail().ToString();
            cboUpdateStatus.Text    = singleMember.getMemberStatus().ToString();
            cboUpdateType.Text      = singleMember.getTypeID().ToString();
            cboUpdatePaid.Text      = singleMember.getPaid().ToString();
        }