Пример #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sRating = ddlRating.SelectedValue;

        if (!String.IsNullOrEmpty(sRating))
        {
            //if the selection is null for some reason
            //default it.
            int rating = int.Parse(sRating);

            //add the review
            string review = Utility.StripHTML(txtReview.Text);
            string title  = Utility.StripHTML(txtTitle.Text);
            try {
                string thisUser = Utility.GetUserName();

                ProductReview rev = new ProductReview();
                rev.ProductID  = productID;
                rev.AuthorName = thisUser;
                rev.Body       = review;
                rev.IsApproved = false;
                rev.PostDate   = DateTime.UtcNow;
                rev.Rating     = rating;
                rev.Title      = title;

                rev.Save(thisUser);

                ResultMessage1.ShowSuccess("Review Saved!");
            } catch (Exception x) {
                ResultMessage1.ShowFail("Oops! There was an error and your review was not saved: " + x.Message);
            }
        }
        ToggleEditor(false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Exception x = Server.GetLastError();

        ResultMessage1.ShowFail("The record you are trying to update/delete cannot be changed at this time because there are associated records with it. <br><br>Error Message:<xmp style='font-face:courier;background-color:whitesmoke;font-size:10pt'>" + x.Message + "</xmp>");
        Server.ClearError();
    }
Пример #3
0
    void SetExpressOrder()
    {
        //use the API to get the SetCheckout response.
        //Then, redirect to PayPal
        int currencyDecimals = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits;
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        string sEmail = "";

        if (Profile.LastShippingAddress != null)
        {
            if (Profile.LastShippingAddress.Email != string.Empty)
            {
                sEmail = Profile.LastShippingAddress.Email;
            }
            else
            {
                sEmail = "*****@*****.**";
            }
        }

        //send them back here for all occassions
        string successURL = Utility.GetSiteRoot() + "/checkout.aspx";
        string failURL    = Utility.GetSiteRoot() + "/default.aspx";


        if (currentOrder.Items.Count > 0)
        {
            string ppToken = wrapper.SetExpressCheckout(sEmail, currentOrder.CalculateSubTotal(),
                                                        successURL, failURL, true, addShipping.SelectedAddress);
            if (ppToken.ToLower().Contains("error"))
            {
                //lblPPErr.Text="PayPal has returned an error message: "+ppToken;
            }
            else
            {
                string sUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;

                if (!SiteConfig.PayPalAPIIsLive)
                {
                    sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                }

                try {
                    Response.Redirect(sUrl, false);
                }
                catch (Exception x)
                {
                    LovRubLogger.LogException(x); // 04/10/08 KPL added
                    ResultMessage1.ShowFail(x.Message);
                }
            }
        }
        else
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        //register them
        MembershipCreateStatus status;

        Membership.CreateUser(txtLogin.Text, txtPassword.Text, txtEmail.Text, txtQ.Text, txtA.Text, true, out status);

        //add the profile
        if (status == MembershipCreateStatus.Success)
        {
            Profile.FirstName = txtFirst.Text;
            Profile.LastName  = txtLast.Text;
            Profile.Email     = txtEmail.Text;


            btnRegister.Enabled = false;
            //set the cookie
            FormsAuthentication.SetAuthCookie(txtLogin.Text, true);



            if (fromPage != string.Empty && !fromPage.ToLower().Contains("register.aspx"))
            {
                Response.Redirect(fromPage);
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        else
        {
            if (status == MembershipCreateStatus.DuplicateEmail)
            {
                ResultMessage1.ShowFail("This email is already in our system");
            }
            if (status == MembershipCreateStatus.DuplicateUserName)
            {
                ResultMessage2.ShowFail("Need to use another login - this one's taken");
            }
            if (status == MembershipCreateStatus.InvalidEmail)
            {
                ResultMessage1.ShowFail("Invalid email address");
            }
            if (status == MembershipCreateStatus.InvalidPassword)
            {
                ResultMessage1.ShowFail("Invalid password. Needs to be 6 or more letters/numbers");
            }
            if (status == MembershipCreateStatus.UserRejected)
            {
                ResultMessage1.ShowFail("You cannot register at this time");
            }
        }
    }
Пример #5
0
    string RunCharge()
    {
        string sOut = "";

        try {
            Transaction trans = OrderController.TransactOrder(currentOrder, TransactionType.CreditCardPayment);
            //the orderID is set during the TransactOrder process
            sOut = currentOrder.OrderGUID;
        }
        catch (Exception x) {
            ResultMessage1.ShowFail(x.Message);
        }

        return(sOut);
    }
Пример #6
0
    void RunSearch(string sQuery)
    {
        if (!String.IsNullOrEmpty(sQuery))
        {
            //IDataReader rdr = Commerce.Services.StoreDataService.ProductsSmartSearch(500, true, sQuery);
            rptSearch.DataSource = ProductController.RunSmartSearch(50,
                                                                    sQuery);;
            rptSearch.DataBind();

            if (rptSearch.Items.Count == 0)
            {
                ResultMessage1.ShowFail("No Results");
            }
        }
    }
Пример #7
0
    protected void SaveCrossList(object sender, EventArgs e)
    {
        //first, remove all the cross-sell bits
        int     productID = Utility.GetIntParameter("id");
        Product prod      = new Product(productID);

        try
        {
            //prod.SaveManyToMany("CSK_Promo_Product_CrossSell_Map", "crossProductID", chkProducts.Items);
            //Utility.SaveManyToMany("CSK_Store_Product", "productID", "CSK_Promo_Product_CrossSell_Map", "crossProductID", chkProducts.Items);
            Utility.SaveManyToMany("productID", productID, "CSK_Promo_Product_CrossSell_Map", "crossProductID", chkProducts.Items);
            ResultMessage1.ShowSuccess("Cross-Sells saved");
        }
        catch (Exception x)
        {
            ResultMessage1.ShowFail(x.Message);
        }
    }
Пример #8
0
    void ResetParent()
    {
        ToggleEditor(true);
        //reset the parent and reload the page
        try {
            int?newParentID = null;
            if (ParentID.SelectedIndex != 0)
            {
                newParentID = int.Parse(ParentID.SelectedValue);
            }

            CMS.ContentService.ChangeParent(thisPage.PageID, newParentID);
            LoadPageHierarchy();
            ResetSiteMap();
        } catch (Exception x) {
            ResultMessage1.ShowFail(x.Message);
        }
    }
Пример #9
0
    void DeletePage()
    {
        //delete the page and send to the admin page list
        bool haveError = false;

        try {
            CMS.ContentService.DeletePage(thisPage.PageID);
            this.ResetSiteMap();
        } catch (Exception x) {
            ResultMessage1.ShowFail(x.Message);
            haveError = true;
            ToggleEditor(true);
        }
        if (!haveError)
        {
            Response.Redirect("~/admin/cmspagelist.aspx");
        }
    }
Пример #10
0
    string RunExpressCheckout()
    {
        //InitOrder();

        //this is the PayPal response holder
        string orderID = "";

        string sToken = Utility.GetParameter("token");

        //run the Final Express Checkout
        try {
            Transaction trans = OrderController.TransactOrder(currentOrder, TransactionType.PayPalPayment);
            orderID = currentOrder.OrderGUID;
        }
        catch (Exception x) {
            ResultMessage1.ShowFail(x.Message);
        }

        return(orderID);
    }
Пример #11
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        int delCatID = int.Parse(lblID.Text);
        //see if this category has children

        //get all the categories
        CategoryCollection coll = new CategoryCollection().Load();

        //find the one to be deleted
        bool hasKids = false;

        foreach (Category cat in coll)
        {
            if (cat.ParentID == delCatID)
            {
                hasKids = true;
                break;
            }
        }

        if (!hasKids)
        {
            Category.Delete(delCatID);
            LoadCatBox();
            if (lstCats.Items.Count > 0)
            {
                lstCats.SelectedIndex = 0;
                LoadCategory(int.Parse(lstCats.SelectedValue));

                //Reload the master category list
                CategoryController.Load();
            }
        }
        else
        {
            ResultMessage1.ShowFail("You must delete all child categories first, or reassign them by dragging and dropping to another parent category");
        }
    }
Пример #12
0
    protected void btnSetGeneral_Click(object sender, EventArgs e)
    {
        // Get the current configuration file.
        System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        GeneralSettings section = (GeneralSettings)config.GetSection("GeneralSettings");

        try {
            if (section != null)
            {
                section.CurrencyCode     = ddlCurrencyType.SelectedValue;
                section.LoginRequirement = ddlLogin.SelectedValue;
                config.Save();
                ResultMessage1.ShowSuccess("General Settings Saved");
            }
            else
            {
                throw new Exception("There is no GeneralSettings section in the Web.Config");
            }
        }
        catch (Exception x) {
            ResultMessage1.ShowFail(x.Message);
        }
    }
Пример #13
0
 void ThrowError(string message)
 {
     ResultMessage1.ShowFail(message);
 }
Пример #14
0
    void SavePage()
    {
        //set the editor
        thisPage.Title     = txtTitle.Text;
        thisPage.Summary   = txtSummary.Text;
        thisPage.Body      = Body.Value;
        thisPage.MenuTitle = txtMenuTitle.Text;
        thisPage.Keywords  = txtKeywords.Text;

        string selectedRoles = string.Empty;
        bool   isAllRoles    = true;

        foreach (ListItem item in chkRoles.Items)
        {
            if (item.Selected)
            {
                selectedRoles += item.Value + ",";
            }
            else
            {
                isAllRoles = false;
            }
        }
        if (isAllRoles)
        {
            selectedRoles = "*";
        }
        else
        {
            if (selectedRoles.Length > 0)
            {
                selectedRoles = selectedRoles.Remove(selectedRoles.Length - 1, 1);
            }
            else
            {
                selectedRoles = "*";
            }
        }

        thisPage.Roles = selectedRoles;

        if (ParentID.SelectedIndex != 0)
        {
            thisPage.ParentID = int.Parse(ParentID.SelectedValue);
        }
        else
        {
            thisPage.ParentID = null;
        }

        bool haveError = false;

        try {
            CMS.ContentService.SavePage(thisPage);
            ResetSiteMap();
        } catch (Exception x) {
            haveError = true;
            ResultMessage1.ShowFail(x.Message);
        }

        //redirect to it
        if (!haveError)
        {
            Response.Redirect("view/" + thisPage.PageUrl);
        }
    }
Пример #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ResultMessage1.ShowFail("We are currently having problems on the site. The problem has been logged.");
 }
Пример #16
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Thanks Herman (osi_ni) for portions of this code
        if (Page.IsValid)
        {
            try {
                int manufacturerId = 0;
                int.TryParse(ddlManufacturerID.SelectedValue, out manufacturerId);
                int statusId = 0;
                int.TryParse(ddlStatusID.SelectedValue, out statusId);
                int productTypeId = 0;
                int.TryParse(ddlProductTypeID.SelectedValue, out productTypeId);
                int shippingTypeId = 0;
                int.TryParse(ddlShippingTypeID.SelectedValue, out shippingTypeId);
                int shipEstimateId = 0;
                int.TryParse(ddlShipEstimateID.SelectedValue, out shipEstimateId);
                int taxTypeId = 0;
                int.TryParse(ddlTaxTypeID.SelectedValue, out taxTypeId);
                decimal ourPrice = 0;
                decimal.TryParse(txtOurPrice.Text.Trim(), out ourPrice);
                decimal retailPrice = 0;
                decimal.TryParse(txtRetailPrice.Text.Trim(), out retailPrice);
                decimal weight = 0;
                decimal.TryParse(txtWeight.Text.Trim(), out weight);
                decimal length = 0;
                decimal.TryParse(txtLength.Text.Trim(), out length);
                decimal height = 0;
                decimal.TryParse(txtHeight.Text.Trim(), out height);
                decimal width = 0;
                decimal.TryParse(txtWidth.Text.Trim(), out width);
                int listOrder = 0;
                int.TryParse(txtListOrder.Text.Trim(), out listOrder);

                Commerce.Common.Product product = new Commerce.Common.Product();

                product.Sku              = txtSku.Text.Trim();
                product.ProductName      = txtProductName.Text.Trim();
                product.ShortDescription = txtShortDescription.Text.Trim();
                product.OurPrice         = ourPrice;
                product.RetailPrice      = retailPrice;
                product.ManufacturerID   = manufacturerId;
                product.Status           = (ProductStatus)statusId;
                product.ProductType      = (ProductType)productTypeId;
                product.ShippingType     = (ShippingType)shippingTypeId;
                product.ShipEstimateID   = shipEstimateId;
                product.TaxTypeID        = taxTypeId;
                product.StockLocation    = txtStockLocation.Text.Trim();
                product.Weight           = weight;
                product.CurrencyCode     = ddlCurrencyCodeID.SelectedValue.Trim();
                product.UnitOfMeasure    = txtUnitOfMeasure.Text.Trim();
                product.AdminComments    = txtAdminComments.Text.Trim();
                product.Length           = length;
                product.Height           = height;
                product.Width            = width;
                product.DimensionUnit    = txtDimensionUnit.Text.Trim();
                product.ListOrder        = listOrder;
                //default this to avoid division errors
                product.TotalRatingVotes = 1;
                product.RatingSum        = 4;


                //save it up and redirect
                product.Save(Utility.GetUserName());
                //send to the detail page
                Response.Redirect("admin_product_details.aspx?id=" + product.ProductID.ToString(), false);
            }
            catch (Exception x) {
                ResultMessage1.ShowFail(x.Message);
            }
        }
    }
Пример #17
0
 void Page_Error(object sender, EventArgs e)
 {
     Response.Write("Hoi");
     ResultMessage1.ShowFail("Cannot delete this manufacturer - there are associated products");
 }
Пример #18
0
    void SetExpressOrder()
    {
        //use the API to get the SetCheckout response.
        //Then, redirect to PayPal
        //get the wrapper
        APIWrapper wrapper = GetPPWrapper();

        string sEmail = "";

        if (Profile.LastShippingAddress != null)
        {
            if (Profile.LastShippingAddress.Email != string.Empty)
            {
                sEmail = Profile.LastShippingAddress.Email;
            }
            else
            {
                MembershipUserCollection membershipUserCollection = Membership.FindUsersByName(Request.Cookies["shopperID"].Value);
                if (membershipUserCollection.Count > 0)
                {
                    sEmail = membershipUserCollection[Request.Cookies["shopperID"].Value].Email;
                }
            }
        }

        //send them back here for all occassions
        string successURL = Utility.GetSiteRoot() + "/checkout.aspx";
        string failURL    = Utility.GetSiteRoot() + "/default.aspx";

        currentOrder = GetCurrentOrder();
        if (currentOrder.Items.Count > 0)
        {
            string ppToken = wrapper.SetExpressCheckout(sEmail, currentOrder.CalculateSubTotal(),
                                                        successURL, failURL, false, null);
            if (ppToken.ToLower().Contains("error"))
            {
                lblPPErr.Text = "PayPal has returned an error message: " + ppToken;
            }
            else
            {
                string sUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                if (!SiteConfig.PayPalAPIIsLive)
                {
                    sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + ppToken;
                }

                try {
                    Response.Redirect(sUrl, false);
                }
                catch (Exception x)
                {
                    LovRubLogger.LogException(x); // 04/10/08 KPL added
                    ResultMessage1.ShowFail(x.Message);
                }
            }
        }
        else
        {
            Response.Redirect("CCBasket.aspx", false);
        }
    }