Exemple #1
0
 private void listViewPharm_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewPharm.SelectedItems.Count == 1)
     {
         Apteka pharm = listViewPharm.SelectedItems[0].Tag as Apteka;
         textBoxName.Text    = pharm.Name;
         textBoxAddress.Text = pharm.Address;
         textBoxEmail.Text   = pharm.Email;
         textBoxPhone.Text   = pharm.Phone;
     }
     else
     {
         textBoxName.Text    = "";
         textBoxAddress.Text = "";
         textBoxEmail.Text   = "";
         textBoxPhone.Text   = "";
     }
 }
Exemple #2
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPharm.SelectedItems.Count == 1)
         {
             Apteka pharm = listViewPharm.SelectedItems[0].Tag as Apteka;
             Program.a.Apteka.Remove(pharm);
             Program.a.SaveChanges();
             ShowPharm();
         }
         textBoxName.Text    = "";
         textBoxAddress.Text = "";
         textBoxEmail.Text   = "";
         textBoxPhone.Text   = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #3
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         Apteka pharm = new Apteka();
         pharm.Name    = textBoxName.Text;
         pharm.Address = textBoxAddress.Text;
         pharm.Email   = textBoxEmail.Text;
         pharm.Phone   = textBoxPhone.Text;
         if (pharm.Name == "" || pharm.Address == "" || pharm.Email == "" || pharm.Phone == "")
         {
             throw new Exception("Обязательное заполнение полей!");
         }
         Program.a.Apteka.Add(pharm);
         Program.a.SaveChanges();
         ShowPharm();
     }
     catch (Exception a)
     {
         MessageBox.Show("" + a.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewPharm.SelectedItems.Count == 1)
         {
             Apteka pharm = listViewPharm.SelectedItems[0].Tag as Apteka;
             pharm.Name    = textBoxName.Text;
             pharm.Address = textBoxAddress.Text;
             pharm.Email   = textBoxEmail.Text;
             pharm.Phone   = textBoxPhone.Text;
             if (pharm.Name == "" || pharm.Address == "" || pharm.Email == "" || pharm.Phone == "")
             {
                 throw new Exception("Обязательное заполнение полей!");
             }
             Program.a.SaveChanges();
             ShowPharm();
         }
     }
     catch (Exception a)
     {
         MessageBox.Show("" + a.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }