private void RDSale_CheckedChanged(object sender, EventArgs e) { if (RDSale.Checked) { TBDeposit.Visible = false; TBRentPrice.Visible = false; TBSalePrice.Visible = true; label10.Visible = true; label8.Visible = false; label9.Visible = false; lblPriceCost.Visible = false; lblGuestPricee.Visible = false; } else { TBSalePrice.Visible = false; label10.Visible = false; TBDeposit.Visible = true; TBRentPrice.Visible = true; label8.Visible = true; label9.Visible = true; lblPriceCost.Visible = true; lblGuestPricee.Visible = true; string guestPrice; lblGuestPricee.Visible = true; RentHouse rh = new RentHouse(Int32.Parse(NUDRooms.Value.ToString()), 1, "", 1); guestPrice = rh.Price().ToString() + " TL"; lblPriceCost.Text = guestPrice; } }
public Result <List <RentHouse> > GetRentHouseList(PagingInfo page) { Result <List <RentHouse> > ret = new Result <List <RentHouse> >() { Data = new List <RentHouse>() }; using (var smartConn = new SmartWorldEntities()) { var list = smartConn.D_House.Where(x => x.IsDelete == false); foreach (var i in list) { RentHouse r = new RentHouse() { Id = i.Id, Address = i.Address, Floor = i.Floor.GetValueOrDefault(0), HomeCode = i.HouseCode, HomeTitle = i.HouseTitle, Price = i.Price.GetValueOrDefault(0), Text = i.Remark }; ret.Data.Add(r); } } return(ret); }
/* Kiralık Ev Güncelleme */ private void btnUpdateRent_Click(object sender, EventArgs e) { if (txtRentId.Text.Length > 0) { var dialogWindow = MessageBox.Show("Kiralık Ev Güncellemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { RentHouse updateHouse = rentHouseOperations.GetById(txtRentId.Text); RentHouse rentHouse = new RentHouse(); rentHouse.Id = txtRentId.Text; rentHouse.RoomCount = Convert.ToInt32(txtRentRoomCount.Value); rentHouse.FloorNumber = Convert.ToInt32(txtRentFloorNumber.Value); rentHouse.District = txtRentDistrict.Text; rentHouse.Area = txtRentArea.Text; rentHouse.CreateDate = Convert.ToDateTime(txtRentCreatedDate.Text); rentHouse.Type = ConvertHouseType.GetHouseType(txtRentType.Text); rentHouse.IsEnabled = Convert.ToBoolean(txtRentEnabled.Checked); rentHouse.RentPrice = Convert.ToDecimal(txtRentPrice.Value); rentHouse.RentDeposit = Convert.ToDecimal(txtRentDeposit.Value); rentHouseOperations.Update(updateHouse, rentHouse); MessageBox.Show("Kiralık Ev Güncellendi."); FillRentHouseList(); } } 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 Kiralik Ev Ekleme */ private void btnAddRent_Click(object sender, EventArgs e) { if (txtRentDistrict.Text.Length > 0 && txtRentArea.Text.Length > 0) { var dialogWindow = MessageBox.Show("Yeni Kiralık Ev Eklemek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { RentHouse rentHouse = new RentHouse(); rentHouse.Id = GeneratorId.GenerateId(); rentHouse.RoomCount = Convert.ToInt32(txtRentRoomCount.Value); rentHouse.FloorNumber = Convert.ToInt32(txtRentFloorNumber.Value); rentHouse.District = txtRentDistrict.Text; rentHouse.Area = txtRentArea.Text; rentHouse.CreateDate = Convert.ToDateTime(txtRentCreatedDate.Text); rentHouse.Type = ConvertHouseType.GetHouseType(txtRentType.Text); rentHouse.IsEnabled = Convert.ToBoolean(txtRentEnabled.Checked); rentHouse.RentPrice = Convert.ToDecimal(txtRentPrice.Value); rentHouse.RentDeposit = Convert.ToDecimal(txtRentDeposit.Value); string path = Application.StartupPath + "/HouseImages/RentHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.CreateFolder(path, rentHouse.Id); rentHouseOperations.Add(rentHouse); MessageBox.Show("Yeni Kiralık Ev Eklendi"); FillRentHouseList(); } } 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(); } } }
/* Evleri Listeleme */ public List <RentHouse> GetAll() { List <RentHouse> rentHouses = new List <RentHouse>(); 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(','); RentHouse rentHouseModel = new RentHouse( 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]), rentPrice: Convert.ToDecimal(splitLine[8]), rentDeposit: Convert.ToDecimal(splitLine[9]) ); rentHouses.Add(rentHouseModel); line = sw.ReadLine(); } sw.Close(); fs.Close(); return(rentHouses); }
/* Yeni Ev Ekleme */ public void Add(RentHouse rentHouse) { string addHouse = rentHouse.Id + "," + rentHouse.RoomCount + "," + rentHouse.FloorNumber + "," + rentHouse.District + "," + rentHouse.Area + "," + rentHouse.CreateDate + "," + rentHouse.Type + "," + rentHouse.IsEnabled + "," + rentHouse.RentPrice + "," + rentHouse.RentDeposit; StreamWriter sw = File.AppendText(document_path); sw.WriteLine(addHouse); sw.Flush(); sw.Close(); }
/* Id Numarasina Gore Ev Bulma */ public RentHouse GetById(string Id) { List <RentHouse> rentHouses = new List <RentHouse>(); rentHouses = this.GetAll(); RentHouse findHouse = rentHouses.Find(x => x.Id == Id); return(findHouse); }
public static RentHouse read(BinaryReader binaryReader) { RentHouse newObj = new RentHouse(); newObj.i_slumlord = binaryReader.ReadUInt32(); Util.readToAlign(binaryReader); newObj.i_stuff = PList <uint> .read(binaryReader); return(newObj); }
/* Ev Silme */ public void Delete(RentHouse rentHouse) { List <RentHouse> rentHouses = new List <RentHouse>(); rentHouses = this.GetAll(); int index = rentHouses.FindIndex(x => x.Id == rentHouse.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(RentHouse rentHouse, RentHouse rentHouseNew) { List <RentHouse> rentHouses = new List <RentHouse>(); rentHouses = this.GetAll(); int index = rentHouses.FindIndex(x => x.Id == rentHouse.Id); string oldRentHouse = rentHouses[index].Id + "," + rentHouses[index].RoomCount + "," + rentHouses[index].FloorNumber + "," + rentHouses[index].District + "," + rentHouses[index].Area + "," + rentHouses[index].CreateDate + "," + rentHouses[index].Type + "," + rentHouses[index].IsEnabled + "," + rentHouses[index].RentPrice + "," + rentHouses[index].RentDeposit; string newRenHouse = rentHouseNew.Id + "," + rentHouseNew.RoomCount + "," + rentHouseNew.FloorNumber + "," + rentHouseNew.District + "," + rentHouseNew.Area + "," + rentHouseNew.CreateDate + "," + rentHouseNew.Type + "," + rentHouseNew.IsEnabled + "," + rentHouseNew.RentPrice + "," + rentHouseNew.RentDeposit; string text = File.ReadAllText(document_path); text = text.Replace(oldRentHouse, newRenHouse); 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 NUDRooms_ValueChanged(object sender, EventArgs e) { string guestPrice = ""; if (RDRent.Checked) { lblGuestPricee.Visible = true; RentHouse rh = new RentHouse(Int32.Parse(NUDRooms.Value.ToString()), 1, "", 1); guestPrice = rh.Price().ToString() + " TL"; } else { lblGuestPricee.Visible = false; } lblPriceCost.Text = guestPrice; }
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); } }
/* Kiralık Ev Silme */ private void btnDeleteRent_Click(object sender, EventArgs e) { if (txtRentId.Text.Length > 0) { var dialogWindow = MessageBox.Show("Kiralık Ev Silmek İstiyor Musunuz ?", "Bilgi Kutusu", MessageBoxButtons.YesNo); if (dialogWindow == DialogResult.Yes) { RentHouse deleteHouse = rentHouseOperations.GetById(txtRentId.Text); string path = Application.StartupPath + "/HouseImages/RentHouses/"; GeneratorFolder generatorFolder = new GeneratorFolder(); generatorFolder.DeleteFolder(path, txtRentId.Text); rentHouseOperations.Delete(deleteHouse); MessageBox.Show("Kiralık Ev Silindi."); FillRentHouseList(); } } else { MessageBox.Show("Lütfen Bir Ev Seçiniz."); } }
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(); } } }
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"); }
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); } }
public override bool acceptMessageData(BinaryReader messageDataReader, TreeView outputTreeView) { bool handled = true; PacketOpcode opcode = Util.readOpcode(messageDataReader); switch (opcode) { case PacketOpcode.Evt_House__QueryHouse_ID: case PacketOpcode.Evt_House__AbandonHouse_ID: case PacketOpcode.Evt_House__RemoveAllStoragePermission_ID: case PacketOpcode.Evt_House__RequestFullGuestList_Event_ID: case PacketOpcode.Evt_House__AddAllStoragePermission_ID: case PacketOpcode.Evt_House__RemoveAllPermanentGuests_Event_ID: case PacketOpcode.Evt_House__BootEveryone_Event_ID: case PacketOpcode.Evt_House__TeleToHouse_Event_ID: case PacketOpcode.Evt_House__TeleToMansion_Event_ID: { EmptyMessage message = new EmptyMessage(opcode); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__DumpHouse_ID case PacketOpcode.Evt_House__BuyHouse_ID: { BuyHouse message = BuyHouse.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_HouseProfile_ID: { Recv_HouseProfile message = Recv_HouseProfile.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__StealHouse_ID: { case PacketOpcode.Evt_House__RentHouse_ID: { RentHouse message = RentHouse.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__LinkToHouse_ID // TODO: PacketOpcode.Evt_House__ReCacheHouse_ID case PacketOpcode.Evt_House__Recv_HouseData_ID: { Recv_HouseData message = Recv_HouseData.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_HouseStatus_ID: { Recv_HouseStatus message = Recv_HouseStatus.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_UpdateRentTime_ID: { Recv_UpdateRentTime message = Recv_UpdateRentTime.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_UpdateRentPayment_ID: { Recv_UpdateRentPayment message = Recv_UpdateRentPayment.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__AddPermanentGuest_Event_ID: { AddPermanentGuest_Event message = AddPermanentGuest_Event.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__RemovePermanentGuest_Event_ID: { RemovePermanentGuest_Event message = RemovePermanentGuest_Event.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__SetOpenHouseStatus_Event_ID: { SetOpenHouseStatus_Event message = SetOpenHouseStatus_Event.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__Recv_UpdateRestrictions_ID case PacketOpcode.Evt_House__ChangeStoragePermission_Event_ID: { ChangeStoragePermission_Event message = ChangeStoragePermission_Event.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__BootSpecificHouseGuest_Event_ID: { BootSpecificHouseGuest_Event message = BootSpecificHouseGuest_Event.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__BootAllUninvitedGuests_Event_ID // TODO: PacketOpcode.Evt_House__RentPay_ID // TODO: PacketOpcode.Evt_House__RentWarn_ID // TODO: PacketOpcode.Evt_House__RentDue_ID // TODO: PacketOpcode.Evt_House__Recv_UpdateHAR_ID case PacketOpcode.Evt_House__QueryLord_ID: { QueryLord message = QueryLord.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_HouseTransaction_ID: { Recv_HouseTransaction message = Recv_HouseTransaction.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__RentOverDue_ID // TODO: PacketOpcode.Evt_House__QueryHouseOwner_ID // TODO: PacketOpcode.Evt_House__AdminTeleToHouse_ID // TODO: PacketOpcode.Evt_House__PayRentForAllHouses_ID case PacketOpcode.Evt_House__SetHooksVisibility_ID: { SetHooksVisibility message = SetHooksVisibility.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__ModifyAllegianceGuestPermission_ID: { ModifyAllegianceGuestPermission message = ModifyAllegianceGuestPermission.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__ModifyAllegianceStoragePermission_ID: { ModifyAllegianceStoragePermission message = ModifyAllegianceStoragePermission.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__ListAvailableHouses_ID: { ListAvailableHouses message = ListAvailableHouses.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } case PacketOpcode.Evt_House__Recv_AvailableHouses_ID: { Recv_AvailableHouses message = Recv_AvailableHouses.read(messageDataReader); message.contributeToTreeView(outputTreeView); break; } // TODO: PacketOpcode.Evt_House__SetMaintenanceFree_ID // TODO: PacketOpcode.Evt_House__DumpHouseAccess_ID default: { handled = false; break; } } return(handled); }
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(); }