Пример #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            WorkersSet workerSet = new WorkersSet();

            workerSet.FirstName  = textBoxFirstName.Text;
            workerSet.MiddleName = textBoxMiddleName.Text;
            workerSet.LastName   = textBoxLastName.Text;
            workerSet.Phone      = textBoxPhone.Text;
            workerSet.Email      = textBoxEmail.Text;
            Program.BSTDB.WorkersSet.Add(workerSet);
            Program.BSTDB.SaveChanges();
            ShowWorker();
        }
Пример #2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewWorker.SelectedItems.Count == 1)
     {
         WorkersSet workerSet = listViewWorker.SelectedItems[0].Tag as WorkersSet;
         workerSet.FirstName  = textBoxFirstName.Text;
         workerSet.MiddleName = textBoxMiddleName.Text;
         workerSet.LastName   = textBoxLastName.Text;
         workerSet.Phone      = textBoxPhone.Text;
         workerSet.Email      = textBoxEmail.Text;
         Program.BSTDB.SaveChanges();
         ShowWorker();
     }
 }
Пример #3
0
 private void listViewWorker_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewWorker.SelectedItems.Count == 1)
     {
         WorkersSet workerSet = listViewWorker.SelectedItems[0].Tag as WorkersSet;
         textBoxFirstName.Text  = workerSet.FirstName;
         textBoxMiddleName.Text = workerSet.MiddleName;
         textBoxLastName.Text   = workerSet.LastName;
         textBoxPhone.Text      = workerSet.Phone;
         textBoxEmail.Text      = workerSet.Email;
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
 }
Пример #4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewWorker.SelectedItems.Count == 1)
         {
             WorkersSet workerSet = listViewWorker.SelectedItems[0].Tag as WorkersSet;
             Program.BSTDB.WorkersSet.Remove(workerSet);
             Program.BSTDB.SaveChanges();
             ShowWorker();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPhone.Text      = "";
         textBoxEmail.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }