예제 #1
0
        private void copyCarrierLocations(List <CarrierLocation> carrierLocations, int cloneCarrierID)
        {
            foreach (CarrierLocation location in carrierLocations)
            {
                CarrierLocation copyLocation = new CarrierLocation();

                copyLocation.CarrierID = cloneCarrierID;

                copyLocation.AddressLine1 = location.AddressLine1;
                copyLocation.AddressLine2 = location.AddressLine2;

                copyLocation.CityId   = location.CityId;
                copyLocation.CityName = location.CityName;

                copyLocation.CountryID      = location.CountryID;
                copyLocation.DepartmentName = location.DepartmentName;
                copyLocation.IsActive       = true;
                copyLocation.LocationName   = location.LocationName;

                copyLocation.StateId   = location.StateId;
                copyLocation.StateName = location.StateName;

                copyLocation.ZipCode   = location.ZipCode;
                copyLocation.ZipCodeId = location.ZipCodeId;

                CarrierLocationManager.Save(copyLocation);
            }
        }
예제 #2
0
        protected void btnLocationSave_Click(object sender, EventArgs e)
        {
            CarrierLocation location = null;

            Page.Validate("Location");
            if (!Page.IsValid)
            {
                return;
            }

            int countryID = Convert.ToInt32(ddlLocationCountry.SelectedValue);

            try {
                int carrierLocationID = Convert.ToInt32(ViewState["CarrierLocationID"]);


                if (carrierLocationID == 0)
                {
                    location          = new CarrierLocation();
                    location.IsActive = true;
                }
                else
                {
                    location = CarrierLocationManager.Get(carrierLocationID);
                }

                if (location != null)
                {
                    location.CarrierID    = carrierID;
                    location.LocationName = txtLocationName.Text;
                    location.AddressLine1 = txtLocationAddressLine1.Text;
                    location.AddressLine2 = txtLocationAddressLine2.Text;

                    if (ddlLocationState.SelectedIndex > 0)
                    {
                        location.StateId = Convert.ToInt32(ddlLocationState.SelectedValue);
                    }

                    if (ddlLocationCity.SelectedIndex > 0)
                    {
                        location.CityId = Convert.ToInt32(ddlLocationCity.SelectedValue);
                    }

                    location.ZipCode        = txtLocationZipCode.Text;
                    location.DepartmentName = txtLocationDepartment.Text;

                    if (countryID > 0)
                    {
                        location.CountryID = countryID;
                    }

                    CarrierLocationManager.Save(location);

                    showLocations();

                    bindLocations();
                }
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);
            }
        }
예제 #3
0
        protected void gvLocation_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            CarrierLocation location          = null;
            int             carrierLocationID = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "DoEdit")
            {
                CollectionManager.FillCollection(ddlLocationState, "StateId", "StateName", State.GetAll());

                location = CarrierLocationManager.Get(carrierLocationID);

                if (location != null)
                {
                    ViewState["CarrierLocationID"] = location.CarrierLocationID.ToString();

                    showLocationPanel();

                    bindLocationCountry();

                    txtLocationAddressLine1.Text = location.AddressLine1;
                    txtLocationAddressLine2.Text = location.AddressLine2;

                    if (location.StateId != null)
                    {
                        ddlLocationState.SelectedValue = location.StateId.ToString();

                        bindLocationStateCities((int)location.StateId);
                    }

                    if (location.CityId != null)
                    {
                        ddlLocationCity.SelectedValue = location.CityId.ToString();
                    }

                    txtLocationName.Text       = location.LocationName;
                    txtLocationZipCode.Text    = location.ZipCode;
                    txtLocationDepartment.Text = location.DepartmentName;

                    if (location.CountryID != null)
                    {
                        ddlLocationCountry.SelectedValue = location.CountryID.ToString();
                    }
                }
            }

            if (e.CommandName == "DoDelete")
            {
                location = CarrierLocationManager.Get(carrierLocationID);

                if (location != null)
                {
                    location.IsActive = false;

                    CarrierLocationManager.Save(location);


                    showLocations();

                    bindLocations();
                }
            }
        }