Exemplo n.º 1
0
        protected void btnApply_Click(object sender, EventArgs e)
        {
            loginID = Convert.ToInt32(Session["loginId"]);
            //loginID = 2;
            cardNum = long.Parse(c.generateCardNum());
            Boolean cardFound;
            cardFound = c.cardExists(cardNum);
            while (cardFound == true)
            {
                cardNum = long.Parse(c.generateCardNum().ToString());
                cardFound = c.cardExists(cardNum);
            }

            Boolean hasCard;
            hasCard = c.cardExists(loginID);
            if (hasCard == false)
            {
                lblYouHaveCard.Text = "Sorry, it looks like you already have an Amazon Card!";
            }
            else
            {
                lblConfirmCard.Text = "Thank you for applying. Your new card will arrive soon! But you can use it in the meantime. "+
                "Go to your account to view your Amazon Card details";
                lblCardNum.Text = cardNum.ToString();
                exp = c.cardExpiration();
                lblExpiration.Text = exp;
                verif = Convert.ToInt32(c.generateCVV());

                findCust.CommandType = CommandType.StoredProcedure;
                findCust.CommandText = "dbo.TP_findCustomerByID";

                SqlParameter inputLoginID = new SqlParameter("@loginID", loginID);
                inputLoginID.Direction = ParameterDirection.Input;
                inputLoginID.SqlDbType = SqlDbType.NVarChar;
                inputLoginID.Size = 50;
                findCust.Parameters.Add(inputLoginID);

                cust = objdb.GetDataSetUsingCmdObj(findCust);
                firstName = cust.Tables[0].Rows[0][0].ToString();
                lastName = cust.Tables[0].Rows[0][1].ToString();
                type = "Amazon Card";
                card addAmazon = new card(loginID, cardNum, firstName, lastName, exp, verif, type);
                pxy.addNewCard(addAmazon.addCard(addAmazon));
            }
        }
Exemplo n.º 2
0
        protected void btnAddCard_Click(object sender, EventArgs e)
        {
            double numbers;
            long value1;
            string value2;
            string value3;
            int value4;

            if (double.TryParse(txtCardNum.Text, out numbers))
            {
                value1 = long.Parse(txtCardNum.Text);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "<script> alert('Please enter a valid credit card number. No letters are allowed!'); </script>");
                return;
            }

            if (Regex.IsMatch(txtFirstName.Text, @"^[\p{L}]+$"))
            { value2 = Convert.ToString(txtFirstName.Text); }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "<script> alert('Please enter your firstname correctly! This is a letter field only'); </script>");
                return;

            }
            if (Regex.IsMatch(txtLastName.Text, @"^[\p{L}]+$"))
            { value3 = Convert.ToString(txtLastName.Text); }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "<script> alert('Please enter your lastname correctly! This is a letter field only'); </script>");
                return;

            }

            if (double.TryParse(txtCVV.Text, out numbers))
            {
                value4 = int.Parse(txtCVV.Text);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "<script> alert('Please enter a valid verification number. No letters are allowed!'); </script>");
                return;
            }

            loginID = Convert.ToInt32(Session["loginId"]);
            cardNum = long.Parse(txtCardNum.Text);
            firstName = txtFirstName.Text;
            lastName = txtLastName.Text;
            expDate = ddlMonth.SelectedValue.ToString() + "/" + DropDownList1.SelectedValue.ToString();
            verif = Convert.ToInt32(txtCVV.Text);
            type = ddlCardType.SelectedValue.ToString();

            card add = new card(loginID, cardNum, firstName, lastName, expDate, verif, type);

            pxy.addNewCard(add.addCard(add));
            gvShowCards.DataSource = refreshCardTable(loginID);
            gvShowCards.DataBind();
        }