Exemple #1
0
        private void recordPaymentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmRecordPayment newPayment = new frmRecordPayment();

            this.Hide();
            newPayment.Show();
        }
        private void btnRecordPayment_Click(object sender, EventArgs e)
        {
            if (txtRecPayRenewalID.Text == "")
            {
                MessageBox.Show("Please fill out the other fields before recording payment.", "Invalid Information");
            }
            else if (cboRecPayMemberID.SelectedItem == null)
            {
                MessageBox.Show("Please select a Member ID", "Invalid Information");
                cboRecPayMemberID.Focus();
            }
            else if (cboRecPayAmount.SelectedItem == null)
            {
                MessageBox.Show("Please select Amount to Pay.", "Invalid Information");
                cboRecPayAmount.Focus();
            }
            else
            {
                //Convert selected combobox items to string.

                Renewals newRenewal = new Renewals();

                newRenewal.setRenewalID(Convert.ToInt32(txtRecPayRenewalID.Text));
                newRenewal.setMemberID(Convert.ToInt32(cboRecPayMemberID.SelectedItem.ToString()));
                newRenewal.setAmountPaid(Convert.ToDecimal(cboRecPayAmount.SelectedItem.ToString()));

                newRenewal.recordNewPayment();

                //Update the member's paid status to y
                Members updatePaid = new Members();

                updatePaid.setMemberID(Convert.ToInt32(cboRecPayMemberID.SelectedItem.ToString()));

                updatePaid.updatePaidStatus();

                MessageBox.Show("Payment has been recorded!");
                frmRecordPayment refresh = new frmRecordPayment();
                this.Close();
                refresh.Show();
            }
        }
        private void btnAddMember_Click(object sender, EventArgs e)
        {
            if (txtFirstName.Text == "" || !Members.validateTextBox(txtFirstName.Text))
            {
                MessageBox.Show("Please enter valid First name.", "Invalid Infomation");
                txtFirstName.Focus();
            }
            else if (txtLastName.Text == "" || !Members.validateTextBox(txtLastName.Text))
            {
                MessageBox.Show("Please enter valid Last name.", "Invalid Infomation");
                txtLastName.Focus();
            }
            else if (txtStreet.Text == "")
            {
                MessageBox.Show("Please enter a street name.", "Invalid Infomation");
                txtStreet.Focus();
            }
            else if (txtTown.Text == "" || !Members.validateTextBox(txtTown.Text))
            {
                MessageBox.Show("Please enter a valid town name.", "Invalid Infomation");
                txtTown.Focus();
            }
            else if (cboCounty.SelectedItem == null)
            {
                MessageBox.Show("Please select a county.", "Invalid Infomation");
                cboCounty.Focus();
            }
            else if (txtMobile.Text == "" || txtMobile.Text[0] != '0')
            {
                MessageBox.Show("Please enter a valid phone number. Phone numbers begin with 0.", "Invalid Infomation");
                txtMobile.Focus();
            }
            else if (txtEmail.Text == "" || !Members.validateEmail(txtEmail.Text))
            {
                MessageBox.Show("Please enter a valid email address.", "Invalid Infomation");
                txtEmail.Focus();
            }
            else if (cboMemberType.SelectedItem == null)
            {
                MessageBox.Show("Please select a Member Type.", "Invalid Infomation");
                cboMemberType.Focus();
            }
            else
            {
                //Set Data
                Members addMember = new Members();

                addMember.setMemberID(Convert.ToInt32(txtMemId.Text));
                addMember.setMemberFirstName(txtFirstName.Text);
                addMember.setMemberLastName(txtLastName.Text);
                addMember.setStreet(txtStreet.Text);
                addMember.setTown(txtTown.Text);
                addMember.setCounty(cboCounty.SelectedItem.ToString());
                addMember.setMobile(txtMobile.Text);
                addMember.setEmail(txtEmail.Text);
                addMember.setMemberStatus("Active");
                addMember.setTypeID(cboMemberType.SelectedItem.ToString());

                //SAVE DATA
                addMember.addMember();

                MessageBox.Show("Newly added members given unpaid status by default. If the member has already paid for this year's membership then confirm their payment in the Record Payment section.", "Information");

                //ASK USER IF THEY WANT TO RECORD NEW MEMBER'S PAYMENT AFTER ADDING A MEMBER
                if (MessageBox.Show("Member Added! Would you like to record their payment?", "Record Payment?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    frmAddMember refresh = new frmAddMember();
                    this.Close();
                    refresh.Show();
                }
                else
                {
                    frmRecordPayment recPay = new frmRecordPayment();
                    this.Close();
                    recPay.Show();
                }
            }
        }