فهرست منبع

Окно редактирования

shabanin.serzh@gmail.com 2 سال پیش
والد
کامیت
55be19f064

+ 59 - 0
ShabaninDemoEkz/AddChanged.xaml

@@ -0,0 +1,59 @@
+<Window x:Class="ShabaninDemoEkz.AddChanged"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:ShabaninDemoEkz"
+        mc:Ignorable="d"
+        MinHeight="750"
+        Title="AddChanged" Height="750" Width="800">
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="75"/>
+            <ColumnDefinition Width="157*"/>
+   
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="100"/>
+            <RowDefinition Height="*"></RowDefinition>
+        </Grid.RowDefinitions>
+        <DockPanel Grid.ColumnSpan="3">
+            <Image Source="Resurses/Приятный шелест.png"/>
+            <TextBlock Text="Приятный шелест" FontSize="58"/>
+        </DockPanel>
+
+        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical"  Width="296" Grid.Row="1" Grid.ColumnSpan="2">
+            <GroupBox Header="Наименование" >
+                <TextBox x:Name="TitleTxt" Text="{Binding Title}"/>
+            </GroupBox>
+            <GroupBox Header="Тип агента">
+                <ComboBox Name="TypeA"/>
+            </GroupBox>
+            <GroupBox Header="Адресс">
+                <TextBox x:Name="AdressTxt" Text="{Binding Address}"/>
+            </GroupBox>
+            <GroupBox Header="ИНН">
+                <TextBox x:Name="InnTxt" Text="{Binding INN}"/>
+            </GroupBox>
+            <GroupBox Header="КПП">
+                <TextBox x:Name="KPP" Text="{Binding KPP}"/>
+            </GroupBox>
+            <GroupBox Header="Директор">
+                <TextBox x:Name="DirectorTxt" Text="{Binding DirectorName}"/>
+            </GroupBox>
+            <GroupBox Header="Телефон">
+                <TextBox x:Name="PhoneTxt" Text="{Binding Phone}"/>
+            </GroupBox>
+            <GroupBox Header="E-mail">
+                <TextBox x:Name="EmailTxt" Text="{Binding Email}"/>
+            </GroupBox>
+            <GroupBox Header="Приоритет">
+                <TextBox x:Name="Prioriti" Text="{Binding Priority}"/>
+            </GroupBox>
+            <Button x:Name="SaveBtn" Content="Сохранить" FontSize="20" Margin="0 20 0 0" Click="SaveBtn_Click"/>
+            <Button x:Name="DelBtn" Content="Удалить" FontSize="20" Margin="0 20 0 0" Click="DelBtn_Click"/>
+        </StackPanel>
+
+
+    </Grid>
+</Window>

+ 91 - 0
ShabaninDemoEkz/AddChanged.xaml.cs

@@ -0,0 +1,91 @@
+using System;
+using System.Collections;
+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 ShabaninDemoEkz
+{
+    /// <summary>
+    /// Логика взаимодействия для AddChanged.xaml
+    /// </summary>
+    public partial class AddChanged : Window
+    {
+        IList ls;
+        Agent Agent;
+        public AddChanged(IList lss)
+        {
+            InitializeComponent();
+            ls = lss;
+            foreach (Agent a in lss)
+            {
+                Agent = a;
+            }
+            DataContext = Agent;
+
+            TypeA.ItemsSource = BaseConnect.BaseModel.AgentType.Where(x => x.ID > 0).ToList();
+
+            TypeA.DisplayMemberPath = "Title";
+            TypeA.SelectedValuePath = "ID";
+            TypeA.SelectedIndex = Agent.AgentTypeID - 1;
+
+
+        }
+
+        private void SaveBtn_Click(object sender, RoutedEventArgs e)
+        {
+
+            try
+            {
+                if (Convert.ToInt32(Prioriti.Text) >= 0)
+                {
+                    MessageBoxResult dialogResult = MessageBox.Show("Сохранить?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Information);
+                    if (dialogResult == MessageBoxResult.Yes)
+                    {
+                        Agent.AgentTypeID = TypeA.SelectedIndex + 1;
+                        BaseConnect.BaseModel.SaveChanges();
+                        MessageBox.Show("Изменения сохранены", "Сохранение изменений", MessageBoxButton.OK, MessageBoxImage.Information);
+                    }
+
+
+                }
+                else
+                {
+                    MessageBox.Show("Ошибка сохранения", "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
+            }
+            catch
+            {
+                MessageBox.Show("Ошибка сохранения", "Ошибка сохранения", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void DelBtn_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                MessageBoxResult dialogResult = MessageBox.Show("Удалить?", "Удаление", MessageBoxButton.YesNo, MessageBoxImage.Information);
+                if (dialogResult == MessageBoxResult.Yes)
+                {
+                    BaseConnect.BaseModel.Agent.Remove(Agent);
+                    BaseConnect.BaseModel.SaveChanges();
+                    MessageBox.Show("Запись удалена", "Удаление", MessageBoxButton.OK, MessageBoxImage.Information);
+                    this.Hide();
+                }
+            }
+            catch
+            {
+                MessageBox.Show("Ошибка удаления", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+    }
+}

+ 10 - 0
ShabaninDemoEkz/App.xaml

@@ -17,5 +17,15 @@
         <Style TargetType="ComboBox">
             <Setter Property="FontFamily" Value="Monotype Corsiva"/>
         </Style>
+
+        <Style TargetType="TextBox">
+            <Setter Property="FontFamily" Value="Monotype Corsiva"/>
+            <Setter Property="FontSize" Value="20"/>
+        </Style>
+
+        <Style TargetType="GroupBox">
+            <Setter Property="FontFamily" Value="Monotype Corsiva"/>
+            <Setter Property="FontSize" Value="20"/>
+        </Style>
     </Application.Resources>
 </Application>

+ 15 - 10
ShabaninDemoEkz/ChangedPrior.xaml.cs

@@ -57,23 +57,28 @@ namespace ShabaninDemoEkz
 
         private void SaveP_Click(object sender, RoutedEventArgs e)
         {
-            if (Convert.ToInt32(priorTxt.Text) > 0 && priorTxt.Text != "")
+            try
             {
-                MessageBoxResult dialogResult = MessageBox.Show("Сохранить?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Information);
-                if (dialogResult == MessageBoxResult.Yes)
+                if (Convert.ToInt32(priorTxt.Text) >= 0 && priorTxt.Text != "")
                 {
-                    changed();
-                    BaseConnect.BaseModel.SaveChanges();
-                    MessageBox.Show("Изменения сохранены", "Сохранение изменений", MessageBoxButton.OK, MessageBoxImage.Information);
+                    MessageBoxResult dialogResult = MessageBox.Show("Сохранить?", "Сохранение", MessageBoxButton.YesNo, MessageBoxImage.Information);
+                    if (dialogResult == MessageBoxResult.Yes)
+                    {
+                        changed();
+                        BaseConnect.BaseModel.SaveChanges();
+                        MessageBox.Show("Изменения сохранены", "Сохранение изменений", MessageBoxButton.OK, MessageBoxImage.Information);
+                    }
+                }
+                else
+                {
+                    MessageBox.Show("Неверный формат приоритета", "Ошибка формата", MessageBoxButton.OK, MessageBoxImage.Error);
+
                 }
             }
-            else
-            {
+            catch {
                 MessageBox.Show("Неверный формат приоритета", "Ошибка формата", MessageBoxButton.OK, MessageBoxImage.Error);
-
             }
 
-
         }
     }
 }

+ 0 - 0
ShabaninDemoEkz/ProdAgent.cs → ShabaninDemoEkz/Clases/ProdAgent.cs


+ 1 - 1
ShabaninDemoEkz/MainWindow.xaml

@@ -8,7 +8,7 @@
         Title="Агенты" Height="450" Width="800"
         Icon="Resurses/Приятный шелест.ico"
         >
-    <Grid>
+    <Grid Background="#C6D7FF">
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="75"/>
             <ColumnDefinition Width="*"/>

+ 1 - 1
ShabaninDemoEkz/Pages/AgentPage.xaml

@@ -69,6 +69,6 @@
             </GroupBox>
             <Button x:Name="ChangePrior" Content="Изменить приоритет на ..." Height="45" Visibility="Collapsed" Click="ChangePrior_Click"/>
         </StackPanel>
-        <ListView x:Name="AgentList" ItemTemplate="{StaticResource ListAgentD}" Grid.ColumnSpan="2" Grid.Row="1" SelectionMode="Extended" SelectionChanged="AgentList_SelectionChanged"/>
+        <ListView x:Name="AgentList" ItemTemplate="{StaticResource ListAgentD}" Grid.ColumnSpan="2" Grid.Row="1" SelectionMode="Extended" SelectionChanged="AgentList_SelectionChanged" MouseDoubleClick="AgentList_MouseDoubleClick"/>
     </Grid>
 </Page>

+ 9 - 0
ShabaninDemoEkz/Pages/AgentPage.xaml.cs

@@ -125,6 +125,15 @@ namespace ShabaninDemoEkz
         {
             IList ls = AgentList.SelectedItems;
             new ChangedPrior(ls).ShowDialog();
+            Filter();
+        }
+
+        private void AgentList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            IList ls = AgentList.SelectedItems;
+            new AddChanged(ls).ShowDialog();
+            VM = new VModel();
+            Filter();
         }
     }
 }

+ 8 - 1
ShabaninDemoEkz/ShabaninDemoEkz.csproj

@@ -64,6 +64,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="AddChanged.xaml.cs">
+      <DependentUpon>AddChanged.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Agent.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -94,7 +97,7 @@
       <DesignTime>True</DesignTime>
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
-    <Compile Include="ProdAgent.cs" />
+    <Compile Include="Clases\ProdAgent.cs" />
     <Compile Include="Product.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -117,6 +120,10 @@
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
     <Compile Include="Clases\VModel.cs" />
+    <Page Include="AddChanged.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="ChangedPrior.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>