private void PrintNearbyForSale(IEnumerable <CommunityInfo> selector) { if (!selector.Any()) { QueryOutputTextbox.AppendText("Your Query Yeilded no Mathches"); return; } //go through the elements foreach (var pro in selector) { //output QueryOutputTextbox.AppendText(string.Format("{0}{1} {2}, {3} {4} {5} units away\r\n", pro.property.StreetAddr, (pro.type == 0) ? "" : " #Apt " + (pro.property as Apartment).Unit + ' ', pro.property.City, pro.property.State, pro.property.Zip, pro.distance )); QueryOutputTextbox.AppendText(string.Format("Owner: {0} | ", pro.FullName)); QueryOutputTextbox.AppendText(string.Format("{0} bed, {1} bath, {2} sq.ft \r\n {3} : {4} {5:C0}\r\n\r\n", (pro.property as Residential).Bedrooms, (pro.property as Residential).Baths, (pro.property as Residential).Sqft, (pro.type == 1) ? "With out garage" : ((pro.property as House).AttatchedGarage == true) ? "With attach Garage" : "With garage", (pro.type == 1) ? "" : (pro.property as House).Flood + " floors.", Int32.Parse(pro.property.ForSale.Split(':')[1]) )); } QueryOutputTextbox.AppendText("\r\n### END OUTPUT ###"); }
// print out the person who has the property but not live in the town private void PrintOutTowner(Community comm1, Community comm2) { //query var List = from res in comm1.Residents from pro in comm2.Props where res.Id == pro.OwnerId select new { forSale = pro.ForSale.Split(':'), FullName = res.FullName, property = pro, type = (pro is Business) ? 0 : (pro is School) ? 1 : (pro is House) ? 2 : 3 }; //match them to the element foreach (var pro in List) { //output QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3}\r\n", pro.property.StreetAddr, pro.property.City, pro.property.State, pro.property.Zip)); QueryOutputTextbox.AppendText(string.Format("Ownwer: {0} |\t{1:C0}\r\n", pro.FullName, (pro.forSale[0] == "T") ? Int32.Parse(pro.forSale[1]) : 0)); QueryOutputTextbox.AppendText(string.Format("{0}, a {1} type of business, established in {2}\r\n\r\n", (pro.property as Business).Name, (pro.property as Business).Type, (pro.property as Business).YearEstablished)); } }
//out of towners button click private void TownersQueryButton_Click(object sender, EventArgs e) { QueryOutputTextbox.Text = string.Format("Properties Ownded by Out-Of-Towners\r\n" + "------------------------------------------------------------------------------------------\r\n"); PrintOutTowner(SycamoreCommunity, DekalbCommunity); PrintOutTowner(DekalbCommunity, SycamoreCommunity); QueryOutputTextbox.AppendText("\r\n### END OUTPUT ###"); }
private void PrintNearbyBusiness(IEnumerable <CommunityInfo> selector) { if (!selector.Any()) { QueryOutputTextbox.AppendText("Your Query Yeilded no Mathches"); return; } //go through each element in the list foreach (var bus in selector) { QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3}\r\n", bus.property.StreetAddr, bus.property.City, bus.property.State, bus.property.Zip)); QueryOutputTextbox.AppendText(string.Format("Owner: {0} | ", bus.FullName)); QueryOutputTextbox.AppendText(string.Format("{0} units away, with {1} open positions \r\n{2}, " + "a {3} type of business, established in {4}\r\n\r\n", bus.distance, (bus.property as Business).ActiveRecruitment, (bus.property as Business).Name, (bus.property as Business).Type, (bus.property as Business).YearEstablished )); } }
private void printList(IEnumerable <IGrouping <string, CommunityInfo> > comm) { if (!comm.Any()) { QueryOutputTextbox.AppendText("Your Query Yeilded no Mathches"); return; } //variables temp int results = 0; //go through the objects foreach (var community in comm) { QueryOutputTextbox.AppendText(string.Format("\r\n\t\t*** {0} ***\r\n", community.Key)); foreach (var pro in community) { if (ResidentialtCheckBox.Checked == true && (pro.type == 2 || pro.type == 3)) { results += 1; QueryOutputTextbox.AppendText(string.Format("{0}{1} {2}, {3} {4}\r\n", pro.property.StreetAddr, (pro.type == 2) ? "" : " #Apt " + (pro.property as Apartment).Unit + ' ', pro.property.City, pro.property.State, pro.property.Zip )); QueryOutputTextbox.AppendText(string.Format("Owner: {0} | ", pro.FullName)); QueryOutputTextbox.AppendText(string.Format("{0} bed, {1} bath, {2} sq.ft \r\n {3} : {4} {5:C0}\r\n\r\n", (pro.property as Residential).Bedrooms, (pro.property as Residential).Baths, (pro.property as Residential).Sqft, (pro.type == 3) ? "With out garage" : ((pro.property as House).AttatchedGarage == true) ? "With attach Garage" : "With garage", (pro.type == 3) ? "" : (pro.property as House).Flood + " floors.", Int32.Parse(pro.property.ForSale.Split(':')[1]) )); } else if (SchoolCheckBox.Checked == true && pro.type == 1) { results += 1; QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3} Ownwer: {4}\r\n", pro.property.StreetAddr, pro.property.City, pro.property.State, pro.property.Zip, pro.FullName)); QueryOutputTextbox.AppendText(string.Format("{0}, established in {1}\r\n", (pro.property as School).Name, (pro.property as School).YearEstablished)); QueryOutputTextbox.AppendText(string.Format("{0} students enrooled {1:C0}\r\n", (pro.property as School).Enrolled, Int32.Parse(pro.property.ForSale.Split(':')[1]))); } else if (BusinessCheckBox.Checked && pro.type == 0) { results += 1; QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3}\r\n", pro.property.StreetAddr, pro.property.City, pro.property.State, pro.property.Zip)); QueryOutputTextbox.AppendText(string.Format("Ownwer: {0} | {1:C0}\r\n", pro.FullName, Int32.Parse(pro.property.ForSale.Split(':')[1]))); QueryOutputTextbox.AppendText(string.Format("{0}, a {1} type of business, established in {2}\r\n\r\n", (pro.property as Business).Name, (pro.property as Business).Type, (pro.property as Business).YearEstablished )); } } } //error output if (results == 0) { QueryOutputTextbox.AppendText("\r\nYour query yielded no matches.\r\n"); } QueryOutputTextbox.AppendText("\r\n### END OUTPUT ###"); }
private void ParametersQueryButton_Click(object sender, EventArgs e) { ushort numOfBath = Convert.ToUInt16(BathUpDown.Value); ushort numOfBed = Convert.ToUInt16(BedUpDown.Value); ushort numOfSpace = Convert.ToUInt16(SqFtUpDown.Value); bool garageCheck = GarageCheckBox.Checked; QueryOutputTextbox.Text = string.Format("House with at least {0} bed, {1} bath, and {2} sq. foot {3}\r\n" + "-----------------------------------------------------------------------------------------\r\n", numOfBed, numOfBath, numOfSpace, (garageCheck) ? "with garage." : "without garage."); //counter int results = 0; //create both of the list List <residentialInfo> DList = ResidentialPara(DekalbCommunity); List <residentialInfo> SList = ResidentialPara(SycamoreCommunity); //combine the 2 lists DList.AddRange(SList); //reorder the list //DList = DList.OrderBy(i => i.ForSale).ToList(); //go throught the list and print if needed foreach (var pro in DList) { //split the first and last name for output string[] splitted = pro.FullName.Split(' '); //checking data based on the list if (HouseCheckBox.Checked == true && pro.proType == true && pro.Bath >= BathUpDown.Value && pro.Bed >= BedUpDown.Value && pro.Sqft >= SqFtUpDown.Value) { if (GarageCheckBox.Checked == true && DetachedGarageCheckBox.Checked == false && pro.Garage == true && pro.AttachedGarage == false) { QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3} \r\nOwner: {4}, {5} | {6}, {7} baths, {8} sq.ft. \r\n {9} : {10} {11:C0}\r\n\r\n", pro.StreetAddr, pro.City, pro.State, pro.Zip, splitted[1], splitted[0].Trim(new char[] { ',' }), (pro.Bed == 1) ? " bed " : pro.Bed + " beds ", pro.Bath, pro.Sqft, (!pro.Garage) ? "With out garage" : (pro.AttachedGarage == true) ? "With attach Garage" : "With detatched garage", (pro.Flood == 1) ? pro.Flood + " floor." : pro.Flood + " floors.", Convert.ToUInt32(pro.ForSale) )); results += 1; } else if (GarageCheckBox.Checked == true && DetachedGarageCheckBox.Checked == true && pro.Garage == true && pro.AttachedGarage == true) { QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3} \r\nOwner: {4}, {5} | {6}, {7} baths, {8} sq.ft. \r\n {9} : {10} {11:C0}\r\n\r\n", pro.StreetAddr, pro.City, pro.State, pro.Zip, splitted[1], splitted[0].Trim(new char[] { ',' }), (pro.Bed == 1) ? " bed " : pro.Bed + " beds ", pro.Bath, pro.Sqft, (!pro.Garage) ? "With out garage" : (pro.AttachedGarage == true) ? "With attach Garage" : "With detatched garage", (pro.Flood == 1) ? pro.Flood + " floor." : pro.Flood + " floors.", Convert.ToUInt32(pro.ForSale) )); results += 1; } else if (GarageCheckBox.Checked == false) { QueryOutputTextbox.AppendText(string.Format("{0} {1}, {2} {3} \r\nOwner: {4}, {5} | {6}, {7} baths, {8} sq.ft. \r\n {9} : {10} {11:C0}\r\n\r\n", pro.StreetAddr, pro.City, pro.State, pro.Zip, splitted[1], splitted[0].Trim(new char[] { ',' }), (pro.Bed == 1) ? " bed " : pro.Bed + " beds ", pro.Bath, pro.Sqft, (!pro.Garage) ? "With out garage" : (pro.AttachedGarage == true) ? "With attach Garage" : "With detatched garage", (pro.Flood == 1) ? pro.Flood + " floor." : pro.Flood + " floors.", Convert.ToUInt32(pro.ForSale) )); results += 1; } } else if (ApartmentCheckBox.Checked == true && pro.proType == false && pro.Bath >= BathUpDown.Value && pro.Bed >= BedUpDown.Value && pro.Sqft >= SqFtUpDown.Value && GarageCheckBox.Checked == false) { QueryOutputTextbox.AppendText(string.Format("{0} Apt. # {1} {2}, {3} {4} \r\nOwner: {5}, {6} | {7}, {8} baths, {9} sq.ft. {10:C0}\r\n\r\n\r\n", pro.StreetAddr, pro.apt, pro.City, pro.State, pro.Zip, splitted[1], splitted[0].Trim(new char[] { ',' }), (pro.Bed == 1) ? " bed " : pro.Bed + " beds ", pro.Bath, pro.Sqft, Convert.ToUInt32(pro.ForSale))); results += 1; } } //error output if (results == 0) { QueryOutputTextbox.AppendText("Your query yielded no matches.\r\n"); } QueryOutputTextbox.AppendText("\r\n### END OUTPUT ###"); }
// action after clicking the 3th query button private void BusinessQueryButton_Click(object sender, EventArgs e) { //exit if null if (ForSaleCombobox.SelectedItem == null) { QueryOutputTextbox.Text = "You have not choose a school yet."; return; } //list of string addresses string[] stAddr = ForSaleCombobox.SelectedItem.ToString().Split(new[] { " # " }, StringSplitOptions.None); ushort distance = Convert.ToUInt16(BusinessDistanceUpDown.Value); QueryOutputTextbox.Text = string.Format("Hiring Businesses within {0} unit of distance\r\n\tfrom {1}\r\n" + "------------------------------------------------------------------------------------------\r\n", distance, stAddr[0]); Community comm; if (ForSaleCombobox.SelectedIndex > (DekalbCommunity.Population + 5)) { comm = SycamoreCommunity; } else { comm = DekalbCommunity; } //create the list SortedList <int, CommunityInfo> propertyList = new SortedList <int, CommunityInfo>(); List <Community> communities = new List <Community>(); communities.Add(DekalbCommunity); communities.Add(SycamoreCommunity); //query var list = from res in comm.Props where (res is House) || (res is Apartment) where (res.StreetAddr == stAddr[0]) from n in communities from pro in n.Props where (pro is Business) where pro.ForSale.Split(':')[0] == "T" let x = Math.Pow((int)(res.X - pro.X), 2) let y = Math.Pow((int)(res.Y - pro.Y), 2) where (x + y) < Math.Pow(distance, 2) from n1 in n.Residents where n1.Id == pro.OwnerId orderby(x + y) descending select new CommunityInfo() { id = pro.Id, property = pro, FullName = n1.FullName, distance = (int)Math.Sqrt(x + y), type = (pro is House) ? 0 : 1 }; //output PrintNearbyBusiness(list); QueryOutputTextbox.AppendText("\r\n### END OUTPUT ###"); }