Пример #1
0
        protected void btConfirm_Click(object sender, EventArgs e)
        {
            lError.Text = "";

            string CountryCode = ddlCountry.SelectedValue;
            string State       = shipState.Text;

            if (CountryCode == "US")
            {
                State = ddlStates.SelectedValue;
            }

            if (string.IsNullOrEmpty(State))
            {
                lState.Text = "State is required";
                return;
            }

            if (!BasicUtils.IsValidEmail(shipEmail.Text))
            {
                lError.Text = "Email must be valid";
                return;
            }

            Guid cartKey = Guid.Parse(Request.Cookies["cartKey"].Value);

            List <SqlParameter> p = new List <SqlParameter>();

            p.Add(new SqlParameter("@CacheID", cartKey));
            p.Add(new SqlParameter("@ShipFirstName", shipFName.Text));
            p.Add(new SqlParameter("@ShipLastName", shipLName.Text));
            p.Add(new SqlParameter("@ShipAddress1", shipAddress1.Text));
            p.Add(new SqlParameter("@ShipAddress2", shipAddress2.Text));
            p.Add(new SqlParameter("@ShipCity", shipCity.Text));
            p.Add(new SqlParameter("@ShipState", State));
            p.Add(new SqlParameter("@ShipCountryCode", ddlCountry.SelectedValue));
            p.Add(new SqlParameter("@ShipZip", shipZip.Text));
            p.Add(new SqlParameter("@ShipEmail", shipEmail.Text));
            p.Add(new SqlParameter("@ShipPhone", shipPhone.Text));
            DB.Set("CartAddressUpdate", p.ToArray());

            decimal Shipping = ScalablePressUtils.GetShippingQuote(cartKey);

            string redirect_url = PayPalUtils.ConfirmSale(cartKey, Shipping);

            Response.Redirect(redirect_url, false);
        }
Пример #2
0
        protected void btConfirm_Click(object sender, EventArgs e)
        {
            if (Request.Cookies["ContestKey"] == null || string.IsNullOrWhiteSpace(Request.Cookies["ContestKey"].Value))
            {
                Response.Redirect("~/Contest/KeyInvalid.aspx", false);
            }

            string key            = Request.Cookies["ContestKey"].Value;
            List <SqlParameter> p = new List <SqlParameter>();

            p.Add(new SqlParameter("@ContestKey", key));

            DataTable dtCode = DB.Get("ContestCodeGetValid", p.ToArray());

            if (dtCode != null && dtCode.Rows.Count > 0)
            {
                string CountryCode = ddlCountry.SelectedValue;
                string State       = shipState.Text;

                if (CountryCode == "US")
                {
                    State = ddlStates.SelectedValue;
                }

                if (string.IsNullOrEmpty(State))
                {
                    lState.Text = "State is required";
                    return;
                }

                if (!BasicUtils.IsValidEmail(shipEmail.Text))
                {
                    lError.Text = "Email must be valid";
                    return;
                }

                int variationID = 0;
                if (!int.TryParse(Request.Params["VariationID"].ToString(), out variationID))
                {
                    Response.Redirect("~/Contest/Prize.aspx", false);
                }

                string OrderToken = ScalablePressUtils.ContestQuote(variationID, shipFName.Text + " " + shipLName.Text, shipAddress1.Text, shipAddress2.Text, shipCity.Text, State,
                                                                    ddlCountry.SelectedValue, shipZip.Text, Request.Params["Size"].ToString());

                if (!string.IsNullOrWhiteSpace(OrderToken))
                {
                    p = new List <SqlParameter>();
                    p.Add(new SqlParameter("@ContestKey", key));
                    p.Add(new SqlParameter("@ProductVariationID", variationID));
                    p.Add(new SqlParameter("@ProductSize", Request.Params["Size"].ToString()));
                    p.Add(new SqlParameter("@ShipFirstName", shipFName.Text));
                    p.Add(new SqlParameter("@ShipLastName", shipLName.Text));
                    p.Add(new SqlParameter("@ShipAddress1", shipAddress1.Text));
                    p.Add(new SqlParameter("@ShipAddress2", shipAddress2.Text));
                    p.Add(new SqlParameter("@ShipCity", shipCity.Text));
                    p.Add(new SqlParameter("@ShipState", State));
                    p.Add(new SqlParameter("@ShipCountryCode", ddlCountry.SelectedValue));
                    p.Add(new SqlParameter("@ShipZip", shipZip.Text));
                    p.Add(new SqlParameter("@ShipEmail", shipEmail.Text));
                    p.Add(new SqlParameter("@ShipPhone", shipPhone.Text));
                    p.Add(new SqlParameter("@OrderToken", OrderToken));

                    SqlParameter outOrderID = new SqlParameter("@OutOrderID", SqlDbType.Int);
                    outOrderID.Direction = ParameterDirection.Output;
                    p.Add(outOrderID);

                    int iRowsAffected = DB.SetWithRowsAffected("ContestOrderInsert", p.ToArray());
                    if (iRowsAffected > 0)
                    {
                        if (ScalablePressUtils.PlaceOrder(outOrderID.Value.ToString()))
                        {
                            Response.Cookies.Remove("ContestKey");
                            Response.Redirect("~/Shop/Confirm.aspx");
                        }
                        else
                        {
                            Response.Redirect("~/Contest/KeyInvalid.aspx", false);
                        }
                    }
                    else
                    {
                        Response.Redirect("~/Contest/KeyInvalid.aspx", false);
                    }
                }
            }
            else
            {
                Response.Redirect("~/Contest/KeyInvalid.aspx", false);
            }
        }