示例#1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            StaffSet staffSet = new StaffSet();

            staffSet.FirstName  = textBoxFirstName.Text;
            staffSet.MiddleName = textBoxMiddleName.Text;
            staffSet.LastName   = textBoxLastName.Text;
            staffSet.Position   = textBoxPosition.Text;
            staffSet.Phone      = textBoxPhone.Text;
            Program.wftDb.StaffSet.Add(staffSet);
            Program.wftDb.SaveChanges();
            ShowStaff();
        }
示例#2
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewStaff.SelectedItems.Count == 1)
     {
         StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet;
         staffSet.FirstName  = textBoxFirstName.Text;
         staffSet.MiddleName = textBoxMiddleName.Text;
         staffSet.LastName   = textBoxLastName.Text;
         staffSet.Position   = textBoxPosition.Text;
         staffSet.Phone      = textBoxPhone.Text;
         Program.wftDb.SaveChanges();
         ShowStaff();
     }
 }
示例#3
0
 private void listViewStaff_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listViewStaff.SelectedItems.Count == 1)
     {
         StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet;
         textBoxFirstName.Text  = staffSet.FirstName;
         textBoxMiddleName.Text = staffSet.MiddleName;
         textBoxLastName.Text   = staffSet.LastName;
         textBoxPosition.Text   = staffSet.Position;
         textBoxPhone.Text      = staffSet.Phone;
     }
     else
     {
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPosition.Text   = "";
         textBoxPhone.Text      = "";
     }
 }
示例#4
0
 private void buttonDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (listViewStaff.SelectedItems.Count == 1)
         {
             StaffSet staffSet = listViewStaff.SelectedItems[0].Tag as StaffSet;
             Program.wftDb.StaffSet.Remove(staffSet);
             Program.wftDb.SaveChanges();
             ShowStaff();
         }
         textBoxFirstName.Text  = "";
         textBoxMiddleName.Text = "";
         textBoxLastName.Text   = "";
         textBoxPosition.Text   = "";
         textBoxPhone.Text      = "";
     }
     catch
     {
         MessageBox.Show("Невозможно удалить, эта запись используется!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }