فهرست منبع

Доделан

Елизавета Голубева 2 سال پیش
والد
کامیت
beb4e76547
1فایلهای تغییر یافته به همراه22 افزوده شده و 0 حذف شده
  1. 22 0
      Demoexample/Redaction.xaml.cs

+ 22 - 0
Demoexample/Redaction.xaml.cs

@@ -22,11 +22,14 @@ namespace Demoexample
     {
         string imgg = "";
         public Agent buffer;
+        public Agent changeagent;
+        ViewModel viewModel = new ViewModel();
         public Redaction(Agent idagent)
         {
             InitializeComponent();
             DataContext = idagent;
             buffer = idagent;
+            changeagent = idagent;
             Type.ItemsSource = DataBase.BaseModel.AgentType.ToList();
             Type.SelectedValuePath = "ID";
             Type.DisplayMemberPath = "Title";
@@ -35,6 +38,25 @@ namespace Demoexample
 
         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();
             this.Close();
         }