Esempio n. 1
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Customers.CustomFields"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Customers.CustomFields");
        }

        // Set edit mode
        customerId = QueryHelper.GetInteger("customerId", 0);
        if (customerId > 0)
        {
            customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);
            // Check if customer belongs to current site
            if (!CheckCustomerSiteID(customerObj))
            {
                customerObj = null;
            }

            EditedObject = customerObj;
            formCustomerCustomFields.Info          = customerObj;
            formCustomerCustomFields.OnBeforeSave += formCustomerCustomFields_OnBeforeSave;
            formCustomerCustomFields.OnAfterSave  += formCustomerCustomFields_OnAfterSave;
        }
        else
        {
            formCustomerCustomFields.Enabled = false;
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Returns customer details
 /// </summary>
 /// <returns></returns>
 private static CustomerDTO GetCustomer()
 {
     try
     {
         var settingKeyValue    = DIContainer.Resolve <IKenticoResourceService>().GetSettingsKey("KDA_SoldToGeneralInventory");
         var distributorID      = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int));
         var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault();
         var customer           = CustomerInfoProvider.GetCustomerInfo(distributorAddress.AddressCustomerID);
         return(new CustomerDTO
         {
             FirstName = customer.CustomerFirstName,
             LastName = customer.CustomerLastName,
             KenticoCustomerID = customer.CustomerID,
             Email = customer.CustomerEmail,
             CustomerNumber = settingKeyValue,
             KenticoUserID = customer.CustomerUserID,
             Phone = customer.CustomerPhone
         });
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("ShoppingCartHelper", "GetCustomer", ex.Message);
         return(null);
     }
 }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Customers.Addresses"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Customers.Addresses");
        }

        customerId  = QueryHelper.GetInteger("customerId", 0);
        customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);

        // Check if customer belongs to current site
        if (!CheckCustomerSiteID(customerObj))
        {
            customerObj = null;
        }

        EditedObject = customerObj;

        UniGrid.OnAction            += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
        UniGrid.WhereCondition       = "AddressCustomerID = " + customerId;

        // Intialize the master page elements
        InitializeMasterPage();
    }
    protected void EditForm_OnAfterDataLoad(object sender, EventArgs e)
    {
        // New objects only
        if ((EditedObject == null) || (((BaseInfo)EditedObject).Generalized.ObjectID <= 0))
        {
            // Fill default values to the form
            CustomerInfo customerInfo = CustomerInfoProvider.GetCustomerInfo(CustomerID);
            if (customerInfo != null)
            {
                if ((string.IsNullOrEmpty(customerInfo.CustomerFirstName)) && (string.IsNullOrEmpty(customerInfo.CustomerLastName)))
                {
                    FillDefaultValue("AddressPersonalName", customerInfo.CustomerCompany);
                }
                else
                {
                    FillDefaultValue("AddressPersonalName", customerInfo.CustomerFirstName + " " + customerInfo.CustomerLastName);
                }

                FillDefaultValue("AddressPhone", customerInfo.CustomerPhone);
                FillDefaultValue("AddressCountryID", customerInfo.CustomerCountryID);

                // Preselect state
                EditForm.Data.SetValue("AddressStateID", customerInfo.CustomerStateID);
            }
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        var id = ValidationHelper.GetInteger(actionArgument, 0);

        if (actionName == "edit")
        {
            URLHelper.Redirect(UIContextHelper.GetElementUrl("CMS.Ecommerce", "EditCustomersProperties", false, id));
        }
        else if (actionName == "delete")
        {
            // Check module permissions
            if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
            {
                RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers");
                return;
            }

            // Get customer to be deleted
            var customer = CustomerInfoProvider.GetCustomerInfo(id);

            // Check customers dependencies
            if ((customer != null) && customer.Generalized.CheckDependencies())
            {
                ShowError(ECommerceHelper.GetDependencyMessage(customer));
                return;
            }

            // Delete CustomerInfo object from database
            CustomerInfoProvider.DeleteCustomerInfo(customer);

            UniGrid.ReloadData();
        }
    }
Esempio n. 6
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Set edit mode
        customerId = QueryHelper.GetInteger("customerId", 0);
        if (customerId > 0)
        {
            customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);
            // Check if customer belongs to current site
            if (!CheckCustomerSiteID(customerObj))
            {
                customerObj = null;
            }

            EditedObject = customerObj;
            formCustomerCustomFields.Info             = customerObj;
            formCustomerCustomFields.OnAfterValidate += formCustomerCustomFields_OnAfterValidate;
            formCustomerCustomFields.OnAfterSave     += formCustomerCustomFields_OnAfterSave;
        }
        else
        {
            formCustomerCustomFields.Enabled = false;
        }
    }
Esempio n. 7
0
    protected ShoppingCartInfo GetNewCart()
    {
        ShoppingCartInfo newCart = ShoppingCartInfoProvider.CreateShoppingCartInfo(CMSContext.CurrentSite.SiteID);

        if (customerId > 0)
        {
            CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId);
            if (ci != null)
            {
                UserInfo ui = null;
                if (ci.CustomerUserID > 0)
                {
                    ui = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                    newCart.UserInfoObj = ui;
                }
                //if (ui == null)
                //{
                //    ui = CMSContext.GlobalPublicUser;
                //}
                //newCart.UserInfoObj = ui;
                newCart.ShoppingCartCustomerID = customerId;
            }
        }

        return(newCart);
    }
Esempio n. 8
0
    private void ucSelectCustomer_Changed(object sender, EventArgs e)
    {
        // Check permissions
        if (ContactHelper.AuthorizedModifyContact(ci.ContactSiteID, true))
        {
            // Load value form dynamic control
            string values = null;
            if (ucSelectCustomer != null)
            {
                values = ValidationHelper.GetString(ucSelectCustomer.GetValue("OnlineMarketingValue"), null);
            }

            if (!String.IsNullOrEmpty(values))
            {
                // Store users one by one
                string[] customerIds   = values.Split(';');
                int      currentSiteID = SiteContext.CurrentSiteID;
                foreach (string customerId in customerIds)
                {
                    // Check if user ID is valid
                    int customerIdInt = ValidationHelper.GetInteger(customerId, 0);
                    if (customerIdInt <= 0)
                    {
                        continue;
                    }

                    var customer = CustomerInfoProvider.GetCustomerInfo(customerIdInt);
                    // Only allow adding customers on the same site as contact or registered customers
                    if ((customer == null) || ((customer.CustomerSiteID != currentSiteID) && (customer.CustomerSiteID != 0)))
                    {
                        continue;
                    }

                    // Add new relation
                    int parentId = (ci.ContactMergedWithContactID == 0)
                   ? ci.ContactID
                   : ci.ContactMergedWithContactID;

                    ContactMembershipInfoProvider.SetRelationship(customerIdInt, MemberTypeEnum.EcommerceCustomer, ci.ContactID, parentId, true);
                    ci = ContactInfoProvider.GetContactInfo(contactId);
                }

                // When contact was merged then refresh complete page
                if ((ci != null) && (ci.ContactMergedWithContactID > 0))
                {
                    Page.Response.Redirect(RequestContext.URL.ToString(), true);
                }
                else
                {
                    gridElem.ReloadData();
                }
            }
        }
    }
Esempio n. 9
0
    private void InitData()
    {
        CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId);

        if (ci != null)
        {
            ucCountrySelector.CountryID  = ci.CustomerCountryID;
            ucCountrySelector.StateID    = ci.CustomerStateID;
            txtAddressDeliveryPhone.Text = ci.CustomerPhone;
            txtPersonalName.Text         = ci.CustomerFirstName + " " + ci.CustomerLastName;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Customers.Credit"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Customers.Credit");
        }

        // Get site id of credits main currency
        creditCurrencySiteId = ECommerceHelper.GetSiteID(CMSContext.CurrentSiteID, ECommerceSettings.USE_GLOBAL_CREDIT);

        // Get currency in which credit is expressed in
        currency = CurrencyInfoProvider.GetMainCurrency(creditCurrencySiteId);

        // Get customerId from url
        customerId = QueryHelper.GetInteger("customerid", 0);

        // Load customer info
        customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);

        // Check if customer belongs to current site
        if (!CheckCustomerSiteID(customerObj))
        {
            customerObj = null;
        }

        // Check, if edited customer exists
        EditedObject = customerObj;

        // Init unigrid
        UniGrid.HideControlForZeroRows = true;
        UniGrid.OnAction            += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
        UniGrid.OrderBy              = "EventDate DESC, EventName ASC";
        UniGrid.WhereCondition       = "EventCustomerID = " + customerId + " AND ISNULL(EventSiteID, 0) = " + creditCurrencySiteId;

        if (customerObj != null)
        {
            InitializeMasterPage();

            // Configuring global records
            if (creditCurrencySiteId == 0)
            {
                // Show "using global settings" info message only if showing global store settings
                lblGlobalInfo.Visible = true;
                lblGlobalInfo.Text    = GetString("com.UsingGlobalSettings");
            }

            // Display customer total credit
            lblCredit.Text      = GetString("CreditEvent_List.TotalCredit");
            lblCreditValue.Text = GetFormatedTotalCredit();
        }
    }
    /// <summary>
    /// On btnOK button click.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event argument</param>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // check 'EcommerceModify' permission

        if (!ECommerceContext.IsUserAuthorizedForPermission("ModifyOrders"))
        {
            RedirectToAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyOrders");
        }

        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            OrderInfo oi = OrderInfoProvider.GetOrderInfo(orderId);
            if (oi != null)
            {
                oi.OrderDate             = orderDate.SelectedDateTime;
                oi.OrderNote             = txtNotes.Text;
                oi.OrderStatusID         = statusElem.OrderStatusID;
                oi.OrderCompanyAddressID = addressElem.AddressID;

                // update orderinfo
                OrderInfoProvider.SetOrderInfo(oi);

                ////Get all params to send in mail
                string invoicenumber = oi.OrderInvoiceNumber; //#OrderInvoiceNumber
                //ev.LogEvent("I", DateTime.Now, "invoicenumber : ", invoicenumber);
                //ev.LogEvent("I", DateTime.Now, " statusElem.Value : ", statusElem.Value.ToString());

                //Send mail
                if (statusElem.Value.ToString() == val)
                {
                    var cu = CustomerInfoProvider.GetCustomerInfo(oi.OrderCustomerID);
                    SendMail(cu.CustomerEmail, invoicenumber);
                }

                URLHelper.Redirect("Order_Edit_General.aspx?orderid=" + Convert.ToString(oi.OrderID) + "&saved=1");
            }
            else
            {
                // Show error message
                ShowError(GetString("order_edit.ordernotexist"));
            }
        }

        // Show error message
        if (errorMessage != "")
        {
            // Show error message
            ShowError(errorMessage);
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Process form data.
    /// </summary>
    public override bool ProcessStep()
    {
        int customerId = 0;

        if (ExistingCustomer)
        {
            // Select an existing customer
            customerId = customerSelector.CustomerID;
        }

        if (!ExistingCustomer)
        {
            // Check permissions
            if (!HasModifyCustomerPermission)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "ModifyCustomers OR EcommerceModify");
                return(false);
            }

            // Create a new customer
            customerForm.SaveData(null, false);

            var customer = (CustomerInfo)EditedObject;
            customerId = customer.CustomerID;

            var reg = ValidationHelper.GetBoolean(customerForm.GetFieldValue("Register"), false);
            if (reg)
            {
                CustomerInfoProvider.RegisterAndNotify(customer, "Ecommerce.AutomaticRegistration");
            }
        }

        // Assign customer and user to the shopping cart
        if (customerId > 0)
        {
            var customer = CustomerInfoProvider.GetCustomerInfo(customerId);

            if (customer != null)
            {
                ShoppingCart.ShoppingCartCustomerID = customerId;

                if (customer.CustomerIsRegistered)
                {
                    ShoppingCart.User = UserInfoProvider.GetUserInfo(customer.CustomerUserID) ?? AuthenticationHelper.GlobalPublicUser;
                }

                return(true);
            }
        }

        return(false);
    }
Esempio n. 13
0
    protected override void OnPreInit(EventArgs e)
    {
        customerId = QueryHelper.GetInteger("customerid", 0);

        if (customerId > 0)
        {
            if (!ECommerceContext.CheckCustomerSiteID(CustomerInfoProvider.GetCustomerInfo(customerId)))
            {
                customerId = 0;
            }
        }
        base.OnPreInit(e);
    }
    /// <summary>
    /// Process form data.
    /// </summary>
    public override bool ProcessStep()
    {
        int customerId = 0;

        if (radSelectCustomer.Checked)
        {
            // Select an existing customer
            customerId = customerSelector.CustomerID;
        }

        if (radCreateCustomer.Checked)
        {
            // Check permissions
            if (!ECommerceContext.IsUserAuthorizedToModifyCustomer())
            {
                RedirectToAccessDenied("CMS.Ecommerce", "ModifyCustomers OR EcommerceModify");
                return(false);
            }

            // Create a new customer
            customerId = ucCustomerNew.Save();
        }

        // Assign customer and user to the shopping cart
        if (customerId > 0)
        {
            CustomerInfo customer = CustomerInfoProvider.GetCustomerInfo(customerId);

            if (customer != null)
            {
                ShoppingCart.ShoppingCartCustomerID = customer.CustomerID;

                if (customer.CustomerUserID > 0)
                {
                    UserInfo user = UserInfoProvider.GetUserInfo(customer.CustomerUserID);

                    if (user == null)
                    {
                        user = AuthenticationHelper.GlobalPublicUser;
                    }

                    ShoppingCart.User = user;
                }

                return(true);
            }
        }

        return(false);
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Retrieve customer from the database
        CustomerInfo customer = CustomerInfoProvider.GetCustomerInfo(FilterCustomerID);

        // If a valid customer is specified, disable filtering by customer's properties
        if (customer != null)
        {
            CustomerFilterEnabled = false;
        }

        // Initialize the control with values All, Yes and No
        InitializeThreeStateDropDownList(drpOrderIsPaid);

        // If this control is associated with an UniGrid control, disable UniGrid's buttons and initialize the Reset button
        UniGrid grid = FilteredControl as UniGrid;

        if (grid != null)
        {
            grid.HideFilterButton = true;
            // Reset button is available only when UniGrid remembers its state
            if (grid.RememberState)
            {
                btnReset.Text   = GetString("general.reset");
                btnReset.Click += btnReset_Click;
            }
            else
            {
                btnReset.Visible = false;
            }
        }

        // Initialize the Show button
        btnFilter.Text   = GetString("general.filter");
        btnFilter.Click += btnFilter_Click;

        // Hide unwanted elements
        plcAdvancedGroup.Visible = false;
        plcSimpleFilter.Visible  = false;

        // Use timezones for DateTimePickers
        TimeZoneInfo timeZone = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite);

        dtpFrom.TimeZone            = TimeZoneTypeEnum.Custom;
        dtpFrom.CustomTimeZone      = timeZone;
        dtpCreatedTo.TimeZone       = TimeZoneTypeEnum.Custom;
        dtpCreatedTo.CustomTimeZone = timeZone;
    }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get site id of credits main currency
        creditCurrencySiteId = ECommerceHelper.GetSiteID(SiteContext.CurrentSiteID, ECommerceSettings.USE_GLOBAL_CREDIT);

        // Get currency in which credit is expressed in
        currency = CurrencyInfoProvider.GetMainCurrency(creditCurrencySiteId);

        // Get customerId from url
        customerId = QueryHelper.GetInteger("customerid", 0);

        // Load customer info
        customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);

        // Check if customer belongs to current site
        if (!CheckCustomerSiteID(customerObj))
        {
            customerObj = null;
        }

        // Check, if edited customer exists
        EditedObject = customerObj;

        // Init unigrid
        UniGrid.HideControlForZeroRows = true;
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
        UniGrid.OrderBy              = "EventDate DESC, EventName ASC";
        UniGrid.WhereCondition       = "EventCustomerID = " + customerId + " AND ISNULL(EventSiteID, 0) = " + creditCurrencySiteId;

        if (customerObj != null)
        {
            InitializeMasterPage();

            // Configuring global credit
            if (creditCurrencySiteId == 0)
            {
                var site = SiteContext.CurrentSite;
                if (site != null)
                {
                    // Show "using global credit" info message
                    ShowInformation(string.Format(GetString("com.UsingGlobalSettings"), site.DisplayName, GetString("com.ui.creditevents")));
                }
            }

            // Display customer total credit
            headTotalCredit.Text = string.Format(GetString("CreditEvent_List.TotalCredit"), GetFormattedTotalCredit());
        }
    }
    /// <summary>
    /// Initialize the form with order values.
    /// </summary>
    protected void InitializeForm(OrderInfo orderInfo)
    {
        lblOrderIdValue.Text       = Convert.ToString(orderInfo.OrderID);
        orderDate.SelectedDateTime = orderInfo.OrderDate;
        lblInvoiceNumberValue.Text = HTMLHelper.HTMLEncode(Convert.ToString(orderInfo.OrderInvoiceNumber));
        txtNotes.Text = orderInfo.OrderNote;

        CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId);

        if (ci != null)
        {
            lblCustomerName.Text = HTMLHelper.HTMLEncode(ci.CustomerFirstName + " " + ci.CustomerLastName);
        }

        statusElem.OrderStatusID = originalStatusId;
        addressElem.AddressID    = originalCompanyAddressId;
    }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (ECommerceContext.CurrentShoppingCart != null)
        {
            ShoppingCartInfoProvider.DeleteShoppingCartInfo(ECommerceContext.CurrentShoppingCart);
            ECommerceContext.CurrentShoppingCart = null;
        }


        string strOrderId = QueryHelper.GetText("orderID", string.Empty);
        int    orderid    = ValidationHelper.GetInteger(strOrderId, 0);
        string status     = QueryHelper.GetString("STATUS", string.Empty);//HttpContext.Current.Request.QueryString["STATUS"];

        ev.LogEvent("I", DateTime.Now, "status", status);
        ev.LogEvent("I", DateTime.Now, "orderid", strOrderId);

        if (status == "5" && orderid > 0)
        {
            ev.LogEvent("I", DateTime.Now, "ICI 2", "");
            var order = OrderInfoProvider.GetOrderInfo(orderid);
            if (order != null)
            {
                ev.LogEvent("I", DateTime.Now, "Order found", "");
                // Update the property
                order.OrderIsPaid   = true;
                order.OrderStatusID = 7;

                // Update the order
                OrderInfoProvider.SetOrderInfo(order);

                //Sendmail link of download to customer
                var    listModel   = GetDownLoadFile(orderid);
                var    oi          = OrderInfoProvider.GetOrderInfo(orderid);
                var    currentCust = CustomerInfoProvider.GetCustomerInfo(oi.OrderCustomerID);
                string mail        = currentCust.CustomerEmail;
                ev.LogEvent("I", DateTime.Now, "cust mail : " + mail, "");
                if (listModel != null)
                {
                    ev.LogEvent("I", DateTime.Now, "send mail to : " + mail, "");
                    SendMail(mail, listModel);
                }
            }
        }
    }
    private void LoadValues(int orderId)
    {
        this._paymentValues = new NameValueCollection();
        this._paymentValues.Add("PSPID", SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".OgonePSPID"));
        this._paymentValues.Add("TXTCOLOR", "#444444");
        this._paymentValues.Add("TBLTXTCOLOR", "#444444");
        this._paymentValues.Add("TBLBGCOLOR", "#F7F7F7");
        this._paymentValues.Add("BGCOLOR", "#F7F7F7");
        this._paymentValues.Add("PM", "CreditCard");

        // this._paymentValues.Add("cancelurl", "hthttp://v2.portedorient.com/fr-BE/Webshop/ShoppingCart");
        var brand = QueryHelper.GetString("brand", String.Empty);

        if (!String.IsNullOrWhiteSpace(brand))
        {
            this._paymentValues.Add("BRAND", brand);
        }


        OrderInfo    oi  = OrderInfoProvider.GetOrderInfo(orderId);
        CustomerInfo ci  = CustomerInfoProvider.GetCustomerInfo(oi.OrderCustomerID);
        CurrencyInfo cui = CurrencyInfoProvider.GetCurrencyInfo(oi.OrderCurrencyID);

        if (oi != null && ci != null && cui != null)
        {
            this._paymentValues.Add("orderID", String.Format("{0}", oi.OrderID));
            this._paymentValues.Add("amount", String.Format("{0}", Math.Floor(oi.OrderTotalPrice * 100)));
            this._paymentValues.Add("currency", cui.CurrencyCode);
            this._paymentValues.Add("language", String.Format("{0}", LocalizationContext.PreferredCultureCode));
            this._paymentValues.Add("CN", String.Format("{0} {1}", ci.CustomerFirstName, ci.CustomerLastName));
            this._paymentValues.Add("EMAIL", ci.CustomerEmail);

            AddressInfo ai = AddressInfoProvider.GetAddressInfo(oi.OrderBillingAddressID);
            if (ai != null)
            {
                this._paymentValues.Add("owneraddress", ai.AddressLine1);
                this._paymentValues.Add("ownerZIP", ai.AddressZip);
                this._paymentValues.Add("ownertown", ai.AddressCity);
                this._paymentValues.Add("ownertelno", ai.AddressPhone);
            }
        }

        AddShaSignature();
    }
Esempio n. 20
0
    /// <summary>
    /// Adds content of order to current shopping cart.
    /// </summary>
    private void AddToCart(int orderId)
    {
        if (!ShowOrderToShoppingCart)
        {
            return;
        }

        // Get order
        OrderInfo order = OrderInfoProvider.GetOrderInfo(orderId);

        if (order != null)
        {
            CustomerInfo customer = CustomerInfoProvider.GetCustomerInfo(order.OrderCustomerID);

            if (customer.CustomerUserID == CurrentUser.UserID)
            {
                // Get current shopping cart
                ShoppingCartInfo cart = ECommerceContext.CurrentShoppingCart;
                // Set new cart
                if (cart.ShoppingCartID == 0)
                {
                    ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
                }

                string cartUrl = ECommerceSettings.ShoppingCartURL(CurrentSite.SiteName);

                // Update shopping cart by items from order
                if (!ShoppingCartInfoProvider.UpdateShoppingCartFromOrder(cart, orderId))
                {
                    cartUrl = URLHelper.AddParameterToUrl(cartUrl, "notallreordered", "1");
                }

                // Update shopping cart items in database
                foreach (ShoppingCartItemInfo item in cart.CartItems)
                {
                    ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(item);
                }

                // Redirect to shopping cart page
                URLHelper.ResponseRedirect(cartUrl);
            }
        }
    }
Esempio n. 21
0
    protected ShoppingCartInfo GetNewCart()
    {
        ShoppingCartInfo cart = null;
        var siteId            = SiteContext.CurrentSiteID;

        if (customerId > 0)
        {
            var customer = CustomerInfoProvider.GetCustomerInfo(customerId);
            if (customer != null)
            {
                cart = ShoppingCartFactory.CreateCart(siteId, customer.CustomerUser);
                cart.ShoppingCartCustomerID = customerId;
            }
        }

        cart = cart ?? ShoppingCartFactory.CreateCart(siteId);

        return(cart);
    }
Esempio n. 22
0
    /// <summary>
    /// New address form initialization.
    /// </summary>
    protected void InitData()
    {
        lblAddress.Text = "> " + GetString("Customer_Edit_Address_Edit.NewItemCaption");
        // Fill default values
        CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(mCustomerId);

        if (ci != null)
        {
            txtAddressDeliveryPhone.Text = ci.CustomerPhone;
            txtPersonalName.Text         = ci.CustomerFirstName + " " + ci.CustomerLastName;

            txtAddressZip.Text          = "";
            txtAddressLine1.Text        = "";
            txtAddressLine2.Text        = "";
            txtAddressCity.Text         = "";
            ucCountrySelector.CountryID = ci.CustomerCountryID;
            ucCountrySelector.StateID   = ci.CustomerStateID;
        }
    }
Esempio n. 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var orderId = QueryHelper.GetInteger("orderid", 0);
        var order   = OrderInfoProvider.GetOrderInfo(orderId);

        if (order != null)
        {
            var currentUser = MembershipContext.AuthenticatedUser;
            var customer    = CustomerInfoProvider.GetCustomerInfo(order.OrderCustomerID);
            var siteName    = SiteInfoProvider.GetSiteName(order.OrderSiteID);

            // To see invoice user needs to be global admin or have read order permission or access her own order
            if (((customer != null) && (customer.CustomerUserID == currentUser.UserID)) ||
                currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) ||
                order.CheckPermissions(PermissionsEnum.Read, siteName, currentUser))
            {
                ltlInvoice.Text = URLHelper.MakeLinksAbsolute(order.OrderInvoice);
            }
        }
    }
Esempio n. 24
0
    protected ShoppingCartInfo GetNewCart()
    {
        ShoppingCartInfo newCart = ShoppingCartInfoProvider.CreateShoppingCartInfo(SiteContext.CurrentSite.SiteID);

        if (customerId > 0)
        {
            CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId);
            if (ci != null)
            {
                if (ci.CustomerIsRegistered)
                {
                    newCart.User = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                }

                newCart.ShoppingCartCustomerID = customerId;
            }
        }

        return(newCart);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        customerId  = QueryHelper.GetInteger("customerId", 0);
        customerObj = CustomerInfoProvider.GetCustomerInfo(customerId);

        // Check if customer belongs to current site
        if (!CheckCustomerSiteID(customerObj))
        {
            customerObj = null;
        }

        EditedObject = customerObj;

        UniGrid.OnAction            += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
        UniGrid.WhereCondition       = "AddressCustomerID = " + customerId;

        // Intialize the master page elements
        InitializeMasterPage();
    }
Esempio n. 26
0
    /// <summary>
    /// New address form initialization.
    /// </summary>
    protected void InitData()
    {
        lblAddress.Text = "> " + GetString("Customer_Edit_Address_Edit.NewItemCaption");
        // Fill default values
        var customer = CustomerInfoProvider.GetCustomerInfo(mCustomerId);

        if (customer != null)
        {
            var customerAddress = ECommerceHelper.GetLastUsedOrDefaultAddress(mCustomerId);

            txtAddressDeliveryPhone.Text = customer.CustomerPhone;
            txtPersonalName.Text         = customer.CustomerFirstName + " " + customer.CustomerLastName;

            txtAddressZip.Text          = "";
            txtAddressLine1.Text        = "";
            txtAddressLine2.Text        = "";
            txtAddressCity.Text         = "";
            ucCountrySelector.CountryID = customerAddress.AddressCountryID;
            ucCountrySelector.StateID   = customerAddress.AddressStateID;
        }
    }
Esempio n. 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string currentCustomer = "";
        int    customerId      = QueryHelper.GetInteger("customerid", 0);

        if (customerId > 0)
        {
            customerInfoObj = CustomerInfoProvider.GetCustomerInfo(customerId);

            // Prepare customer name string
            if (customerInfoObj != null)
            {
                if (ValidationHelper.GetString(customerInfoObj.CustomerCompany, "") != "")
                {
                    currentCustomer = customerInfoObj.CustomerCompany;
                }
                else
                {
                    currentCustomer = customerInfoObj.CustomerLastName + " " + customerInfoObj.CustomerFirstName;
                }
            }
        }

        // Initialize breadcrumbs when visible
        if (!hideBreadcrumbs)
        {
            InitializeBreadcrumbs(currentCustomer);
        }

        // Ensure page with changes saved message is loaded initially if required
        if (QueryHelper.GetInteger("saved", 0) == 1)
        {
            CurrentMaster.Tabs.StartPageURL = "Customer_Edit_General.aspx" + URLHelper.Url.Query;
        }

        InitializeMasterPage();

        AddMenuButtonSelectScript("Customers", "");
    }
Esempio n. 28
0
    /// <summary>
    /// Process form data.
    /// </summary>
    public override bool ProcessStep()
    {
        try
        {
            // Get the customer
            int customerId = customerSelector.CustomerID;
            if (customerId > 0)
            {
                CustomerInfo ci = CustomerInfoProvider.GetCustomerInfo(customerId);
                if (ci != null)
                {
                    UserInfo ui = null;
                    if (ci.CustomerUserID > 0)
                    {
                        ui = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                    }
                    if (ui == null)
                    {
                        ui = CMSContext.GlobalPublicUser;
                    }

                    this.ShoppingCartInfoObj.UserInfoObj            = ui;
                    this.ShoppingCartInfoObj.ShoppingCartCustomerID = customerId;

                    return(true);
                }
            }

            lblError.Visible = true;
            lblError.Text    = GetString("ShoppingCartSelectCustomer.ErrorSelect");
            return(false);
        }
        catch (Exception ex)
        {
            lblError.Visible = true;
            lblError.Text    = ex.Message;
            return(false);
        }
    }
    protected void EditForm_OnAfterDataLoad(object sender, EventArgs e)
    {
        // Fill default values to the form
        var customerInfo = CustomerInfoProvider.GetCustomerInfo(CustomerID);

        if (customerInfo != null)
        {
            var customerAddressInfo = ECommerceHelper.GetLastUsedOrDefaultAddress(CustomerID);

            if ((string.IsNullOrEmpty(customerInfo.CustomerFirstName)) && (string.IsNullOrEmpty(customerInfo.CustomerLastName)))
            {
                FillDefaultValue("AddressPersonalName", customerInfo.CustomerCompany);
            }
            else
            {
                FillDefaultValue("AddressPersonalName", customerInfo.CustomerFirstName + " " + customerInfo.CustomerLastName);
            }

            FillDefaultValue("AddressPhone", customerInfo.CustomerPhone);
            FillDefaultValue("AddressCountryID", customerAddressInfo.AddressCountryID);
            EditForm.Data.SetValue("AddressStateID", customerAddressInfo.AddressStateID);
        }
    }
    /// <summary>
    /// Process valid values of this step.
    /// </summary>
    public override bool ProcessStep()
    {
        if (plcAccount.Visible)
        {
            string siteName = SiteContext.CurrentSiteName;

            // Existing account
            if (radSignIn.Checked)
            {
                // Authenticate user
                UserInfo ui = AuthenticationHelper.AuthenticateUser(txtUsername.Text.Trim(), txtPsswd1.Text, SiteContext.CurrentSiteName, false);
                if (ui == null)
                {
                    lblError.Text    = GetString("ShoppingCartCheckRegistration.LoginFailed");
                    lblError.Visible = true;
                    return(false);
                }

                // Sign in customer with existing account
                AuthenticationHelper.AuthenticateUser(ui.UserName, false);

                // Registered user has already started shopping as anonymous user -> Drop his stored shopping cart
                ShoppingCartInfoProvider.DeleteShoppingCartInfo(ui.UserID, siteName);

                // Assign current user to the current shopping cart
                ShoppingCart.User = ui;

                // Save changes to database
                if (!ShoppingCartControl.IsInternalOrder)
                {
                    ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
                }

                // Log "login" activity
                MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument);

                LoadStep(true);

                // Return false to get to Edit customer page
                return(false);
            }
            // New registration
            else if (radNewReg.Checked)
            {
                txtEmail2.Text             = txtEmail2.Text.Trim();
                pnlCompanyAccount1.Visible = chkCorporateBody.Checked;

                string[] siteList = { siteName };

                // If AssignToSites field set
                if (!String.IsNullOrEmpty(ShoppingCartControl.AssignToSites))
                {
                    siteList = ShoppingCartControl.AssignToSites.Split(';');
                }

                // Check if user exists
                UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail2.Text);
                if (ui != null)
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("ShoppingCartUserRegistration.ErrorUserExists");
                    return(false);
                }

                // Check all sites where user will be assigned
                if (!UserInfoProvider.IsEmailUnique(txtEmail2.Text.Trim(), siteList, 0))
                {
                    lblError.Visible = true;
                    lblError.Text    = GetString("UserInfo.EmailAlreadyExist");
                    return(false);
                }

                // Create new customer and user account and sign in
                // User
                ui           = new UserInfo();
                ui.UserName  = txtEmail2.Text.Trim();
                ui.Email     = txtEmail2.Text.Trim();
                ui.FirstName = txtFirstName1.Text.Trim();
                ui.LastName  = txtLastName1.Text.Trim();
                ui.FullName  = ui.FirstName + " " + ui.LastName;
                ui.Enabled   = true;
                ui.SiteIndependentPrivilegeLevel = UserPrivilegeLevelEnum.None;
                ui.UserURLReferrer = CookieHelper.GetValue(CookieName.UrlReferrer);
                ui.UserCampaign    = Service <ICampaignService> .Entry().CampaignCode;

                ui.UserSettings.UserRegistrationInfo.IPAddress = RequestContext.UserHostAddress;
                ui.UserSettings.UserRegistrationInfo.Agent     = HttpContext.Current.Request.UserAgent;

                try
                {
                    UserInfoProvider.SetPassword(ui, passStrength.Text);

                    foreach (string site in siteList)
                    {
                        UserInfoProvider.AddUserToSite(ui.UserName, site);

                        // Add user to roles
                        if (ShoppingCartControl.AssignToRoles != "")
                        {
                            AssignUserToRoles(ui.UserName, ShoppingCartControl.AssignToRoles, site);
                        }
                    }

                    // Log registered user
                    AnalyticsHelper.LogRegisteredUser(siteName, ui);

                    MembershipActivityLogger.LogRegistration(ui.UserName, DocumentContext.CurrentDocument);
                }
                catch (Exception ex)
                {
                    lblError.Visible = true;
                    lblError.Text    = ex.Message;
                    return(false);
                }

                // Customer
                CustomerInfo ci = new CustomerInfo();
                ci.CustomerFirstName = txtFirstName1.Text.Trim();
                ci.CustomerLastName  = txtLastName1.Text.Trim();
                ci.CustomerEmail     = txtEmail2.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";
                if (chkCorporateBody.Checked)
                {
                    ci.CustomerCompany = txtCompany1.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim();
                    }
                }

                ci.CustomerUserID  = ui.UserID;
                ci.CustomerSiteID  = 0;
                ci.CustomerCreated = DateTime.Now;
                CustomerInfoProvider.SetCustomerInfo(ci);

                // Track successful registration conversion
                string name = ShoppingCartControl.RegistrationTrackConversionName;
                ECommerceHelper.TrackRegistrationConversion(ShoppingCart.SiteName, name);

                CreateContactRelation(ci);

                // Sign in
                if (ui.Enabled)
                {
                    AuthenticationHelper.AuthenticateUser(ui.UserName, false);
                    ShoppingCart.User = ui;

                    MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument);
                }

                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;

                // Send new registration notification email
                if (ShoppingCartControl.SendNewRegistrationNotificationToAddress != "")
                {
                    SendRegistrationNotification(ui);
                }
            }
            // Anonymous customer
            else if (radAnonymous.Checked)
            {
                CustomerInfo ci = null;
                if (ShoppingCart.ShoppingCartCustomerID > 0)
                {
                    // Update existing customer account
                    ci = CustomerInfoProvider.GetCustomerInfo(ShoppingCart.ShoppingCartCustomerID);
                }
                if (ci == null)
                {
                    // Create new customer account
                    ci = new CustomerInfo();
                }

                ci.CustomerFirstName = txtFirstName2.Text.Trim();
                ci.CustomerLastName  = txtLastName2.Text.Trim();
                ci.CustomerEmail     = txtEmail3.Text.Trim();

                ci.CustomerCompany           = "";
                ci.CustomerOrganizationID    = "";
                ci.CustomerTaxRegistrationID = "";

                if (chkCorporateBody2.Checked)
                {
                    ci.CustomerCompany = txtCompany2.Text.Trim();
                    if (mShowOrganizationIDField)
                    {
                        ci.CustomerOrganizationID = txtOrganizationID2.Text.Trim();
                    }
                    if (mShowTaxRegistrationIDField)
                    {
                        ci.CustomerTaxRegistrationID = txtTaxRegistrationID2.Text.Trim();
                    }
                }

                ci.CustomerCreated = DateTime.Now;
                ci.CustomerSiteID  = SiteContext.CurrentSiteID;
                CustomerInfoProvider.SetCustomerInfo(ci);

                CreateContactRelation(ci);

                // Assign customer to shoppingcart
                ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
            }
            else
            {
                return(false);
            }
        }
        else
        {
            // Save the customer data
            bool         newCustomer = false;
            CustomerInfo ci          = CustomerInfoProvider.GetCustomerInfoByUserID(ShoppingCartControl.UserInfo.UserID);
            if (ci == null)
            {
                ci = new CustomerInfo();
                ci.CustomerUserID = ShoppingCartControl.UserInfo.UserID;
                ci.CustomerSiteID = 0;
                newCustomer       = true;
            }

            // Old email address
            string oldEmail = ci.CustomerEmail.ToLowerCSafe();

            ci.CustomerFirstName = txtEditFirst.Text.Trim();
            ci.CustomerLastName  = txtEditLast.Text.Trim();
            ci.CustomerEmail     = txtEditEmail.Text.Trim();

            pnlCompanyAccount2.Visible = chkEditCorpBody.Checked;

            ci.CustomerCompany           = "";
            ci.CustomerOrganizationID    = "";
            ci.CustomerTaxRegistrationID = "";
            if (chkEditCorpBody.Checked)
            {
                ci.CustomerCompany = txtEditCompany.Text.Trim();
                if (mShowOrganizationIDField)
                {
                    ci.CustomerOrganizationID = txtEditOrgID.Text.Trim();
                }
                if (mShowTaxRegistrationIDField)
                {
                    ci.CustomerTaxRegistrationID = txtEditTaxRegID.Text.Trim();
                }
            }

            // Update customer data
            CustomerInfoProvider.SetCustomerInfo(ci);

            // Update corresponding user email when required
            if (oldEmail != ci.CustomerEmail.ToLowerCSafe())
            {
                UserInfo user = UserInfoProvider.GetUserInfo(ci.CustomerUserID);
                if (user != null)
                {
                    user.Email = ci.CustomerEmail;
                    UserInfoProvider.SetUserInfo(user);
                }
            }

            if (newCustomer)
            {
                CreateContactRelation(ci);
            }

            // Set the shopping cart customer ID
            ShoppingCart.ShoppingCartCustomerID = ci.CustomerID;
        }

        try
        {
            if (!ShoppingCartControl.IsInternalOrder)
            {
                ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
            }

            ShoppingCart.InvalidateCalculations();
            return(true);
        }
        catch
        {
            return(false);
        }
    }