Exemple #1
0
    protected void rptrProductDetail_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "AddCart")
        {
            ProductId = e.CommandArgument.ToString();

            DataTable dtproduct;
            dtproduct = new DataTable();
            dtproduct = cls.ReturnDataTable("Select_ProductDetailOnId", new SqlParameter("@pid", ProductId));

            if (dtproduct.Rows.Count <= 0)
            {
                MsgBox("This Product is no longer available.");
                return;
            }
            else
            {
                foreach (DataRow dr in dtproduct.Rows)
                {
                    ProductId           = dr["Id"].ToString();
                    CategoryName        = dr["CategoryName"].ToString();
                    SubCategoryName     = dr["SubCategoryName"].ToString();
                    ProductName         = dr["ProductName"].ToString();
                    Productdescp        = dr["Productdescp"].ToString();
                    BrandName           = dr["BrandName"].ToString();
                    SupplierName        = dr["SupplierName"].ToString();
                    Unit                = dr["Unit"].ToString();
                    ProductCode         = dr["ProductCode"].ToString();
                    SupplierProductCode = dr["SupplierProductCode"].ToString();
                    PackSize            = dr["PackSize"].ToString();
                    ProductCost         = Convert.ToDouble(dr["ProductCost"].ToString());
                    ProductWeight       = Convert.ToDouble(dr["ProductWeight"].ToString());
                    Image               = dr["Image"].ToString();
                    Certification       = dr["Certification"].ToString();
                    Description         = dr["Description"].ToString();
                    Margin              = Convert.ToDouble(dr["Margin"].ToString());
                    SalePrice           = Convert.ToDouble(dr["SalePrice"].ToString());
                    Tax               = Convert.ToDouble(dr["Tax"].ToString());
                    SalesPrice_Incl   = Convert.ToDouble(dr["SalesPrice_Incl"].ToString());
                    MRP               = Convert.ToDouble(dr["MRP"].ToString());
                    Discount          = Convert.ToDouble(dr["Discount"].ToString());
                    CalDiscount       = Convert.ToDouble(dr["CalDiscount"].ToString());
                    ShippingCost      = Convert.ToDouble(dr["ShippingCost"].ToString());
                    FinalSellingPrice = Convert.ToDouble(dr["FinalSellingPrice"].ToString());
                    TaxFinalPrice     = Convert.ToDouble(dr["TaxFinalPrice"].ToString());
                    MinQty            = Convert.ToDouble(dr["Quantity"].ToString());
                    ShippingDays      = dr["ShippingDays"].ToString();
                    IsCOD             = Convert.ToBoolean(dr["IsCOD"]);
                }

                Label lblSize  = (Label)e.Item.FindControl("lblSize");
                Label lblColor = (Label)e.Item.FindControl("lblColor");

                SizeName   = lblSize.Text;
                ColourName = lblColor.Text;

                Price = MinQty * FinalSellingPrice;

                clsCart = new clsAddToCart();
                if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName))
                {
                    clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, MinQty, FinalSellingPrice, SizeName, ColourName);
                }
                else
                {
                    clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, MinQty, ShippingDays, IsCOD, Price);
                }
                Response.Redirect("Cart.aspx");
                BindTopCartItems();
            }
        }
    }
    protected void Addingitemincart(string ProductId, string size, string color, double quantity)
    {
        DataTable dt = new DataTable();

        clsWishlist = new clsWishlist();
        dt          = clsWishlist.BindWishlistOnProductSizeColor(ProductId, size, color);


        foreach (DataRow dr in dt.Rows)
        {
            ProductId           = dr["ProductId"].ToString();
            CategoryName        = dr["CategoryName"].ToString();
            SubCategoryName     = dr["SubCategoryName"].ToString();
            ProductName         = dr["ProductName"].ToString();
            Productdescp        = dr["Productdescp"].ToString();
            BrandName           = dr["BrandName"].ToString();
            SupplierName        = dr["SupplierName"].ToString();
            Unit                = dr["Unit"].ToString();
            ProductCode         = dr["ProductCode"].ToString();
            SupplierProductCode = dr["SupplierProductCode"].ToString();
            PackSize            = dr["PackSize"].ToString();
            ProductCost         = Convert.ToDouble(dr["ProductCost"].ToString());
            ProductWeight       = Convert.ToDouble(dr["ProductWeight"].ToString());
            Image               = dr["Image"].ToString();
            Certification       = dr["Certification"].ToString();
            Description         = dr["Description"].ToString();
            Margin              = Convert.ToDouble(dr["Margin"].ToString());
            SalePrice           = Convert.ToDouble(dr["SalePrice"].ToString());
            Tax               = Convert.ToDouble(dr["Tax"].ToString());
            SalesPrice_Incl   = Convert.ToDouble(dr["SalesPrice_Incl"].ToString());
            MRP               = Convert.ToDouble(dr["MRP"].ToString());
            Discount          = Convert.ToDouble(dr["Discount"].ToString());
            CalDiscount       = Convert.ToDouble(dr["CalDiscount"].ToString());
            ShippingCost      = Convert.ToDouble(dr["ShippingCost"].ToString());
            FinalSellingPrice = Convert.ToDouble(dr["FinalSellingPrice"].ToString());
            TaxFinalPrice     = Convert.ToDouble(dr["TaxFinalPrice"].ToString());
            MinQty            = Convert.ToDouble(dr["Qty"].ToString());
            ShippingDays      = dr["ShippingDays"].ToString();
            IsCOD             = Convert.ToBoolean(dr["IsCOD"]);
        }

        SizeName   = size;
        ColourName = color;

        if (quantity < MinQty)
        {
            MsgBox("Minimum Qty required for order is : " + MinQty);
            return;
        }

        Price = quantity * FinalSellingPrice;

        clsCart = new clsAddToCart();

        if (quantity != 0)
        {
            if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName))
            {
                clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, Qty, FinalSellingPrice, SizeName, ColourName);
            }
            else
            {
                clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, Qty, ShippingDays, IsCOD, Price);
            }
        }
    }
    protected void rptrProductDetail_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        bool IsLogin;

        // Add to Cart
        if (e.CommandName == "AddCart")
        {
            RadioButtonList rdbSize = (RadioButtonList)e.Item.FindControl("rdbSize");
            Panel           pnlSize = (Panel)e.Item.FindControl("pnlSize");

            if (!pnlSize.Visible)
            {
                SizeName = "NA";
            }
            else if (rdbSize.SelectedIndex > -1)
            {
                SizeName = rdbSize.SelectedItem.Text;
            }
            else
            {
                MsgBox("Please Select Size");
                return;
            }

            RadioButtonList rdbColor = (RadioButtonList)e.Item.FindControl("rdbColor");
            Panel           pnlColor = (Panel)e.Item.FindControl("pnlColour");

            if (!pnlColor.Visible)
            {
                ColourName = "NA";
            }
            else if (rdbColor.SelectedIndex > -1)
            {
                ColourName = rdbColor.SelectedItem.Text;
            }
            else
            {
                MsgBox("Please Select Color");
                return;
            }

            TextBox txtQty = (TextBox)e.Item.FindControl("txtQty");

            Qty = Convert.ToDouble(txtQty.Text);

            dtproduct = new DataTable();
            dtproduct = cl.getdataset("select ProductCategory.CategoryName,ProductSubCategory.SubCategoryName,Brand.BrandName,product.*,(case Productdescp when '' then ProductName else ProductName +'&nbsp;('+Productdescp+')'  end ) as pname, (case Productdescp when '' then '' else '('+Productdescp+')'  end ) as pline2,  Supplier.SupplierName,Unit.Unit,  c.*,c.discount as crmdiscount from  Product inner join ProductCategory on Product.ProductCategoryId=ProductCategory.Id  inner join ProductSubCategory on Product.ProductSubCategoryId=ProductSubCategory.Id  inner join Brand on Product.BrandId=Brand.Id  left join unit on Product.UnitId=Unit.Id inner join crm c on c.productid=Product.id left join Supplier on Product.SupplierId=Supplier.Id   where Product.IsActive=1 and Product.Id='" + pid + "' and c.cusotmerid='" + memberid + "'");

            if (dtproduct != null)
            {
                foreach (DataRow dr in dtproduct.Rows)
                {
                    ProductId           = dr["Id"].ToString();
                    CategoryName        = dr["CategoryName"].ToString();
                    SubCategoryName     = dr["SubCategoryName"].ToString();
                    ProductName         = dr["ProductName"].ToString();
                    Productdescp        = dr["Productdescp"].ToString();
                    BrandName           = dr["BrandName"].ToString();
                    SupplierName        = dr["SupplierName"].ToString();
                    Unit                = dr["Unit"].ToString();
                    ProductCode         = dr["ProductCode"].ToString();
                    SupplierProductCode = dr["SupplierProductCode"].ToString();
                    PackSize            = dr["PackSize"].ToString();
                    ProductCost         = Convert.ToDouble(dr["ProductCost"].ToString());
                    ProductWeight       = Convert.ToDouble(dr["ProductWeight"].ToString());
                    Image               = dr["Image"].ToString();
                    Certification       = dr["Certification"].ToString();
                    Description         = dr["Description"].ToString();
                    Margin              = Convert.ToDouble(dr["Margin"].ToString());
                    SalePrice           = Convert.ToDouble(dr["SalePrice"].ToString());
                    Tax               = Convert.ToDouble(dr["Tax"].ToString());
                    SalesPrice_Incl   = Convert.ToDouble(dr["SalesPrice_Incl"].ToString());
                    MRP               = Convert.ToDouble(dr["MRP"].ToString());
                    Discount          = Convert.ToDouble(dr["Discount"].ToString());
                    CalDiscount       = Convert.ToDouble(dr["CalDiscount"].ToString());
                    ShippingCost      = Convert.ToDouble(dr["ShippingCost"].ToString());
                    FinalSellingPrice = Convert.ToDouble(dr["netsaleprice"].ToString());
                    TaxFinalPrice     = Convert.ToDouble(dr["TaxFinalPrice"].ToString());
                    MinQty            = Convert.ToDouble(dr["Quantity"].ToString());
                    ShippingDays      = dr["ShippingDays"].ToString();
                    IsCOD             = Convert.ToBoolean(dr["IsCOD"]);
                }

                if (Qty < MinQty)
                {
                    MsgBox("Minimum Qty required for order is : " + MinQty);
                    return;
                }

                Price = Qty * FinalSellingPrice;

                clsCart = new clsAddToCart();
                if (clsCart.FindExistItemWithSizeColor(ProductId, SizeName, ColourName))
                {
                    clsCart.UpdateQtyAndPriceWithSizeColor(ProductId, Qty, FinalSellingPrice, SizeName, ColourName);
                }
                else
                {
                    clsCart.AddToCart(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, Qty, ShippingDays, IsCOD, Price);
                }
                if (Qty > 0)
                {
                    Response.Redirect("Cart.aspx");
                }
                else
                {
                    //Response.Redirect("Cart.aspx");
                    //BindTopCartItems();

                    MsgBox("Please Select Color");
                }
            }
            else
            {
                BindProductDetail(pid);
            }
        }
        // Add to Wishlist
        else if (e.CommandName == "AddWishlist")
        {
            RadioButtonList rdbSize = (RadioButtonList)e.Item.FindControl("rdbSize");
            Panel           pnlSize = (Panel)e.Item.FindControl("pnlSize");

            if (!pnlSize.Visible)
            {
                SizeName = "NA";
            }
            else if (rdbSize.SelectedIndex > -1)
            {
                SizeName = rdbSize.SelectedItem.Text;
            }
            else
            {
                MsgBox("Please Select Size");
                return;
            }

            RadioButtonList rdbColor = (RadioButtonList)e.Item.FindControl("rdbColor");
            Panel           pnlColor = (Panel)e.Item.FindControl("pnlColour");

            if (!pnlColor.Visible)
            {
                ColourName = "NA";
            }
            else if (rdbColor.SelectedIndex > -1)
            {
                ColourName = rdbColor.SelectedItem.Text;
            }
            else
            {
                MsgBox("Please Select Color");
                return;
            }

            //TextBox txtQty = (TextBox)e.Item.FindControl("txtQty");

            //if (string.IsNullOrEmpty(txtQty.Text))
            //{
            //    Qty = 0;
            //}
            //else
            //{
            //    Qty = Convert.ToDouble(txtQty.Text);
            //}
            dtproduct = new DataTable();
            dtproduct = cl.getdataset("select ProductCategory.CategoryName,ProductSubCategory.SubCategoryName,Brand.BrandName,product.*,(case Productdescp when '' then ProductName else ProductName +'&nbsp;('+Productdescp+')'  end ) as pname, (case Productdescp when '' then '' else '('+Productdescp+')'  end ) as pline2,  Supplier.SupplierName,Unit.Unit,  c.*,c.discount as crmdiscount from  Product inner join ProductCategory on Product.ProductCategoryId=ProductCategory.Id  inner join ProductSubCategory on Product.ProductSubCategoryId=ProductSubCategory.Id  inner join Brand on Product.BrandId=Brand.Id  left join unit on Product.UnitId=Unit.Id inner join crm c on c.productid=Product.id left join Supplier on Product.SupplierId=Supplier.Id   where Product.IsActive=1 and Product.Id='" + pid + "' and c.cusotmerid='" + memberid + "'");

            foreach (DataRow dr in dtproduct.Rows)
            {
                ProductId           = dr["Id"].ToString();
                CategoryName        = dr["CategoryName"].ToString();
                SubCategoryName     = dr["SubCategoryName"].ToString();
                ProductName         = dr["ProductName"].ToString();
                Productdescp        = dr["Productdescp"].ToString();
                BrandName           = dr["BrandName"].ToString();
                SupplierName        = dr["SupplierName"].ToString();
                Unit                = dr["Unit"].ToString();
                ProductCode         = dr["ProductCode"].ToString();
                SupplierProductCode = dr["SupplierProductCode"].ToString();
                PackSize            = dr["PackSize"].ToString();
                ProductCost         = Convert.ToDouble(dr["ProductCost"].ToString());
                ProductWeight       = Convert.ToDouble(dr["ProductWeight"].ToString());
                Image               = dr["Image"].ToString();
                Certification       = dr["Certification"].ToString();
                Description         = dr["Description"].ToString();
                Margin              = Convert.ToDouble(dr["Margin"].ToString());
                SalePrice           = Convert.ToDouble(dr["SalePrice"].ToString());
                Tax               = Convert.ToDouble(dr["Tax"].ToString());
                SalesPrice_Incl   = Convert.ToDouble(dr["SalesPrice_Incl"].ToString());
                MRP               = Convert.ToDouble(dr["MRP"].ToString());
                Discount          = Convert.ToDouble(dr["Discount"].ToString());
                CalDiscount       = Convert.ToDouble(dr["CalDiscount"].ToString());
                ShippingCost      = Convert.ToDouble(dr["ShippingCost"].ToString());
                FinalSellingPrice = Convert.ToDouble(dr["netsaleprice"].ToString());
                TaxFinalPrice     = Convert.ToDouble(dr["TaxFinalPrice"].ToString());
                MinQty            = Convert.ToDouble(dr["Quantity"].ToString());
                ShippingDays      = dr["ShippingDays"].ToString();
                IsCOD             = Convert.ToBoolean(dr["IsCOD"]);
            }

            Price = MinQty * FinalSellingPrice;

            clsWishlist = new clsWishlist();
            if (clsWishlist.FindExistItemWithSizeColor(ProductId, SizeName, ColourName))
            {
                clsWishlist.UpdateQtyAndPriceWithSizeColor(ProductId, MinQty, FinalSellingPrice, SizeName, ColourName);
            }
            else
            {
                clsWishlist.AddToWishlist(ProductId, CategoryName, SubCategoryName, ProductName, Productdescp, BrandName, SupplierName, Unit, ColourName, SizeName, ProductCode, SupplierProductCode, PackSize, ProductCost, ProductWeight, Image, Certification, Description, Margin, SalePrice, Tax, SalesPrice_Incl, MRP, Discount, CalDiscount, ShippingCost, FinalSellingPrice, TaxFinalPrice, MinQty, ShippingDays, IsCOD, Price);
            }
            IsLogin = CheckUserSession();
            if (!IsLogin)
            {
                Session["CameFrom"] = "Wishlist";
                MessageThenRedirectTo("Please Login to Save Wishlist", "Register");
                return;
            }
            else
            {
                Response.Redirect("WishList.aspx");
            }
        }
        //check pincode
        else if (e.CommandName == "CheckPincode")
        {
            TextBox txtPinCode = (TextBox)e.Item.FindControl("txtPinCode");
            if (txtPinCode != null)
            {
                DataTable dt = new DataTable();
                dt = getStateCityOnPincode(Convert.ToInt64(txtPinCode.Text));
                Panel pnlShippingAvailable = (Panel)e.Item.FindControl("pnlShippingAvailable");
                Panel pnlShippingPin       = (Panel)e.Item.FindControl("pnlShippingPin");

                if (dt.Rows.Count > 0)
                {
                    pnlShippingAvailable.Visible = true;
                    pnlShippingPin.Visible       = false;
                }
                else
                {
                    pnlShippingAvailable.Visible = false;
                    pnlShippingPin.Visible       = true;
                }
            }
        }
    }