Exemple #1
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewAvailability.SelectedItems.Count == 1)
     {
         AvailabilitySet availability = listViewAvailability.SelectedItems[0].Tag as AvailabilitySet;
         availability.IdPharmacy = Convert.ToInt32(comboBoxPharmacy.SelectedItem.ToString().Split('.')[0]);
         availability.IdMedicine = Convert.ToInt32(comboBoxMedicine.SelectedItem.ToString().Split('.')[0]);
         availability.Amount     = Convert.ToInt32(textBoxAmount.Text);
         availability.Price      = Convert.ToInt32(textBoxPrice.Text);
         Program.pharmacy.SaveChanges();
         ShowAvailability();
     }
 }
Exemple #2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxMedicine.SelectedItem != null && comboBoxPharmacy.SelectedItem != null && textBoxAmount.Text != null && textBoxPrice.Text != null)
     {
         AvailabilitySet availability = new AvailabilitySet();
         availability.IdPharmacy = Convert.ToInt32(comboBoxPharmacy.SelectedItem.ToString().Split('.')[0]);
         availability.IdMedicine = Convert.ToInt32(comboBoxMedicine.SelectedItem.ToString().Split('.')[0]);
         availability.Amount     = Convert.ToInt32(textBoxAmount.Text);
         availability.Price      = Convert.ToInt32(textBoxPrice.Text);
         Program.pharmacy.AvailabilitySet.Add(availability);
         Program.pharmacy.SaveChanges();
         ShowAvailability();
     }
     else
     {
         MessageBox.Show("Данные не выбраны", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #3
0
 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewAvailability.SelectedItems.Count == 1)
     {
         AvailabilitySet availability = listViewAvailability.SelectedItems[0].Tag as AvailabilitySet;
         comboBoxPharmacy.SelectedIndex = comboBoxPharmacy.FindString(availability.IdPharmacy.ToString());
         comboBoxMedicine.SelectedIndex = comboBoxMedicine.FindString(availability.IdMedicine.ToString());
         textBoxAmount.Text             = availability.Amount.ToString();
         textBoxPrice.Text = availability.Price.ToString();
     }
     else
     {
         comboBoxPharmacy.SelectedItem = null;
         comboBoxMedicine.SelectedItem = null;
         textBoxAmount.Text            = "";
         textBoxPrice.Text             = "";
     }
 }
Exemple #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewAvailability.SelectedItems.Count == 1)
         {
             AvailabilitySet availability = listViewAvailability.SelectedItems[0].Tag as AvailabilitySet;
             Program.pharmacy.AvailabilitySet.Remove(availability);
             Program.pharmacy.SaveChanges();
             ShowAvailability();
         }
         comboBoxPharmacy.SelectedItem = null;
         comboBoxMedicine.SelectedItem = null;
         textBoxAmount.Text            = "";
         textBoxPrice.Text             = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }