Exemple #1
0
 private void listViewNal_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewNal.SelectedItems.Count == 1)
     {
         Nal nal = listViewNal.SelectedItems[0].Tag as Nal;
         comboBoxMed.SelectedIndex   = comboBoxMed.FindString(nal.IdMedicine.ToString());
         comboBoxPharm.SelectedIndex = comboBoxPharm.FindString(nal.IdApteka.ToString());
         textBoxQuantity.Text        = nal.Quantity.ToString();
         textBoxPrice.Text           = nal.Price.ToString();
     }
     else
     {
         comboBoxMed.SelectedItem   = null;
         comboBoxPharm.SelectedItem = null;
         textBoxQuantity.Text       = "";
         textBoxPrice.Text          = "";
     }
 }
Exemple #2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewNal.SelectedItems.Count == 1)
         {
             Nal nal = listViewNal.SelectedItems[0].Tag as Nal;
             Program.a.Nal.Remove(nal);
             Program.a.SaveChanges();
             ShowNal();
         }
         comboBoxMed.SelectedItem   = null;
         comboBoxPharm.SelectedItem = null;
         textBoxQuantity.Text       = "";
         textBoxPrice.Text          = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Nal nal = new Nal();
         nal.IdMedicine = Convert.ToInt32(comboBoxMed.SelectedItem.ToString().Split('.')[0]);
         nal.IdApteka   = Convert.ToInt32(comboBoxPharm.SelectedItem.ToString().Split('.')[0]);
         nal.Quantity   = Convert.ToInt32(textBoxQuantity.Text);
         nal.Price      = Convert.ToInt32(textBoxPrice.Text);
         if (nal.IdMedicine == null || nal.IdApteka == null)
         {
             throw new Exception("Обязательное заполнение полей!");
         }
         Program.a.Nal.Add(nal);
         Program.a.SaveChanges();
         ShowNal();
     }
     catch (Exception a)
     {
         MessageBox.Show("" + a.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }