Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 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 = "";
     }
 }
Esempio n. 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);
     }
 }