private void BindBillToAddress() { string pattern = "[Company]\r\n[Name]\r\n[Address1]\r\n[Address2]\r\n[City], [Province] [PostalCode]\r\n[Country_U]\r\n"; Country country = CountryDataSource.Load(_order.BillToCountryCode); if (country != null) { if (!string.IsNullOrEmpty(country.AddressFormat)) { pattern = country.AddressFormat; } } BillingAddress.Text = _order.FormatAddress(pattern, true); BillToEmail.Text = _order.BillToEmail; MoveOrderButton.NavigateUrl = string.Format(MoveOrderButton.NavigateUrl, _order.OrderNumber.ToString()); string returnUrl = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("~/Admin/Orders/ViewOrder.aspx?OrderNumber=" + _order.OrderNumber.ToString())); BillToEmail.NavigateUrl += "?OrderNumber=" + _order.OrderNumber.ToString() + "&ReturnUrl=" + returnUrl; if (!string.IsNullOrEmpty(_order.BillToPhone)) { BillToPhone.Text = string.Format(BillToPhone.Text, _order.BillToPhone); } else { BillToPhone.Visible = false; } if (!string.IsNullOrEmpty(_order.BillToFax)) { BillToFax.Text = string.Format(BillToFax.Text, _order.BillToFax); } else { BillToFax.Visible = false; } }
protected void ChangeCountryListOKButton_Click(object sender, System.EventArgs e) { string controlName = HiddenSelectedCountries.UniqueID; string postedValue = Request.Form[controlName]; //REMOVE ALL COUNTRIES ASSOCIATED WITH SHIPZONE _ShipZone.Countries.Clear(); _ShipZone.Save(); if (!string.IsNullOrEmpty(postedValue)) { //GET LIST OF VALID COUNTRY CODES List <string> validCountryCodes = GetValidCountryCodes(); //ADD SELECTED COUNTRIES BACK IN string[] postedCountryCodes = postedValue.Split(",".ToCharArray()); foreach (string tempCode in postedCountryCodes) { string countryCode = tempCode.Trim(); if (validCountryCodes.Contains(countryCode)) { Country country = CountryDataSource.Load(countryCode); _ShipZone.Countries.Add(country); } } _ShipZone.Save(); } CountryList.Text = GetCountryList(); }
protected void Page_Init(object sender, EventArgs e) { _subscriptionId = AlwaysConvert.ToInt(Request.QueryString["SubscriptionId"]); _subscription = SubscriptionDataSource.Load(_subscriptionId); CountryCode.DataSource = CountryDataSource.LoadAll("Name"); CountryCode.DataBind(); //INIT ADDRESS Address address = _subscription.GetShippingAddress(); FirstName.Text = address.FirstName; LastName.Text = address.LastName; Company.Text = address.Company; Address1.Text = address.Address1; Address2.Text = address.Address2; City.Text = address.City; Province.Text = address.Province; PostalCode.Text = address.PostalCode; ListItem selectedCountry = CountryCode.Items.FindByValue(AbleContext.Current.Store.DefaultWarehouse.CountryCode); if (!String.IsNullOrEmpty(address.CountryCode)) { selectedCountry = CountryCode.Items.FindByValue(address.CountryCode.ToString()); } if (selectedCountry != null) { CountryCode.SelectedIndex = CountryCode.Items.IndexOf(selectedCountry); } Phone.Text = address.Phone; Fax.Text = address.Fax; Residence.SelectedIndex = (address.Residence ? 0 : 1); }
private IList <Country> GetProvinceCountries() { if (_ShipZone.CountryRule == FilterRule.All) { return(CountryDataSource.LoadAll()); } IList <Country> includedCountries = new List <Country>(); if (_ShipZone.CountryRule == FilterRule.IncludeSelected) { foreach (Country country in _ShipZone.Countries) { includedCountries.Add(country); } } else { IList <Country> allCountries = CountryDataSource.LoadAll(); foreach (Country c in allCountries) { if (_ShipZone.Countries.IndexOf(c) < 0) { includedCountries.Add(c); } } } return(includedCountries); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // set default start/end date range // use query parameters if found, otherwise default to start beginning of current month ending current day DateTime localNow = LocaleHelper.LocalNow; StartDate.SelectedDate = AlwaysConvert.ToDateTime(Request.QueryString["SDate"], new DateTime(localNow.Year, localNow.Month, 1)); EndDate.SelectedDate = AlwaysConvert.ToDateTime(Request.QueryString["EDate"], new DateTime(localNow.Year, localNow.Month, DateTime.DaysInMonth(localNow.Year, localNow.Month))); // set up country list list_Country.DataSource = CountryDataSource.LoadAll(); list_Country.DataTextField = "Name"; list_Country.DataValueField = "CountryCode"; list_Country.DataBind(); // set country to default to primary warehouse country string defCountry = Request.QueryString["CountryCode"]; if (string.IsNullOrEmpty(defCountry)) { defCountry = AbleContext.Current.Store.DefaultWarehouse.CountryCode; } ListItem findItem = list_Country.Items.FindByValue(defCountry); if (findItem != null) { list_Country.SelectedIndex = list_Country.Items.IndexOf(findItem); } // fire immediate report ProcessButton_Click(null, null); } }
public void Constructor() { CountryDataSource countryDataSource; countryDataSource = new CountryDataSource(); Assert.IsNotNull(countryDataSource); }
protected void CountryChanged(object sender, EventArgs e) { //LOAD PROVINCES FOR SELECTED COUNTRY int provincesCount = ProvinceDataSource.CountForCountry(CountryFilter.SelectedValue); //WE WANT TO SHOW THE DROP DOWN IF THE COUNTRY HAS BEEN CHANGED BY THE CLIENT //AND ALSO IF PROVINCES ARE AVAILABLE FOR THIS COUNTRY if (provincesCount > 0) { Province.Visible = false; Province2.Visible = true; Country county = CountryDataSource.Load(CountryFilter.SelectedValue); if (county != null) { Province2.Items.Clear(); Province2.Items.Add(new ListItem("All Provinces", "")); Province2.DataSource = county.Provinces; Province2.DataBind(); } } else { //WE ONLY WANT A TEXTBOX TO SHOW //REQUIRE THE TEXTBOX IF THERE ARE PROVINCES Province.Visible = true; Province2.Visible = false; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var group = CountryDataSource.GetGroup((int)navigationParameter); this.DefaultViewModel["Group"] = group; this.DefaultViewModel["Items"] = group.Items; }
protected void Page_Init(object sender, EventArgs e) { _userId = AlwaysConvert.ToInt(Request.QueryString["UserId"]); _User = UserDataSource.Load(_userId); CountryCode.DataSource = CountryDataSource.LoadAll("Name"); CountryCode.DataBind(); BindShippingAddresses(true); }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { // TODO: Create an appropriate data model for your problem domain to replace the sample data var countryDataGroups = CountryDataSource.GetGroups((String)navigationParameter); this.DefaultViewModel["Groups"] = countryDataGroups; this.groupGridView.ItemsSource = this.groupedItemsViewSource.View.CollectionGroups; }
private CountryDataSource GetCountryDataSource(Boolean refresh) { if (_countryDataSource.IsNull() || refresh) { _countryDataSource = new CountryDataSource(); } return(_countryDataSource); }
protected void Page_Init(object sender, EventArgs e) { InitAddressBook(); Country.DataSource = CountryDataSource.LoadAll("Name"); Country.DataBind(); //LOAD VIEW STATE LoadCustomViewState(); }
protected void InitializeCountryList(DropDownList DDL) { CountryDataSource.DataBind(); DDL.DataSourceID = "CountryDataSource"; DDL.DataTextField = "countryname"; DDL.DataValueField = "countryid"; DDL.DataBind(); DDL.Items.Insert(0, "-Select Country-"); }
public void LoadDialog(string countryCode) { this.CountryCode = countryCode; Country country = CountryDataSource.Load(countryCode); Caption.Text = string.Format(Caption.Text, country.Name); CountryCodeLabel2.Text = countryCode; Name.Text = country.Name; AddressFormat.Text = country.AddressFormat; }
protected void Page_Init(object sender, EventArgs e) { _settings = AbleContext.Current.Store.Settings; if (AbleContext.Current.User.Basket.Items.Count == 0) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetBasketUrl()); } Country.DataSource = CountryDataSource.LoadAll(); Country.DataBind(); }
private List <string> GetValidCountryCodes() { List <string> allCountryCodes = new List <string>(); IList <Country> allCountries = CountryDataSource.LoadAll(); foreach (Country c in allCountries) { allCountryCodes.Add(c.Id); } return(allCountryCodes); }
protected void Page_Init(object sender, EventArgs e) { this.TrackViewState(); Country.DataSource = CountryDataSource.LoadAll(); Country.DataBind(); _Basket = AbleContext.Current.User.Basket; if (_Basket.Items.Count == 0) { Response.Redirect(NavigationHelper.GetMobileStoreUrl("~/Basket.aspx")); } }
public void DataSource() { ICountryDataSource dataSource; dataSource = null; GetCountryManager(true).DataSource = dataSource; Assert.AreEqual(dataSource, GetCountryManager().DataSource); dataSource = new CountryDataSource(); GetCountryManager(true).DataSource = dataSource; Assert.AreEqual(dataSource, GetCountryManager().DataSource); }
protected void CountryGrid_RowEditing(object sender, GridViewEditEventArgs e) { string countryCode = CountryGrid.DataKeys[e.NewEditIndex].Value.ToString(); Country country = CountryDataSource.Load(countryCode); if (country != null) { AddCountryDialog1.Visible = false; EditCountryDialog1.Visible = true; EditCountryDialog1.LoadDialog(countryCode); } }
public static bool DeleteAllCountries(string alphabet) { IList <Country> countries = CountryDataSource.SearchByName(alphabet + "%"); IDatabaseSessionManager database = AbleContext.Current.Database; database.BeginTransaction(); foreach (Country country in countries) { CountryDataSource.Delete(country); } database.CommitTransaction(); return(true); }
public static bool DeleteCountries(string[] countryIds) { List <string> ids = new List <string>(); IDatabaseSessionManager database = AbleContext.Current.Database; database.BeginTransaction(); foreach (string cid in countryIds) { CountryDataSource.Delete(cid); } database.CommitTransaction(); return(true); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { await CountryDataSource.LoadXMLData(); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); //Associate the frame with a SuspensionManager key SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // Register handler for CommandsRequested events from the settings pane SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { Country country = CountryDataSource.Load(CountryCode); country.Name = Name.Text; country.AddressFormat = AddressFormat.Text.Replace("\r\n", "\n").Replace("\n", "\r\n"); country.Save(); //TRIGER ANY EVENT ATTACHED TO THE UPDATE if (ItemUpdated != null) { ItemUpdated(this, new EventArgs()); } } }
protected void Page_Load(object sender, EventArgs e) { string countryCode = Request.QueryString["CountryCode"]; if (!Page.IsPostBack) { Country country = CountryDataSource.Load(countryCode); if (country != null) { Caption.Text = string.Format(Caption.Text, country.Name); } } AddProvinceDialog1.ItemAdded += new EventHandler(AddProvinceDialog1_ItemAdded); ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "provinceCountryCode", "var countryCode = '" + countryCode + "';", true); }
protected void DeleteRow(object sender, GridViewDeletedEventArgs e) { if (e.Exception == null) { lblMessError.Visible = false; CountryDataSource.DataBind(); dgCountry.DataBind(); } else { e.ExceptionHandled = true; lblMessError.Text = "Delete operation is fail because the data you deleted is still referenced by other data"; lblMessError.Visible = true; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState) { // Allow saved page state to override the initial item to display if (pageState != null && pageState.ContainsKey("SelectedItem")) { navigationParameter = pageState["SelectedItem"]; } // TODO: Create an appropriate data model for your problem domain to replace the sample data var item = CountryDataSource.GetItem((int)navigationParameter); this.DefaultViewModel["Group"] = item.Group; this.DefaultViewModel["Items"] = item.Group.Items; this.flipView.SelectedItem = item; }
protected void Page_Init(object sender, System.EventArgs e) { Country.DataSource = CountryDataSource.LoadAll(); Country.DataBind(); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Name); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Address1); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Address2); AbleCommerce.Code.PageHelper.ConvertEnterToTab(City); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Province); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Province2); AbleCommerce.Code.PageHelper.ConvertEnterToTab(PostalCode); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Country); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Phone); AbleCommerce.Code.PageHelper.ConvertEnterToTab(Fax); AbleCommerce.Code.PageHelper.SetDefaultButton(Email, SaveButton.ClientID); }
public static bool DeleteAllProvinces(string countryCode) { Country country = CountryDataSource.Load(countryCode); if (country != null) { IDatabaseSessionManager database = AbleContext.Current.Database; database.BeginTransaction(); country.Provinces.DeleteAll(); database.CommitTransaction(); return(true); } else { return(false); } }
/// <summary> /// Formats the address using the default address format for the given country. /// </summary> /// <param name="name">The name in address</param> /// <param name="company">The company name</param> /// <param name="address1">Address line 1</param> /// <param name="address2">Address line 2</param> /// <param name="city">The city</param> /// <param name="province">The province</param> /// <param name="postalCode">The postal code</param> /// <param name="countryCode">The country code</param> /// <param name="phone">The phone number</param> /// <param name="fax">The fax number</param> /// <param name="email">The email address</param> /// <param name="isHtml">If true address is formatted in HTML otherwise plain text.</param> /// <returns>Formatted address</returns> public static string Format(string name, string company, string address1, string address2, string city, string province, string postalCode, string countryCode, string phone, string fax, string email, bool isHtml) { string pattern = string.Empty; string countryName = countryCode; //NEED TO GET FORMAT FOR pattern FOR THIS COUNTRY Country country = CountryDataSource.Load(countryCode); if (country != null) { //GET pattern FORMAT FROM COUNTRY RECORD pattern = country.AddressFormat; countryName = country.Name; } return(AddressFormatter.Format(pattern, name, company, address1, address2, city, province, postalCode, countryName, phone, fax, email, isHtml)); }
protected void OnCountryDataBound(object sender, EventArgs e) { if (!Page.IsPostBack) { string warehouseCountry = AbleContext.Current.Store.DefaultWarehouse.CountryCode; ListItem defaultCountry = CountryFilter.Items.FindByValue(warehouseCountry); if (defaultCountry != null) { CountryFilter.SelectedIndex = CountryFilter.Items.IndexOf(defaultCountry); } } Country county = CountryDataSource.Load(CountryFilter.SelectedValue); if (county != null) { Province2.Visible = county.Provinces.Count > 0; if (Province2.Visible) { Province2.Items.Clear(); Province2.Items.Add(new ListItem("All Provinces", "")); Province2.DataSource = county.Provinces; Province2.DataBind(); } Province.Visible = !Province2.Visible; } if (!Page.IsPostBack) { string warehouseProvince = AbleContext.Current.Store.DefaultWarehouse.Province; if (county.Provinces.Count > 0) { ListItem defaultProvince = Province2.Items.FindByValue(warehouseProvince); if (defaultProvince != null) { Province2.SelectedIndex = Province2.Items.IndexOf(defaultProvince); } } else { Province.Text = warehouseProvince; } } }