Exemplo n.º 1
0
        protected void BindRentalsList()
        {
            //standard lookup
            try
            {
                RentalsController sysmgr = new RentalsController();
                List <Rentals>    info   = null;

                AddressesController addControl = new AddressesController();

                if (!string.IsNullOrEmpty(LandlordList.SelectedValue))
                {
                    info = sysmgr.Rentals_FindByLandlord(int.Parse(LandlordList.SelectedValue));

                    foreach (Rentals item in info) // Loop through List with foreach
                    {
                        item.AddressName = (addControl.Addresses_FindByID(item.AddressID)).FullAddress;
                    }

                    info.Sort((x, y) => x.AddressName.CompareTo(y.AddressName));
                    AddressSearchList.DataSource     = info;
                    AddressSearchList.DataTextField  = nameof(Rentals.AddressName);
                    AddressSearchList.DataValueField = nameof(Rentals.RentalID);
                    AddressSearchList.DataBind();
                    AddressSearchList.Items.Insert(0, "Select an Address...");
                }
            }
            catch (Exception ex)
            {
                errormsgs.Add(GetInnerException(ex).ToString());
                LoadMessageDisplay(errormsgs, "alert alert-danger");
            }
        }
Exemplo n.º 2
0
        protected void FindRentalAddresses_Click(object sender, EventArgs e)
        {
            if (LandlordList.SelectedIndex == 0)
            {
                errormsgs.Add("Select a landlord to obtain rental address/es.");
                LoadMessageDisplay(errormsgs, "alert alert-danger");
                AddressSearchList.DataSource = null;
                AddressSearchList.DataBind();
            }
            else
            {
                try
                {
                    // Clear_Click(sender, e);
                    RentalsController sysmgr = new RentalsController();
                    List <Rentals>    info   = sysmgr.Rentals_FindByLandlord(int.Parse(LandlordList.SelectedValue));

                    AddressesController addControl = new AddressesController();

                    foreach (Rentals item in info) // Loop through List with foreach
                    {
                        item.AddressName = (addControl.Addresses_FindByID(item.AddressID)).FullAddress;
                    }

                    if (info.Count == 0)
                    {
                        errormsgs.Add("No data found for the landlord");
                        LoadMessageDisplay(errormsgs, "alert alert-danger");
                        AddressSearchList.DataSource = null;
                        AddressSearchList.DataBind();
                    }
                    else
                    {
                        info.Sort((x, y) => x.AddressName.CompareTo(y.AddressName));
                        AddressSearchList.DataSource     = info;
                        AddressSearchList.DataTextField  = nameof(Rentals.AddressName);
                        AddressSearchList.DataValueField = nameof(Rentals.RentalID);
                        AddressSearchList.DataBind();
                        AddressSearchList.Items.Insert(0, "Select an Address...");
                    }
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }