Пример #1
0
 private void buttonEditInfo_Click(object sender, EventArgs e)
 {
     if (comboBoxTypeProp.SelectedIndex == 0)
     {
         if (listViewHouse.SelectedItems.Count == 1)
         {
             RentProperty rp = listViewHouse.SelectedItems[0].Tag as RentProperty;
             rp.Name         = textBoxName.Text;
             rp.Surname      = textBoxSurname.Text;
             rp.Patronymic   = textBoxPatronymic.Text;
             rp.AddressHouse = textBoxAdHouse.Text;
             rp.PriceHouse   = textBoxPriceHouse.Text;
             Program.ADb.SaveChanges();
             ShowRentProper();
         }
     }
     else
     {
         if (listViewFloor.SelectedItems.Count == 1)
         {
             RentProperty rp = listViewFloor.SelectedItems[0].Tag as RentProperty;
             rp.Name         = textBoxName.Text;
             rp.Surname      = textBoxSurname.Text;
             rp.Patronymic   = textBoxPatronymic.Text;
             rp.AddressFloor = textBoxAdFloor.Text;
             rp.PriceFloor   = textBoxPriceFloor.Text;
             Program.ADb.SaveChanges();
             ShowRentProper();
         }
     }
 }
Пример #2
0
 private void listViewFloor_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewFloor.SelectedItems.Count == 1)
     {
         RentProperty rp = listViewFloor.SelectedItems[0].Tag as RentProperty;
         textBoxName.Text       = rp.Name;
         textBoxSurname.Text    = rp.Surname;
         textBoxPatronymic.Text = rp.Patronymic;
         textBoxAdFloor.Text    = rp.AddressFloor;
         textBoxPriceFloor.Text = rp.PriceFloor;
     }
     else
     {
         textBoxName.Text       = "";
         textBoxSurname.Text    = "";
         textBoxPatronymic.Text = "";
         textBoxAdFloor.Text    = "";
         textBoxPriceFloor.Text = "";
     }
 }
Пример #3
0
 private void buttonDelInfo_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBoxTypeProp.SelectedIndex == 0)
         {
             if (listViewHouse.SelectedItems.Count == 1)
             {
                 RentProperty rp = listViewHouse.SelectedItems[0].Tag as RentProperty;
                 Program.ADb.RentProperty.Remove(rp);
                 Program.ADb.SaveChanges();
                 ShowRentProper();
             }
             textBoxName.Text       = "";
             textBoxSurname.Text    = "";
             textBoxPatronymic.Text = "";
             textBoxAdHouse.Text    = "";
             textBoxPriceHouse.Text = "";
         }
         else
         {
             if (listViewFloor.SelectedItems.Count == 1)
             {
                 RentProperty rp = listViewFloor.SelectedItems[0].Tag as RentProperty;
                 Program.ADb.RentProperty.Remove(rp);
                 Program.ADb.SaveChanges();
                 ShowRentProper();
             }
             textBoxName.Text       = "";
             textBoxSurname.Text    = "";
             textBoxPatronymic.Text = "";
             textBoxAdFloor.Text    = "";
             textBoxPriceFloor.Text = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            RentProperty rp = new RentProperty();

            rp.Name       = textBoxName.Text;
            rp.Surname    = textBoxSurname.Text;
            rp.Patronymic = textBoxPatronymic.Text;
            if (comboBoxTypeProp.SelectedIndex == 0)
            {
                rp.TypeProp     = 0;
                rp.AddressHouse = textBoxAdHouse.Text;
                rp.PriceHouse   = textBoxPriceHouse.Text;
            }
            else
            {
                rp.TypeProp     = 1;
                rp.AddressFloor = textBoxAdFloor.Text;
                rp.PriceFloor   = textBoxPriceFloor.Text;
            }
            Program.ADb.RentProperty.Add(rp);
            Program.ADb.SaveChanges();
            ShowRentProper();
        }