Ejemplo n.º 1
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     Caption.Text            = string.Format(Caption.Text, _ShipMethod.Name);
     RateMatrixHelpText.Text = string.Format(RateMatrixHelpText.Text, GetMatrixType());
     if (!Page.IsPostBack)
     {
         Name.Text           = _ShipMethod.Name;
         ShipMethodType.Text = AbleCommerce.Code.StoreDataHelper.GetFriendlyShipMethodType(_ShipMethod);
         BindShipRateMatrix();
         if (_ShipMethod.Surcharge > 0)
         {
             Surcharge.Text = string.Format("{0:F2}", _ShipMethod.Surcharge);
         }
         SurchargeMode.SelectedIndex           = _ShipMethod.SurchargeModeId;
         SurchargeIsVisible.SelectedIndex      = AlwaysConvert.ToBool(_ShipMethod.SurchargeIsVisible == true) ? 1 : 0;
         UseWarehouseRestriction.SelectedIndex = (_ShipMethod.Warehouses.Count == 0) ? 0 : 1;
         BindWarehouses();
         UseZoneRestriction.SelectedIndex = (_ShipMethod.ShipZones.Count == 0) ? 0 : 1;
         BindZones();
         UseGroupRestriction.SelectedIndex = (_ShipMethod.Groups.Count == 0) ? 0 : 1;
         BindGroups();
         if (_ShipMethod.MinPurchase > 0)
         {
             MinPurchase.Text = string.Format("{0:F2}", _ShipMethod.MinPurchase);
         }
         if (_ShipMethod.MaxPurchase > 0)
         {
             MaxPurchase.Text = string.Format("{0:F2}", _ShipMethod.MaxPurchase);
         }
     }
     trSurchargeTaxCode.Visible = _ShipMethod.SurchargeIsVisible;
     AbleCommerce.Code.PageHelper.ConvertEnterToTab(Name);
     AbleCommerce.Code.PageHelper.ConvertEnterToTab(Surcharge);
 }
Ejemplo n.º 2
0
        protected void GoButton_Click(object sender, EventArgs e)
        {
            bool selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);

            if (selectAll)
            {
                BitFieldState   featured = (BitFieldState)Enum.Parse(typeof(BitFieldState), FeaturedFilter.SelectedValue);
                IList <Product> products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), AlwaysConvert.ToInt(CategoriesList.SelectedValue), AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue));
                foreach (var product in products)
                {
                    SetFeatured(product.Id, link);
                }
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int productId = (int)PG.DataKeys[row.DataItemIndex - indexPeg].Values[0];
                        SetFeatured(productId, link);
                    }
                }
            }

            PG.DataBind();
        }
Ejemplo n.º 3
0
 public override void Initialize(int taxGatewayId, Dictionary <string, string> configurationData)
 {
     base.Initialize(taxGatewayId, configurationData);
     if (configurationData.ContainsKey("ConfirmAddresses"))
     {
         this.ConfirmAddresses = AlwaysConvert.ToBool(configurationData["ConfirmAddresses"], false);
     }
     if (configurationData.ContainsKey("IgnoreFailedConfirm"))
     {
         this.IgnoreFailedConfirm = AlwaysConvert.ToBool(configurationData["IgnoreFailedConfirm"], false);
     }
     if (configurationData.ContainsKey("ReportBreakdown"))
     {
         this.ReportBreakdown = AlwaysConvert.ToBool(configurationData["ReportBreakdown"], true);
     }
     if (configurationData.ContainsKey("Location"))
     {
         this.Location = configurationData["Location"];
     }
     if (configurationData.ContainsKey("Nexus"))
     {
         this.Nexus = (Nexus)AlwaysConvert.ToInt(configurationData["Nexus"]);
     }
     if (configurationData.ContainsKey("UseLineItems"))
     {
         this.UseLineItems = AlwaysConvert.ToBool(configurationData["UseLineItems"], true);
     }
 }
Ejemplo n.º 4
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("AccountNumber"))
     {
         AccountNumber = ConfigurationData["AccountNumber"];
     }
     if (ConfigurationData.ContainsKey("MeterNumber"))
     {
         MeterNumber = ConfigurationData["MeterNumber"];
     }
     if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
     {
         EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
     }
     if (ConfigurationData.ContainsKey("MinPackageWeight"))
     {
         MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
     }
     if (ConfigurationData.ContainsKey("MaxPackageWeight"))
     {
         MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
     }
     if (ConfigurationData.ContainsKey("IncludeDeclaredValue"))
     {
         IncludeDeclaredValue = AlwaysConvert.ToBool(ConfigurationData["IncludeDeclaredValue"], true);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], false);
     }
     if (ConfigurationData.ContainsKey("AccountActive"))
     {
         AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
     }
     if (ConfigurationData.ContainsKey("DropOffType"))
     {
         DropOffType = (FDXDropOffType)AlwaysConvert.ToEnum(typeof(FDXDropOffType), ConfigurationData["DropOffType"], FDXDropOffType.REGULARPICKUP, true);
     }
     if (ConfigurationData.ContainsKey("PackagingType"))
     {
         PackagingType = (FDXPackagingType)AlwaysConvert.ToEnum(typeof(FDXPackagingType), ConfigurationData["PackagingType"], FDXPackagingType.YOURPACKAGING, true);
     }
     if (ConfigurationData.ContainsKey("TestModeUrl"))
     {
         TestModeUrl = ConfigurationData["TestModeUrl"];
     }
     if (ConfigurationData.ContainsKey("LiveModeUrl"))
     {
         LiveModeUrl = ConfigurationData["LiveModeUrl"];
     }
     if (ConfigurationData.ContainsKey("TrackingUrl"))
     {
         TrackingUrl = ConfigurationData["TrackingUrl"];
     }
 }
Ejemplo n.º 5
0
        private Transaction ProcessResponse(Payment payment, String responseData, TransactionType transactionType, LSDecimal transactionAmount)
        {
            //CREATE THE TRANSACTION OBJECT
            Transaction transaction = new Transaction();

            transaction.PaymentGatewayId = this.PaymentGatewayId;
            transaction.TransactionType  = transactionType;

            NameValueCollection response = ParseResponseString(responseData);

            bool   success     = false;
            string queryStatus = response.Get("dc_query_status");

            if (!string.IsNullOrEmpty(queryStatus))
            {
                success = AlwaysConvert.ToBool(queryStatus, false);
            }
            else
            {
                int responseCode = AlwaysConvert.ToInt(response.Get("dc_response_code"), -9999);
                success = (responseCode == 0 || responseCode == 85);
            }

            transaction.TransactionDate = DateTime.UtcNow;
            transaction.Amount          = transactionAmount;
            if (!success)
            {
                //failed
                transaction.TransactionStatus = TransactionStatus.Failed;
                transaction.ResponseCode      = response.Get("dc_response_code");
                transaction.ResponseMessage   = response.Get("dc_response_message");
            }
            else
            {
                //successful
                transaction.TransactionStatus     = TransactionStatus.Successful;
                transaction.ProviderTransactionId = response.Get("dc_transaction_id");
                transaction.AuthorizationCode     = response.Get("dc_approval_code");
                if (transaction.AuthorizationCode == "null")
                {
                    transaction.AuthorizationCode = string.Empty;
                }
                //no avs or cvv in response? return unavailable codes
                transaction.AVSResultCode = "U";
                transaction.CVVResultCode = "X";

                HttpContext context = HttpContext.Current;
                if (context != null)
                {
                    transaction.RemoteIP = context.Request.ServerVariables["REMOTE_ADDR"];
                    transaction.Referrer = context.Request.ServerVariables["HTTP_REFERER"];
                }
            }

            return(transaction);
        }
Ejemplo n.º 6
0
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("ExecutionMode"))
     {
         ExecutionMode = ParseExecutionMode(ConfigurationData["ExecutionMode"]);
     }
     if (ConfigurationData.ContainsKey("UseAuthCapture"))
     {
         UseAuthCapture = AlwaysConvert.ToBool(ConfigurationData["UseAuthCapture"], true);
     }
 }
        protected void GoButton_Click(object sender, EventArgs e)
        {
            bool selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);

            if (selectAll)
            {
                BitFieldState featured = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
                BitFieldState status   = (BitFieldState)Enum.Parse(typeof(BitFieldState), ProductAssignment.SelectedValue);

                int categoryId = 0;
                if (!_DisplayCategorySearch)
                {
                    categoryId = AlwaysConvert.ToInt(CategoriesList.SelectedValue);
                }
                else
                {
                    categoryId = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
                }

                IList <Product> products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), categoryId, AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue), AssignmentTable, AssignmentValue, status);
                foreach (var product in products)
                {
                    if (OnAssignProduct != null)
                    {
                        OnAssignProduct(this, new FindAssignProductEventArgs(product.Id, link));
                    }
                }
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int productId = (int)PG.DataKeys[row.DataItemIndex - indexPeg].Values[0];
                        if (OnAssignProduct != null)
                        {
                            OnAssignProduct(this, new FindAssignProductEventArgs(productId, link));
                        }
                    }
                }
            }

            PG.DataBind();
        }
Ejemplo n.º 8
0
        protected bool IsHandleAllRequestsConfigured()
        {
            bool isConfigured = false;

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(_WebConfigPath);
            XmlNode xmlNode = xmlDocument.SelectSingleNode("/configuration/system.webServer/modules");

            if (xmlNode != null)
            {
                isConfigured = AlwaysConvert.ToBool(((XmlElement)xmlNode).GetAttribute("runAllManagedModulesForAllRequests"), false);
            }
            return(isConfigured);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Load feed options using the given option keys
        /// </summary>
        /// <param name="settingKeys">Feed Option Setting Keys</param>
        public void Load(IFeedOptionKeys settingKeys)
        {
            StoreSettingCollection settings = Token.Instance.Store.Settings;

            _CompressedFeedFileName = settings.GetValueByKey(settingKeys.CompressedFeedFileName);
            _FeedDataPath           = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\Feeds");
            _FeedFileName           = settings.GetValueByKey(settingKeys.FeedFileName);
            _FtpHost                 = settings.GetValueByKey(settingKeys.FtpHost);
            _FtpPassword             = settings.GetValueByKey(settingKeys.FtpPassword);
            _FtpUser                 = settings.GetValueByKey(settingKeys.FtpUser);
            _IncludeAllProducts      = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeAllProducts), false);
            _OverwriteCompressedFile = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteCompressedFile), true);
            _OverwriteFeedFile       = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteFeedFile), true);
            _RemoteFileName          = settings.GetValueByKey(settingKeys.RemoteFileName);
            IsDirty = false;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes this tax gateway with the given configuration data
 /// </summary>
 /// <param name="taxGatewayId">ID of this tax gateway</param>
 /// <param name="configurationData">configuration dictionary</param>
 public override void Initialize(int taxGatewayId, Dictionary <string, string> configurationData)
 {
     base.Initialize(taxGatewayId, configurationData);
     if (configurationData.ContainsKey("UseDebugMode"))
     {
         this.UseDebugMode = AlwaysConvert.ToBool(configurationData["UseDebugMode"], false);
     }
     if (configurationData.ContainsKey("TaxName"))
     {
         this.TaxName = configurationData["TaxName"];
     }
     if (configurationData.ContainsKey("TaxCodes"))
     {
         this.TaxCodes.AddRange(configurationData["TaxCodes"]);
     }
 }
Ejemplo n.º 11
0
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("AccountToken"))
     {
         AccountToken = ConfigurationData["AccountToken"];
     }
     if (ConfigurationData.ContainsKey("UseAuthCapture"))
     {
         UseAuthCapture = AlwaysConvert.ToBool(ConfigurationData["UseAuthCapture"], true);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], true);
     }
 }
Ejemplo n.º 12
0
        public void Load(ISiteMapOptionKeys settingKeys)
        {
            StoreSettingCollection settings = Token.Instance.Store.Settings;

            _CompressedSiteMapFileName = settings.GetValueByKey(settingKeys.CompressedSiteMapFileName);
            _SiteMapDataPath           = settings.GetValueByKey(settingKeys.SiteMapDataPath);
            _SiteMapFileName           = settings.GetValueByKey(settingKeys.SiteMapFileName);
            _IncludeProducts           = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeProducts), true);
            _IncludeCategories         = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeCategories), true);
            _IncludeWebpages           = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeWebpages), true);
            _OverwriteCompressedFile   = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteCompressedFile), true);
            _OverwriteSiteMapFile      = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteSiteMapFile), true);
            _DefaultChangeFrequency    = (changefreq)AlwaysConvert.ToEnum(typeof(changefreq), settings.GetValueByKey(settingKeys.DefaultChangeFrequency), changefreq.weekly);
            _DefaultUrlPriority        = AlwaysConvert.ToDecimal(settings.GetValueByKey(settingKeys.DefaultUrlPriority), 0.5M);
            IsDirty = false;
        }
Ejemplo n.º 13
0
        public ActionResult Config(int?id)
        {
            int            gatewayId = id ?? 0;
            PaymentGateway gateway   = _gatewayRepo.Load(gatewayId);

            var    aName        = GetType().Assembly.GetName();
            string assemblyInfo = aName.Name.ToString() + "&nbsp;(v" + aName.Version.ToString() + ")";

            var model = new ConfigModel();

            model.AssemblyInfo   = assemblyInfo;
            model.ExecutionModes = Enum.GetNames(typeof(EPProvider.GatewayExecutionMode))
                                   .Select(name => new SelectListItem()
            {
                Text = name, Value = name
            })
                                   .ToList();
            model.PaymentMethods = _methodRepo.LoadPaymentMethods(_hiddenMethods).Select(method => new PaymentMethodModel()
            {
                Id   = method.Id,
                Name = method.Name
            }
                                                                                         ).ToList();

            if (gateway != null)
            {
                model.GatewayId = gateway.Id;
                model.PaymentMethods.ForEach(method => method.IsSelected = gateway.PaymentMethods.Any(pm => pm.Id == method.Id));

                var configurationData = gateway.ParseConfigData();
                if (configurationData.ContainsKey("UseDebugMode"))
                {
                    model.UseDebugMode = AlwaysConvert.ToBool(configurationData["UseDebugMode"], false);
                }
                if (configurationData.ContainsKey("ExecutionMode"))
                {
                    model.ExecutionMode = AlwaysConvert.ToEnum <EPProvider.GatewayExecutionMode>(configurationData["ExecutionMode"], EPProvider.GatewayExecutionMode.AlwaysAccept);
                }
                if (configurationData.ContainsKey("UseAuthCapture"))
                {
                    model.UseAuthCapture = AlwaysConvert.ToBool(configurationData["UseAuthCapture"], true);
                }
            }

            return(View("~/Plugins/ExamplePaymentPlugin/Views/Config.cshtml", model));
        }
Ejemplo n.º 14
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("UserId"))
     {
         UserId = ConfigurationData["UserId"];
     }
     if (ConfigurationData.ContainsKey("Password"))
     {
         Password = ConfigurationData["Password"];
     }
     if (ConfigurationData.ContainsKey("UserIdActive"))
     {
         UserIdActive = AlwaysConvert.ToBool(ConfigurationData["UserIdActive"], false);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], false);
     }
     if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
     {
         EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
     }
     if (ConfigurationData.ContainsKey("MinPackageWeight"))
     {
         MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
     }
     if (ConfigurationData.ContainsKey("MaxPackageWeight"))
     {
         MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
     }
     if (ConfigurationData.ContainsKey("TestModeUrl"))
     {
         TestModeUrl = ConfigurationData["TestModeUrl"];
     }
     if (ConfigurationData.ContainsKey("LiveModeUrl"))
     {
         LiveModeUrl = ConfigurationData["LiveModeUrl"];
     }
     if (ConfigurationData.ContainsKey("TrackingUrl"))
     {
         TrackingUrl = ConfigurationData["TrackingUrl"];
     }
 }
Ejemplo n.º 15
0
 protected void initAddress()
 {
     ShipToFirstName.Text             = _OrderShipment.ShipToFirstName;
     ShipToLastName.Text              = _OrderShipment.ShipToLastName;
     ShipToAddress1.Text              = _OrderShipment.ShipToAddress1;
     ShipToAddress2.Text              = _OrderShipment.ShipToAddress2;
     ShipToCity.Text                  = _OrderShipment.ShipToCity;
     ShipToProvince.Text              = _OrderShipment.ShipToProvince;
     ShipToPostalCode.Text            = _OrderShipment.ShipToPostalCode;
     ShipToCountryCode.DataSource     = AbleContext.Current.Store.Countries;
     ShipToCountryCode.DataTextField  = "Name";
     ShipToCountryCode.DataValueField = "CountryCode";
     ShipToCountryCode.DataBind();
     ShipToCountryCode.SelectedValue = _OrderShipment.ShipToCountryCode;
     ShipToPhone.Text              = _OrderShipment.ShipToPhone;
     ShipToCompany.Text            = _OrderShipment.ShipToCompany;
     ShipToFax.Text                = _OrderShipment.ShipToFax;
     ShipToResidence.SelectedIndex = (AlwaysConvert.ToBool(_OrderShipment.ShipToResidence) ? 0 : 1);
 }
Ejemplo n.º 16
0
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("UseAuthCapture"))
     {
         UseAuthCapture = AlwaysConvert.ToBool(ConfigurationData["UseAuthCapture"], true);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], true);
     }
     if (ConfigurationData.ContainsKey("LoginName"))
     {
         LoginName = ConfigurationData["LoginName"];
     }
     if (ConfigurationData.ContainsKey("Password"))
     {
         Password = ConfigurationData["Password"];
     }
 }
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], true);
     }
     if (ConfigurationData.ContainsKey("MerchantNumber"))
     {
         MerchantNumber = ConfigurationData["MerchantNumber"];
     }
     if (ConfigurationData.ContainsKey("IncludeOrderItems"))
     {
         IncludeOrderItems = AlwaysConvert.ToBool(ConfigurationData["IncludeOrderItems"], false);
     }
     if (ConfigurationData.ContainsKey("IsUSD"))
     {
         IsUSD = AlwaysConvert.ToBool(ConfigurationData["IsUSD"], true);
     }
 }
Ejemplo n.º 18
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
     {
         EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
     }
     if (ConfigurationData.ContainsKey("AccountActive"))
     {
         AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
     }
     if (ConfigurationData.ContainsKey("MinPackageWeight"))
     {
         MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
     }
     if (ConfigurationData.ContainsKey("MaxPackageWeight"))
     {
         MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
     }
 }
Ejemplo n.º 19
0
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("MerchantID"))
     {
         MerchantID = ConfigurationData["MerchantID"];
     }
     if (ConfigurationData.ContainsKey("MerchantKey"))
     {
         MerchantKey = ConfigurationData["MerchantKey"];
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], true);
     }
     if (ConfigurationData.ContainsKey("UseBasicAuth"))
     {
         UseBasicAuth = AlwaysConvert.ToBool(ConfigurationData["UseBasicAuth"], false);
     }
     if (ConfigurationData.ContainsKey("CouponsEnabled"))
     {
         CouponsEnabled = AlwaysConvert.ToBool(ConfigurationData["CouponsEnabled"], true);
     }
     if (ConfigurationData.ContainsKey("GiftCertificatesEnabled"))
     {
         GiftCertificatesEnabled = AlwaysConvert.ToBool(ConfigurationData["GiftCertificatesEnabled"], true);
     }
     if (ConfigurationData.ContainsKey("TrackingEnabled"))
     {
         TrackingEnabled = AlwaysConvert.ToBool(ConfigurationData["TrackingEnabled"], true);
     }
     if (ConfigurationData.ContainsKey("ExpirationMinutes"))
     {
         ExpirationMinutes = AlwaysConvert.ToInt(ConfigurationData["ExpirationMinutes"], 0);
     }
     if (ConfigurationData.ContainsKey("DefaultShipRate"))
     {
         DefaultShipRate = AlwaysConvert.ToDecimal(ConfigurationData["DefaultShipRate"], 0);
     }
 }
        public IList <Product> GetSelectedProducts()
        {
            bool            selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool            link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);
            IList <Product> products  = new List <Product>();

            if (selectAll)
            {
                BitFieldState featured   = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
                BitFieldState status     = (BitFieldState)Enum.Parse(typeof(BitFieldState), ProductAssignment.SelectedValue);
                int           categoryId = 0;
                if (!_DisplayCategorySearch)
                {
                    categoryId = AlwaysConvert.ToInt(CategoriesList.SelectedValue);
                }
                else
                {
                    categoryId = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
                }
                products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), categoryId, AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue), AssignmentTable, AssignmentValue, status);
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int dataItemIndex = row.DataItemIndex;
                        dataItemIndex = (dataItemIndex - (PG.PageSize * PG.PageIndex));
                        int productId = (int)PG.DataKeys[dataItemIndex].Value;
                        products.Add(ProductDataSource.Load(productId));
                    }
                }
            }

            return(products);
        }
 private void LoadCustomViewState()
 {
     if (Page.IsPostBack)
     {
         UrlEncodedDictionary customViewState = new UrlEncodedDictionary(EncryptionHelper.DecryptAES(Request.Form[VS.UniqueID]));
         _ShowEditGrid    = AlwaysConvert.ToBool(customViewState.TryGetValue("ShowEditGrid"), false);
         _EnableScrolling = AlwaysConvert.ToBool(customViewState.TryGetValue("EnableScrolling"), true);
         string selectedCategories = customViewState.TryGetValue("SC");
         if (!string.IsNullOrEmpty(selectedCategories))
         {
             int[] tempCategoryIds = AlwaysConvert.ToIntArray(selectedCategories);
             if (tempCategoryIds != null && tempCategoryIds.Length > 0)
             {
                 for (int i = 0; i < tempCategoryIds.Length; i++)
                 {
                     AddCategoryToList(tempCategoryIds[i]);
                 }
             }
         }
         BuildFieldList(customViewState.TryGetValue("SF"));
     }
 }
        private void LoadSearchCriteria()
        {
            string searchCriteriaList = AbleContext.Current.User.Settings.GetValueByKey("CategoryBatchEditSearchCriteria");

            if (!string.IsNullOrEmpty(searchCriteriaList))
            {
                string[] searchCriteriaArray = searchCriteriaList.Split("|".ToCharArray());
                if (searchCriteriaArray.Length == 7)
                {
                    NameFilter.Text = searchCriteriaArray[0];
                    ListItem selItem = null;
                    if (!_DisplayCategorySearch)
                    {
                        selItem = CategoryFilter.Items.FindByValue(searchCriteriaArray[2]);
                        if (selItem != null)
                        {
                            CategoryFilter.SelectedIndex = CategoryFilter.Items.IndexOf(selItem);
                        }
                    }
                    else
                    {
                        Category selectedCategory = CategoryDataSource.Load(AlwaysConvert.ToInt(searchCriteriaArray[2]));
                        if (selectedCategory != null)
                        {
                            CategoryAutoComplete.Text = selectedCategory.Name;
                        }
                        HiddenSelectedCategoryId.Value = searchCriteriaArray[2];
                    }

                    selItem = MaximumRows.Items.FindByValue(searchCriteriaArray[5]);
                    if (selItem != null)
                    {
                        MaximumRows.SelectedIndex = MaximumRows.Items.IndexOf(selItem);
                    }
                    EnableScrolling.Checked = AlwaysConvert.ToBool(searchCriteriaArray[6], true);
                }
            }
        }
        protected void AcceptButton_Click(object sender, EventArgs e)
        {
            this.DisplayIndex++;
            if (this.DisplayIndex < _LicenseAgreementIds.Length)
            {
                //SHOW THE NEXT AGREEMENT
                UpdateAgreementText();
            }
            else
            {
                //ALL AGREEMENTS HAVE BEEN ACCEPTED
                //CLEAR ITEMS FROM APPLICATION CACHE
                Cache.Remove(_CacheKey);
                bool addToWishlist = AlwaysConvert.ToBool(Request.QueryString["ToWishlist"], false);

                if (addToWishlist)
                {
                    Wishlist wishlist = AbleContext.Current.User.PrimaryWishlist;
                    foreach (BasketItem item in _BasketItems)
                    {
                        wishlist.WishlistItems.Add(item);
                    }
                    wishlist.Save();
                }
                else
                {
                    //ADD PRODUCTS TO BASKET
                    Basket basket = AbleContext.Current.User.Basket;
                    foreach (BasketItem item in _BasketItems)
                    {
                        basket.Items.Add(item);
                    }
                    basket.Save();
                }
                //ROUTE TO ACCEPT URL
                Response.Redirect(AcceptUrl);
            }
        }
Ejemplo n.º 24
0
        private List <int> GetSelectedOrderIds()
        {
            List <int> selectedOrders = new List <int>();

            if (AlwaysConvert.ToBool(SelectAll.Value, false))
            {
                OrderFilter   filter = GetOrderFilter();
                IList <Order> orders = OrderDataSource.LoadForFilter(filter, 0, 0, "OrderNumber ASC");
                foreach (Order order in orders)
                {
                    selectedOrders.Add(order.Id);
                }
            }
            else
            {
                int[] orderNumbers = AlwaysConvert.ToIntArray(Request.Form["OID"]);
                IDictionary <int, int> orderIds = OrderDataSource.LookupOrderIds(orderNumbers);
                foreach (int orderId in orderIds.Values)
                {
                    selectedOrders.Add(orderId);
                }
            }
            return(selectedOrders);
        }
        protected void SaveAddressButton_Click(object sender, EventArgs e)
        {
            Subscription subscription      = SubscriptionDataSource.Load(AlwaysConvert.ToInt(HiddenSubscriptionId.Value));
            bool         isShippingAddress = AlwaysConvert.ToBool(HiddenIsShipping.Value, false);

            if (Page.IsValid && subscription != null)
            {
                string buttonId = ((Button)sender).ID;
                string formattedProvinceName;
                if (ValidateProvince(Country, Province, Province2, out formattedProvinceName))
                {
                    string address1   = StringHelper.StripHtml(Address1.Text);
                    string address2   = StringHelper.StripHtml(Address2.Text);
                    string city       = StringHelper.StripHtml(City.Text);
                    string postalCode = StringHelper.StripHtml(PostalCode.Text);

                    if (isShippingAddress)
                    {
                        subscription.ShipToFirstName   = StringHelper.StripHtml(FirstName.Text);
                        subscription.ShipToLastName    = StringHelper.StripHtml(LastName.Text);
                        subscription.ShipToAddress1    = address1;
                        subscription.ShipToAddress2    = address2;
                        subscription.ShipToCompany     = StringHelper.StripHtml(Company.Text);
                        subscription.ShipToCity        = city;
                        subscription.ShipToProvince    = formattedProvinceName;
                        subscription.ShipToPostalCode  = postalCode;
                        subscription.ShipToCountryCode = Country.SelectedValue;
                        subscription.ShipToPhone       = StringHelper.StripHtml(Phone.Text);
                        subscription.ShipToFax         = StringHelper.StripHtml(Fax.Text);
                        subscription.ShipToResidence   = !IsBusiness.Checked;

                        try
                        {
                            EmailProcessor.NotifySubscriptionUpdated(subscription);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("Error sending subscription updated email.", ex);
                        }

                        subscription.Save();
                    }
                    else
                    {
                        subscription.BillToFirstName   = StringHelper.StripHtml(FirstName.Text);
                        subscription.BillToLastName    = StringHelper.StripHtml(LastName.Text);
                        subscription.BillToAddress1    = address1;
                        subscription.BillToAddress2    = address2;
                        subscription.BillToCompany     = StringHelper.StripHtml(Company.Text);
                        subscription.BillToCity        = city;
                        subscription.BillToProvince    = formattedProvinceName;
                        subscription.BillToPostalCode  = postalCode;
                        subscription.BillToCountryCode = Country.SelectedValue;
                        subscription.BillToPhone       = StringHelper.StripHtml(Phone.Text);
                        subscription.BillToFax         = StringHelper.StripHtml(Fax.Text);
                        subscription.BillToResidence   = !IsBusiness.Checked;

                        try
                        {
                            EmailProcessor.NotifySubscriptionUpdated(subscription);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("Error sending subscription updated email.", ex);
                        }

                        subscription.Save();
                    }

                    //REBUILD ADDRESS BOOK
                    InitAddressForm(null);
                    EditAddressPopup.Hide();
                }
                else
                {
                    Province2Required.IsValid = false;
                    CountryChanged(null, null);
                }
            }
        }
Ejemplo n.º 26
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // DUPLICATE TAX RULE NAMES SHOULD NOT BE ALLOWED
                int taxRuleId = TaxRuleDataSource.GetTaxRuleIdByName(Name.Text);
                if (taxRuleId > 0)
                {
                    // TAX RULE(S) WITH SAME NAME ALREADY EXIST
                    CustomValidator customNameValidator = new CustomValidator();
                    customNameValidator.ControlToValidate = "Name";
                    customNameValidator.Text         = "*";
                    customNameValidator.ErrorMessage = "A Tax Rule with the same name already exists.";
                    customNameValidator.IsValid      = false;
                    phNameValidator.Controls.Add(customNameValidator);
                    return;
                }
                //SAVE TAX RULE
                TaxRule taxRule = new TaxRule();
                taxRule.Name              = Name.Text;
                taxRule.TaxRate           = AlwaysConvert.ToDecimal(TaxRate.Text);
                taxRule.UseBillingAddress = AlwaysConvert.ToBool(UseBillingAddress.SelectedValue.Equals("1"), false);
                taxRule.TaxCodeId         = AlwaysConvert.ToInt(TaxCode.SelectedValue);
                taxRule.Priority          = AlwaysConvert.ToInt16(Priority.Text);
                taxRule.UsePerItemTax     = PerUnitCalculation.Checked;
                taxRule.Save();
                //UPDATE TAX CODES
                taxRule.TaxCodes.Clear();
                taxRule.Save();
                foreach (ListItem listItem in TaxCodes.Items)
                {
                    if (listItem.Selected)
                    {
                        TaxCode taxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(listItem.Value));
                        taxRule.TaxCodes.Add(taxCode);
                        listItem.Selected = false;
                    }
                }
                //UPDATE ZONES
                taxRule.ShipZones.Clear();
                if (ZoneRule.SelectedIndex > 0)
                {
                    foreach (ListItem item in ZoneList.Items)
                    {
                        ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value));
                        if (item.Selected)
                        {
                            taxRule.ShipZones.Add(shipZone);
                        }
                    }
                }
                //UPDATE GROUP FILTER
                taxRule.Groups.Clear();
                taxRule.GroupRule = (FilterRule)GroupRule.SelectedIndex;
                if (taxRule.GroupRule != FilterRule.All)
                {
                    foreach (ListItem item in GroupList.Items)
                    {
                        Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
                        if (item.Selected)
                        {
                            taxRule.Groups.Add(group);
                        }
                    }
                }
                //IF NO GROUPS ARE SELECTED, APPLY TO ALL GROUPS
                if (taxRule.Groups.Count == 0)
                {
                    taxRule.GroupRule = FilterRule.All;
                }

                // UPDATE ROUNDING RULE
                taxRule.RoundingRuleId = AlwaysConvert.ToByte(RoundingRule.SelectedValue);

                taxRule.Save();
                //UPDATE THE ADD MESSAGE
                Response.Redirect("TaxRules.aspx");
            }
        }
Ejemplo n.º 27
0
        protected BasketItem CreateBasketItem()
        {
            //GET THE PRODUCT ID
            int     productId = AlwaysConvert.ToInt(AddProductId.Value);
            Product product   = ProductDataSource.Load(productId);

            if (product == null)
            {
                return(null);
            }
            //GET THE QUANTITY
            short tempQuantity = AlwaysConvert.ToInt16(AddProductQuantity.Text);

            if (tempQuantity < 1)
            {
                return(null);
            }
            //RECALCULATE SELECTED KIT OPTIONS
            GetSelectedKitOptions(product);
            // DETERMINE THE OPTION LIST
            string optionList = ProductVariantDataSource.GetOptionList(productId, _SelectedOptions, false);

            //CREATE THE BASKET ITEM WITH GIVEN OPTIONS
            bool       calculateOneTimePrice = AlwaysConvert.ToBool(OptionalSubscription.SelectedValue, false);
            BasketItem basketItem            = BasketItemDataSource.CreateForProduct(productId, tempQuantity, optionList, AlwaysConvert.ToList(",", _SelectedKitProducts), _UserId, calculateOneTimePrice);

            if (basketItem != null)
            {
                //BASKET ID
                basketItem.BasketId = _Basket.Id;

                // PRODUCT PRICE FOR VARIABLE PRICE PRODUCT
                if (product.UseVariablePrice && !product.IsSubscription && !product.IsKit)
                {
                    basketItem.Price = AlwaysConvert.ToDecimal(AddProductVariablePrice.Text);
                }
                else
                {
                    basketItem.Price = AlwaysConvert.ToDecimal(AddProductPrice.Text);
                }

                if (product.IsSubscription)
                {
                    if (product.SubscriptionPlan.IsOptional)
                    {
                        basketItem.IsSubscription = !calculateOneTimePrice;
                    }
                    else
                    {
                        basketItem.IsSubscription = true;
                    }

                    if (basketItem.IsSubscription && product.SubscriptionPlan.IsRecurring)
                    {
                        basketItem.Frequency     = product.SubscriptionPlan.PaymentFrequencyType == PaymentFrequencyType.Optional ? AlwaysConvert.ToInt16(AutoDeliveryInterval.SelectedValue) : product.SubscriptionPlan.PaymentFrequency;
                        basketItem.FrequencyUnit = product.SubscriptionPlan.PaymentFrequencyUnit;
                    }
                    else if (basketItem.IsSubscription)
                    {
                        basketItem.Frequency     = product.SubscriptionPlan.PaymentFrequency;
                        basketItem.FrequencyUnit = product.SubscriptionPlan.PaymentFrequencyUnit;
                    }
                }


                // COLLECT ANY ADDITIONAL INPUTS
                AbleCommerce.Code.ProductHelper.CollectProductTemplateInput(basketItem, this);
            }
            return(basketItem);
        }
Ejemplo n.º 28
0
        protected void AddProductPrice_PreRender(object sender, EventArgs e)
        {
            int     productId = AlwaysConvert.ToInt(AddProductId.Value);
            Product product   = ProductDataSource.Load(productId);

            if (product != null)
            {
                //GET THE SELECTED KIT OPTIONS
                GetSelectedKitOptions(product);
                //SET THE CURRENT CALCULATED PRICE
                string            optionList            = ProductVariantDataSource.GetOptionList(productId, _SelectedOptions, true);
                bool              calculateOneTimePrice = AlwaysConvert.ToBool(OptionalSubscription.SelectedValue, false);
                ProductCalculator pcalc = ProductCalculator.LoadForProduct(productId, 1, optionList, AlwaysConvert.ToList(",", _SelectedKitProducts), _UserId, false, calculateOneTimePrice);
                AddProductPrice.Text = string.Format("{0:F2}", pcalc.Price);

                if (product.IsSubscription)
                {
                    if (product.SubscriptionPlan.IsRecurring)
                    {
                        if (!calculateOneTimePrice)
                        {
                            short frequency = product.SubscriptionPlan.PaymentFrequencyType == PaymentFrequencyType.Optional ? AlwaysConvert.ToInt16(AutoDeliveryInterval.SelectedValue) : product.SubscriptionPlan.PaymentFrequency;
                            SubscriptionMessage.Text    = ProductHelper.GetRecurringPaymentMessage(product.Price, 0, product.SubscriptionPlan, frequency);
                            SubscriptionMessage.Visible = true;
                        }
                        else
                        {
                            SubscriptionMessage.Visible = false;
                        }
                    }
                    else
                    {
                        trSubscriptionRow.Visible = product.SubscriptionPlan.IsOptional;
                    }
                }
                else
                {
                    trSubscriptionRow.Visible = false;
                }

                if (product.UseVariablePrice && !product.IsSubscription && !product.IsKit)
                {
                    AddProductVariablePrice.Text    = string.Format("{0:F2}", pcalc.Price);
                    AddProductVariablePrice.Visible = true;
                    string varPriceText = string.Empty;
                    if (product.MinimumPrice > 0)
                    {
                        if (product.MaximumPrice > 0)
                        {
                            varPriceText = string.Format("(between {0} and {1})", product.MinimumPrice.LSCurrencyFormat("lcf"), product.MaximumPrice.LSCurrencyFormat("lcf"));
                        }
                        else
                        {
                            varPriceText = string.Format("(at least {0})", product.MinimumPrice.LSCurrencyFormat("lcf"));
                        }
                    }
                    else if (product.MaximumPrice > 0)
                    {
                        varPriceText = string.Format("({0} maximum)", product.MaximumPrice.LSCurrencyFormat("lcf"));
                    }
                    phVariablePrice.Controls.Add(new LiteralControl(varPriceText));
                }
                AddProductPrice.Visible = !AddProductVariablePrice.Visible;
                if ((AddProductPrice.Visible && _Basket.UserId == AbleContext.Current.UserId) || (product.IsKit))
                {
                    AddProductPrice.Enabled = false;
                }
            }
        }
Ejemplo n.º 29
0
        public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
        {
            base.Initialize(ShipGatewayId, ConfigurationData);
            //INITIALIZE MY FIELDS
            if (ConfigurationData.ContainsKey("UserID"))
            {
                UserID = ConfigurationData["UserID"];
            }
            if (ConfigurationData.ContainsKey("Password"))
            {
                Password = ConfigurationData["Password"];
            }
            if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
            {
                EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
            }
            if (ConfigurationData.ContainsKey("AccountNumber"))
            {
                AccountNumber = ConfigurationData["AccountNumber"];
            }
            if (ConfigurationData.ContainsKey("ShippingKey"))
            {
                ShippingKey = ConfigurationData["ShippingKey"];
            }
            if (ConfigurationData.ContainsKey("DaysToShip"))
            {
                DaysToShip = AlwaysConvert.ToInt(ConfigurationData["DaysToShip"], 0);
            }
            if (ConfigurationData.ContainsKey("UseTestMode"))
            {
                UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], false);
            }
            if (ConfigurationData.ContainsKey("AccountActive"))
            {
                AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
            }
            if (ConfigurationData.ContainsKey("TestModeUrl"))
            {
                TestModeUrl = ConfigurationData["TestModeUrl"];
            }
            if (ConfigurationData.ContainsKey("LiveModeUrl"))
            {
                LiveModeUrl = ConfigurationData["LiveModeUrl"];
            }
            if (ConfigurationData.ContainsKey("TrackingUrl"))
            {
                TrackingUrl = ConfigurationData["TrackingUrl"];
            }

            if (ConfigurationData.ContainsKey("DOSFlag"))
            {
                DOSFlag = AlwaysConvert.ToBool(ConfigurationData["DOSFlag"], false);
            }
            if (ConfigurationData.ContainsKey("DutiableFlag"))
            {
                DutiableFlag = AlwaysConvert.ToBool(ConfigurationData["DutiableFlag"], false);
            }
            if (ConfigurationData.ContainsKey("CustomsValueMultiplier"))
            {
                CustomsValueMultiplier = AlwaysConvert.ToDecimal(ConfigurationData["CustomsValueMultiplier"], 1);
            }
            if (ConfigurationData.ContainsKey("CommerceLicensed"))
            {
                CommerceLicensed = AlwaysConvert.ToBool(ConfigurationData["CommerceLicensed"], false);
            }
            if (ConfigurationData.ContainsKey("FilingType"))
            {
                FilingType = (FilingTypeFlags)AlwaysConvert.ToEnum(typeof(FilingTypeFlags), ConfigurationData["FilingType"], FilingTypeFlags.ITN, true);
            }
            if (ConfigurationData.ContainsKey("FTRExemptionCode"))
            {
                FTRExemptionCode = ConfigurationData["FTRExemptionCode"];
            }
            if (ConfigurationData.ContainsKey("ITNNumber"))
            {
                ITNNumber = ConfigurationData["ITNNumber"];
            }
            if (ConfigurationData.ContainsKey("EINCode"))
            {
                EINCode = ConfigurationData["EINCode"];
            }

            if (ConfigurationData.ContainsKey("MinPackageWeight"))
            {
                MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
            }
            if (ConfigurationData.ContainsKey("MaxPackageWeight"))
            {
                MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
            }
        }
Ejemplo n.º 30
0
        private void SaveProduct()
        {
            // get a reference to the loaded product
            // this assists in file comparions between add/edit page
            Product product = _Product;

            // basic product information pane
            product.Name           = Name.Text;
            product.ManufacturerId = AlwaysConvert.ToInt(ManufacturerList.SelectedValue);
            product.Price          = AlwaysConvert.ToDecimal(Price.Text);
            product.ModelNumber    = ModelNumber.Text;
            product.MSRP           = AlwaysConvert.ToDecimal(Msrp.Text);
            product.Weight         = AlwaysConvert.ToDecimal(Weight.Text);
            product.CostOfGoods    = AlwaysConvert.ToDecimal(CostOfGoods.Text);
            product.GTIN           = Gtin.Text;
            product.Sku            = Sku.Text;
            product.IsFeatured     = IsFeatured.Checked;

            // descriptions
            product.Summary             = Summary.Text;
            product.Description         = Description.Text;
            product.ExtendedDescription = ExtendedDescription.Text;

            // shipping, tax, and inventory
            product.WarehouseId = AlwaysConvert.ToInt(Warehouse.SelectedValue);
            product.VendorId    = AlwaysConvert.ToInt(Vendor.SelectedValue);
            product.ShippableId = (byte)AlwaysConvert.ToInt(IsShippable.SelectedValue);
            product.Length      = AlwaysConvert.ToDecimal(Length.Text);
            product.Width       = AlwaysConvert.ToDecimal(Width.Text);
            product.Height      = AlwaysConvert.ToDecimal(Height.Text);
            product.TaxCodeId   = AlwaysConvert.ToInt(TaxCode.SelectedValue);
            if (CurrentInventoryMode.Visible)
            {
                product.InventoryModeId = AlwaysConvert.ToByte(CurrentInventoryMode.SelectedIndex);
                if (product.InventoryMode == InventoryMode.Product)
                {
                    product.InStock             = AlwaysConvert.ToInt(InStock.Text);
                    product.AvailabilityDate    = AvailabilityDate.SelectedDate;
                    product.InStockWarningLevel = AlwaysConvert.ToInt(LowStock.Text);
                    product.AllowBackorder      = BackOrder.Checked;
                }
                else if (product.InventoryMode == InventoryMode.Variant)
                {
                    product.AllowBackorder = BackOrder.Checked;
                }

                product.EnableRestockNotifications = EnableRestockNotifications.Checked;
            }

            // advanced settings
            product.WrapGroupId       = AlwaysConvert.ToInt(WrapGroup.SelectedValue);
            product.AllowReviews      = AllowReviewsPanel.Visible ? AllowReviews.Checked : true;
            product.Visibility        = (CatalogVisibility)Visibility.SelectedIndex;
            product.HidePrice         = HidePrice.Checked;
            product.Webpage           = WebpageDataSource.Load(AlwaysConvert.ToInt(DisplayPage.SelectedValue));
            product.IsProhibited      = IsProhibited.Checked;
            product.IsGiftCertificate = GiftCertificate.Checked;
            product.DisablePurchase   = DisablePurchase.Checked;
            product.UseVariablePrice  = UseVariablePrice.Checked;
            product.MinimumPrice      = AlwaysConvert.ToDecimal(MinPrice.Text);
            product.MaximumPrice      = AlwaysConvert.ToDecimal(MaxPrice.Text);
            product.HandlingCharges   = AlwaysConvert.ToDecimal(HandlingCharges.Text);
            product.MinQuantity       = AlwaysConvert.ToInt16(MinQuantity.Text);
            product.MaxQuantity       = AlwaysConvert.ToInt16(MaxQuantity.Text);
            product.HtmlHead          = HtmlHead.Text.Trim();
            product.SearchKeywords    = SearchKeywords.Text.Trim();
            _Product.EnableGroups     = AlwaysConvert.ToBool(EnableGroups.SelectedValue, false);
            _Product.ProductGroups.DeleteAll();
            foreach (ListItem item in ProductGroups.Items)
            {
                if (item.Selected)
                {
                    int          groupId = AlwaysConvert.ToInt(item.Value);
                    ProductGroup pg      = new ProductGroup(_Product, GroupDataSource.Load(groupId));
                    _Product.ProductGroups.Add(pg);
                }
            }

            // search engines and feeds
            product.CustomUrl = CustomUrl.Text;
            CustomUrlValidator.OriginalValue = _Product.CustomUrl;
            product.ExcludeFromFeed          = !IncludeInFeed.Checked;
            product.Title                 = ProductTitle.Text.Trim();
            product.MetaDescription       = MetaDescriptionValue.Text.Trim();
            product.MetaKeywords          = MetaKeywordsValue.Text.Trim();
            product.GoogleCategory        = GoogleCategory.Text;
            product.Condition             = Condition.SelectedValue;
            product.Gender                = Gender.SelectedValue;
            product.AgeGroup              = AgeGroup.SelectedValue;
            product.Color                 = Color.Text;
            product.Size                  = Size.Text;
            product.AdwordsGrouping       = AdwordsGrouping.Text;
            product.AdwordsLabels         = AdwordsLabels.Text;
            product.ExcludedDestination   = ExcludedDestination.SelectedValue;
            product.AdwordsRedirect       = AdwordsRedirect.Text;
            product.PublishFeedAsVariants = PublishAsVariants.Checked;

            // TAX CLOUD PRODUCT TIC
            if (trTIC.Visible && !string.IsNullOrEmpty(HiddenTIC.Value))
            {
                product.TIC = AlwaysConvert.ToInt(HiddenTIC.Value);
            }
            else
            {
                product.TIC = null;
            }

            // save product
            product.Save();
            ModalPopupExtender.Hide();
        }