コード例 #1
0
        public void GrdLocations_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Select":
                int location = Convert.ToInt16(GrdLocations.DataKeys[e.Item.ItemIndex]);
                _objLocation = _objCtlLocation.EventsLocationGet(location, PortalId);

                // Clear selections.
                cboCountry.ClearSelection();
                cboRegion.ClearSelection();
                txtRegion.Text = string.Empty;

                // Fill fields.
                txtLocationName.Text = _objLocation.LocationName;
                txtMapURL.Text       = _objLocation.MapURL;
                txtStreet.Text       = _objLocation.Street;
                txtPostalCode.Text   = _objLocation.PostalCode;
                txtCity.Text         = _objLocation.City;

                if (cboCountry.Items.FindByText(_objLocation.Country) != null)
                {
                    cboCountry.Items.FindByText(_objLocation.Country).Selected = true;
                }
                BindRegion();
                if (cboRegion.Items.FindByText(_objLocation.Region) != null)
                {
                    cboRegion.Items.FindByText(_objLocation.Region).Selected = true;
                }
                else
                {
                    txtRegion.Text = _objLocation.Region;
                }

                ViewState.Add("Location", _objLocation.Location.ToString());
                BindData();

                //We can update
                cmdUpdate.Visible = true;
                break;
            }
        }
コード例 #2
0
        private void SaveLocation(int locationID)
        {
            // Only Update if the Entered Data is Valid
            if (Page.IsValid && !string.IsNullOrEmpty(txtLocationName.Text))
            {
                var    objLocation  = new EventLocationInfo();
                var    objSecurity  = new PortalSecurity();
                var    locationName = "";
                var    mapURL       = "";
                var    street       = "";
                var    postalCode   = "";
                var    city         = "";
                string region       = null;
                string country      = null;

                // Filter text for non-admins
                if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    locationName = txtLocationName.Text;
                    mapURL       = PutHTTPInFront(txtMapURL.Text);
                    street       = txtStreet.Text;
                    postalCode   = txtPostalCode.Text;
                    city         = txtCity.Text;
                    if (cboRegion.SelectedIndex > 0)
                    {
                        region = cboRegion.SelectedItem.Text;
                    }
                    else
                    {
                        region = txtRegion.Text;
                    }
                    if (cboCountry.SelectedIndex > 0)
                    {
                        country = Convert.ToString(cboCountry.SelectedItem.Text);
                    }
                }
                else
                {
                    locationName =
                        objSecurity.InputFilter(txtLocationName.Text, PortalSecurity.FilterFlag.NoScripting);
                    mapURL = objSecurity.InputFilter(PutHTTPInFront(txtMapURL.Text),
                                                     PortalSecurity.FilterFlag.NoScripting);
                    street     = objSecurity.InputFilter(txtStreet.Text, PortalSecurity.FilterFlag.NoScripting);
                    postalCode =
                        objSecurity.InputFilter(txtPostalCode.Text, PortalSecurity.FilterFlag.NoScripting);
                    city = objSecurity.InputFilter(txtCity.Text, PortalSecurity.FilterFlag.NoScripting);
                    if (cboRegion.SelectedIndex > 0)
                    {
                        region = objSecurity.InputFilter(cboRegion.SelectedItem.Text,
                                                         PortalSecurity.FilterFlag.NoScripting);
                    }
                    else
                    {
                        region = objSecurity.InputFilter(txtRegion.Text, PortalSecurity.FilterFlag.NoScripting);
                    }
                    if (cboCountry.SelectedIndex > 0)
                    {
                        country = objSecurity.InputFilter(Convert.ToString(cboCountry.SelectedItem.Text),
                                                          PortalSecurity.FilterFlag.NoScripting);
                    }
                }

                //bind text values to object
                objLocation.Location     = locationID;
                objLocation.PortalID     = PortalId;
                objLocation.LocationName = locationName;
                objLocation.MapURL       = mapURL;
                objLocation.Street       = street;
                objLocation.PostalCode   = postalCode;
                objLocation.City         = city;
                objLocation.Region       = region;
                objLocation.Country      = country;
                _objCtlLocation.EventsLocationSave(objLocation);

                //Back to normal (add) mode
                txtLocationName.Text = "";
                txtMapURL.Text       = "";
                txtStreet.Text       = "";
                txtPostalCode.Text   = "";
                txtCity.Text         = "";
                txtRegion.Text       = "";
                cboRegion.ClearSelection();
                cboCountry.ClearSelection();

                ViewState.Remove("Location");
                cmdUpdate.Visible = false;
            }
        }