protected void btnSave_Click(object sender, EventArgs e) { bool canContinue = false; try { double.Parse(TextBoxHeight.Text); double.Parse(TextBoxWidth.Text); LabelSizeError.Visible = false; canContinue = true; } catch { LabelSizeError.Visible = true; } if (canContinue) { if (int.Parse(DropDownListLanguages.SelectedValue) > 509) { Account newAccount = CurrentUser.CurrentAccount; bool isEditing = !newAccount.IsNew; newAccount.Description = TextBoxDescription.Text; newAccount.CountryId = int.Parse(DropDownCountry.SelectedValue); newAccount.LanguageId = int.Parse(DropDownListLanguages.SelectedValue); newAccount.CityId = int.Parse(DropDownListCityList.SelectedValue); newAccount.TrackNames = CheckBoxNames.Checked; newAccount.TrackPhoneNumbers = CheckBoxPhoneNumbers.Checked; newAccount.PrintHeight = double.Parse(TextBoxHeight.Text); newAccount.PrintUnit = DropDownListUnit.SelectedValue; newAccount.PrintWidth = double.Parse(TextBoxWidth.Text); newAccount.IsForeignLanguage = CheckBoxIsForeignLanguage.Checked; newAccount.Save(); CurrentUser.SetAccountCookie(newAccount); if (!isEditing) { if (AccountUserMap.GetForCurrentUser() == null) { AccountUserMap newMap = new AccountUserMap(); newMap.AccountId = newAccount.AccountId; newMap.UserId = CurrentUser.UserName; newMap.Save(); } Language defaultLanguage = new Language(509); defaultLanguage.AddLanguageToCurrentAccount(); defaultLanguage = new Language(int.Parse(DropDownListLanguages.SelectedValue)); defaultLanguage.AddLanguageToCurrentAccount(); City selectedCity = new City(int.Parse(this.DropDownListCityList.SelectedValue)); selectedCity.AssociateWithCurrentAccount(); } LabelMessage.Text = "Saved."; Saved(); CurrentUser.Refresh(); } else { LabelMessage.Text = "Please select a valid language"; } } }
protected void ButtonSave_Click(object sender, EventArgs e) { TerritorySite.BL.CMS.City selectedCity = new TerritorySite.BL.CMS.City(this.DropDownListCityList.SelectedValue); selectedCity.AssociateWithCurrentAccount(); DoDataBind(); // if it does exist don't do anything // if it does not existist : Create it, add it to the account. }
protected void Button1_Click(object sender, EventArgs e) { // search if the city already exists TerritorySite.BL.CMS.City findMe = new TerritorySite.BL.CMS.City(); findMe.StateProvinceId = int.Parse(this.DropDownListStates.SelectedValue); findMe.Description = TextBoxNewCity.Text.Trim(); TerritorySite.BL.CMS.CityCollection foundCities = new TerritorySite.BL.CMS.CityCollection(); foundCities.LoadAndCloseReader(TerritorySite.BL.CMS.City.Find(findMe)); if (foundCities.Count == 0) { findMe.StateProvinceId = int.Parse(this.DropDownListStates.SelectedValue); findMe.Description = TextBoxNewCity.Text.Trim(); findMe.Save(); findMe.AssociateWithCurrentAccount(); } else { foundCities[0].AssociateWithCurrentAccount(); } DoDataBind(); TextBoxNewCity.Text = string.Empty; }