예제 #1
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];

            switch (e.CommandName.ToLower())
            {
                case "addnew":
                    var shipping = new ShippingData(_ctrlkey);
                    shipping.AddNewRule();
                    shipping.Save();
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "delete":
                    if (Utils.IsNumeric(cArg))
                    {
                        var shipping2 = new ShippingData(_ctrlkey);
                        shipping2.RemoveRule(Convert.ToInt32(cArg));
                        shipping2.Save();
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "saveall":
                    Update();
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "cancel":
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
            }
        }
예제 #2
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg  = e.CommandArgument.ToString();
            var param = new string[3];

            switch (e.CommandName.ToLower())
            {
            case "addnew":
                var shipping = new ShippingData(_ctrlkey);
                shipping.AddNewRule();
                shipping.Save();
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "delete":
                if (Utils.IsNumeric(cArg))
                {
                    var shipping2 = new ShippingData(_ctrlkey);
                    shipping2.RemoveRule(Convert.ToInt32(cArg));
                    shipping2.Save();
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "saveall":
                Update();
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "cancel":
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;
            }
        }
예제 #3
0
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var    shipData   = new ShippingData(Shippingkey);
            var    shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;

            if (shipData.CalculationUnit == "1")
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            }
            else
            {
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            }
            var countrycode = "";
            var regioncode  = "";
            var regionkey   = "";
            var postCode    = "";
            var total       = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");

            switch (shipoption)
            {
            case "1":
                countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                postCode    = cartInfo.GetXmlProperty("genxml/billaddress/genxml/textbox/postalcode");
                break;

            case "2":
                countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                regionkey   = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                postCode    = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/textbox/postalcode");
                break;
            }

            var shippingcost = shipData.CalculateShippingByPC(postCode, rangeValue, total);

            if (shippingcost == -1)
            {
                if (regionkey != "")
                {
                    var rl = regionkey.Split(':');
                    if (rl.Count() == 2)
                    {
                        regioncode = rl[1];
                    }
                }
                shippingcost = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            }
            var shippingdealercost = shippingcost;

            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return(cartInfo);
        }
예제 #4
0
        private void AlterCost()
        {
            var info     = new NBrightInfo();
            var shipping = new ShippingData(_ctrlkey);

            info.XMLData = GenXmlFunctions.GetGenXml(rpDataH);
            var percentValue = info.GetXmlPropertyDouble("genxml/textbox/alterpercent");

            shipping.UpdateCost(percentValue);
            shipping.Save();

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightBuyShipping" + PortalSettings.Current.PortalId.ToString(""));
        }
예제 #5
0
        private void PageLoad()
        {
            if (UserId > 0) // only logged in users can see data on this module.
            {
                var shipping = new ShippingData(_ctrlkey);
                rpData.DataSource = shipping.GetRuleList();
                rpData.DataBind();

                // display header
                base.DoDetail(rpDataH, shipping.Info);

                // display footer
                base.DoDetail(rpDataF);
            }
        }
예제 #6
0
        public override string Name()
        {
            var shipData = new ShippingData(Shippingkey);
            var rtn      = shipData.Info.GetXmlProperty("genxml/lang/genxml/textbox/name");

            if (rtn == "")
            {
                rtn = shipData.Info.GetXmlProperty("genxml/textbox/name");
            }
            if (rtn == "")
            {
                rtn = "Standard";
            }
            return(rtn);
        }
예제 #7
0
        private void Update()
        {
            var shipping = new ShippingData(_ctrlkey);

            shipping.Update(rpDataH);
            shipping.UpdateRule(rpData);
            shipping.Save();

            if (StoreSettings.Current.DebugMode)
            {
                shipping.Info.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "\\debug_Shipping.xml");
            }

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightBuyShipping" + PortalSettings.Current.PortalId.ToString(""));
        }
예제 #8
0
        public override NBrightInfo CalculateShipping(NBrightInfo cartInfo)
        {
            var shipData = new ShippingData(Shippingkey);
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            Double rangeValue = 0;
            if (shipData.CalculationUnit == "1")
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/totalweight");
            else
                rangeValue = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            var countrycode = "";
            var regioncode = "";
            var regionkey = "";
            var total = cartInfo.GetXmlPropertyDouble("genxml/appliedsubtotal");
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/region");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    regionkey = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/region");
                    break;
            }

            if (regionkey != "")
            {
                var rl = regionkey.Split(':');
                if (rl.Count() == 2) regioncode = rl[1];
            }

            var shippingcost = shipData.CalculateShipping(countrycode, regioncode, rangeValue, total);
            var shippingdealercost = shippingcost;
            cartInfo.SetXmlPropertyDouble("genxml/shippingcost", shippingcost);
            cartInfo.SetXmlPropertyDouble("genxml/shippingdealercost", shippingdealercost);

            return cartInfo;
        }
예제 #9
0
        public override bool IsValid(NBrightInfo cartInfo)
        {
            // check if this provider is valid for the counrty in the checkout
            var shipoption  = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            var countrycode = "";

            switch (shipoption)
            {
            case "1":
                countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                break;

            case "2":
                countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                break;
            }

            var isValid      = true;
            var shipData     = new ShippingData(Shippingkey);
            var validlist    = "," + shipData.Info.GetXmlProperty("genxml/textbox/validcountrycodes") + ",";
            var notvalidlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/notvalidcountrycodes") + ",";

            if (validlist.Trim(',') != "")
            {
                isValid = false;
                if (validlist.Contains("," + countrycode + ","))
                {
                    isValid = true;
                }
            }
            if (notvalidlist.Trim(',') != "" && notvalidlist.Contains("," + countrycode + ","))
            {
                isValid = false;
            }

            return(isValid);
        }
예제 #10
0
        private void Update()
        {
            var shipping = new ShippingData(_ctrlkey);

            shipping.Update(rpDataH);
            shipping.UpdateRule(rpData);
            shipping.Save();

            if (StoreSettings.Current.DebugMode) shipping.Info.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "\\debug_Shipping.xml");

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightBuyShipping" + PortalSettings.Current.PortalId.ToString(""));
        }
예제 #11
0
        private void PageLoad()
        {
            if (UserId > 0) // only logged in users can see data on this module.
            {
                var shipping = new ShippingData(_ctrlkey);
                rpData.DataSource = shipping.GetRuleList();
                rpData.DataBind();

                // display header
                base.DoDetail(rpDataH,shipping.Info);

                // display footer
                base.DoDetail(rpDataF);
            }
        }
예제 #12
0
        public override bool IsValid(NBrightInfo cartInfo)
        {
            // check if this provider is valid for the counrty in the checkout
            var shipoption = cartInfo.GetXmlProperty("genxml/extrainfo/genxml/radiobuttonlist/rblshippingoptions");
            var countrycode = "";
            switch (shipoption)
            {
                case "1":
                    countrycode = cartInfo.GetXmlProperty("genxml/billaddress/genxml/dropdownlist/country");
                    break;
                case "2":
                    countrycode = cartInfo.GetXmlProperty("genxml/shipaddress/genxml/dropdownlist/country");
                    break;
            }

            var isValid = true;
            var shipData = new ShippingData(Shippingkey);
            var validlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/validcountrycodes") + ",";
            var notvalidlist = "," + shipData.Info.GetXmlProperty("genxml/textbox/notvalidcountrycodes") + ",";
            if (validlist.Trim(',') != "")
            {
                isValid = false;
                if (validlist.Contains("," + countrycode + ",")) isValid = true;
            }
            if (notvalidlist.Trim(',') != "" && notvalidlist.Contains("," + countrycode + ",")) isValid = false;

            return isValid;
        }