示例#1
0
        private void cboTenant_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if resetting combo, ignore
            if (cboTenant.SelectedIndex == -1)
            {
                return;
            }
            //Instantiate Tenant Objects
            Tenant newTenant = new Tenant();

            newTenant.getTenant(Convert.ToInt32(cboTenant.Text.Substring(0, 1)));


            if (newTenant.getTenantId().Equals(0))
            {
                MessageBox.Show("No details found", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtBookingID.Focus();
                return;
            }

            //Populate Text Boxes

            txtTenantID.Text = newTenant.getTenantId().ToString();
            txtForename.Text = newTenant.getForename();
            txtSurname.Text  = newTenant.getSurname();
            txtPhone.Text    = newTenant.getPhone().ToString();
            txtEmail.Text    = newTenant.getEmail();
            dtpDOB.Text      = newTenant.getDOB();

            //Reset UI
            grpTenants.Visible  = true;
            txtPropID.Enabled   = false;
            txtTenantID.Enabled = false;
            txtForename.Enabled = false;
            txtSurname.Enabled  = false;
            txtPhone.Enabled    = false;
            txtEmail.Enabled    = false;
            dtpDOB.Enabled      = false;
            btnExisting.Visible = true;
            btnAdd.Visible      = false;
        }