예제 #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {

            panelPg1.Visible = false;
            panelPg2.Visible = true;
            DialogResult dr;

            DBPOS dbp = new DBPOS();
            string cardType = "";
            if (radioMasterVisa.Checked)
            {
                cardType = radioMasterVisa.Text;
            }

            else if (radioAmericanExp.Checked)
            {
                cardType = radioAmericanExp.Text;
            }

            

            if (String.IsNullOrEmpty(txtBxCreditCardName.Text) || String.IsNullOrEmpty(txtBxCreditCardNo.Text) ||
                   String.IsNullOrEmpty(txtBxCVC.Text) || String.IsNullOrEmpty(txtBxSixDigitPIN.Text) ||
                    !radioAmericanExp.Checked && !radioMasterVisa.Checked)
            {
                dr = MessageBox.Show("Are you sure you want to skip Entering Credit Card Details? (Can be entered later)",
                     "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.No)
                {
                    MessageBox.Show(
                           "Please ensure that you have fill in all your credit card credentials to complete your payment.",
                           "Error",
                           MessageBoxButtons.OK,
                           MessageBoxIcon.Exclamation);
                }
                else {
                    dbp.InsertAccount(txtBxEmail.Text, txtBxUsername.Text, txtBxPassword.Text, "GETDATE()", 1);
                    dbp.InsertCustomer(dbp.GetAccountID(txtBxUsername.Text), txtBxFirstName.Text, txtBxLastName.Text, txtBxMobileNo.Text, dtpDOB.Value.Date);
                    MessageBox.Show("Your account has been created, without payment");
                    this.Close();
                }

            }

            else
            {
                dbp.InsertAccount(txtBxEmail.Text, txtBxUsername.Text, txtBxPassword.Text, "GETDATE()", 1);
                dbp.InsertCustomer(dbp.GetAccountID(txtBxUsername.Text), txtBxFirstName.Text, txtBxLastName.Text, txtBxMobileNo.Text, dtpDOB.Value.Date);
                dbp.InsertCreditCard(dbp.GetAccountID(txtBxUsername.Text), txtBxCreditCardName.Text, long.Parse(txtBxCreditCardNo.Text), dtpExpiryDate.Value,int.Parse(txtBxCVC.Text), int.Parse(txtBxSixDigitPIN.Text), cardType);
                MessageBox.Show("Your account has been created, with payment");
                this.Close();
            }
        }
        private void btnUpdateCreditCard_Click(object sender, EventArgs e)
        {
            string cardType = "";
            if (radioMasterVisa.Checked)
            {
                cardType = radioMasterVisa.Text;
            }

            else if (radioAmericanExp.Checked)
            {
                cardType = radioAmericanExp.Text;
            }

            dbp = new DBPOS();
            dbp.UpdateAccount(txtBxEmailNew.Text, txtBxPasswordNew.Text, user.Username);
            dbp.UpdateCustomer(txtBxFirstNameNew.Text, txtBxLastNameNew.Text, txtBxMobileNoNew.Text, user.Username);
            dbp.InsertCreditCard(dbp.GetAccountID(user.Username), txtBxCreditCardName.Text, long.Parse(txtBxCreditCardNo.Text), dtpExpiryDate.Value, int.Parse(txtBxCVC.Text), int.Parse(txtBxSixDigitPIN.Text), cardType);

            MessageBox.Show("Your account has been updated, with payment changes");
            this.Close();

        }