Ejemplo n.º 1
0
        /// <summary>
        /// Кнопка редактиировать из таблицы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_edit_Click(object sender, RoutedEventArgs e)
        {
            var bt      = e.OriginalSource as Button;
            var current = bt.DataContext as DB.Contragent;

            if (current != null)
            {
                try
                {
                    text_editnamecontragent.Text = "Редактирование элемента " + current.Name;
                    using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
                    {
                        var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == current.IdContragent);
                        tb_idcontragent.Text = temp.IdContragent.ToString();
                        tb_edit_name.Text    = temp.Name.ToString();
                        ContentEdit.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
                    ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Кнопка редактиировать из таблицы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_edit_Click(object sender, RoutedEventArgs e)
        {
            var bt      = e.OriginalSource as Button;
            var current = bt?.DataContext as Contragent;

            if (current != null)
            {
                try
                {
                    text_editnamecontragent.Text   = $"Редактирование элемента {current.Name}";
                    using RegistrantCoreContext ef = new RegistrantCoreContext();
                    var contragent = ef.Contragents.FirstOrDefault(x => x.IdContragent == current.IdContragent);
                    if (contragent != null)
                    {
                        tb_idcontragent.Text = contragent.IdContragent.ToString();
                        tb_edit_name.Text    = contragent.Name;
                    }
                    ContentEdit.ShowAsync();
                }
                catch (Exception ex)
                {
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    if (mainWindow != null)
                    {
                        mainWindow.ContentErrorText.ShowAsync();
                        mainWindow.text_debuger.Text = ex.ToString();
                    }
                }
            }
        }