Example #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_EditDepartment editWindow = new Win_EditDepartment(newRow);

            editWindow.Owner = this;
            editWindow.ShowDialog();
            if (editWindow.DialogResult.HasValue && editWindow.DialogResult.Value)
            {
                dt.Rows.Add(editWindow.resultRow);
                adapter.Update(dt);
            }
        }
Example #2
0
 /// <summary>
 /// Кнопка "Редактировать"
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_edit_Click(object sender, RoutedEventArgs e)
 {
     if (lst_Departments.SelectedItem != null)
     {
         DataRowView newRow = (DataRowView)lst_Departments.SelectedItem;
         newRow.BeginEdit();
         Win_EditDepartment editWindow = new Win_EditDepartment(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("Для редактирования выберите департамент в списке");
     }
 }