protected void FindByPartialStreetAddress_Click(object sender, EventArgs e) { AddressDetailList.DataSource = null; AddressDetailList.DataBind(); if (string.IsNullOrEmpty(AddressNumber.Text) || string.IsNullOrEmpty(AddressStreet.Text)) { errormsgs.Add("Please provide Number and Street to search."); LoadMessageDisplay(errormsgs, "alert alert-danger"); } else { try { AddressesController sysmgr = new AddressesController(); List <Addresses> info = sysmgr.Addresses_FindByPartialStreetAddress(AddressNumber.Text, AddressStreet.Text); if (info.Count == 0) { errormsgs.Add("No data found for the supplied number and street."); LoadMessageDisplay(errormsgs, "alert alert-danger"); AddressDetailList.DataSource = null; AddressDetailList.DataBind(); } else { info.Sort((x, y) => x.FullAddress.CompareTo(y.FullAddress)); //Second Dropdown list drill down AddressDetailList.DataSource = info; AddressDetailList.DataTextField = nameof(Addresses.FullAddress); AddressDetailList.DataValueField = nameof(Addresses.AddressID); AddressDetailList.DataBind(); AddressDetailList.Items.Insert(0, "Select an Address..."); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }
protected void FindRental_Click(object sender, EventArgs e) { if (AddressSearchList.SelectedIndex == 0 || AddressSearchList.Items.Count < 1) { errormsgs.Add("Select a rental address to maintain."); LoadMessageDisplay(errormsgs, "alert alert-danger"); } else { try { RentalsController rentalsctrlr = new RentalsController(); Rentals info = null; info = rentalsctrlr.Rentals_FindByID(int.Parse(AddressSearchList.SelectedValue)); AddressesController addressctrlr = new AddressesController(); Addresses address = null; List <Addresses> alladdresses = addressctrlr.Address_List(); address = addressctrlr.Addresses_FindByID(info.AddressID); if (info == null) { errormsgs.Add("Cannot find Rental in database."); LoadMessageDisplay(errormsgs, "alert alert-danger"); Clear_Click(sender, e); } else { RentalID.Text = info.RentalID.ToString(); AddressNumber.Text = address.Number; AddressStreet.Text = address.Street; alladdresses.Sort((x, y) => x.FullAddress.CompareTo(y.FullAddress)); AddressDetailList.DataSource = alladdresses; AddressDetailList.DataTextField = nameof(Addresses.FullAddress); AddressDetailList.DataValueField = nameof(Addresses.AddressID); AddressDetailList.DataBind(); AddressDetailList.Items.Insert(0, "Select an Address..."); AddressDetailList.SelectedValue = address.AddressID.ToString(); AddressID.Text = address.AddressID.ToString(); SelectedAddress.Text = address.FullAddress; if (info.RentalTypeID.HasValue) { RentalTypeList.SelectedValue = info.RentalTypeID.ToString(); } else { RentalTypeList.SelectedIndex = 0; } MonthlyRent.Text = string.Format("{0:0.00}", info.MonthlyRent); Vacancies.Text = info.Vacancies.ToString(); MaxVacancy.Text = info.MaxVacancy.ToString(); DamageDeposit.Text = string.IsNullOrEmpty(info.DamageDeposit.ToString()) ? "" : string.Format("{0:0.00}", info.DamageDeposit); AvailableDate.Text = string.IsNullOrEmpty(info.AvailableDate.ToString()) ? "" : info.AvailableDate.Value.ToString("yyyy-MM-dd"); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }