예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lDiscount.Visible = false;
            if (!string.IsNullOrWhiteSpace(Request.Params["paymentId"].ToString()) && !string.IsNullOrWhiteSpace(Request.Params["PayerID"].ToString()))
            {
                paymentid.Value = Request.Params["paymentId"].ToString();
                payerid.Value   = Request.Params["PayerID"].ToString();
            }
            else
            {
                Response.Redirect("~/Shop", false);
            }

            if (Request.Cookies["cartKey"] != null)
            {
                Guid cartKey          = Guid.Parse(Request.Cookies["cartKey"].Value);
                List <SqlParameter> p = new List <SqlParameter>();
                p.Add(new SqlParameter("@GUID", cartKey));

                DataTable cartDetails = DB.Get("CartSummaryGet", p.ToArray());
                CartView.DataSource = cartDetails;
                CartView.DataBind();

                p = new List <SqlParameter>();
                p.Add(new SqlParameter("@CacheID", cartKey));

                decimal   Subtotal = 0M;
                DataTable dtSub    = DB.Get("CartSubtotalGet", p.ToArray());
                if (dtSub != null && dtSub.Rows.Count > 0)
                {
                    string  strSub     = dtSub.Rows[0][0].ToString();
                    decimal tryDecimal = 0M;
                    if (decimal.TryParse(strSub, out tryDecimal))
                    {
                        Subtotal = tryDecimal;
                    }
                }

                DataRow dr       = cartDetails.Rows[0];
                decimal Discount = 0M;
                if (!string.IsNullOrEmpty(dr["DiscountID"].ToString()))
                {
                    Discount = DiscountUtils.CalculateDiscountTotal((int)dr["DiscountID"], cartKey);
                }

                decimal Shipping = ScalablePressUtils.GetShippingQuote(cartKey);
                if (Shipping > 0M)
                {
                    lSubTotal.Text = "Subtotal: $" + Subtotal.ToString("0.00");
                    if (Discount > 0)
                    {
                        lDiscount.Text    = "Discount: -$" + Discount.ToString("0.00");
                        lDiscount.Visible = true;
                    }
                    lShipTotal.Text = "S&H: $" + Shipping.ToString("0.00");
                    lTotal.Text     = "Total: $" + Math.Round(Subtotal - Discount + Shipping, 2, MidpointRounding.AwayFromZero).ToString("0.00");
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            List <SqlParameter> p        = new List <SqlParameter>();
            DataTable           dtOrders = DB.Get("OrderUpdatableSelect", p.ToArray());

            foreach (DataRow drOrder in dtOrders.Rows)
            {
                ScalablePressUtils.UpdateOrderStatus(drOrder["OrderID"].ToString());
            }
        }
예제 #3
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);
        }
예제 #4
0
        public Variation FetchVariationData(string ID)
        {
            Variation v = new Variation();

            using (SqlConnection conn = DB.GetConnection())
            {
                v = conn.Query <Variation>("ProductVariationSelect", new { VariationID = ID }, commandType: CommandType.StoredProcedure).FirstOrDefault();
            }

            if (v != null)
            {
                List <string> Sizes = ScalablePressUtils.GetProductSizes(v.Type, v.Color);
                v.Sizes = BasicUtils.GetSizeDictionary(Sizes);
            }

            return(v);
        }
예제 #5
0
        protected void SetVariantInfo(int VariationID)
        {
            hdnVariation.Value = VariationID.ToString();

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

            p.Add(new SqlParameter("@ProductVariationID", VariationID));

            DataTable dtVariants = DB.Get("ShopItemDetailed", p.ToArray());

            if (dtVariants != null && dtVariants.Rows.Count > 0)
            {
                DataRow drVariant = dtVariants.Rows[0];

                lName.Text              = drVariant["ImageName"].ToString() + " - " + drVariant["ColorDisplayName"].ToString();
                iDesign.ImageUrl        = drVariant["ProofURL"].ToString();
                iSizeChart.ImageUrl     = drVariant["SizeChartURL"].ToString();
                hlSizeChart.NavigateUrl = drVariant["SizeChartURL"].ToString();
                lPrice.Text             = "$" + ((decimal)drVariant["UnitPrice"]).ToString("0.00");
                lDescription.Text       = drVariant["ImageDescription"].ToString();

                blMaterial.Items.Clear();
                string materialInfo = drVariant["MaterialInfo"].ToString();
                if (!string.IsNullOrWhiteSpace(materialInfo))
                {
                    string[] materialBullets = materialInfo.Split(';');
                    foreach (string bullet in materialBullets)
                    {
                        blMaterial.Items.Add(new ListItem(bullet));
                    }
                }

                List <string> Sizes = ScalablePressUtils.GetProductSizes(drVariant["Type"].ToString(), drVariant["Color"].ToString());
                Dictionary <string, string> DicSize = BasicUtils.GetSizeDictionary(Sizes);

                ddlSize.DataSource     = DicSize;
                ddlSize.DataTextField  = "Key";
                ddlSize.DataValueField = "Value";
                ddlSize.DataBind();
            }
        }
예제 #6
0
        public ActionResult Add(string ID, string Size)
        {
            HttpStatusCodeResult result = new HttpStatusCodeResult(System.Net.HttpStatusCode.InternalServerError);
            Guid cartKey;

            if (Request.Cookies.Get("cartKey") == null)
            {
                cartKey = Guid.NewGuid();

                List <SqlParameter> gp = new List <SqlParameter>();
                gp.Add(new SqlParameter("@GUID", cartKey));
                DB.Set("CartCreate", gp.ToArray());

                Response.Cookies["cartKey"].Value   = cartKey.ToString();
                Response.Cookies["cartKey"].Expires = DateTime.Now.AddMonths(1);
            }
            else
            {
                cartKey = Guid.Parse(Request.Cookies["cartKey"].Value);
            }

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

            p.Add(new SqlParameter("@GUID", cartKey));

            DataTable dtCart = DB.Get("CartIDSelect", p.ToArray());

            if (dtCart != null && dtCart.Rows.Count > 0)
            {
                int CartID = (int)dtCart.Rows[0][0];

                List <SqlParameter> cp = new List <SqlParameter>();
                cp.Add(new SqlParameter("@CartID", CartID));
                cp.Add(new SqlParameter("@VariationID", ID));

                DataTable dtCartItems = DB.Get("CartItemSelect", cp.ToArray());
                if (dtCartItems == null || dtCartItems.Rows.Count <= 0)
                {
                    string DesignID = ScalablePressUtils.GetDesignID(ID);
                    if (string.IsNullOrWhiteSpace(DesignID))
                    {
                        Exception ex = new Exception("Design ID not found for variation ID " + ID);
                        LoggingUtil.InsertError(ex);
                    }
                    else
                    {
                        cp.Add(new SqlParameter("@DesignID", DesignID));
                    }
                }

                cp.Add(new SqlParameter("@ProductSize", Size));
                cp.Add(new SqlParameter("@Quantity", 1));

                try
                {
                    int iAffected = DB.SetWithRowsAffected("CartItemInsert", cp.ToArray());

                    if (iAffected > 0)
                    {
                        result = new HttpStatusCodeResult(System.Net.HttpStatusCode.OK);
                    }
                }
                catch (Exception ex)
                {
                    LoggingUtil.InsertError(ex);
                }
            }

            return(result);
        }
예제 #7
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            int VariationID = int.Parse(hdnVariation.Value);

            lMessage.Text = "";
            int qty = 1;// qb.GetQuantity();

            if (qty > 0)
            {
                Guid cartKey;
                if (Request.Cookies.Get("cartKey") == null)
                {
                    cartKey = Guid.NewGuid();

                    List <SqlParameter> gp = new List <SqlParameter>();
                    gp.Add(new SqlParameter("@GUID", cartKey));
                    DB.Set("CartCreate", gp.ToArray());

                    Response.Cookies["cartKey"].Value   = cartKey.ToString();
                    Response.Cookies["cartKey"].Expires = DateTime.Now.AddDays(7);
                }
                else
                {
                    cartKey = Guid.Parse(Request.Cookies["cartKey"].Value);
                }

                List <SqlParameter> p = new List <SqlParameter>();
                p.Add(new SqlParameter("@GUID", cartKey));

                DataTable dtCart = DB.Get("CartIDSelect", p.ToArray());
                if (dtCart != null && dtCart.Rows.Count > 0)
                {
                    int CartID = (int)dtCart.Rows[0][0];

                    List <SqlParameter> cp = new List <SqlParameter>();
                    cp.Add(new SqlParameter("@CartID", CartID));
                    cp.Add(new SqlParameter("@VariationID", VariationID));

                    DataTable dtCartItems = DB.Get("CartItemSelect", cp.ToArray());
                    if (dtCartItems == null || dtCartItems.Rows.Count <= 0)
                    {
                        string DesignID = ScalablePressUtils.GetDesignID(VariationID.ToString());
                        if (string.IsNullOrWhiteSpace(DesignID))
                        {
                            Exception ex = new Exception("Design ID not found for variation ID " + VariationID);
                            LoggingUtil.InsertError(ex);
                            lMessage.Text = "An error has occured with this product and our men in black have been notified.";
                        }
                        else
                        {
                            cp.Add(new SqlParameter("@DesignID", DesignID));
                        }
                    }

                    cp.Add(new SqlParameter("@ProductSize", ddlSize.SelectedValue));
                    cp.Add(new SqlParameter("@Quantity", qty));

                    try
                    {
                        int iAffected = DB.SetWithRowsAffected("CartItemInsert", cp.ToArray());

                        if (!(iAffected > 0))
                        {
                            lMessage.Text = "An unknown error has occured and our men in black have been notified.";
                        }
                        else
                        {
                            Response.Redirect("~/Shop/Cart.aspx", false);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggingUtil.InsertError(ex);
                    }
                }
                else
                {
                    lMessage.Text = "An unknown error has occured and our men in black have been notified.";
                }
            }
            else
            {
                lMessage.Text = "Quantity orderable needs to be greater than 0.";
            }
        }
예제 #8
0
        protected void completeSale_Click(object sender, EventArgs e)
        {
            try
            {
                string PID = PayPalUtils.ExecuteSale(paymentid.Value, payerid.Value);

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

                decimal ShippingTotal = ScalablePressUtils.GetShippingQuote(cartKey);

                List <SqlParameter> p = new List <SqlParameter>();
                p.Add(new SqlParameter("@CacheID", cartKey));
                p.Add(new SqlParameter("@ShippingPaid", ShippingTotal));
                p.Add(new SqlParameter("@PaymentID", PID));

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

FORCEREPEAT:
                try
                {
                    DB.Set("CartOrderedInsert", p.ToArray());
                }
                catch
                {
                    goto FORCEREPEAT;
                }

                string     OrderID    = outOrderID.Value.ToString();
                HttpCookie cartCookie = new HttpCookie("cartKey");
                cartCookie.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(cartCookie);

                bool ordered  = false;
                int  retry    = 0;
                int  maxRetry = 3;

                while (!ordered)
                {
                    try
                    {
                        ordered = ScalablePressUtils.PlaceOrder(OrderID);
                    }
                    catch (Exception ex)
                    {
                        LoggingUtil.InsertError(ex);
                        if (retry > maxRetry)
                        {
                            return;
                        }
                        else
                        {
                            retry++;
                        }
                    }
                }

                BasicUtils.SendConfirmation(OrderID);
                Response.Redirect("~/Shop/Confirm.aspx", false);
            }
            catch (Exception ex)
            {
                LoggingUtil.InsertError(ex);
            }
        }
예제 #9
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);
            }
        }