Пример #1
0
        private void btnRmv_Click(object sender, EventArgs e)
        {
            Booking delBook = new Booking();

            delBook.rmvBooking(Convert.ToInt32(txtPropID.Text));

            //instantiate Tenant Object
            Tenant myTenant = new Tenant();

            myTenant.setTenantId(Convert.ToInt32(txtTenantID.Text));
            myTenant.setForename(txtForename.Text);
            myTenant.setSurname(txtTenantSearch.Text);
            myTenant.setPhone(txtPhone.Text);
            myTenant.setEmail(txtEmail.Text);

            //Set Tenant record in table as Inactive
            myTenant.rmvTenant();


            //Display Confirmation message
            MessageBox.Show("Tenant Removed From System", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Reset UI
            txtTenantID.Text     = "";
            txtForename.Text     = "";
            txtTenantSearch.Text = "";
            txtPhone.Text        = "";
            txtEmail.Text        = "";

            grpTenants.Visible = false;
            grdTenants.Visible = false;
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate data
            if (txtForename.Text.Equals("") || txtSurname.Text.Equals("") || txtPhone.Text.Equals("") || txtEmail.Text.Equals(""))
            {
                MessageBox.Show("All fields must be entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            String phone = txtPhone.Text;

            foreach (char c in phone)
            {
                if (c < '0' || c > '9')
                {
                    MessageBox.Show("Phone must be numeric!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPhone.Text = "";
                    return;
                }
            }


            if (txtActivity.Text.ToUpper() != "A" && txtActivity.Text.ToUpper() != "I")
            {
                MessageBox.Show("Activity must be A or I!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtActivity.Text = "";
                return;
            }

            //Display Confirmation message
            MessageBox.Show("Tenant Updated!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //instantiate Tenant Object
            Tenant myTenant = new Tenant();

            myTenant.setTenantId(Convert.ToInt32(txtTenantID.Text));

            if (PropertySysv2.Owner.validText(txtForename.Text))
            {
                myTenant.setForename(txtForename.Text);
            }
            else
            {
                MessageBox.Show("Forename must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtForename.Text = "";
                txtForename.Focus();
                return;
            }


            if (PropertySysv2.Owner.validText(txtSurname.Text))
            {
                myTenant.setSurname(txtSurname.Text);
            }
            else
            {
                MessageBox.Show("Address Line 2 must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSurname.Text = "";
                txtSurname.Focus();
                return;
            }


            myTenant.setPhone(txtPhone.Text);
            if (PropertySysv2.Owner.validEmail(txtEmail.Text))
            {
                myTenant.setEmail(txtEmail.Text);
            }
            else
            {
                MessageBox.Show("Email must be correct format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }
            myTenant.setActivity(txtActivity.Text);

            //INSERT Tenant record into tenant table
            myTenant.updTenant();

            //reset UI
            txtTenantSearch.Text = "";
            txtForename.Text     = "";
            txtSurname.Text      = "";
            txtPhone.Text        = "";
            txtEmail.Text        = "";
            txtActivity.Text     = "";

            grpTenants.Visible = false;
            grdTenants.Visible = false;
            txtTenantSearch.Focus();
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            String activity = "A";
            String dob      = String.Format("{0:dd-MMM-yy}", dtpDOB.Value);
            var    today    = DateTime.Today;
            var    birth    = dtpDOB.Value.Year;
            int    age      = today.Year - birth;

            if (age < 18)
            {
                MessageBox.Show("Tenant must be 18 or over!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpDOB.Focus();
                return;
            }

            //Validate Data
            if (txtSurname.Text.Equals("") || txtForename.Text.Equals("") || txtPhone.Text.Equals("") || txtEmail.Text.Equals("") || dtpDOB.Equals(""))
            {
                MessageBox.Show("All fields must be entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            String phone = txtPhone.Text;

            foreach (char c in phone)
            {
                if (c < '0' || c > '9')
                {
                    MessageBox.Show("Phone must be numeric!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPhone.Text = "";
                    return;
                }
            }

            //Instantiate Tenant Object
            Tenant myTenant = new Tenant();

            myTenant.setTenantId(Convert.ToInt32(txtTenantID.Text));
            if (PropertySysv2.Owner.validText(txtForename.Text))
            {
                myTenant.setForename(txtForename.Text);
            }
            else
            {
                MessageBox.Show("Forename must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtForename.Text = "";
                txtForename.Focus();
                return;
            }


            if (PropertySysv2.Owner.validText(txtSurname.Text))
            {
                myTenant.setSurname(txtSurname.Text);
            }
            else
            {
                MessageBox.Show("Address Line 2 must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSurname.Text = "";
                txtSurname.Focus();
                return;
            }


            if (PropertySysv2.Owner.validNumbers(txtPhone.Text))
            {
                myTenant.setPhone(txtPhone.Text);
            }
            else
            {
                MessageBox.Show("Phone must be numbers only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPhone.Text = "";
                txtPhone.Focus();
                return;
            }


            if (PropertySysv2.Owner.validEmail(txtEmail.Text))
            {
                myTenant.setEmail(txtEmail.Text);
            }
            else
            {
                MessageBox.Show("Email must be correct format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }

            myTenant.setDob(dob);
            myTenant.setActivity(activity);
            myTenant.setPropID(Convert.ToInt32(txtPropID.Text));


            //INSERT Tenant Record Into Tenant Table
            myTenant.regTenant();

            //Reset UI
            txtPropID.Enabled   = false;
            txtSurname.Enabled  = false;
            txtForename.Enabled = false;
            txtPhone.Enabled    = false;
            txtEmail.Enabled    = false;
            dtpDOB.Enabled      = false;
            lblMsg.Visible      = true;

            grpDates.Visible = true;
        }