Exemple #1
0
        /// <summary>
        /// Кнопка "Добавить"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Click(object sender, RoutedEventArgs e)
        {
            DataRow          newRow     = dt.NewRow();
            Win_EditEmployee editWindow = new Win_EditEmployee(newRow);

            editWindow.Owner = this;
            editWindow.ShowDialog();
            if (editWindow.DialogResult.HasValue && editWindow.DialogResult.Value)
            {
                dt.Rows.Add(editWindow.resultRow);
                adapter.Update(dt);
            }
        }
Exemple #2
0
 /// <summary>
 /// Кнопка "Редактировать"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_edit_Click(object sender, RoutedEventArgs e)
 {
     if (lst_Employees.SelectedItem != null)
     {
         DataRowView newRow = (DataRowView)lst_Employees.SelectedItem;
         newRow.BeginEdit();
         Win_EditEmployee editWindow = new Win_EditEmployee(newRow.Row);
         editWindow.Owner = this;
         editWindow.ShowDialog();
         if (editWindow.DialogResult.HasValue && editWindow.DialogResult.Value)
         {
             newRow.EndEdit();
             adapter.Update(dt);
         }
         else
         {
             newRow.CancelEdit();
         }
     }
     else
     {
         MessageBox.Show("Для редактирования выберите департамент в списке");
     }
 }