示例#1
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewDrugs.SelectedItems.Count == 1)
         {
             Drugs drugs = listViewDrugs.SelectedItems[0].Tag as Drugs;
             Program.PhDB.Drugs.Remove(drugs);
             Program.PhDB.SaveChanges();
             ShowDrugs();
             textBoxName.Text      = "";
             comboBoxFormRel.Text  = "";
             textBoxDos.Text       = "";
             textBoxMan.Text       = "";
             textBoxDateOfMan.Text = "";
         }
         else
         {
             textBoxName.Text      = "";
             comboBoxFormRel.Text  = "";
             textBoxDos.Text       = "";
             textBoxMan.Text       = "";
             textBoxDateOfMan.Text = "";
         }
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Drugs drugs = new Drugs();

            drugs.DrugName          = textBoxName.Text;
            drugs.ReleaseForm       = comboBoxFormRel.Text;
            drugs.Dosage            = textBoxDos.Text;
            drugs.Manufacturer      = textBoxMan.Text;
            drugs.DateOfManufacture = textBoxDateOfMan.Text;
            Program.PhDB.Drugs.Add(drugs);
            Program.PhDB.SaveChanges();
            ShowDrugs();
        }
示例#3
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewDrugs.SelectedItems.Count == 1)
     {
         Drugs drugs = listViewDrugs.SelectedItems[0].Tag as Drugs;
         drugs.DrugName          = textBoxName.Text;
         drugs.ReleaseForm       = comboBoxFormRel.Text;
         drugs.Dosage            = textBoxDos.Text;
         drugs.Manufacturer      = textBoxMan.Text;
         drugs.DateOfManufacture = textBoxDateOfMan.Text;
         Program.PhDB.SaveChanges();
         ShowDrugs();
     }
 }
示例#4
0
 private void listViewDrugs_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewDrugs.SelectedItems.Count == 1)
     {
         Drugs drugs = listViewDrugs.SelectedItems[0].Tag as Drugs;
         textBoxName.Text      = drugs.DrugName;
         comboBoxFormRel.Text  = drugs.ReleaseForm;
         textBoxDos.Text       = drugs.Dosage;
         textBoxMan.Text       = drugs.Manufacturer;
         textBoxDateOfMan.Text = drugs.DateOfManufacture;
         double price = 0;
         double i     = 0;
         int    value = 0;
         foreach (Availability availability in Program.PhDB.Availability)
         {
             if (drugs.Id == availability.IdDrugs)
             {
                 i++;
                 price += Convert.ToInt32(availability.Price);
                 value += Convert.ToInt32(availability.Value);
                 ListViewItem item = new ListViewItem(new string[]
                 {
                     availability.Id.ToString(),
                     availability.Pharmacy.PharmacyName,
                 });
                 item.Tag = availability;
                 listViewAdv.Items.Add(item);
             }
         }
         price             = price / i;
         textBoxPrice.Text = price.ToString();
         textBoxValue.Text = value.ToString();
     }
     else
     {
         textBoxName.Text      = "";
         comboBoxFormRel.Text  = "";
         textBoxDos.Text       = "";
         textBoxMan.Text       = "";
         textBoxDateOfMan.Text = "";
     }
 }