Imagara před 3 roky
rodič
revize
f18c8bbebe

+ 1 - 1
PartsWarehouse/App.config

@@ -14,6 +14,6 @@
     </providers>
   </entityFramework>
 <connectionStrings>
-<add name="EDMEntities" connectionString="metadata=res://*/EDM.csdl|res://*/EDM.ssdl|res://*/EDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=mssql;initial catalog=gr692_gav;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+<add name="EDMEntities" connectionString="metadata=res://*/EDM.csdl|res://*/EDM.ssdl|res://*/EDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\MSSQLLocalDB;initial catalog=PartsWarehouseDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>
 </configuration>

+ 52 - 0
PartsWarehouse/ChangePasswordWindow.xaml

@@ -0,0 +1,52 @@
+<Window x:Class="PartsWarehouse.ChangePasswordWindow"
+        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:PartsWarehouse"
+        mc:Ignorable="d"
+        ResizeMode="NoResize"
+        WindowStartupLocation="CenterScreen"
+        WindowStyle="None"
+        Title="ChangePasswordWindow" 
+        Height="250" 
+        Width="400">
+    <Grid Background="#FF2D2D2D">
+        <StackPanel Orientation="Vertical"
+                    Margin="10">
+            <TextBlock  x:Name="OldPassBox"
+                        Height="50" 
+                        Background="#32353B"
+                        Text="Старый пароль"
+                        FontSize="20"
+                        Foreground="{StaticResource TextColor}"
+                        Margin="0,10,0,10">
+            </TextBlock>
+            <TextBlock  Name="NewPassBox"
+                        Height="50" 
+                        Background="#32353B"
+                        Text="Новый пароль"
+                        FontSize="20"
+                        Foreground="{StaticResource TextColor}"
+                        Margin="0,10,0,10">
+            </TextBlock>
+        </StackPanel>
+        <StackPanel Orientation="Horizontal"
+                    VerticalAlignment="Bottom"
+                    HorizontalAlignment="Center"
+                    Margin="0,0,0,20">
+            <Button 
+            Content="Отмена"
+            Height="40" 
+            Width="120" 
+                Margin="7,0,7,0"
+            Click="BackButton_Click"/>
+            <Button 
+            Content="Сохранить" 
+            Height="40" 
+            Width="120" 
+                Margin="7,0,7,0"
+            Click="Save_Click"/>
+        </StackPanel>
+    </Grid>
+</Window>

+ 26 - 0
PartsWarehouse/ChangePasswordWindow.xaml.cs

@@ -0,0 +1,26 @@
+using System.Linq;
+using System.Windows;
+namespace PartsWarehouse
+{
+    public partial class ChangePasswordWindow : Window
+    {
+        public ChangePasswordWindow()
+        {
+            InitializeComponent();
+        }
+
+        private void Save_Click(object sender, RoutedEventArgs e)
+        {
+            User user = cnt.db.User.Where(item => item.IdUser == Session.userId).FirstOrDefault();
+            if (Encrypt.GetHash(OldPassBox.Text) == user.Password && NewPassBox.Text.Trim() != "" && NewPassBox.Text.Length > 5)
+                user.Password = Encrypt.GetHash(NewPassBox.Text);
+            else
+                new ErrorWindow("Произошла ошибка").ShowDialog();
+        }
+
+        private void BackButton_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 7 - 0
PartsWarehouse/PartsWarehouse.csproj

@@ -67,6 +67,9 @@
     <Compile Include="Car.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Compile Include="ChangePasswordWindow.xaml.cs">
+      <DependentUpon>ChangePasswordWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="cnt.cs" />
     <Compile Include="EDM.Context.cs">
       <AutoGen>True</AutoGen>
@@ -115,6 +118,10 @@
     <Compile Include="СatalogPage.xaml.cs">
       <DependentUpon>СatalogPage.xaml</DependentUpon>
     </Compile>
+    <Page Include="ChangePasswordWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="ErrorWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 4 - 8
PartsWarehouse/ProfilePage.xaml

@@ -32,7 +32,7 @@
                                     Width="420">
                             <Label Content="Логин"
                                Foreground="#FFC9C7C7"/>
-                            <TextBox x:Name="EmailBox"
+                            <TextBox x:Name="LoginBox"
                                      Text="UserLogin"
                                      Margin="3,-5,0,0"
                                      Height="30"
@@ -40,11 +40,6 @@
                                      SelectionBrush="{x:Null}"
                                      Background="{x:Null}"/>
                         </StackPanel>
-                        <Button Width="80"
-                                Content="Изменить"
-                                Margin="0,18,0,0"
-                                HorizontalAlignment="Right">
-                        </Button>
                     </StackPanel>
 
 
@@ -56,7 +51,7 @@
                                     Width="420">
                             <Label Content="Пароль"
                                    Foreground="#FFC9C7C7"/>
-                            <TextBox x:Name="BirthdayBox"
+                            <TextBox x:Name="PasswordBox"
                                Text="***********"
                                Margin="3,-5,0,0"
                                Height="30"
@@ -68,7 +63,8 @@
                         <Button Width="80"
                             Content="Изменить"
                             Margin="0,18,0,0"
-                            HorizontalAlignment="Right">
+                            HorizontalAlignment="Right"
+                                Click="ChangePassButton_Click">
                         </Button>
                     </StackPanel>
 

+ 7 - 0
PartsWarehouse/ProfilePage.xaml.cs

@@ -21,6 +21,8 @@ namespace PartsWarehouse
         {
             InitializeComponent();
             LoadingCars();
+            User user = cnt.db.User.Where(item => item.IdUser == Session.userId).FirstOrDefault();
+            LoginBox.Text = user.Login;
         }
         private void LoadingCars()
         {
@@ -84,5 +86,10 @@ namespace PartsWarehouse
 
             CarsListBox.Items.Add(messageGrid);
         }
+
+        private void ChangePassButton_Click(object sender, RoutedEventArgs e)
+        {
+            new ChangePasswordWindow().ShowDialog();
+        }
     }
 }

+ 0 - 25
PartsWarehouse/СatalogPage.xaml

@@ -107,30 +107,5 @@
                  BorderBrush="{Binding PartsListBox}">
             <ScrollViewer VerticalScrollBarVisibility="Visible"/>
         </ListBox>
-
-        <!--<TextBox Grid.RowSpan="2">
-            <TextBox.ItemsPanel>
-                <ItemsPanelTemplate>
-                    <WrapPanel Orientation="Vertical" Height="100" />
-                </ItemsPanelTemplate>
-            </TextBox.ItemsPanel>
-
-            <ComboBoxItem Content="Value 1" />
-            <ComboBoxItem Content="Value 2" />
-            <ComboBoxItem Content="Value 3" />
-            <ComboBoxItem Content="Value 4" />
-            <ComboBoxItem Content="Value 5" />
-            <ComboBoxItem Content="Value 6" />
-            <ComboBoxItem Content="Value 7" />
-            <ComboBoxItem Content="Value 8" />
-            <ComboBoxItem Content="Value 9" />
-            <ComboBoxItem Content="Value 10" />
-            <ComboBoxItem Content="Value 11" />
-            <ComboBoxItem Content="Value 12" />
-            <ComboBoxItem Content="Value 13" />
-            <ComboBoxItem Content="Value 14" />
-            <ComboBoxItem Content="Value 15" />
-
-        </TextBox>-->
     </Grid>
 </Page>

+ 11 - 15
PartsWarehouse/СatalogPage.xaml.cs

@@ -1,23 +1,14 @@
 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.Navigation;
-using System.Windows.Shapes;
 
 namespace PartsWarehouse
 {
-    /// <summary>
-    /// Логика взаимодействия для СatalogPage.xaml
-    /// </summary>
     public partial class СatalogPage : Page
     {
         public СatalogPage(string carCompany = null, string carName = null, int carGeneration = -1)
@@ -112,6 +103,10 @@ namespace PartsWarehouse
         {
             PartsUpdate();
         }
+        private void OpenPartInfoPage(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new PartInfoPage(1));
+        }
         private void PartsUpdate()
         {
             try
@@ -139,7 +134,7 @@ namespace PartsWarehouse
                         img = new BitmapImage(new Uri("../Resources/NotFound.png", UriKind.RelativeOrAbsolute));
                     else
                         img = ImagesManip.NewImage(part);
-                    AddPart(part.Name, part.Description, part.PartNum, img);
+                    AddPart(part.Name, part.Description, part.PartNum, img, part.Remain, part.Price);
                 }
             }
             catch (Exception ex)
@@ -148,7 +143,7 @@ namespace PartsWarehouse
             }
 
         }
-        private void AddPart(string name, string desc, int partNum, BitmapImage imageSource)
+        private void AddPart(string name, string desc, int partNum, BitmapImage imageSource, int remain, double price)
         {
             Grid partGrid = new Grid();
             partGrid.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x40, 0x44, 0x4B));
@@ -175,12 +170,13 @@ namespace PartsWarehouse
             partNameLabel.VerticalAlignment = VerticalAlignment.Top;
             partNameLabel.Margin = new Thickness(40, 0, 0, 0);
 
-            Label dateLabel = new Label();
-            dateLabel.Content = partNum.ToString();
-            dateLabel.Foreground = Brushes.White;
+            Label partNumLabel = new Label();
+            partNumLabel.Content = $"модель: {partNum}, остаток {remain} по {price}руб.";
+            partNumLabel.Foreground = Brushes.White;
+            partNumLabel.MouseDown += OpenPartInfoPage;
 
             stackpanel.Children.Add(partNameLabel);
-            stackpanel.Children.Add(dateLabel);
+            stackpanel.Children.Add(partNumLabel);
             partGrid.Children.Add(stackpanel);
 
             Label descLabel = new Label();