private void frmClient_Load(object sender, EventArgs e) { if (frmLogin.agent != null) { cboAgent.Visible = lblCAgent.Visible = false; } else { cboAgent.DataSource = Remax.TabAgents(); cboAgent.DisplayMember = "Name"; cboAgent.ValueMember = "Id"; } if (frmManage.mode == "edit") { client = frmManage.client; txtCName.Text = client.Name; txtCPhone.Text = client.Phone; txtCEmail.Text = client.Email; txtCComment.Text = client.Comment; cboRole.Text = client.Role; foreach (DataRow row in Remax.TabAgents()) { if (row["Id"].ToString() == client.IdAgent) { cboAgent.Text = row["Name"].ToString(); } } } }
private void btnDelete_Click(object sender, EventArgs e) { string id = dgvResult.Rows[dgvResult.CurrentCell.RowIndex].Cells[0].Value.ToString(); DialogResult dr = new DialogResult(); dr = MessageBox.Show("Do you really want to delete a record, ID = " + id + " ?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if ((int)dr == 6) { if (frmRemax.formToManage == "house") { if (frmLogin.admin != null) { frmLogin.admin.Houses = Remax.TabHouses(); frmLogin.admin.DeleteHouse(id); HouseDB.UpdateHousesDB(frmLogin.admin.Houses); } if (frmLogin.agent != null) { house = HouseDB.getHouse(id); if (house.IdAgent != frmLogin.agent.Id) { MessageBox.Show("The house added by another agent.You can not delete."); } else { frmLogin.agent.Houses = Remax.TabHouses(); frmLogin.agent.DeleteHouse(id); HouseDB.UpdateHousesDB(frmLogin.agent.Houses); } } } else if (frmRemax.formToManage == "client") { if (frmLogin.admin != null) { frmLogin.admin.Clients = Remax.TabClients(); frmLogin.admin.DeleteClient(id); ClientDB.UpdateClientsDB(frmLogin.admin.Clients); } else { frmLogin.agent.Clients = Remax.TabClients(); frmLogin.agent.DeleteClient(id); ClientDB.UpdateClientsDB(frmLogin.agent.Clients); } } else if (frmRemax.formToManage == "employee") { frmLogin.admin.Employees = Remax.TabEmployees(); frmLogin.admin.Languages = Remax.TabLanguages(); frmLogin.admin.DeleteEmployee(id); EmployeeDB.UpdateEmployeesDB(frmLogin.admin.Employees, frmLogin.admin.Languages); } } }
private void btnHSave_Click(object sender, EventArgs e) { House house = new House(); house.BuildingType = cboHBuilding.SelectedValue.ToString(); house.NumberParking = cboHParking.SelectedValue.ToString(); house.NumberBedrooms = cboHBedrooms.SelectedValue.ToString(); house.PropertyType = cboHProperty.SelectedValue.ToString(); house.Price = float.Parse(txtHPrice.Text); house.IdAgent = (frmLogin.agent != null) ? frmLogin.agent.Id : cboHAgent.SelectedValue.ToString(); house.IdSeller = cboHClient.SelectedValue.ToString(); house.Pool = (checkBoxPool.Checked) ? true : false; house.Waterfront = (checkBoxWater.Checked) ? true : false; house.Elevator = (checkBoxElevator.Checked) ? true : false; house.AdapterMobility = (checkBoxMobility.Checked) ? true : false; house.NetArea = int.Parse(txtHNetArea.Text); house.YearBuilt = int.Parse(txtYear.Text); house.Description = txtHDesc.Text; house.Name = txtHName.Text; house.Address = txtHAddress.Text; if (frmManage.mode == "add" && frmLogin.admin != null) { frmLogin.admin.Houses = Remax.TabHouses(); frmLogin.admin.AddHouse(house); HouseDB.UpdateHousesDB(frmLogin.admin.Houses); } if (frmManage.mode == "add" && frmLogin.agent != null) { frmLogin.agent.Houses = Remax.TabHouses(); frmLogin.agent.AddHouse(house); HouseDB.UpdateHousesDB(frmLogin.agent.Houses); } if (frmManage.mode == "edit" && frmLogin.admin != null) { house.Id = frmManage.house.Id; frmLogin.admin.Houses = Remax.TabHouses(); frmLogin.admin.EditHouse(house); HouseDB.UpdateHousesDB(frmLogin.admin.Houses); } if (frmManage.mode == "edit" && frmLogin.agent != null) { house.Id = frmManage.house.Id; frmLogin.agent.Houses = Remax.TabHouses(); frmLogin.agent.EditHouse(house); HouseDB.UpdateHousesDB(frmLogin.agent.Houses); } this.Close(); }
private void btnCSave_Click(object sender, EventArgs e) { Client client = new Client(); if (frmManage.mode == "edit") { client.Id = frmManage.client.Id; } client.Name = txtCName.Text; client.Phone = txtCPhone.Text; client.Email = txtCEmail.Text; client.Comment = txtCComment.Text; client.IdAgent = (frmLogin.agent != null) ? frmLogin.agent.Id : cboAgent.SelectedValue.ToString(); client.Role = cboRole.Text; if (frmManage.mode == "add" && frmLogin.admin != null) { frmLogin.admin.Clients = Remax.TabClients(); frmLogin.admin.AddClient(client); ClientDB.UpdateClientsDB(frmLogin.admin.Clients); } if (frmManage.mode == "add" && frmLogin.agent != null) { frmLogin.agent.Clients = Remax.TabClients(); frmLogin.agent.AddClient(client); ClientDB.UpdateClientsDB(frmLogin.agent.Clients); } if (frmManage.mode == "edit" && frmLogin.admin != null) { client.Id = frmManage.client.Id; frmLogin.admin.Clients = Remax.TabClients(); frmLogin.admin.EditClient(client); ClientDB.UpdateClientsDB(frmLogin.admin.Clients); } if (frmManage.mode == "edit" && frmLogin.agent != null) { client.Id = frmManage.client.Id; frmLogin.agent.Clients = Remax.TabClients(); frmLogin.agent.EditClient(client); ClientDB.UpdateClientsDB(frmLogin.agent.Clients); } this.Close(); }
private void btnESave_Click(object sender, EventArgs e) { string gender = ""; gender = (radEFemale.Checked) ? "f" : "m"; Agent agent = (frmManage.mode == "edit")? new Agent(frmManage.agent.Id, txtEName.Text, txtEPhone.Text, txtEEmail.Text, cboERole.Text, gender, txtEAddress.Text, "1", listLanguages, txtEPassword.Text): new Agent(txtEName.Text, txtEPhone.Text, txtEEmail.Text, cboERole.Text, gender, txtEAddress.Text, "1", listLanguages, txtEPassword.Text); if (frmManage.mode == "add") { frmLogin.admin.Employees = Remax.TabEmployees(); frmLogin.admin.Languages = Remax.TabLanguages(); frmLogin.admin.AddEmployee(agent); EmployeeDB.UpdateEmployeesDB(frmLogin.admin.Employees, frmLogin.admin.Languages); } if (frmManage.mode == "edit") { frmLogin.admin.Employees = Remax.TabEmployees(); frmLogin.admin.Languages = Remax.TabLanguages(); frmLogin.admin.EditEmployee(agent); EmployeeDB.UpdateEmployeesDB(frmLogin.admin.Employees, frmLogin.admin.Languages); } this.Close(); }
public void ScrapeIt(IProgress <int> progress) { setCurLoadingTextSafe("Realtor.com..."); Realtor scraper = new Realtor(); scraper.Progress = progress; scraper.Start(); setCurLoadingTextSafe("redfin.com..."); Redfin scraperRedfin = new Redfin(); scraperRedfin.Progress = progress; scraperRedfin.Start(); setCurLoadingTextSafe("sibcycline.com..."); SibcyCline scraperSibcycline = new SibcyCline(); scraperSibcycline.Progress = progress; scraperSibcycline.Start(); setCurLoadingTextSafe("movoto.com..."); Movoto scraperMovoto = new Movoto(); scraperMovoto.Progress = progress; scraperMovoto.Start(); setCurLoadingTextSafe("trulia.com..."); Trulia scraperTrulia = new Trulia(); scraperTrulia.Progress = progress; scraperTrulia.Start(); setCurLoadingTextSafe("remax.com..."); Remax scraperRemax = new Remax(); scraperRemax.Progress = progress; scraperRemax.Start(); // this site doesnt work //setCurLoadingTextSafe("irongaterentals.com..."); //IronGateRealtors scraperIron = new IronGateRealtors(); //scraperIron.Progress = progress; //scraperIron.Start(); // this site doesnt work //setCurLoadingTextSafe("forsalebyowner.com..."); //ForSaleByOwner scraperFSBO = new ForSaleByOwner(); //scraperFSBO.Progress = progress; //scraperFSBO.Start(); setCurLoadingTextSafe("hotpads.com..."); Hotpads scraperHotpads = new Hotpads(); scraperHotpads.Progress = progress; scraperHotpads.Start(); setCurLoadingTextSafe("craigslist.com..."); Craigslist scraperCraigslist = new Craigslist(); scraperCraigslist.Progress = progress; scraperCraigslist.Start(); setCurLoadingTextSafe("apartmentfinder.com..."); ApartmentFinder scraperApartmentFinder = new ApartmentFinder(); scraperApartmentFinder.Progress = progress; scraperApartmentFinder.Start(); setCurLoadingTextSafe("apartmenthomeliving.com..."); ApartmentHomeLiving scraperApartmentLiving = new ApartmentHomeLiving(); scraperApartmentLiving.Progress = progress; scraperApartmentLiving.Start(); setCurLoadingTextSafe("apartments.com..."); Apartments scraperApartments = new Apartments(); scraperApartments.Progress = progress; scraperApartments.Start(); // update our scraper stats and change the labels DatabaseUtils.UpdateScraperStats(); updateScraperStatsLabels(); // reset the progress bar if (progress != null) { progress.Report(0); } setCurLoadingTextSafe("---"); MessageBox.Show(@"Scrape Complete!" + "\n" + "----------------------" + "\n" + "hotpads.com: " + scraperHotpads.Status.ToString() + "\n" + "craigslist.com: " + scraperRedfin.Status.ToString() + "\n" + "sibcycline.com: " + scraperSibcycline.Status.ToString() + "\n" + "movoto.com: " + scraperMovoto.Status.ToString() + "\n" + "trulia.com: " + scraperTrulia.Status.ToString() + "\n" + "remax.com: " + scraperRemax.Status.ToString() + "\n" + "hotpads.com: " + scraperHotpads.Status.ToString() + "\n" + "craigslist.com: " + scraperCraigslist.Status.ToString() + "\n" + "apartmentfinder.com: " + scraperApartmentFinder.Status.ToString() + "\n" + "apartmenthomeliving.com: " + scraperApartmentLiving.Status.ToString() + "\n" + "apartments.com: " + scraperApartments.Status.ToString() + "\n" ); }
private void frmHouse_Load(object sender, EventArgs e) { txtHName.Focus(); if (frmLogin.admin != null) { DataTable dt = Remax.ViewClients(); DataView dv = dt.DefaultView; dv.RowFilter = " Role='Seller' "; cboHClient.DataSource = dv; } else { DataTable dt = Remax.ViewClients(); DataView dv = dt.DefaultView; dv.RowFilter = "Agent = '" + frmLogin.agent.Name + "' AND Role='Seller'"; cboHClient.DataSource = dv; } cboHClient.DisplayMember = "Name"; cboHClient.ValueMember = "Id"; if (frmLogin.admin != null) { cboHAgent.DataSource = Remax.ViewEmployees(); cboHAgent.DisplayMember = "Name"; cboHAgent.ValueMember = "Id"; } else { cboHAgent.Visible = false; lblHAgent.Visible = false; } cboHBuilding.DataSource = Remax.TabBuilding(); cboHBuilding.ValueMember = "refBuildingType"; cboHBuilding.DisplayMember = "BuildingType"; cboHProperty.DataSource = Remax.TabProperty(); cboHProperty.ValueMember = "refPropertyType"; cboHProperty.DisplayMember = "propertyType"; cboHParking.DataSource = Remax.TabParking(); cboHParking.DisplayMember = "NumParking"; cboHParking.ValueMember = "refNumParking"; cboHBedrooms.DataSource = Remax.TabBedrooms(); cboHBedrooms.DisplayMember = "NumBedrooms"; cboHBedrooms.ValueMember = "refNumBedrooms"; if (frmManage.mode == "edit") { house = frmManage.house; txtHName.Text = house.Name; txtHPrice.Text = house.Price.ToString(); txtHNetArea.Text = house.NetArea.ToString(); txtYear.Text = house.YearBuilt.ToString(); checkBoxElevator.Checked = house.Elevator; checkBoxMobility.Checked = house.AdapterMobility; checkBoxPool.Checked = house.Pool; checkBoxWater.Checked = house.Waterfront; foreach (DataRow row in Remax.ViewEmployees()) { if (row["Id"].ToString() == house.IdAgent) { cboHAgent.Text = row["Name"].ToString(); } } foreach (DataRow row in Remax.ViewClients()) { if (row["Id"].ToString() == house.IdSeller) { cboHClient.Text = row["Name"].ToString(); } } foreach (DataRow row in Remax.TabBuilding()) { if (row["refBuildingType"].ToString() == house.BuildingType) { cboHBuilding.Text = row["BuildingType"].ToString(); } } foreach (DataRow row in Remax.TabProperty()) { if (row["refPropertyType"].ToString() == house.BuildingType) { cboHProperty.Text = row["PropertyType"].ToString(); } } foreach (DataRow row in Remax.TabParking()) { if (row["refNumParking"].ToString() == house.BuildingType) { cboHParking.Text = row["NumParking"].ToString(); } } foreach (DataRow row in Remax.TabBedrooms()) { if (row["refNumBedrooms"].ToString() == house.BuildingType) { cboHBedrooms.Text = row["NumBedrooms"].ToString(); } } txtHDesc.Text = house.Description; txtHAddress.Text = house.Address; } }
private void btnSearch_Click(object sender, EventArgs e) { if (checkBoxID.Checked) { if (txtSearch.Text == "") { MessageBox.Show("Enter a criteria"); } else { string criteria = txtSearch.Text; if (frmRemax.formToManage == "house") { if (frmLogin.admin != null) { DataView dv = HouseDB.getViewHouses("admin"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataView dv = HouseDB.getViewHouses("user or agent"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "client") { if (frmLogin.agent == null) { DataView dv = ClientDB.getViewClients(""); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataView dv = ClientDB.getViewClients(frmLogin.agent.Name); dv.RowFilter = " CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "employee") { DataView dv = EmployeeDB.getViewEmployees(""); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } if (frmRemax.formToManage == "agent") { DataView dv = EmployeeDB.getViewEmployees("agent"); dv.RowFilter = "CONVERT(Id, System.String) LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } } if (checkBoxName.Checked) { if (txtSearch.Text == "") { MessageBox.Show("Enter a criteria"); } else { string criteria = txtSearch.Text; if (frmRemax.formToManage == "house") { if (frmLogin.employee == null) { DataTable dt = Remax.ViewHouses("user"); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataTable dt = Remax.ViewHouses(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "client") { if (frmLogin.agent != null) { DataView dv = Remax.ViewClients(frmLogin.agent.Name); dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } else { DataTable dt = Remax.ViewClients(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } if (frmRemax.formToManage == "employee") { DataTable dt = Remax.ViewEmployees(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } if (frmRemax.formToManage == "agent") { DataTable dt = Remax.TabAgents(); DataView dv = dt.DefaultView; dv.RowFilter = "Name LIKE '%" + criteria + "%'"; dgvResult.DataSource = dv; } } } if (!checkBoxName.Checked && !checkBoxID.Checked) { MessageBox.Show("Check type of search."); } }