Jelajahi Sumber

Доделан

Елизавета Голубева 2 tahun lalu
induk
melakukan
beb4e76547
1 mengubah file dengan 22 tambahan dan 0 penghapusan
  1. 22 0
      Demoexample/Redaction.xaml.cs

+ 22 - 0
Demoexample/Redaction.xaml.cs

@@ -22,11 +22,14 @@ namespace Demoexample
     {
     {
         string imgg = "";
         string imgg = "";
         public Agent buffer;
         public Agent buffer;
+        public Agent changeagent;
+        ViewModel viewModel = new ViewModel();
         public Redaction(Agent idagent)
         public Redaction(Agent idagent)
         {
         {
             InitializeComponent();
             InitializeComponent();
             DataContext = idagent;
             DataContext = idagent;
             buffer = idagent;
             buffer = idagent;
+            changeagent = idagent;
             Type.ItemsSource = DataBase.BaseModel.AgentType.ToList();
             Type.ItemsSource = DataBase.BaseModel.AgentType.ToList();
             Type.SelectedValuePath = "ID";
             Type.SelectedValuePath = "ID";
             Type.DisplayMemberPath = "Title";
             Type.DisplayMemberPath = "Title";
@@ -35,6 +38,25 @@ namespace Demoexample
 
 
         private void add_Click(object sender, RoutedEventArgs e)
         private void add_Click(object sender, RoutedEventArgs e)
         {
         {
+            List<Agent> pro = DataBase.BaseModel.Agent.ToList();
+            if (Convert.ToInt32(priority.Text) < 0 && Convert.ToInt32(priority.Text) % 10 == 0)
+            {
+                throw new Exception("Приоритет не может быть отрицательным");
+            }
+            changeagent.Title = name.Text;
+            changeagent.AgentTypeID = Type.SelectedIndex;
+            changeagent.Priority = Convert.ToInt32(priority.Text);
+            changeagent.Logo = imgg;
+            changeagent.Address = address.Text;
+            changeagent.INN = inn.Text;
+            changeagent.KPP = kpp.Text;
+            changeagent.DirectorName = director.Text;
+            changeagent.Phone = telephone.Text;
+            changeagent.Email = email.Text;
+
+            DataBase.BaseModel.SaveChanges();
+            viewModel.agents = viewModel.newagent();
+
             new MainWindow().Show();
             new MainWindow().Show();
             this.Close();
             this.Close();
         }
         }