コード例 #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
        static public CarrierLocation Get(int id)
        {
            CarrierLocation location = (from x in DbContextHelper.DbContext.CarrierLocation.Include("CountryMaster").Include("StateMaster").Include("CityMaster")
                                        where x.CarrierLocationID == id
                                        select x).FirstOrDefault <CarrierLocation>();

            return(location);
        }
コード例 #3
0
        public static CarrierLocation Save(CarrierLocation location)
        {
            if (location.CarrierLocationID == 0)
            {
                DbContextHelper.DbContext.Add(location);
            }

            DbContextHelper.DbContext.SaveChanges();

            return(location);
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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();
                }
            }
        }
コード例 #7
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);
            }
        }