/* Evleri Listeleme */ public List <SaleHouse> GetAll() { List <SaleHouse> saleHouses = new List <SaleHouse>(); FileStream fs = new FileStream(document_path, FileMode.Open, FileAccess.Read); StreamReader sw = new StreamReader(fs); string line = sw.ReadLine(); while (line != null) { string[] splitLine = line.Split(','); SaleHouse saleHouseModel = new SaleHouse( id: splitLine[0], roomCount: Convert.ToInt32(splitLine[1]), floorNumber: Convert.ToInt32(splitLine[2]), district: splitLine[3], area: splitLine[4], createDate: Convert.ToDateTime(splitLine[5]), type: ConvertHouseType.GetHouseType(splitLine[6]), isEnabled: Convert.ToBoolean(splitLine[7]), salePrice: Convert.ToDecimal(splitLine[8]) ); saleHouses.Add(saleHouseModel); line = sw.ReadLine(); } sw.Close(); fs.Close(); return(saleHouses); }
/* Satilik Ev Güncelleme */ private void btnSaleUpdate_Click(object sender, EventArgs e) { if (txtSaleId.Text.Length > 0) { var dialogWindow = MessageBox.Show("Satılık Ev Güncellemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { SaleHouse updateHouse = saleHouseOperations.GetById(txtSaleId.Text); SaleHouse saleHouse = new SaleHouse(); saleHouse.Id = txtSaleId.Text; saleHouse.RoomCount = Convert.ToInt32(txtSaleRoomCount.Value); saleHouse.FloorNumber = Convert.ToInt32(txtSaleFloorNumber.Value); saleHouse.District = txtSaleDistrict.Text; saleHouse.Area = txtSaleArea.Text; saleHouse.CreateDate = Convert.ToDateTime(txtSaleCreatedDate.Text); saleHouse.Type = ConvertHouseType.GetHouseType(txtSaleType.Text); saleHouse.IsEnabled = Convert.ToBoolean(txtSaleEnabled.Checked); saleHouse.SalePrice = Convert.ToDecimal(txtSalePrice.Value); saleHouseOperations.Update(updateHouse, saleHouse); MessageBox.Show("Satılık Ev Güncellendi."); FillSaleHouseList(); } } else { MessageBox.Show("Lütfen Bir Ev Seçiniz."); } }
private void reloadTable() { Program.readXML(); this.dataGridView1.Rows.Clear(); foreach (var advert in Program.adverts) { string cat = ""; string slPrice = ""; string rnPrice = ""; string deposit = ""; if (advert.Value.GetType().ToString() == "AdvertLibrary.RentHouse") { cat = "Rent"; RentHouse rhouse = advert.Value as RentHouse; rnPrice = rhouse.RentPrice.ToString("#,##0.00"); // # --> para formatı deposit = rhouse.Deposit.ToString("#,##0.00"); } else if (advert.Value.GetType().ToString() == "AdvertLibrary.SaleHouse") { cat = "Sale"; SaleHouse shouse = advert.Value as SaleHouse; slPrice = shouse.SalePrice.ToString("#,##0.00"); } this.dataGridView1.Rows.Add(advert.Key, cat, advert.Value.Rooms, advert.Value.Floor, advert.Value.State, advert.Value.Area, advert.Value.Age(), advert.Value.HouseType, advert.Value.Status ? "Active " : "Passive", slPrice, rnPrice, deposit); } }
/* Yeni Satilik Ev Ekleme */ private void btnSaleAdd_Click(object sender, EventArgs e) { if (txtSaleDistrict.Text.Length > 0 && txtSaleArea.Text.Length > 0) { var dialogWindow = MessageBox.Show("Yeni Satılık Ev Eklemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { SaleHouse saleHouse = new SaleHouse(); saleHouse.Id = GeneratorId.GenerateId(); saleHouse.RoomCount = Convert.ToInt32(txtSaleRoomCount.Value); saleHouse.FloorNumber = Convert.ToInt32(txtSaleFloorNumber.Value); saleHouse.District = txtSaleDistrict.Text; saleHouse.Area = txtSaleArea.Text; saleHouse.CreateDate = Convert.ToDateTime(txtSaleCreatedDate.Text); saleHouse.Type = ConvertHouseType.GetHouseType(txtSaleType.Text); saleHouse.IsEnabled = Convert.ToBoolean(txtSaleEnabled.Checked); saleHouse.SalePrice = Convert.ToDecimal(txtSalePrice.Value); string path = Application.StartupPath + "/HouseImages/SaleHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.CreateFolder(path, saleHouse.Id); saleHouseOperations.Add(saleHouse); MessageBox.Show("Yeni Satılık Ev Eklendi"); FillSaleHouseList(); } } else { MessageBox.Show("Gerekli Alanları Doldurunuz."); } }
private void btnDelete_Click(object sender, EventArgs e) { if (type == "Kiralik") { var dialogWindow = MessageBox.Show("Kiralık Ev Silmek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { RentHouse deleteHouse = rentHouseOperations.GetById(txtId.Text); string path = Application.StartupPath + "/HouseImages/RentHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.DeleteFolder(path, txtId.Text); rentHouseOperations.Delete(deleteHouse); MessageBox.Show("Kiralık Ev Silindi."); this.Hide(); } } else { var dialogWindow = MessageBox.Show("Satılık Ev Silmek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { SaleHouse deleteHouse = saleHouseOperations.GetById(txtId.Text); string path = Application.StartupPath + "/HouseImages/SaleHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.DeleteFolder(path, txtId.Text); saleHouseOperations.Delete(deleteHouse); MessageBox.Show("Satılık Ev Silindi."); this.Hide(); } } }
/* Yeni Ev Ekleme */ public void Add(SaleHouse saleHouse) { string addHouse = saleHouse.Id + "," + saleHouse.RoomCount + "," + saleHouse.FloorNumber + "," + saleHouse.District + "," + saleHouse.Area + "," + saleHouse.CreateDate + "," + saleHouse.Type + "," + saleHouse.IsEnabled + "," + saleHouse.SalePrice; StreamWriter sw = File.AppendText(document_path); sw.WriteLine(addHouse); sw.Flush(); sw.Close(); }
/* Id Numarasina Gore Ev Bulma */ public SaleHouse GetById(string Id) { List <SaleHouse> saleHouses = new List <SaleHouse>(); saleHouses = this.GetAll(); SaleHouse findHouse = saleHouses.Find(x => x.Id == Id); return(findHouse); }
/* Ev Silme */ public void Delete(SaleHouse saleHouse) { List <SaleHouse> saleHouses = new List <SaleHouse>(); saleHouses = this.GetAll(); int index = saleHouses.FindIndex(x => x.Id == saleHouse.Id); var file = new List <string>(File.ReadAllLines(document_path)); file.RemoveAt(index); File.WriteAllLines(document_path, file.ToArray()); }
private void FrmEdit_Load(object sender, EventArgs e) { FillHouseTypesInComboboxes(); if (type == "Kiralik") { panel1.Visible = true; try { RentHouse rentHouse = rentHouseOperations.GetById(id); txtId.Text = rentHouse.Id; txtRentPrice.Text = rentHouse.RentPrice.ToString(); txtRentDeposit.Text = rentHouse.RentDeposit.ToString(); txtRoomCount.Text = rentHouse.RoomCount.ToString(); txtFloorNumber.Text = rentHouse.FloorNumber.ToString(); txtDistrict.Text = rentHouse.District; txtArea.Text = rentHouse.Area; txtCreatedDate.Text = rentHouse.CreateDate.ToString(); txtType.Text = rentHouse.Type.ToString(); txtEnabled.Checked = Convert.ToBoolean(rentHouse.IsEnabled.ToString()); } catch { MessageBox.Show("Hata Oluştu"); } } else if (type == "Satilik") { panel2.Visible = true; try { SaleHouse rentHouse = saleHouseOperations.GetById(id); txtId.Text = rentHouse.Id; txtSalePrice.Text = rentHouse.SalePrice.ToString(); txtRoomCount.Text = rentHouse.RoomCount.ToString(); txtFloorNumber.Text = rentHouse.FloorNumber.ToString(); txtDistrict.Text = rentHouse.District; txtArea.Text = rentHouse.Area; txtCreatedDate.Text = rentHouse.CreateDate.ToString(); txtType.Text = rentHouse.Type.ToString(); txtEnabled.Checked = Convert.ToBoolean(rentHouse.IsEnabled.ToString()); } catch { MessageBox.Show("Hata Oluştu"); } } }
/* Ev Guncelleme */ public void Update(SaleHouse saleHouse, SaleHouse saleHouseNew) { List <SaleHouse> saleHouses = new List <SaleHouse>(); saleHouses = this.GetAll(); int index = saleHouses.FindIndex(x => x.Id == saleHouse.Id); string oldSaleHouse = saleHouses[index].Id + "," + saleHouses[index].RoomCount + "," + saleHouses[index].FloorNumber + "," + saleHouses[index].District + "," + saleHouses[index].Area + "," + saleHouses[index].CreateDate + "," + saleHouses[index].Type + "," + saleHouses[index].IsEnabled + "," + saleHouses[index].SalePrice; string newSaleHouse = saleHouseNew.Id + "," + saleHouseNew.RoomCount + "," + saleHouseNew.FloorNumber + "," + saleHouseNew.District + "," + saleHouseNew.Area + "," + saleHouseNew.CreateDate + "," + saleHouseNew.Type + "," + saleHouseNew.IsEnabled + "," + saleHouseNew.SalePrice; string text = File.ReadAllText(document_path); text = text.Replace(oldSaleHouse, newSaleHouse); File.WriteAllText(document_path, text); }
private void btnUpdate_Click(object sender, EventArgs e) { if (type == "Kiralik") { var dialogWindow = MessageBox.Show("Kiralık Ev Güncellemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { RentHouse updateHouse = rentHouseOperations.GetById(txtId.Text); RentHouse rentHouse = new RentHouse(); rentHouse.Id = txtId.Text; rentHouse.RoomCount = Convert.ToInt32(txtRoomCount.Value); rentHouse.FloorNumber = Convert.ToInt32(txtFloorNumber.Value); rentHouse.District = txtDistrict.Text; rentHouse.Area = txtArea.Text; rentHouse.CreateDate = Convert.ToDateTime(txtCreatedDate.Text); rentHouse.Type = ConvertHouseType.GetHouseType(txtType.Text); rentHouse.IsEnabled = Convert.ToBoolean(txtEnabled.Checked); rentHouse.RentPrice = Convert.ToDecimal(txtRentPrice.Value); rentHouse.RentDeposit = Convert.ToDecimal(txtRentDeposit.Value); rentHouseOperations.Update(updateHouse, rentHouse); MessageBox.Show("Kiralık Ev Güncellendi."); this.Hide(); } } else { var dialogWindow = MessageBox.Show("Satılık Ev Güncellemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { SaleHouse updateHouse = saleHouseOperations.GetById(txtId.Text); SaleHouse saleHouse = new SaleHouse(); saleHouse.Id = txtId.Text; saleHouse.RoomCount = Convert.ToInt32(txtRoomCount.Value); saleHouse.FloorNumber = Convert.ToInt32(txtFloorNumber.Value); saleHouse.District = txtDistrict.Text; saleHouse.Area = txtArea.Text; saleHouse.CreateDate = Convert.ToDateTime(txtCreatedDate.Text); saleHouse.Type = ConvertHouseType.GetHouseType(txtType.Text); saleHouse.IsEnabled = Convert.ToBoolean(txtEnabled.Checked); saleHouse.SalePrice = Convert.ToDecimal(txtSalePrice.Value); saleHouseOperations.Update(updateHouse, saleHouse); MessageBox.Show("Satılık Ev Güncellendi."); this.Hide(); } } }
private void BTClearSearch_Click(object sender, EventArgs e) { RBAll.Checked = true; NUDRoomsMin.Value = 0; NUDRoomsMax.Value = 0; NUDFloorMin.Value = 0; NUDFloorMax.Value = 0; NUDAreaMin.Value = 0; NUDAreaMax.Value = 0; NUDAgeMin.Value = 0; NUDAgeMax.Value = 0; NUDPriceMin.Value = 0; NUDPriceMax.Value = 0; NUDDepositMin.Value = 0; NUDDepositMax.Value = 0; CBOAA.Checked = false; NUDIDSearch.Value = 0; CBHType.SelectedIndex = -1; CBState.SelectedIndex = -1; CBCity.SelectedIndex = -1; this.dataGridView1.Rows.Clear(); foreach (var advert in Program.adverts) { string cat = ""; string slPrice = ""; string rnPrice = ""; string deposit = ""; if (advert.Value.GetType().ToString() == "AdvertLibrary.RentHouse") { cat = "Rent"; RentHouse rhouse = advert.Value as RentHouse; rnPrice = rhouse.RentPrice.ToString(); deposit = rhouse.Deposit.ToString(); } else if (advert.Value.GetType().ToString() == "AdvertLibrary.SaleHouse") { cat = "Sale"; SaleHouse shouse = advert.Value as SaleHouse; slPrice = shouse.SalePrice.ToString(); } this.dataGridView1.Rows.Add(advert.Key, cat, advert.Value.Rooms, advert.Value.Floor, advert.Value.State, advert.Value.Area, advert.Value.Age(), advert.Value.HouseType, advert.Value.Status, slPrice, rnPrice, deposit); } }
/* Satilik Ev Silme */ private void btnSaleDelete_Click(object sender, EventArgs e) { if (txtSaleId.Text.Length > 0) { var dialogWindow = MessageBox.Show("Satılık Ev Silmek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { SaleHouse deleteHouse = saleHouseOperations.GetById(txtSaleId.Text); string path = Application.StartupPath + "/HouseImages/SaleHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.DeleteFolder(path, txtSaleId.Text); saleHouseOperations.Delete(deleteHouse); MessageBox.Show("Satılık Ev Silindi."); txtSaleId.Text = ""; FillSaleHouseList(); } } else { MessageBox.Show("Lütfen Bir Ev Seçiniz."); } }
private void ButtonAdd_Click(object sender, EventArgs e) { string category; if (RDSale.Checked) { category = "sale"; } else { category = "rent"; } int rooms = Int32.Parse(NUDRooms.Value.ToString()); int floor = Int32.Parse(NUDFloor.Value.ToString()); string city = CBCity.SelectedItem.ToString(); string state = CBState.SelectedItem.ToString(); double area = double.Parse(NUDArea.Value.ToString()); House.houseType type; if (RBApartment.Checked) { type = House.houseType.Apartment; } else if (RBDublex.Checked) { type = House.houseType.Dublex; } else if (RBGarden.Checked) { type = House.houseType.withGarden; } else { type = House.houseType.Sparate; } bool status; if (CBActive.Checked) { status = true; } else { status = false; } DateTime datepicker = DPConstructionDate.Value.Date; if (category == "sale") { decimal salePrice = decimal.Parse(TBSalePrice.Text); SaleHouse salehouse = new SaleHouse(rooms, floor, state, area, datepicker, status); salehouse.HouseType = type; salehouse.SalePrice = salePrice; if (this.isEdit) { Program.adverts[this.house.Id] = salehouse; Program.Log("Edited sale advert " + this.house.Id + " with " + NUDRooms.Value.ToString() + " rooms", "ACTION"); Program.save(); } else { uint SaleHouseID = Program.lastId() + 105; salehouse.Id = SaleHouseID; Directory.CreateDirectory(Application.StartupPath + "/photos/" + SaleHouseID.ToString()); Program.Log("Created new directory: " + Application.StartupPath + "/photos/" + SaleHouseID.ToString(), "FILE"); XElement yeniEklenecek = XElement.Parse(salehouse.Info()); // XML için sanal Node oluşturuyor. https://msdn.microsoft.com/en-us/library/bb468714(v=vs.110).aspx XDocument doc = XDocument.Load("Sale.xml"); doc.Root.Add(yeniEklenecek); doc.Save("Sale.xml"); Program.Log("Created sale advert " + SaleHouseID + " with " + NUDRooms.Value.ToString() + " rooms", "ACTION"); Program.Log("Inserted new advert in Sale.xml file", "FILE"); } } else { decimal rentPrice = decimal.Parse(TBRentPrice.Text); decimal deposit = decimal.Parse(TBDeposit.Text); RentHouse renthouse = new RentHouse(rooms, floor, state, area, datepicker, status); renthouse.HouseType = type; renthouse.RentPrice = rentPrice; renthouse.Deposit = deposit; if (this.isEdit) { Program.adverts[this.house.Id] = renthouse; Program.Log("Edited rent advert " + this.house.Id + " with " + NUDRooms.Value.ToString() + " rooms", "ACTION"); Program.save(); } else { uint RentHouseID = Program.lastId() + 105; renthouse.Id = RentHouseID; Directory.CreateDirectory(Application.StartupPath + "/photos/" + RentHouseID.ToString()); Program.Log("Created new directory: " + Application.StartupPath + "/photos/" + RentHouseID.ToString(), "FILE"); XElement yeniEklenecek = XElement.Parse(renthouse.Info()); // XML için sanal Node oluşturuyor. https://msdn.microsoft.com/en-us/library/bb468714(v=vs.110).aspx XDocument doc = XDocument.Load("Rent.xml"); doc.Root.Add(yeniEklenecek); doc.Save("Rent.xml"); Program.Log("Inserted new advert in Rent.xml file", "FILE"); } } Program.newForm = new AdvertsForm(); Program.close = false; Close(); }
public static void readXML() { adverts = new Dictionary <uint, House>(); XDocument doc = XDocument.Load("Sale.xml"); //XDocument xml i açıp okumak için yardımcı lib. Program.Log("Loaded Sale.xml!", "FILE"); var satiliklar = doc.Descendants("house"); foreach (var satilik in satiliklar) { uint id = UInt32.Parse(satilik.Element("id").Value); int rooms = Int32.Parse(satilik.Element("rooms").Value); int floor = Int32.Parse(satilik.Element("floor").Value); string state = satilik.Element("state").Value; double area = double.Parse(satilik.Element("area").Value); DateTime constructionDate = DateTime.Parse(satilik.Element("constructionDate").Value); bool status = bool.Parse(satilik.Element("status").Value); string houseType = satilik.Element("houseType").Value; decimal Price = decimal.Parse(satilik.Element("salePrice").Value); House.houseType htype; if (houseType == "Apartment") { htype = House.houseType.Apartment; } else if (houseType == "withGarden") { htype = House.houseType.withGarden; } else if (houseType == "Dublex") { htype = House.houseType.Dublex; } else { htype = House.houseType.Sparate; } SaleHouse ev = new SaleHouse(rooms, floor, state, area, constructionDate, status, htype); ev.SalePrice = Price; ev.Id = id; adverts.Add(id, ev); } Program.Log("Loaded Rent.xml!", "FILE"); doc = XDocument.Load("Rent.xml"); var kiraliklar = doc.Descendants("house"); foreach (var kiralik in kiraliklar) { uint id = UInt32.Parse(kiralik.Element("id").Value); int rooms = Int32.Parse(kiralik.Element("rooms").Value); int floor = Int32.Parse(kiralik.Element("floor").Value); string state = kiralik.Element("state").Value; double area = double.Parse(kiralik.Element("area").Value); DateTime constructionDate = DateTime.Parse(kiralik.Element("constructionDate").Value); bool status = bool.Parse(kiralik.Element("status").Value); string houseType = kiralik.Element("houseType").Value; decimal Price = decimal.Parse(kiralik.Element("rentPrice").Value); decimal Deposit = decimal.Parse(kiralik.Element("deposit").Value); House.houseType htype; if (houseType == "Apartment") { htype = House.houseType.Apartment; } else if (houseType == "withGarden") { htype = House.houseType.withGarden; } else if (houseType == "Dublex") { htype = House.houseType.Dublex; } else { htype = House.houseType.Sparate; } RentHouse ev = new RentHouse(rooms, floor, state, area, constructionDate, status, htype); ev.RentPrice = Price; ev.Deposit = Deposit; ev.Id = id; adverts.Add(id, ev); } }
private void button3_Click(object sender, EventArgs e) { string state = CBState.SelectedIndex != -1 ? CBState.SelectedItem.ToString() : ""; decimal roomsMin = NUDRoomsMin.Value; decimal roomsMax = NUDRoomsMax.Value; decimal floorMin = NUDFloorMin.Value; decimal floorMax = NUDFloorMax.Value; decimal areaMin = NUDAreaMin.Value; decimal areaMax = NUDAreaMax.Value; decimal ageMin = NUDAgeMin.Value; decimal ageMax = NUDAgeMax.Value; string type = CBHType.SelectedIndex != -1 ? CBHType.SelectedItem.ToString() : ""; bool oaa = CBOAA.Checked; decimal priceMin = NUDPriceMin.Value; decimal priceMax = NUDPriceMax.Value; decimal depositMin = NUDDepositMin.Value; decimal depositMax = NUDDepositMax.Value; decimal SearchID = NUDIDSearch.Value; //MessageBox.Show("State: " + state + "\nRooms: " + roomsMin.ToString() + "-" + roomsMax.ToString() + "\nFloor: " + floorMin.ToString() + "-" + floorMax.ToString() + "\nArea: " + areaMin.ToString() + "\nAge: " + ageMin.ToString() + "-" + ageMax.ToString() + "\nH.Type: " + type + "\nOnly Active? " + oaa.ToString() + "\nPrice: " + priceMin.ToString() + "-" + priceMax.ToString() + "\nDeposit: " + depositMin.ToString() + "-" + depositMax.ToString() + "\nID: " + SearchID.ToString()); House.houseType Htype; if (type == "Dublex") { Htype = House.houseType.Dublex; } else if (type == "Apartment") { Htype = House.houseType.Apartment; } else if (type == "withGarden") { Htype = House.houseType.withGarden; } else if (type == "Sparate") { Htype = House.houseType.Sparate; } else { Htype = House.houseType.Dublex; } Dictionary <uint, House> results = new Dictionary <uint, House>(); foreach (var advert in Program.adverts) { bool right = true; decimal price = 0; decimal deposit = 0; if (advert.Value.GetType().ToString() == "AdvertLibrary.RentHouse") { RentHouse rh = advert.Value as RentHouse; price = rh.RentPrice; deposit = rh.Deposit; } else { SaleHouse sh = advert.Value as SaleHouse; price = sh.SalePrice; } if (state != "") { if (right && advert.Value.State == state) { right = true; } else { right = false; } } //for rooms if (roomsMin != 0 || roomsMax != 0) { if (roomsMin != 0 && roomsMax == 0) { if (right && advert.Value.Rooms >= roomsMin) { right = true; } else { right = false; } } else { if (right && advert.Value.Rooms >= roomsMin && advert.Value.Rooms <= roomsMax) { right = true; } else { right = false; } } } //for floor if (floorMin != 0 || floorMax != 0) { if (floorMin != 0 && floorMax == 0) { if (right && advert.Value.Floor >= floorMin) { right = true; } else { right = false; } } else { if (right && advert.Value.Floor >= floorMin && advert.Value.Floor <= floorMax) { right = true; } else { right = false; } } } //for area if (areaMin != 0 || areaMax != 0) { if (areaMin != 0 && areaMax == 0) { if (right && advert.Value.Area >= double.Parse(areaMin.ToString())) { right = true; } else { right = false; } } else { if (right && advert.Value.Area >= double.Parse(areaMin.ToString()) && advert.Value.Area <= double.Parse(areaMax.ToString())) { right = true; } else { right = false; } } } //for age if (ageMin != 0 || ageMax != 0) { if (ageMin != 0 && ageMax == 0) { if (right && advert.Value.Age() >= ageMin) { right = true; } else { right = false; } } else { if (right && advert.Value.Age() >= ageMin && advert.Value.Age() <= ageMax) { right = true; } else { right = false; } } } //for htype if (type != "") { if (right && advert.Value.HouseType == Htype) { right = true; } else { right = false; } } //for price // Todo: if (priceMin != 0 || priceMax != 0) { if (priceMin != 0 && priceMax == 0) { if (right && price >= priceMin) { right = true; } else { right = false; } } else { if (right && price >= priceMin && price <= priceMax) { right = true; } else { right = false; } } } //for deposit if (depositMin != 0 || depositMax != 0) { if (depositMin != 0 && depositMax == 0) { if (right && deposit >= depositMin) { right = true; } else { right = false; } } else { if (right && deposit >= depositMin && deposit <= depositMax) { right = true; } else { right = false; } } } //for active if (oaa) { if (right && advert.Value.Status) { right = true; } else { right = false; } } //for ID if (SearchID != 0) { if (right && advert.Key == SearchID) { right = true; } else { right = false; } } if (right) { results.Add(advert.Key, advert.Value); } } this.dataGridView1.Rows.Clear(); foreach (var advert in results) { string cat = ""; string slPrice = ""; string rnPrice = ""; string deposit = ""; if (advert.Value.GetType().ToString() == "AdvertLibrary.RentHouse") { cat = "Rent"; RentHouse rhouse = advert.Value as RentHouse; rnPrice = rhouse.RentPrice.ToString(); deposit = rhouse.Deposit.ToString(); } else if (advert.Value.GetType().ToString() == "AdvertLibrary.SaleHouse") { cat = "Sale"; SaleHouse shouse = advert.Value as SaleHouse; slPrice = shouse.SalePrice.ToString(); } this.dataGridView1.Rows.Add(advert.Key, cat, advert.Value.Rooms, advert.Value.Floor, advert.Value.State, advert.Value.Area, advert.Value.Age(), advert.Value.HouseType, advert.Value.Status, slPrice, rnPrice, deposit); } Program.Log("Advert search form submitted", "ACTION"); }
private void AdvertAdd_Load(object sender, EventArgs e) { // 'cities' foreach (var city in Program.cities)//şehirler cbox doldur { CBCity.Items.Add(city.Key); } if (this.isEdit) { Text = "Advert Edit"; ButtonAdd.Image = AdvertApplication.Properties.Resources._1478167791_InterfaceExpendet_01; btnArchive.Visible = true; ButtonAdd.Size = new Size(255, 81); this.NUDRooms.Value = this.house.Rooms; this.NUDFloor.Value = this.house.Floor; this.NUDArea.Value = decimal.Parse(this.house.Area.ToString()); this.CBActive.Checked = this.house.Status; this.DPConstructionDate.Value = this.house.ConstructionDate; if (this.house.HouseType == House.houseType.Apartment) { this.RBApartment.Checked = true; } else if (this.house.HouseType == House.houseType.Dublex) { this.RBDublex.Checked = true; } else if (this.house.HouseType == House.houseType.Sparate) { this.RBSparate.Checked = true; } else if (this.house.HouseType == House.houseType.withGarden) { this.RBGarden.Checked = true; } int i = 0, s = 0; foreach (var city in Program.cities)//şehirler cbox doldur { foreach (string state in city.Value) { if (state == this.house.State) { this.CBCity.SelectedIndex = i; this.CBState.SelectedIndex = s; } s++; } s = 0; i++; } if (this.house.GetType().ToString() == "AdvertLibrary.RentHouse") { this.RDRent.Checked = true; RentHouse rh = this.house as RentHouse; // Kiralik this.TBRentPrice.Text = rh.RentPrice.ToString(); this.TBDeposit.Text = rh.Deposit.ToString(); } else { this.RDSale.Checked = true; SaleHouse sh = this.house as SaleHouse; // Satılık this.TBSalePrice.Text = sh.SalePrice.ToString(); } } }