예제 #1
0
 private void button_Delete_Click(object sender, RoutedEventArgs e)
 {
     using (workEntities1 db = new workEntities1())
     {
         int id         = (dataGrid.SelectedItem as Employee).Id;
         var deleteUser = db.Employee.Where(u => u.Id == id).Single();
         if (deleteUser.Name == null)
         {
         }
         db.Employee.Remove(deleteUser);
         db.SaveChanges();
     }
     _renewControl();
 }
예제 #2
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     using (workEntities1 db = new workEntities1())
     {
         db.Employee.Add(new Employee()
         {
             SecondName = textBox_SecondName.Text,
             Name       = textBox_Name.Text,
             Login      = textBox_Login.Text,
             Password   = passwordBox.Password,
             PositionId = comboBox.SelectedIndex + 1
         }).ToString();
         db.SaveChanges();
     }
     _renewControl();
 }