Ejemplo n.º 1
0
        private void buttonAdd_Click_1(object sender, EventArgs e)
        {
            WorkerSet workerSet = new WorkerSet();

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