Esempio n. 1
0
    private Dictionary <string, string> validateProduct()
    {
        Dictionary <string, string> dic = new Dictionary <string, string>();
        string size    = Request.QueryString["size"];
        string color   = Request.QueryString["color"];
        string isSize  = Request.QueryString["isSize"];
        string isColor = Request.QueryString["isColor"];
        string isSku   = Request.QueryString["isSku"];
        string style   = Request.QueryString["sku"];
        FrontViewProductDetailsDAO fvpd = new FrontViewProductDetailsDAO();
        DataTable dt = null;

        if ("true".Equals(isColor) && "true".Equals(isSize))
        {
            if (StringUtil.isNullOrEmpty(color))
            {
                dic.Add("error", "Please select the color");
            }
            else if (StringUtil.isNullOrEmpty(size))
            {
                dic.Add("error", "Please select the Size");
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuColorSize(style, color, size);
                }
                else
                {
                    dt = fvpd.getProdByStyleColorSize(style, color, size);
                }
            }
        }
        else if ("true".Equals(isColor))
        {
            if (StringUtil.isNullOrEmpty(color))
            {
                dic.Add("error", "Please select the color");
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuColor(style, color);
                }
                else
                {
                    dt = fvpd.getProdByStyleColor(style, color);
                }
            }
        }
        else if ("true".Equals(isSize))
        {
            if (StringUtil.isNullOrEmpty(size))
            {
                dic.Add("error", "Please select the size");
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuSize(style, size);
                }
                else
                {
                    dt = fvpd.getProdByStyleSize(style, size);
                }
            }
        }
        return(dic);
    }
Esempio n. 2
0
    protected void addToCart()
    {
        string qty     = Request.QueryString["qty"];
        string size    = Request.QueryString["size"];
        string color   = Request.QueryString["color"];
        string isSize  = Request.QueryString["isSize"];
        string isColor = Request.QueryString["isColor"];
        string isSku   = Request.QueryString["isSku"];
        string style   = Request.QueryString["sku"];

        Session.Remove("sessExpire");
        FrontViewProductDetailsDAO fvpd = new FrontViewProductDetailsDAO();

        Session.Remove(Constant.Session.PRODUCT_COUNT);
        DataTable dt = null;

        if ("true".Equals(isColor) && "true".Equals(isSize))
        {
            if (StringUtil.isNullOrEmpty(color))
            {
                string msg = "<error>please select the color<error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
                return;
            }
            else if (StringUtil.isNullOrEmpty(size))
            {
                string msg = "<error>please select the size<error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
                return;
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuColorSize(style, color, size);
                }
                else
                {
                    dt = fvpd.getProdByStyleColorSize(style, color, size);
                }
            }
        }
        else if ("true".Equals(isColor))
        {
            if (StringUtil.isNullOrEmpty(color))
            {
                string msg = "<error>please select the color<error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
                return;
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuColor(style, color);
                }
                else
                {
                    dt = fvpd.getProdByStyleColor(style, color);
                }
            }
        }
        else if ("true".Equals(isSize))
        {
            if (StringUtil.isNullOrEmpty(size))
            {
                string msg = "<error>please select the size<error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
                return;
            }
            else
            {
                if ("true".Equals(isSku))
                {
                    dt = fvpd.getProdBySkuSize(style, size);
                }
                else
                {
                    dt = fvpd.getProdByStyleSize(style, size);
                }
            }
        }
        else
        {
            dt = GenericDAO.getDataTable("select * from View_ImageProductNew_Master where SKUCode='" + style + "'");
        }

        string    skuCode = dt.Rows[0]["SKUCode"] + "";
        DataTable dt1     = GenericDAO.getDataTable("select * from CART where SESSION_ID='" + Session.SessionID + "' and  SKU ='" + skuCode + "'");

        if (!CommonUtil.DT.isEmptyOrNull(dt1))
        {
            int cartQuantity = Int32.Parse(dt1.Rows[0]["QTY"] + "");
            int t            = Convert.ToInt32(qty) + cartQuantity;
            int u            = Convert.ToInt32(dt1.Rows[0]["UNIT_PRICE"] + "");
            int TotalPrice   = t * u;
            if (t <= 20)
            {
                GenericDAO.updateQuery("update   CART set QTY ='" + t + "', TOTAL='" + TotalPrice + "' where SESSION_ID='" + Session.SessionID + "' and SKU ='" + skuCode + "'");
                Session.Remove(Constant.Session.CART_ITEMS);
                Session.Remove(Constant.Session.TOTAL);

                string msg = "success";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
            }
            else
            {
                string msg = "<error>Item is More Than 20</error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
            }
        }
        else
        {
            int inventory = 0;
            if (StringUtil.isNullOrEmpty(dt.Rows[0]["Inventory"] + ""))
            {
                inventory = 0;
            }
            else
            {
                inventory = (int)float.Parse(dt.Rows[0]["Inventory"] as String);
            }
            if (inventory == 0)
            {
                string msg = "<error>Product is Sold Out!!</error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
            }
            else if (inventory < Int32.Parse(qty))
            {
                string msg = "<error>Only " + inventory + " Product(s) are left in inventory!!</error>";
                Response.Write(msg);
                Response.AddHeader("Content-Length", msg.Length.ToString());
                Response.Flush();
                Response.Close();
            }
            else
            {
                string userID = "";
                int    price  = Convert.ToInt32("" + dt.Rows[0]["SpecialPrice"]);
                int    Total  = price * Int32.Parse(qty);
                if (Session[Constant.Session.LOGED_IN_EMAIL] != null)
                {
                    userID = Session[Constant.Session.LOGED_IN_EMAIL].ToString();
                }
                CartDAO.addToCart(Session.SessionID, qty, price.ToString(), Total.ToString(), dt.Rows[0]["SKUCode"] + "", userID);
                Session.Remove(Constant.Session.CART_ITEMS);
                Session.Remove(Constant.Session.TOTAL);
                Response.Write("success");
                Response.AddHeader("Content-Length", "success".Length.ToString());
                Response.Flush();
                Response.Close();
            }
        }
    }