コード例 #1
0
ファイル: FormPharm.cs プロジェクト: pasyutina/Pharmacy
 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   = "";
     }
 }
コード例 #2
0
ファイル: FormPharm.cs プロジェクト: pasyutina/Pharmacy
 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);
     }
 }
コード例 #3
0
ファイル: FormPharm.cs プロジェクト: pasyutina/Pharmacy
 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);
     }
 }
コード例 #4
0
ファイル: FormPharm.cs プロジェクト: pasyutina/Pharmacy
 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);
     }
 }