예제 #1
0
        private void AddressDropdownDataBind(object sender, EventArgs e)
        {
            var ddl = (DropDownList)sender;
            var container = (IDataItemContainer)ddl.NamingContainer;
            try
            {
                ddl.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (ddl.Visible)
                {

                    var usr = UserController.GetCurrentUserInfo();
                    var addressData = new AddressData(usr.UserID.ToString(""));

                    if (ddl.Attributes["blank"] != null)
                    {
                        var li = new ListItem();
                        li.Text = ddl.Attributes["blank"];
                        li.Value = "-1";
                        ddl.Items.Add(li);
                        ddl.Attributes.Remove("blank");
                    }

                    var addrlist = addressData.GetAddressList();
                    foreach (var tItem in addrlist)
                    {
                        var itemtext = tItem.GetXmlProperty("genxml/textbox/firstname") + "," + tItem.GetXmlProperty("genxml/textbox/lastname") + "," + tItem.GetXmlProperty("genxml/textbox/unit") + "," + tItem.GetXmlProperty("genxml/textbox/street") + "," + tItem.GetXmlProperty("genxml/textbox/city");
                        if (ddl.Attributes["template"] != null)
                        {
                            itemtext = "";
                            var xpathList = ddl.Attributes["template"].Split(',');
                            foreach (var xp in xpathList)
                            {
                                itemtext += "," + tItem.GetXmlProperty(xp);
                            }
                        }
                        var datatext = "";
                        if (ddl.Attributes["data"] != null)
                        {
                            var xpathList = ddl.Attributes["data"].Split(',');
                            foreach (var xp in xpathList)
                            {
                                datatext += "," + tItem.GetXmlProperty(xp).Replace(","," ");
                            }
                        }
                        var datavalue = "";
                        if (ddl.Attributes["datavalue"] != null) datavalue += ddl.Attributes["datavalue"];

                        var idx = tItem.GetXmlProperty("genxml/hidden/index");
                        if (ddl.Items.FindByValue(idx) == null)
                        {
                            var li = new ListItem();
                            li.Text = itemtext.TrimStart(',');
                            li.Value = idx;
                            li.Attributes.Add("data", datatext.TrimStart(','));
                            li.Attributes.Add("datavalue", datavalue);
                            ddl.Items.Add(li);
                        }
                    }

                }

            }
            catch (Exception)
            {
                ddl.Visible = false;
            }
        }
예제 #2
0
        public Boolean ConvertToOrder(Boolean debugMode = false)
        {
            var itemList = GetCartItemList();

            if (IsValidated() && itemList.Count > 0)
            {
                PurchaseTypeCode = "ORDER";
                if (base.PurchaseInfo.GetXmlProperty("genxml/createddate") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/createddate", DateTime.Now.ToString("O"), TypeCode.DateTime);
                }
                if (base.PurchaseInfo.GetXmlProperty("genxml/ordernumber") == "")
                {
                    base.PurchaseInfo.SetXmlProperty("genxml/ordernumber", StoreSettings.Current.Get("orderprefix") + DateTime.Today.Year.ToString("").Substring(2, 2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + _cartId);
                }

                Save();
                var orderPortalId = PortalId;
                if (StoreSettings.Current.GetBool("shareorders"))
                {
                    orderPortalId = -1;
                }
                var ordData = new OrderData(orderPortalId, base.PurchaseInfo.ItemID);
                if (orderPortalId == -1)
                {
                    // shared order, so save the orginal portal
                    ordData.PurchaseInfo.SetXmlProperty("genxml/createdportalid", PortalId.ToString(""));
                }

                ordData.OrderStatus = "010";
                if (ordData.EditMode == "") // don't update if we are in edit mode, we dont; want manager email to be altered.
                {
                    // if the client has updated the email address, link this back to DNN profile. (We assume they alway place there current email address on th order.)
                    //var objUser = UserController.GetUserById(PortalSettings.Current.PortalId, ordData.UserId);
                    //if (objUser != null && objUser.Email != ordData.EmailAddress)
                    //{
                    //    var clientData = new ClientData(PortalId, ordData.UserId);
                    //    clientData.UpdateEmail(ordData.EmailAddress);
                    //}
                    // ++++++ Assumption Wrong!!! never assume!!  ++++++++++
                    // This also leads to problem is using the email form the username,
                    //   people don;t understand why their login isn't working when they haven't specificlly change the email address on the site!!


                    var addrData            = new AddressData(ordData.UserId.ToString());
                    var billAddr            = ordData.GetBillingAddress();
                    var selectedbilladdrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedbilladdrIdx))
                    {
                        selectedbilladdrIdx = "-1";
                    }
                    addrData.AddAddress(billAddr, Convert.ToInt32(selectedbilladdrIdx));
                    var shipAddr            = ordData.GetShippingAddress();
                    var selectedShipaddrIdx = shipAddr.GetXmlProperty("genxml/dropdownlist/selectshipaddress");
                    if (!Utils.IsNumeric(selectedShipaddrIdx))
                    {
                        selectedShipaddrIdx = "-1";
                    }
                    addrData.AddAddress(shipAddr, Convert.ToInt32(selectedShipaddrIdx));
                }
                ordData.Save();

                if (StoreSettings.Current.DebugModeFileOut)
                {
                    OutputDebugFile("debug_convertedcart.xml");
                }
                Exists = false;
                return(true);
            }
            return(false);
        }
예제 #3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // get setting via control params
            if (DisplayHeader != null && DisplayHeader == "") DisplayHeader = "minicartheader.html";
            if (DisplayBody != null && DisplayHeader == "") DisplayBody = "minicartbody.html";
            if (DisplayFooter != null && DisplayHeader == "") DisplayFooter = "minicartfooter.html";
            if (!String.IsNullOrEmpty(DisplayHeader) && !ModSettings.Settings().ContainsKey("txtdisplayheader")) ModSettings.Settings().Add("txtdisplayheader", DisplayHeader);
            if (!String.IsNullOrEmpty(DisplayBody) && !ModSettings.Settings().ContainsKey("txtdisplaybody")) ModSettings.Settings().Add("txtdisplaybody", DisplayBody);
            if (!String.IsNullOrEmpty(DisplayFooter) && !ModSettings.Settings().ContainsKey("txtdisplayfooter")) ModSettings.Settings().Add("txtdisplayfooter", DisplayFooter);
            if (!String.IsNullOrEmpty(PaymentTab) && !ModSettings.Settings().ContainsKey("PaymentTab")) ModSettings.Settings().Add("PaymentTab",PaymentTab );
            if (!String.IsNullOrEmpty(Themefolder) && !ModSettings.Settings().ContainsKey("themefolder")) ModSettings.Settings().Add("themefolder", Themefolder);

            _cartInfo = new CartData(PortalId);

            _addressData = new AddressData(_cartInfo.UserId.ToString(""));

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templDfoot = ModSettings.Get("txtdisplaybodyfoot");
                _templF = ModSettings.Get("txtdisplayfooter");

                const string templAB = "cartbillingaddress.html";
                const string templAS = "cartshippingaddress.html";
                const string templS = "cartshipment.html";
                const string templE = "cartextra.html";
                const string templD = "cartdetails.html";

                carttype = ModSettings.Get("ddlcarttype");  // This is left for backward compatiblity with NBS_Cart module (now removed from install).

                if (carttype == "")
                {
                    // cart type is not a setting, so use the controlanme
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_MiniCart") carttype = "1";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_FullCart") carttype = "3";
                    if (ModuleConfiguration.DesktopModule.ModuleName == "NBS_Checkout") carttype = "2";
                }

                if (carttype == "3" || carttype == "2") // check if we need to add cookie items
                {
                    _cartInfo.AddCookieToCart();
                    _cartInfo.Save();
                }
                if (!_cartInfo.GetCartItemList().Any() && (carttype == "3" || carttype == "2"))
                    _templH = "cartempty.html"; // check for empty cart
                else
                {
                    // Get Display Body
                    var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                    rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get Display Footer
                    var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                    rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                    // Get CartLayout
                    var layouttemplate = "checkoutlayout.html";
                    if (carttype == "3") layouttemplate = "fullcartlayout.html";
                    var checkoutlayoutTempl = ModCtrl.GetTemplateData(ModSettings, layouttemplate, Utils.GetCurrentCulture(), DebugMode);
                    checkoutlayout.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutlayoutTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate)checkoutlayout.ItemTemplate;

                }
                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                if (carttype == "2")
                {
                    // add any shiiping provider templates to the cart layout, so we can process any data required by them
                    rpShip.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrB.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAB, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    rpAddrS.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, templAS, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);

                    var checkoutextraTempl = ModCtrl.GetTemplateData(ModSettings, templE, Utils.GetCurrentCulture(), DebugMode);
                    checkoutextraTempl += GetShippingProviderTemplates();
                    rpExtra.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(checkoutextraTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                }

            }
            catch (Exception exc)
            {
                rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
예제 #4
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _addressData = new AddressData();

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templF = ModSettings.Get("txtdisplayfooter");
                _templinp = ModSettings.Get("txtinputform");

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                _templateHeader = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                rpDataH.ItemTemplate = _templateHeader;

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpInpTempl = ModCtrl.GetTemplateData(ModSettings, _templinp, Utils.GetCurrentCulture(), DebugMode);
                rpAddr.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpInpTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

            }
            catch (Exception exc)
            {
                rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
예제 #5
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _uid = Utils.RequestParam(Context, "uid");
            _addressData = new AddressData(_uid);

            try
            {
                _templH = "addressbookheader.html";
                _templD = "addressbookbody.html";
                _templF = "addressbookfooter.html";
                _templinp = "addressbookinput.html";

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                _templateHeader = (GenXmlTemplate)rpDataH.ItemTemplate;

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpInpTempl = ModCtrl.GetTemplateData(ModSettings, _templinp, Utils.GetCurrentCulture(), DebugMode);
                rpAddr.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpInpTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

            }
            catch (Exception exc)
            {
                rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
예제 #6
0
        public Boolean ConvertToOrder(Boolean debugMode = false)
        {
            var itemList = GetCartItemList();
            if (IsValidated() && itemList.Count > 0)
            {
                PurchaseTypeCode = "ORDER";
                if (base.PurchaseInfo.GetXmlProperty("genxml/createddate") == "") base.PurchaseInfo.SetXmlProperty("genxml/createddate", DateTime.Now.ToString(CultureInfo.GetCultureInfo(Utils.GetCurrentCulture())), TypeCode.DateTime);
                if (base.PurchaseInfo.GetXmlProperty("genxml/ordernumber") == "") base.PurchaseInfo.SetXmlProperty("genxml/ordernumber", StoreSettings.Current.Get("orderprefix") + DateTime.Today.Year.ToString("").Substring(2, 2) + DateTime.Today.Month.ToString("00") + DateTime.Today.Day.ToString("00") + _cartId);

                Save();
                var ordData = new OrderData(PortalId, base.PurchaseInfo.ItemID);
                ordData.OrderStatus = "010";
                if (ordData.EditMode == "") // don't update if we are in edit mode, we dont; want manager email to be altered.
                {
                    // if the client has updated the email address, link this back to DNN profile. (We assume they alway place there current email address on th order.)
                    var objUser = UserController.GetUserById(PortalSettings.Current.PortalId, ordData.UserId);
                    if (objUser != null && objUser.Email != ordData.EmailAddress)
                    {
                        var clientData = new ClientData(PortalId, ordData.UserId);
                        clientData.UpdateEmail(ordData.EmailAddress);
                    }
                    var addrData = new AddressData(ordData.UserId.ToString());
                    var billAddr = ordData.GetBillingAddress();
                    var selectedbilladdrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedbilladdrIdx)) selectedbilladdrIdx = "-1";
                    addrData.AddAddress(billAddr, Convert.ToInt32(selectedbilladdrIdx));
                    var shipAddr = ordData.GetShippingAddress();
                    var selectedShipaddrIdx = billAddr.GetXmlProperty("genxml/dropdownlist/selectaddress");
                    if (!Utils.IsNumeric(selectedShipaddrIdx)) selectedShipaddrIdx = "-1";
                    addrData.AddAddress(shipAddr, Convert.ToInt32(selectedShipaddrIdx));
                }
                ordData.Save();

                if (StoreSettings.Current.DebugModeFileOut) OutputDebugFile("debug_convertedcart.xml");
                Exists = false;
                return true;
            }
            return false;
        }