Ejemplo n.º 1
0
 public bool SetHouse(House updateHouse)
 {
     return(HouseAccess != null && HouseAccess.UpdateHouse(updateHouse));
 }
Ejemplo n.º 2
0
        private void btnSaveHouse_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtHostName.Text == string.Empty || txtHostLastName.Text == string.Empty || txtHostPhone.Text == string.Empty || txtHostTC.Text == string.Empty || txtHouseNo.Text == string.Empty || txtHouseFloor.Text == string.Empty)
                {
                    throw new Exception("Tüm alanları doldurmalısınız.");
                }

                if (btnSaveHouse.Text == "Ekle")  // Yeni Daire Ekleme
                {
                    HouseHost houseHost = new HouseHost()
                    {
                        HostName      = txtHostName.Text,
                        HostLastName  = txtHostLastName.Text,
                        HostPhone     = txtHostPhone.Text,
                        HostTC        = txtHostTC.Text,
                        HostIsRemoved = false
                    };
                    hostAccess.NewHost(houseHost);

                    houseAccess.NewHouse(new House()
                    {
                        HouseNo     = txtHouseNo.Text,
                        HouseFloor  = txtHouseFloor.Text,
                        HouseHostID = houseHost.HostID
                    });

                    MessageBox.Show("Yeni Daire Eklendi.");
                    pbHouse.Visible = true;
                    FillHousesToFlpHouses();
                }
                else // Daire Bilgilerinin Güncellenmesi
                {
                    hostAccess.UpdateHost(new HouseHost()
                    {
                        HostID        = int.Parse(txtHouseNo.Tag.ToString()),
                        HostName      = txtHostName.Text,
                        HostLastName  = txtHostLastName.Text,
                        HostPhone     = txtHostPhone.Text,
                        HostTC        = txtHostTC.Text,
                        HostIsRemoved = false
                    });

                    houseAccess.UpdateHouse(new House()
                    {
                        HouseID     = int.Parse(txtHouseNo.Tag.ToString()),
                        HouseNo     = txtHouseNo.Text,
                        HouseFloor  = txtHouseFloor.Text,
                        HouseHostID = int.Parse(txtHouseNo.Tag.ToString())
                    });

                    MessageBox.Show("Daire Bilgileri GÜncellendi.");
                    pbHouse.Visible = true;
                    FillHousesToFlpHouses();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }