예제 #1
0
        public void UpdateAddressSettings(int portalID, AddressSettings addressSettings)
        {
            string settings = ProviderSettingsHelper.SerializeSettings(addressSettings, typeof(AddressSettings));

            DataProvider.Instance().ExecuteNonQuery("Store_Administration_UpdateAddressSettings", portalID, DataHelper.GetNull(settings));
            DataCache.SetCache("StoreDefaultAddressSettings", addressSettings);
        }
예제 #2
0
        public AddressSettings GetAddressSettings(int portalID)
        {
            AddressSettings addressSettings = (AddressSettings)DataCache.GetCache("StoreDefaultAddressSettings" + portalID);

            if (addressSettings == null)
            {
                using (IDataReader reader = DataProvider.Instance().ExecuteReader("Store_Administration_GetAddressSettings", portalID))
                {
                    if (reader != null)
                    {
                        if (reader.Read())
                        {
                            string settings = "";
                            settings = (string)Null.SetNull(reader["DefaultAddressSettings"], settings);
                            if (!string.IsNullOrEmpty(settings))
                            {
                                addressSettings = (AddressSettings)ProviderSettingsHelper.DeserializeSettings(settings, typeof(AddressSettings));
                                DataCache.SetCache("StoreDefaultAddressSettings", addressSettings);
                            }
                        }
                        reader.Close();
                    }
                }
                if (addressSettings == null)
                {
                    addressSettings = new AddressSettings();
                }
            }
            return(addressSettings);
        }
예제 #3
0
파일: TaxInfo.cs 프로젝트: valadas/DNNStore
        public void Fill(System.Data.IDataReader dr)
        {
            KeyID            = Convert.ToInt32(dr["PortalID"]);
            DefaultTaxRate   = Convert.ToDecimal(Null.SetNull(dr["DefaultTaxRate"], DefaultTaxRate));
            ShowTax          = Convert.ToBoolean(dr["ShowTax"]);
            _defaultTaxRates = Convert.ToString(Null.SetNull(dr["DefaultTaxRates"], _defaultTaxRates));
            if (!string.IsNullOrEmpty(_defaultTaxRates))
            {
                CountryTaxes = (CountryTaxRates)ProviderSettingsHelper.DeserializeSettings(_defaultTaxRates, typeof(CountryTaxRates));
            }

            if (CountryTaxes == null)
            {
                CountryTaxes = new CountryTaxRates();
            }
        }
예제 #4
0
        private void SaveTaxRates()
        {
            if (!Page.IsValid)
            {
                return;
            }

            bool    enableTax      = cbEnableTax.Checked;
            decimal defaultTaxRate = Null.NullDecimal;

            if (enableTax)
            {
                defaultTaxRate = Decimal.Parse(txtDefaultTaxRate.Text);
            }

            CountryTaxRates countryTaxRates = (CountryTaxRates)ViewState["Store_CountryTaxRates"];
            List <int>      deletedItems    = new List <int>();

            foreach (DataGridItem gridItem in grdCountryTaxRates.Items)
            {
                CheckBox chkDelete = (CheckBox)gridItem.FindControl("chkDelete");
                if (chkDelete != null && chkDelete.Checked)
                {
                    deletedItems.Add(gridItem.ItemIndex);
                }
                else
                {
                    TextBox txtTaxRate = (TextBox)gridItem.FindControl("txtTaxRate");
                    if (txtTaxRate != null)
                    {
                        string textTaxRate = txtTaxRate.Text;
                        if (!string.IsNullOrEmpty(textTaxRate))
                        {
                            decimal taxRate;
                            if (decimal.TryParse(textTaxRate, out taxRate))
                            {
                                countryTaxRates.TaxRates[gridItem.ItemIndex].TaxRate = taxRate;
                            }
                        }
                    }
                }
            }

            if (deletedItems.Count > 0)
            {
                deletedItems.Reverse();
                foreach (int deletedItem in deletedItems)
                {
                    countryTaxRates.TaxRates.RemoveAt(deletedItem);
                }
            }

            countryTaxRates.TaxRates.Sort();

            string taxRates = ProviderSettingsHelper.SerializeSettings(countryTaxRates, typeof(CountryTaxRates));

            TaxController controller = new TaxController();

            controller.UpdateTaxRates(PortalId, defaultTaxRate, cbEnableTax.Checked, taxRates);

            BindTaxRates(countryTaxRates);
        }