123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using Microsoft.Win32;
- using System;
- 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 Demoexample
- {
- /// <summary>
- /// Логика взаимодействия для NewAgent.xaml
- /// </summary>
- public partial class NewAgent : Window
- {
- string imgg = " ";
- public Agent buffer;
- public NewAgent()
- {
- InitializeComponent();
- Type.ItemsSource = DataBase.BaseModel.AgentType.ToList();
- Type.SelectedValuePath = "ID";
- Type.DisplayMemberPath = "Title";
- Type.SelectedIndex = 1;
- }
- private void newImg_Click(object sender, RoutedEventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.DefaultExt = ".jpg";
- openFileDialog.Filter = "Изображение | *.jpg; *.png";
- var result = openFileDialog.ShowDialog();
- if (result == true)
- {
- imgg = openFileDialog.FileName;
- imgnew.Source = BitmapFrame.Create(new Uri(imgg));
- }
- }
- private void add_Click(object sender, RoutedEventArgs e)
- {
- List<Agent> pro = DataBase.BaseModel.Agent.ToList();
- if(Convert.ToInt32(prioritey.Text)<0 && Convert.ToInt32(prioritey.Text) % 10==0)
- {
- throw new Exception("Приоритет не может быть отрицательным");
- }
- Agent agent = new Agent()
- {
- Title = name.Text,
- AgentTypeID = Type.SelectedIndex,
- Priority = Convert.ToInt32(prioritey.Text),
- Logo = imgg,
- Address = address.Text,
- INN = inn.Text,
- KPP = kpp.Text,
- DirectorName = director.Text,
- Phone = telephone.Text,
- Email = email.Text
- };
- DataBase.BaseModel.Agent.Add(agent);
- DataBase.BaseModel.SaveChanges();
- DataBase.BaseModel = new user32Entities();
- new MainWindow().Show();
- this.Close();
- }
- }
- }
|