Exemple #1
0
 /// <summary>
 /// Кнопка сохранить изменения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_save_edit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using RegistrantCoreContext ef = new RegistrantCoreContext();
         var contragent = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt32(tb_idcontragent.Text));
         if (contragent != null)
         {
             contragent.Name        = tb_edit_name.Text;
             contragent.ServiceInfo =
                 $"{contragent.ServiceInfo}\n {DateTime.Now} {App.ActiveUser} изменил название контрагента";
         }
         ef.SaveChanges();
         btn_refresh_Click(sender, e);
         ContentEdit.Hide();
     }
     catch (Exception ex)
     {
         MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
         if (mainWindow != null)
         {
             mainWindow.ContentErrorText.ShowAsync();
             mainWindow.text_debuger.Text = ex.ToString();
         }
     }
 }
Exemple #2
0
        //Кнопка удалить
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            if (tb_idcontragent != null)
            {
                try
                {
                    using RegistrantCoreContext ef = new RegistrantCoreContext();
                    var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt32(tb_idcontragent.Text));
                    if (temp != null)
                    {
                        temp.Active = "0";
                    }
                    ef.SaveChanges();
                    ContentEdit.Hide();
                }
                catch (Exception ex)
                {
                    MainWindow mainWindow = (MainWindow)Application.Current.MainWindow;
                    if (mainWindow != null)
                    {
                        mainWindow.ContentErrorText.ShowAsync();
                        mainWindow.text_debuger.Text = ex.ToString();
                    }
                }
            }
            //Кнопа перенесена в другоме место,

            /*var bt = e.OriginalSource as Button;
             * var current = bt.DataContext as DB.Contragent;
             *
             * try
             * {
             *  using RegistrantCoreContext ef = new RegistrantCoreContext();
             *  var contragent = ef.Contragents.FirstOrDefault(x => x.IdContragent == current.IdContragent);
             *  if (contragent != null)
             *  {
             *      contragent.Active = "0";
             *      contragent.ServiceInfo = $"{contragent.ServiceInfo}\n{DateTime.Now} {App.ActiveUser} изменил удалил";
             *  }
             *  ef.SaveChanges();
             *  btn_refresh_Click(sender, e);
             * }
             * catch (Exception ex)
             * {
             *  MainWindow mainWindow = (MainWindow) Application.Current.MainWindow;
             *  if (mainWindow != null)
             *  {
             *      mainWindow.ContentErrorText.ShowAsync();
             *      mainWindow.text_debuger.Text = ex.ToString();
             *  }
             * }
             * }*/
        }
Exemple #3
0
        //Кнопка удалить
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            if (tb_idcontragent != null)
            {
                try
                {
                    using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
                    {
                        var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt64(tb_idcontragent.Text));
                        temp.Active = "0";
                        ef.SaveChanges();
                        ContentEdit.Hide();
                    }
                }
                catch (Exception ex)
                {
                    ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
                    ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
                }
            }
            //Кнопа перенесена в другоме место,

            /*var bt = e.OriginalSource as Button;
             * var current = bt.DataContext as DB.Contragent;
             *
             * try
             * {
             *  using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
             *  {
             *      var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == current.IdContragent);
             *      temp.Active = "0";
             *      temp.ServiceInfo = temp.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " изменил удалил";
             *      ef.SaveChanges();
             *      btn_refresh_Click(sender, e);
             *
             *  }
             * }
             * catch (Exception ex)
             * {
             *  ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
             *  ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
             * }*/
        }
Exemple #4
0
 /// <summary>
 /// Кнопка сохранить изменения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_save_edit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         using (DB.RegistrantCoreContext ef = new DB.RegistrantCoreContext())
         {
             var temp = ef.Contragents.FirstOrDefault(x => x.IdContragent == Convert.ToInt64(tb_idcontragent.Text));
             temp.Name        = tb_edit_name.Text;
             temp.ServiceInfo = temp.ServiceInfo + "\n" + DateTime.Now + " " + App.ActiveUser + " изменил название контрагента";
             ef.SaveChanges();
             //btn_refresh_Click(sender, e);
             ContentEdit.Hide();
         }
     }
     catch (Exception ex)
     {
         ((MainWindow)System.Windows.Application.Current.MainWindow).ContentErrorText.ShowAsync();
         ((MainWindow)System.Windows.Application.Current.MainWindow).text_debuger.Text = ex.ToString();
     }
 }
Exemple #5
0
 //Кнопка закрыть окна редактирования
 private void btn_edit_close_Click(object sender, RoutedEventArgs e)
 {
     ContentEdit.Hide();
 }