protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int clientID = SessionHelper.getClientId(); carriers = CarrierManager.GetCarriers(clientID).ToList(); CollectionManager.FillCollection(ddlCarrier, "CarrierID", "CarrierName", carriers); if (carriers != null) { int[] carrierID = new int[carriers.Count]; for (var i = 0; i < carriers.Count; i++) { carrierID[i] = carriers[i].CarrierID; } List <CarrierLocation> CarrierLocationArr = new List <CarrierLocation>(); CarrierLocationArr = CarrierLocationManager.GetAllList(carrierID); CollectionManager.FillCollection(gvLocation, "CarrierLocationID", "LocationName", CarrierLocationArr); } ddlCarrier.Items[0].Text = "Select All"; gvLocation.Items[0].Text = "Select All"; ddlCarrier.SelectedIndex = 0; gvLocation.SelectedIndex = 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); } }
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); } }
private void bindLocations() { gvLocation.DataSource = CarrierLocationManager.GetAll(carrierID); gvLocation.DataBind(); }
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(); } } }