|
@@ -0,0 +1,91 @@
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Data;
|
|
|
+using System.Windows.Documents;
|
|
|
+using System.Windows.Input;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
+using System.Windows.Shapes;
|
|
|
+
|
|
|
+namespace ShabaninDemoEkz
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Логика взаимодействия для AddChanged.xaml
|
|
|
+ /// </summary>
|
|
|
+ public partial class AddChanged : Window
|
|
|
+ {
|
|
|
+ IList ls;
|
|
|
+ Agent Agent;
|
|
|
+ public AddChanged(IList lss)
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ ls = lss;
|
|
|
+ foreach (Agent a in lss)
|
|
|
+ {
|
|
|
+ Agent = a;
|
|
|
+ }
|
|
|
+ DataContext = Agent;
|
|
|
+
|
|
|
+ TypeA.ItemsSource = BaseConnect.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
|
|
|
+
|
|
|
+ TypeA.DisplayMemberPath = "Title";
|
|
|
+ TypeA.SelectedValuePath = "ID";
|
|
|
+ TypeA.SelectedIndex = Agent.AgentTypeID - 1;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SaveBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (Convert.ToInt32(Prioriti.Text) >= 0)
|
|
|
+ {
|
|
|
+ MessageBoxResult dialogResult = MessageBox.Show("Сохранить?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Information);
|
|
|
+ if (dialogResult == MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ Agent.AgentTypeID = TypeA.SelectedIndex + 1;
|
|
|
+ BaseConnect.BaseModel.SaveChanges();
|
|
|
+ MessageBox.Show("Изменения сохранены", "Сохранение изменений", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Ошибка сохранения", "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ MessageBox.Show("Ошибка сохранения", "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DelBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ MessageBoxResult dialogResult = MessageBox.Show("Удалить?", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Information);
|
|
|
+ if (dialogResult == MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ BaseConnect.BaseModel.Agent.Remove(Agent);
|
|
|
+ BaseConnect.BaseModel.SaveChanges();
|
|
|
+ MessageBox.Show("Запись удалена", "Удаление", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
+ this.Hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ MessageBox.Show("Ошибка удаления", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|