Example #1
0
        private void AddEmp_Click(object sender, RoutedEventArgs e)
        {
            DataRow newRow     = dtEmployee.NewRow();
            EditEmp editWindow = new EditEmp(newRow, dtDepartments, DepBox.SelectedIndex);

            editWindow.ShowDialog();

            if (editWindow.DialogResult.Value)
            {
                dtEmployee.Rows.Add(editWindow.resultRow);
                adapterEmp.Update(dtEmployee);
                dtEmployee.Clear();
                adapterEmp.Fill(dtEmployee);
            }
        }
Example #2
0
 private void EditEmp_Click(object sender, RoutedEventArgs e)
 {
     if (employeeDataGrid.SelectedIndex > -1)
     {
         DataRowView curRow = (DataRowView)employeeDataGrid.SelectedItem;
         curRow.BeginEdit();
         EditEmp editWindow = new EditEmp(curRow.Row, dtDepartments, DepBox.SelectedIndex);
         editWindow.ShowDialog();
         if (editWindow.DialogResult.Value)
         {
             curRow.EndEdit();
             adapterEmp.Update(dtEmployee);
             dtEmployee.Clear();
             adapterEmp.Fill(dtEmployee);
         }
         else
         {
             curRow.CancelEdit();
         }
     }
 }