소스 검색

Изменение агента

Barsik Kato 2 년 전
부모
커밋
7710e3e608
2개의 변경된 파일34개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 1
      Session1/Windows/EditAgent.xaml
  2. 33 2
      Session1/Windows/EditAgent.xaml.cs

+ 1 - 1
Session1/Windows/EditAgent.xaml

@@ -16,7 +16,7 @@
             <StackPanel Grid.Column="0" VerticalAlignment="Center">
                 <Image x:Name="agentImg" Height="150" Width="150"></Image>
                 <TextBox x:Name="imgPath" Width="150"></TextBox>
-                <Button x:Name="addImage" Width="150">Добавить изображение</Button>
+                <Button x:Name="addImage" Width="150" Click="addImage_Click">Добавить изображение</Button>
             </StackPanel>
         </GroupBox>
         <GroupBox Header="Основные данные" Grid.Column="1">

+ 33 - 2
Session1/Windows/EditAgent.xaml.cs

@@ -1,5 +1,7 @@
-using System;
+using Microsoft.Win32;
+using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -49,12 +51,41 @@ namespace Session1
 
         private void save_Click(object sender, RoutedEventArgs e)
         {
-
+            Agent updatedAgent = new Agent();
+            selectedAgent.Logo = imgPath.Text = selectedAgent.Logo;
+            selectedAgent.Title = agentName.Text;
+            selectedAgent.AgentTypeID = ((AgentType)agentType.SelectedItem).ID;
+            selectedAgent.Priority = Convert.ToInt32(agentPriority.Text);
+            selectedAgent.Address = agentAddress.Text;
+            selectedAgent.INN = agentINN.Text;
+            selectedAgent.KPP = agentKPP.Text;
+            selectedAgent.Phone = agentPhone.Text;
+            selectedAgent.DirectorName = agentDirector.Text;
+            selectedAgent.Email = agentEmail.Text;
+            try
+            {
+                BaseConnect.baseModel.SaveChanges();
+                MessageBox.Show("Данные успешно изменены.");
+                Close();
+            }
+            catch
+            {
+                MessageBox.Show("Не удалось изменить данные.");
+            }
         }
 
         private void cancel_Click(object sender, RoutedEventArgs e)
         {
             Close();
         }
+
+        private void addImage_Click(object sender, RoutedEventArgs e)
+        {
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            openFileDialog.Filter = "*.jpg | *.png";
+            openFileDialog.ShowDialog();
+            string filePath = openFileDialog.FileName;
+            imgPath.Text = filePath;
+        }
     }
 }