Ver código fonte

Работа страниц изменения и добавления

y.buzueva2002 2 anos atrás
pai
commit
70be40ea59

+ 1 - 1
BuzuevaDemo/CreateChange.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:BuzuevaDemo"
         mc:Ignorable="d"
-        Title="Добавление/редактирование данных" Height="730" Width="410" Icon="/Img/Приятный шелест.ico">
+        Title="Добавление/редактирование данных" Height="760" Width="410" MinHeight="730" MinWidth="410" Icon="/Img/Приятный шелест.ico">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="100"/>

+ 1 - 1
BuzuevaDemo/CreateChange.xaml.cs

@@ -26,7 +26,7 @@ namespace BuzuevaDemo
             InitializeComponent();
             if (a == 0)
             {
-                PageChange.Navigate(new ChangeData());
+                PageChange.Navigate(new ChangeData(idagent));
                 ChangePage.swithpages = PageChange;
             }
             if (a == 1)

+ 8 - 3
BuzuevaDemo/Pages/Agents.xaml

@@ -37,13 +37,13 @@
         <Grid.RowDefinitions>
             <RowDefinition Height="64"/>
             <RowDefinition Height="363*"/>
-            <RowDefinition Height="23*"/>
+            <RowDefinition Height="23"/>
         </Grid.RowDefinitions>
         <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Background="#C6D7FF" >
             <GroupBox Header="Введите для поиска" Width="300">
                 <TextBox x:Name="poisk" Height="40" TextChanged="Changeg" />
             </GroupBox>
-            <ComboBox x:Name="sort" Width="200" Margin="10, 5" Height="40">
+            <ComboBox x:Name="sort" Width="200" Margin="10, 5" Height="40" SelectionChanged="sortSelectionChanged" >
                 <TextBlock>Наименование (возр.)</TextBlock>
                 <TextBlock>Наименование (убыв.)</TextBlock>
                 <TextBlock>Размер скидки (возр.)</TextBlock>
@@ -51,7 +51,7 @@
                 <TextBlock>Приоритет агента (возр.)</TextBlock>
                 <TextBlock>Приоритет агента (убыв.)</TextBlock>
             </ComboBox>
-            <ComboBox x:Name="filt" Width="200" Margin="10, 5" Height="40" >
+            <ComboBox x:Name="filt" Width="200" Margin="10, 5" Height="40" SelectionChanged ="filtSelectionChanged">
                 <TextBlock>Все типы</TextBlock>
                 <TextBlock>МФО</TextBlock>
                 <TextBlock>ПАО</TextBlock>
@@ -63,5 +63,10 @@
             <Button Content="Добавить агента" Click="PerexodСhange" Width="150" Margin="10, 5" Height="40" />
         </StackPanel>
         <ListBox  Grid.Row="1" x:Name="AllAgent" ItemTemplate="{StaticResource AllAgent}" />
+        <StackPanel  Background="#C6D7FF" Grid.Row="2" Orientation="Horizontal">
+            <TextBlock Text="Пред. "/>
+            <TextBlock Text="1 2 3 4 5 6 7 8 9 10"/>
+            <TextBlock Text=" След."/>
+        </StackPanel>
     </Grid>
 </Page>

+ 56 - 1
BuzuevaDemo/Pages/Agents.xaml.cs

@@ -23,13 +23,26 @@ namespace BuzuevaDemo.Pages
     {
         ViewModel view = new ViewModel();
         List<Agent> filter;
-
+        List<Agent> sortirov;
+        List<Agent> filtrasia;
+        List<Agent> agents = new List<Agent>();
+        public string[] typelist = new string[5];
         public Agents()
         {
             InitializeComponent();
             AllAgent.ItemsSource = view.agent.ToList();
             AllAgent.Items.Refresh();
             filter = view.agent.ToList();
+            sortirov = view.agent.ToList();
+            filtrasia = view.agent.ToList();
+            List<AgentType> type = DataBase.BaseModel.AgentType.ToList();
+            int i = 0;
+            foreach (AgentType tps in type)
+            {
+                typelist[i] = tps.Title;
+                i++;
+            }
+            
         }
 
         private void Changeg(object sender, TextChangedEventArgs e)
@@ -57,5 +70,47 @@ namespace BuzuevaDemo.Pages
         { 
             new CreateChange(null, 1).ShowDialog();
         }
+
+        private void sortSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            switch (sort.SelectedIndex)
+            {
+                case 0:
+                    sortirov = sortirov.OrderBy(x => x.Title).ToList();
+                    AllAgent.ItemsSource = sortirov.ToList();
+                    break;
+                case 1:
+                    sortirov = sortirov.OrderBy(x => x.Title).ToList();
+                    sortirov.Reverse();
+                    AllAgent.ItemsSource = sortirov.ToList();
+                    break;
+                case 2:
+                    sortirov = sortirov.ToList();
+                    break;
+                case 3:
+                    sortirov = sortirov.ToList();
+                    break;
+                case 4:
+                    sortirov = sortirov.OrderBy(x => x.Priority).ToList();
+                    AllAgent.ItemsSource = sortirov.ToList();
+                    break;
+                case 5:
+                    sortirov = sortirov.OrderBy(x => x.Priority).ToList();
+                    sortirov.Reverse();
+                    AllAgent.ItemsSource = sortirov.ToList();
+                    break;
+                default:
+                    sortirov = sortirov.ToList();
+                    break;
+                   
+            } 
+            AllAgent.ItemsSource = sortirov.ToList();
+        }
+
+
+        private void filtSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+
+        }
     }
 }

+ 21 - 10
BuzuevaDemo/Pages/ChangeData.xaml

@@ -5,33 +5,44 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:BuzuevaDemo.Pages"
       mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="245"
+      d:DesignHeight="550" d:DesignWidth="245"
       Title="ChangeData">
 
     <Grid>
-        <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
+        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Center">
             <GroupBox Header="Наименование">
-                <TextBox/>
+                <TextBox Text="{Binding Title}" x:Name="Title"/>
             </GroupBox>
             <GroupBox Header="Тип агента">
-                <ComboBox/>
+                <ComboBox x:Name="typeag"/>
             </GroupBox>
             <GroupBox Header="Приоритет">
-                <TextBox/>
+                <TextBox Text="{Binding Priority}" x:Name="Priority"/>
             </GroupBox>
             <GroupBox Header="Адрес">
-                <TextBox/>
+                <TextBox Text="{Binding Address}" x:Name="Address"/>
             </GroupBox>
             <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                 <GroupBox  Header="ИНН">
-                    <TextBox Width="90"/>
+                    <TextBox Width="90" Text="{Binding INN}"  x:Name="INN"/>
                 </GroupBox>
                 <GroupBox  Header="КПП">
-                    <TextBox  Width="90"/>
+                    <TextBox  Width="90" Text="{Binding KPP}"  x:Name="KPP"/>
                 </GroupBox>
             </StackPanel>
-            <Image Width="100" Height="100"/>
-            <Button Content="Внести изменения"/>
+            <GroupBox Header="Имя директора">
+                <TextBox Text="{Binding DirectorName}"  x:Name="DirectorName"/>
+            </GroupBox>
+            <GroupBox Header="Телефон">
+                <TextBox Text="{Binding Phone}" x:Name="Phone"/>
+            </GroupBox>
+            <GroupBox Header="Email">
+                <TextBox Text="{Binding Email}" x:Name="Email"/>
+            </GroupBox>
+            <Image Width="100" Height="100" Source="{Binding Logo}" x:Name="Logo"/>
+            <Button Content="Внести изменения" Click="Perezapis" />
+            <Button Content="Добавить изображение" Click="NewImage" Margin="0, 2" />
+            <Button Content="Удалить запись" Margin="0, 1" />
         </StackPanel>
     </Grid>
 </Page>

+ 48 - 1
BuzuevaDemo/Pages/ChangeData.xaml.cs

@@ -12,6 +12,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using BuzuevaDemo.Classes;
 
 namespace BuzuevaDemo.Pages
 {
@@ -20,9 +21,55 @@ namespace BuzuevaDemo.Pages
     /// </summary>
     public partial class ChangeData : Page
     {
-        public ChangeData()
+        public int ind, id = 0;
+        string newimg;
+        ViewModel view = new ViewModel();
+        public Agent agent;
+        public string[] type = new string[6];
+        public Agent buffer;
+        public ChangeData(Agent idagent)
         {
             InitializeComponent();
+            DataContext = idagent;
+            agent = idagent;
+            buffer = idagent;
+            DataContext = buffer;
+            typeag.ItemsSource = DataBase.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
+            typeag.SelectedValue = "ID";
+            typeag.DisplayMemberPath = "Title";
+            typeag.SelectedIndex = (int)buffer.AgentTypeID - 1;
         }
+        private void Perezapis(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                agent.Title = Title.Text;
+                agent.TitleType = typeag.Text;
+                agent.Priority = Convert.ToInt32(Priority.Text);
+                agent.Address = Address.Text;
+                agent.INN = INN.Text;
+                agent.KPP = KPP.Text;
+                agent.Logo = newimg;
+                agent.DirectorName = DirectorName.Text;
+                agent.Phone = Phone.Text;
+                agent.Email = Email.Text;
+                DataBase.BaseModel.SaveChanges();
+                view.agent = view.ListAgent();
+                MessageBox.Show("Данные успешно обновлены");
+            }
+            catch
+            {
+                MessageBox.Show("Произошла ошибка слхранения", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void NewImage(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+
+
+
     }
 }

+ 14 - 4
BuzuevaDemo/Pages/CreateData.xaml

@@ -5,15 +5,15 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:BuzuevaDemo.Pages"
       mc:Ignorable="d"
-      Title="CreateZapis" Height="450" Width="245">
+      Title="CreateZapis" Height="500" Width="245">
 
     <Grid>
-        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="10">
+        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
             <GroupBox Header="Наименование">
                 <TextBox/>
             </GroupBox>
             <GroupBox Header="Тип агента">
-                <ComboBox/>
+                <ComboBox x:Name="typeag"/>
             </GroupBox>
             <GroupBox Header="Приоритет">
                 <TextBox/>
@@ -29,8 +29,18 @@
                     <TextBox  Width="80"/>
                 </GroupBox>
             </StackPanel>
+            <GroupBox Header="Имя директора">
+                <TextBox />
+            </GroupBox>
+            <GroupBox Header="Телефон">
+                <TextBox />
+            </GroupBox>
+            <GroupBox Header="Email">
+                <TextBox/>
+            </GroupBox>
             <Image Width="100" Height="100"/>
-            <Button Content="Создать"/>
+            <Button Content="Создать" Click="NewZapis"/>
+            <Button Content="Добавить изображение" Click="NewImage" Margin="0, 5" />
         </StackPanel>
     </Grid>
 </Page>

+ 19 - 0
BuzuevaDemo/Pages/CreateData.xaml.cs

@@ -12,6 +12,7 @@ using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using BuzuevaDemo.Classes;
 
 namespace BuzuevaDemo.Pages
 {
@@ -20,9 +21,27 @@ namespace BuzuevaDemo.Pages
     /// </summary>
     public partial class CreateData : Page
     {
+        string newimg = "";
+        ViewModel view = new ViewModel();
+        public List<AgentType> buffer;
         public CreateData()
         {
             InitializeComponent();
+            buffer = DataBase.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
+            typeag.SelectedValue = "ID";
+            typeag.DisplayMemberPath = "Title";
+            typeag.SelectedIndex = 1;
+        }
+
+        private void NewImage(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+
+        private void NewZapis(object sender, RoutedEventArgs e)
+        {
+
         }
     }
 }