Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            PharmacySet pharmacy = listViewPharmacy.SelectedItems[0].Tag as PharmacySet;

            pharmacy.Name       = textBoxName.Text;
            pharmacy.Address    = textBoxAddress.Text;
            pharmacy.Phone      = textBoxPhone.Text;
            pharmacy.OpenHourse = textBoxOpenHours.Text;
            Program.pharmacy.SaveChanges();
            ShowPharmacy();
        }
Пример #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            PharmacySet pharmacy = new PharmacySet();

            pharmacy.Name       = textBoxName.Text;
            pharmacy.Address    = textBoxAddress.Text;
            pharmacy.Phone      = textBoxPhone.Text;
            pharmacy.OpenHourse = textBoxOpenHours.Text;
            Program.pharmacy.PharmacySet.Add(pharmacy);
            Program.pharmacy.SaveChanges();
            ShowPharmacy();
        }
Пример #3
0
 private void listViewPharmacy_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewPharmacy.SelectedItems.Count == 1)
     {
         PharmacySet pharmacy = listViewPharmacy.SelectedItems[0].Tag as PharmacySet;
         textBoxName.Text      = pharmacy.Name;
         textBoxAddress.Text   = pharmacy.Address;
         textBoxPhone.Text     = pharmacy.Phone;
         textBoxOpenHours.Text = pharmacy.OpenHourse;
     }
     else
     {
         textBoxName.Text      = "";
         textBoxAddress.Text   = "";
         textBoxPhone.Text     = "";
         textBoxOpenHours.Text = "";
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPharmacy.SelectedItems.Count == 1)
         {
             PharmacySet pharmacy = listViewPharmacy.SelectedItems[0].Tag as PharmacySet;
             Program.pharmacy.PharmacySet.Remove(pharmacy);
             Program.pharmacy.SaveChanges();
             ShowPharmacy();
         }
         textBoxName.Text      = "";
         textBoxAddress.Text   = "";
         textBoxPhone.Text     = "";
         textBoxOpenHours.Text = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }