Drenbb před 2 roky
rodič
revize
e32c557a5f

+ 6 - 0
TestDemo.sln

@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Check", "Check\Check.csproj
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ses", "Ses\Ses.csproj", "{FB8AE15A-571D-4A10-82DC-564126DCC8C3}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sect1", "Sect1\Sect1.csproj", "{917C8D27-74B2-47D5-A91D-201E97AC0A38}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,10 @@ Global
 		{FB8AE15A-571D-4A10-82DC-564126DCC8C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{FB8AE15A-571D-4A10-82DC-564126DCC8C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{FB8AE15A-571D-4A10-82DC-564126DCC8C3}.Release|Any CPU.Build.0 = Release|Any CPU
+		{917C8D27-74B2-47D5-A91D-201E97AC0A38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{917C8D27-74B2-47D5-A91D-201E97AC0A38}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{917C8D27-74B2-47D5-A91D-201E97AC0A38}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{917C8D27-74B2-47D5-A91D-201E97AC0A38}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 21 - 0
WpfApp1/Auth.cs

@@ -0,0 +1,21 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace WpfApp1
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Auth
+    {
+        public int id { get; set; }
+        public string Login { get; set; }
+        public string Password { get; set; }
+    }
+}

+ 1 - 1
WpfApp1/MainWindow.xaml.cs

@@ -25,7 +25,7 @@ namespace WpfApp1
             InitializeComponent();
             LoadPages.frmMain = frm;
             BaseConnect.BaseModel = new ToursEntities();
-            LoadPages.frmMain.Navigate(new pgTours());
+            LoadPages.frmMain.Navigate(new pgAuth());
         }
     }
 }

+ 1 - 0
WpfApp1/Model1.Context.cs

@@ -25,6 +25,7 @@ namespace WpfApp1
             throw new UnintentionalCodeFirstException();
         }
     
+        public virtual DbSet<Auth> Auth { get; set; }
         public virtual DbSet<Country> Country { get; set; }
         public virtual DbSet<Hotel> Hotel { get; set; }
         public virtual DbSet<HotelComment> HotelComment { get; set; }

+ 28 - 1
WpfApp1/Model1.edmx

@@ -5,6 +5,14 @@
     <!-- SSDL content -->
     <edmx:StorageModels>
     <Schema Namespace="Хранилище ToursModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+        <EntityType Name="Auth">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Login" Type="varchar" MaxLength="50" Nullable="false" />
+          <Property Name="Password" Type="varchar" MaxLength="50" Nullable="false" />
+        </EntityType>
         <EntityType Name="Country">
           <Key>
             <PropertyRef Name="Code" />
@@ -176,6 +184,7 @@
           </ReferentialConstraint>
         </Association>
         <EntityContainer Name="Хранилище ToursModelContainer">
+          <EntitySet Name="Auth" EntityType="Self.Auth" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Country" EntityType="Self.Country" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Hotel" EntityType="Self.Hotel" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="HotelComment" EntityType="Self.HotelComment" Schema="dbo" store:Type="Tables" />
@@ -222,6 +231,7 @@
     <edmx:ConceptualModels>
       <Schema Namespace="ToursModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
         <EntityContainer Name="ToursEntities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Auth" EntityType="ToursModel.Auth" />
           <EntitySet Name="Country" EntityType="ToursModel.Country" />
           <EntitySet Name="Hotel" EntityType="ToursModel.Hotel" />
           <EntitySet Name="HotelComment" EntityType="ToursModel.HotelComment" />
@@ -253,6 +263,14 @@
             <End Role="Type" EntitySet="Type" />
           </AssociationSet>
         </EntityContainer>
+        <EntityType Name="Auth">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Login" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="false" />
+          <Property Name="Password" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="false" />
+        </EntityType>
         <EntityType Name="Country">
           <Key>
             <PropertyRef Name="Code" />
@@ -379,12 +397,21 @@
           <End Type="ToursModel.Tour" Role="Tour" Multiplicity="*" />
           <End Type="ToursModel.Type" Role="Type" Multiplicity="*" />
         </Association>
-      </Schema>
+        </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
     <edmx:Mappings>
       <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
         <EntityContainerMapping StorageEntityContainer="Хранилище ToursModelContainer" CdmEntityContainer="ToursEntities">
+          <EntitySetMapping Name="Auth">
+            <EntityTypeMapping TypeName="ToursModel.Auth">
+              <MappingFragment StoreEntitySet="Auth">
+                <ScalarProperty Name="Password" ColumnName="Password" />
+                <ScalarProperty Name="Login" ColumnName="Login" />
+                <ScalarProperty Name="id" ColumnName="id" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
           <EntitySetMapping Name="Country">
             <EntityTypeMapping TypeName="ToursModel.Country">
               <MappingFragment StoreEntitySet="Country">

+ 1 - 0
WpfApp1/Model1.edmx.diagram

@@ -5,6 +5,7 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="103e74b4c3fb4331aa80c8b64d8ed690" Name="Diagram1">
+        <EntityTypeShape EntityType="ToursModel.Auth" Width="1.5" PointX="0.75" PointY="0.75" />
         <EntityTypeShape EntityType="ToursModel.Country" Width="1.5" PointX="0.75" PointY="4.875" />
         <EntityTypeShape EntityType="ToursModel.Hotel" Width="1.5" PointX="3" PointY="4.375" />
         <EntityTypeShape EntityType="ToursModel.HotelComment" Width="1.5" PointX="5.25" PointY="3.375" />

+ 10 - 0
WpfApp1/WpfApp1.csproj

@@ -64,6 +64,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="Auth.cs">
+      <DependentUpon>Model1.tt</DependentUpon>
+    </Compile>
     <Compile Include="classes\BaseConnect.cs" />
     <Compile Include="Country.cs">
       <DependentUpon>Model1.tt</DependentUpon>
@@ -86,6 +89,9 @@
     <Compile Include="pgAddHotel.xaml.cs">
       <DependentUpon>pgAddHotel.xaml</DependentUpon>
     </Compile>
+    <Compile Include="pgAuth.xaml.cs">
+      <DependentUpon>pgAuth.xaml</DependentUpon>
+    </Compile>
     <Compile Include="pgHotels.xaml.cs">
       <DependentUpon>pgHotels.xaml</DependentUpon>
     </Compile>
@@ -118,6 +124,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="pgAuth.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="pgHotels.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 19 - 0
WpfApp1/pgAuth.xaml

@@ -0,0 +1,19 @@
+<Page x:Class="WpfApp1.pgAuth"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:WpfApp1"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="pgAuth">
+
+    <Grid>
+        <StackPanel>
+            <TextBox Name="tbLogin"></TextBox>
+            <TextBox Name="tbPass"></TextBox>
+            <Image Name="imgCaptcha" Width="150px" Height="150px"></Image>
+            <Button Content="Войти" Click="Button_Click"></Button>
+        </StackPanel>
+    </Grid>
+</Page>

+ 62 - 0
WpfApp1/pgAuth.xaml.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+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 WpfApp1
+{
+    /// <summary>
+    /// Логика взаимодействия для pgAuth.xaml
+    /// </summary>
+    public partial class pgAuth : Page
+    {
+        public pgAuth()
+        {
+            InitializeComponent();
+            BaseConnect.BaseModel = new ToursEntities();
+            Captha();
+        }
+
+        void Captha()
+        {
+            Random random = new Random();
+            int num = random.Next(1000, 9999);
+            var pixels = new byte[150 * 150 * 4];
+            random.NextBytes(pixels);
+            var visual = new DrawingVisual();
+            BitmapSource bitmapSource = BitmapSource.Create(150, 150, 96, 96, PixelFormats.Pbgra32, null, pixels, 150 * 4);
+            using (DrawingContext drawingContext = visual.RenderOpen())
+            {
+                drawingContext.DrawText(
+                new FormattedText(num.ToString(), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 100, System.Windows.Media.Brushes.Red),
+                new System.Windows.Point(0, 150 / 2));
+
+                drawingContext.DrawImage(bitmapSource, new Rect(0, 0, 256, 256));
+            }
+            var image = new DrawingImage(visual.Drawing);
+            imgCaptcha.Source = image;
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            Auth auth = BaseConnect.BaseModel.Auth.FirstOrDefault(x => x.Login == tbLogin.Text && x.Password == tbPass.Text);
+            if (auth != null)
+            {
+                MessageBox.Show("Auth");
+            }
+            else
+                MessageBox.Show("Dis");
+        }
+    }
+}

+ 1 - 1
WpfApp1/pgTours.xaml

@@ -13,7 +13,7 @@
                 <StackPanel Width="250px" Height="250px">
                     <TextBlock Text="{Binding Name}" HorizontalAlignment="Center"></TextBlock>
                     <Image Source="{Binding ToutImage}" Width="150px" Height="150px"></Image>
-                    <TextBlock Text="{Binding Price}" HorizontalAlignment="Center"></TextBlock>
+                    <TextBlock  Text="{Binding Price, StringFormat=\{0:F\}}"  HorizontalAlignment="Center"></TextBlock>
                     <DockPanel Width="240px">
                         <TextBlock Text="{Binding IsActualStr}" Foreground="{Binding IsActualClor}" HorizontalAlignment="Left"></TextBlock>
                         <TextBlock HorizontalAlignment="Right">