/* 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); }
/* 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."); } }
/* 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."); } }
/* 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 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(); } } }
/* Ev Tipine Gore Arama */ private void txtType_SelectedIndexChanged(object sender, EventArgs e) { dgvRentHouses.DataSource = rentHouseOperations.GetAll().Where(x => x.Type == ConvertHouseType.GetHouseType(txtType.Text)).ToList(); dgvSaleHouses.DataSource = saleHouseOperations.GetAll().Where(x => x.Type == ConvertHouseType.GetHouseType(txtType.Text)).ToList(); }