示例#1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            bool valid = true;

            Customer.PPSNo      = null;
            Customer.CustomerId = txtCustomerid.Text;
            Customer.PAC        = txtPUC.Text;
            Validation v = new Validation();

            errorProvider.Clear();

            if (Customer.CustomerId.Length != 8 || !v.IsNumeric(Customer.CustomerId))
            {
                valid = false;
                errorProvider.SetError(txtCustomerid, "Please enter a valid customerID");
            }
            if (Customer.PAC.Length != 5 || !v.IsNumeric(Customer.PAC))
            {
                valid = false;
                errorProvider.SetError(txtPUC, "Please enter a valid PAC");
            }
            if (valid)
            {
                try
                {
                    if (CustomerSQL.Login(Customer.CustomerId, Customer.PAC))
                    {
                        FrmDisplayAccounts Display = new FrmDisplayAccounts();
                        Display.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Login failed: Please try again");
                    }
                }
                catch
                {
                    MessageBox.Show("Error 001: Could not connect to database. Please contact an administratior");
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (AccountSQL.AllBalanceEmpty())
            {
                if (MessageBox.Show("Are you sure you want to terminate your account?\n\nYou will not be able to login again and all open accounts will be closed!", "Terminate Account", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    AccountSQL.CloseCustAccounts();
                    CustomerSQL.TerminateAccount(Customer.CustomerId);

                    Customer.Clear();
                    FrmStartScreen start = new FrmStartScreen();
                    start.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Please Empty all open accounts of funds");
            }
        }
示例#3
0
        private void btnsubmit_Click(object sender, EventArgs e)
        {
            Customer.PPSNo = txtppsno.Text;
            bool valid = true;

            Customer.PAC = txtpacno1.Text + txtpacno2.Text + txtpacno3.Text + txtpacno4.Text + txtpacno5.Text;
            Validation v = new Validation();

            errorProvider.Clear();
            if (!v.IsNumeric(Customer.PAC))
            {
                errorProvider.SetError(txtpacno5, "PAC must only contain numbers");
                valid = false;
            }
            if (!v.IsPPS(Customer.PPSNo))
            {
                errorProvider.SetError(txtppsno, "Please enter a valid pps number");
                valid = false;
            }
            if (valid.Equals(true))
            {
                Customer.PPSNo = Customer.PPSNo.ToUpper();
                try
                {
                    if (CustomerSQL.IsInUse(Customer.PPSNo))
                    {
                        MessageBox.Show("This PPS number is already regestered to an account.");
                    }
                    else
                    {
                        FrmRegisterUserData Register = new FrmRegisterUserData();
                        Register.Show();
                        this.Hide();
                    }
                }
                catch
                {
                    MessageBox.Show("Error 002: Could not connect to database. Please contact an administratior");
                }
            }
        }
示例#4
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Validation v     = new Validation();
            bool       valid = true;

            Customer.Fname       = txtfname.Text;
            Customer.Lname       = txtlname.Text;
            Customer.CountryCode = cboCountryCode.SelectedValue.ToString();
            Customer.PhoneNo     = txtphoneno.Text;
            Customer.DOB         = dtpdob.Value.ToString("dd-MM-yyyy");
            Customer.AddressL1   = txtAddl1.Text;
            Customer.AddressL2   = txtAddl2.Text;
            Customer.AddressL3   = txtAddl3.Text;
            Customer.County      = cboCounty.SelectedValue.ToString();
            Customer.Town        = txttown.Text;
            Customer.Eir         = txteir.Text;

            Customer.Eir = Customer.Eir.ToUpper();

            errorprovider.Clear();

            if (!v.IsAlphabeticNoSpace(Customer.Fname))
            {
                errorprovider.SetError(txtfname, "First name must only contain letters");
                valid = false;
            }
            if (!v.IsAlphabeticNoSpace(Customer.Lname))
            {
                errorprovider.SetError(txtlname, "Last name must only contain letters");
                valid = false;
            }
            if (!v.IsNumeric(Customer.PhoneNo))
            {
                errorprovider.SetError(txtphoneno, "phone number must only contain numbers");
                valid = false;
            }
            if (v.IsEmpty(Customer.CountryCode))
            {
                errorprovider.SetError(cboCountryCode, "Please select a country code");
                valid = false;
            }
            if (v.IsEmpty(Customer.AddressL1))
            {
                errorprovider.SetError(txtAddl1, "Please enter an address");
                valid = false;
            }
            if (v.IsEmpty(Customer.County))
            {
                errorprovider.SetError(cboCounty, "Please select a county");
                valid = false;
            }
            if (!v.IsAlphabetic(Customer.Town))
            {
                errorprovider.SetError(txttown, "Town must only be alphabetic");
                valid = false;
            }
            if (!v.IsEir(Customer.Eir))
            {
                errorprovider.SetError(txteir, "Please enter a valid eircode");
                valid = false;
            }

            if (valid.Equals(true))
            {
                Customer.Fname = char.ToUpper(Customer.Fname[0]) + Customer.Fname.Substring(1);
                Customer.Lname = char.ToUpper(Customer.Lname[0]) + Customer.Lname.Substring(1);

                if (!Customer.Eir.Contains(" "))
                {
                    Customer.Eir = Customer.Eir.Substring(0, 3) + " " + Customer.Eir.Substring(3, 4);
                }
                Customer.DateCreated = DateTime.Now.ToString("dd-MM-yyyy");
                Customer.Lname       = Customer.Lname.Replace("'", "''");

                try
                {
                    CustomerSQL.AddUser();

                    MessageBox.Show("Your Customer ID is \n" + Customer.CustomerId + ". \nKeep track of this number as you will use it to login");

                    FrmStartScreen Start = new FrmStartScreen();
                    Start.Show();
                    this.Hide();
                }
                catch
                {
                    MessageBox.Show("Error 005: Could not connect to database. Please contact an administratior");
                }
            }
        }
        private void btnUpdateCustomer_Click(object sender, EventArgs e)
        {
            Validation v     = new Validation();
            bool       valid = true;

            //making things uppercase
            Customer.Eir = Customer.Eir.ToUpper();

            errorProvider1.Clear();

            if (!v.IsAlphabeticNoSpace(txtFName.Text))
            {
                errorProvider1.SetError(txtFName, "First name must only contain letters");
                valid = false;
            }
            if (!v.IsAlphabeticNoSpace(txtLName.Text))
            {
                errorProvider1.SetError(txtLName, "Last name must only contain letters");
                valid = false;
            }
            if (!v.IsNumeric(txtPhoneNo.Text))
            {
                errorProvider1.SetError(txtPhoneNo, "phone number must only contain numbers");
                valid = false;
            }
            if (v.IsEmpty(txtAddressL1.Text))
            {
                errorProvider1.SetError(txtAddressL1, "Please enter an address");
                valid = false;
            }
            if (!v.IsAlphabetic(txtTown.Text))
            {
                errorProvider1.SetError(txtTown, "Town must only be alphabetic");
                valid = false;
            }
            if (!v.IsEir(txtEircode.Text))
            {
                errorProvider1.SetError(txtEircode, "Please enter a valid eircode");
                valid = false;
            }

            if (valid.Equals(true))
            {
                Customer.Fname       = txtFName.Text;
                Customer.Lname       = txtLName.Text;
                Customer.CountryCode = cboCountryCode.SelectedValue.ToString();
                Customer.PhoneNo     = txtPhoneNo.Text;
                Customer.AddressL1   = txtAddressL1.Text;
                Customer.AddressL2   = txtAddressL2.Text;
                Customer.AddressL3   = txtAddressL3.Text;
                Customer.County      = cboCounty.SelectedValue.ToString();
                Customer.Town        = txtTown.Text;
                Customer.Eir         = txtEircode.Text;

                Customer.Fname = char.ToUpper(Customer.Fname[0]) + Customer.Fname.Substring(1);
                Customer.Lname = char.ToUpper(Customer.Lname[0]) + Customer.Lname.Substring(1);
                Customer.Lname = Customer.Lname.Replace("'", "''");
                if (!Customer.Eir.Contains(" "))
                {
                    Customer.Eir = Customer.Eir.Substring(0, 3) + " " + Customer.Eir.Substring(3, 4);
                }
                CustomerSQL.UpdateInfo();

                MessageBox.Show("Your Information has been updated");

                CustomerSQL.GetCustInfo();

                FrmDisplayAccounts Display = new FrmDisplayAccounts();
                Display.Show();
                this.Hide();
                MessageBox.Show("Error 004: Could not connect to database. Please contact an administratior");
            }
        }