Exemplo n.º 1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            MedicineSet medicine = listViewMedicine.SelectedItems[0].Tag as MedicineSet;

            medicine.Name         = textBoxName.Text;
            medicine.ReleaseForm  = comboBoxReleaseForm.Text;
            medicine.Dosage       = textBoxDosage.Text;
            medicine.Manufacturer = textBoxManufacturer.Text;
            medicine.ShelfLife    = textBoxShelfLife.Text;
            Program.pharmacy.SaveChanges();
            ShowMedicine();
        }
Exemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            MedicineSet medicine = new MedicineSet();

            medicine.Name         = textBoxName.Text;
            medicine.ReleaseForm  = comboBoxReleaseForm.Text;
            medicine.Dosage       = textBoxDosage.Text;
            medicine.Manufacturer = textBoxManufacturer.Text;
            medicine.ShelfLife    = textBoxShelfLife.Text;
            Program.pharmacy.MedicineSet.Add(medicine);
            Program.pharmacy.SaveChanges();
            ShowMedicine();
        }
Exemplo n.º 3
0
        private void listViewMedicine_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewMedicine.SelectedItems.Count == 1)
            {
                MedicineSet medicine = listViewMedicine.SelectedItems[0].Tag as MedicineSet;

                textBoxName.Text         = medicine.Name;
                comboBoxReleaseForm.Text = medicine.ReleaseForm;
                textBoxDosage.Text       = medicine.Dosage;
                textBoxManufacturer.Text = medicine.Manufacturer;
                textBoxShelfLife.Text    = medicine.ShelfLife;
            }
            else
            {
                textBoxName.Text         = "";
                comboBoxReleaseForm.Text = "";
                textBoxDosage.Text       = "";
                textBoxManufacturer.Text = "";
                textBoxShelfLife.Text    = "";
            }
        }
Exemplo n.º 4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewMedicine.SelectedItems.Count == 1)
         {
             MedicineSet medicine = listViewMedicine.SelectedItems[0].Tag as MedicineSet;
             Program.pharmacy.MedicineSet.Remove(medicine);
             Program.pharmacy.SaveChanges();
             ShowMedicine();
         }
         textBoxName.Text         = "";
         comboBoxReleaseForm.Text = "";
         textBoxDosage.Text       = "";
         textBoxManufacturer.Text = "";
         textBoxShelfLife.Text    = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }