]> fbox.kageds.com Git - NEATEST.git/commitdiff
Read/Write pictures to Games table
authorgareth <ge@kagesys.com>
Thu, 14 May 2020 13:51:49 +0000 (14:51 +0100)
committergareth <ge@kagesys.com>
Thu, 14 May 2020 13:51:49 +0000 (14:51 +0100)
16 files changed:
Game Icons/Astroids.png [deleted file]
Game Icons/Frogger.png [deleted file]
NEA/AddGame.xaml [new file with mode: 0644]
NEA/AddGame.xaml.vb [new file with mode: 0644]
NEA/GarethGames Full.png [new file with mode: 0644]
NEA/GarethGames.png [new file with mode: 0644]
NEA/NEA.accdb
NEA/NEA.vbproj
NEA/SignUp.xaml.vb
NEA/Store.xaml
NEA/Store.xaml.vb
NEA/mainwindow.xaml.vb
NEA/search.png [new file with mode: 0644]
Pictures/GarethGames Full.png [new file with mode: 0644]
Pictures/GarethGames.png [new file with mode: 0644]
Pictures/search.png [new file with mode: 0644]

diff --git a/Game Icons/Astroids.png b/Game Icons/Astroids.png
deleted file mode 100644 (file)
index 3e2ad23..0000000
Binary files a/Game Icons/Astroids.png and /dev/null differ
diff --git a/Game Icons/Frogger.png b/Game Icons/Frogger.png
deleted file mode 100644 (file)
index 3d16573..0000000
Binary files a/Game Icons/Frogger.png and /dev/null differ
diff --git a/NEA/AddGame.xaml b/NEA/AddGame.xaml
new file mode 100644 (file)
index 0000000..6dcf148
--- /dev/null
@@ -0,0 +1,13 @@
+<Window x:Class="AddGame"
+        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:NEA"
+        mc:Ignorable="d"
+        Title="AddGame" Height="450" Width="800">
+    <Grid>
+        <Button x:Name="bntadd" Content="Button" HorizontalAlignment="Left" Height="33" Margin="63,59,0,0" VerticalAlignment="Top" Width="105"/>
+
+    </Grid>
+</Window>
diff --git a/NEA/AddGame.xaml.vb b/NEA/AddGame.xaml.vb
new file mode 100644 (file)
index 0000000..3a1efa4
--- /dev/null
@@ -0,0 +1,62 @@
+Imports System.Data
+Imports System.Drawing
+Imports System.IO
+Imports Microsoft.Win32
+Public Class AddGame
+    Dim cmd As New OleDb.OleDbCommand
+    Dim da3 As New OleDb.OleDbDataAdapter
+    Dim result As Integer
+    Dim imgpath As String
+    Dim arrImage() As Byte
+    Dim sql As String
+    Dim fileUri As Uri
+
+    Dim ds As New NEADataSet
+    Dim da As New NEADataSetTableAdapters.GamesTableAdapter
+    Dim dt As New NEADataSet.GamesDataTable
+
+
+    Private Sub Bntadd_Click(sender As Object, e As RoutedEventArgs) Handles bntadd.Click
+        Dim dr As NEADataSet.GamesRow
+
+
+        Try
+            Dim OFD As FileDialog = New OpenFileDialog()
+
+            OFD.Filter = "Image File (*.jpg;*.bmp;*.gif;*.png)|*.jpg;*.bmp;*.gif;*.png"
+
+            OFD.ShowDialog()
+
+            imgpath = OFD.FileName
+            fileUri = New Uri(OFD.FileName)
+
+
+
+            OFD = Nothing
+
+
+        Catch ex As Exception
+            MsgBox(ex.Message.ToString())
+        End Try
+
+        dr = dt.NewGamesRow()
+        dr.Item("Name") = "Hello"
+        If imgpath <> "" Then
+            Dim img As Image = Image.FromFile(imgpath)
+            Dim bArr As Byte() = imgToByteArray(img)
+            dr.Item("Icon") = bArr
+
+        End If
+        dt.AddGamesRow(dr)
+        da.Update(dt)
+        dt.Dispose()
+        da.Dispose()
+    End Sub
+    Private Function imgToByteArray(ByVal img As Image) As Byte()
+        Using mStream As New MemoryStream()
+            img.Save(mStream, Imaging.ImageFormat.Jpeg)
+            Return mStream.GetBuffer()
+        End Using
+    End Function
+
+End Class
diff --git a/NEA/GarethGames Full.png b/NEA/GarethGames Full.png
new file mode 100644 (file)
index 0000000..df0305c
Binary files /dev/null and b/NEA/GarethGames Full.png differ
diff --git a/NEA/GarethGames.png b/NEA/GarethGames.png
new file mode 100644 (file)
index 0000000..65df956
Binary files /dev/null and b/NEA/GarethGames.png differ
index e4baf044f67aa467b7a1b6bc77b7e1e7c4dc9e02..a5e74da0200348a2e7e3e9463b52ba97a8dc7780 100644 (file)
Binary files a/NEA/NEA.accdb and b/NEA/NEA.accdb differ
index 636d98c31bcf9a0aafc3f506c822629f9cbb99f4..9858b732f082a56da3d6a5c59973c0dac4bb2e5b 100644 (file)
@@ -80,6 +80,9 @@
     <Compile Include="Achievemants.xaml.vb">
       <DependentUpon>Achievemants.xaml</DependentUpon>
     </Compile>
+    <Compile Include="AddGame.xaml.vb">
+      <DependentUpon>AddGame.xaml</DependentUpon>
+    </Compile>
     <Compile Include="fmProfile.xaml.vb">
       <DependentUpon>fmProfile.xaml</DependentUpon>
     </Compile>
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="AddGame.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="fmProfile.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </COMReference>
   </ItemGroup>
   <ItemGroup>
+    <Resource Include="search.png" />
+    <Resource Include="GarethGames Full.png" />
+    <Resource Include="GarethGames.png" />
     <Content Include="NEA.accdb">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
index ce33a2e785dd88188e12032548d4b98f4daa7f58..05ff931f784a5f7aa95d605a76974240ef62d995 100644 (file)
@@ -1,4 +1,4 @@
-' This is a comment
+
 Imports System.Data
 Imports System.Drawing
 Imports System.IO
@@ -46,10 +46,9 @@ Public Class SignUp
         If imgpath <> "" Then
             Dim img As Image = Image.FromFile(imgpath)
             Dim bArr As Byte() = imgToByteArray(img)
-            '   da.InsertQuery(txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtTown.Text, txtPostcode.Text, CardNum, CVC, txtIGN.Text, txtEmail.Text, bArr)
             dr.Item("ProfilePic") = bArr
         End If
-        '
+
         dt.AddUser_DetailsRow(dr)
         da.Update(dt)
         MsgBox("Your data has been successfully added")
@@ -107,14 +106,6 @@ Public Class SignUp
             MsgBox(ex.Message.ToString())
         End Try
     End Sub
-
-    '    Private Sub txtIGN_LostFocus(sender As Object, e As RoutedEventArgs) Handles txtIGN.LostFocus
-    '   If txtIGN.Text <> "In Game Name" Then
-    '          lblIGN.Content = txtIGN
-    ' End If
-    'End Sub
-
-    'convert image to bytearray
     Private Function imgToByteArray(ByVal img As Image) As Byte()
         Using mStream As New MemoryStream()
             img.Save(mStream, Imaging.ImageFormat.Jpeg)
index c181834612ebd1c33689102fa84b3f201133cec2..ec56587b017d42810182087814b3182bed80d3c9 100644 (file)
@@ -5,16 +5,20 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:NEA"
         mc:Ignorable="d"
-        Title="Store">
+        Title="Store"
+        ResizeMode="NoResize"  
+        WindowStartupLocation="CenterScreen" 
+        WindowState="Maximized" Width="1089" Height="719" Background="#FF403939">
     <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="Auto"/>
-            <ColumnDefinition Width="Auto"/>
-        </Grid.ColumnDefinitions>
-        <TextBox x:Name="txtSearch" Grid.Column="1" HorizontalAlignment="Left" Height="27" Margin="589,32,0,0" TextWrapping="Wrap" Text="Search" VerticalAlignment="Top" Width="136"/>
-        <Button x:Name="btnSearch" Content="" Grid.Column="1" HorizontalAlignment="Left" Height="27" Margin="725,32,0,0" VerticalAlignment="Top" Width="24"/>
-        <Image x:Name="imgLogo" Grid.Column="1" HorizontalAlignment="Left" Height="98" Margin="10,81,0,0" VerticalAlignment="Top" Width="243"/>
-        <TextBox Grid.Column="1" HorizontalAlignment="Left" Height="56" Margin="10,179,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="249" FontSize="36"/>
+        <Border x:Name="bor1" BorderBrush="White" BorderThickness="1" Height="41" Margin="1534,262,0,0"  CornerRadius="15" Background="#FF499E3C" HorizontalAlignment="Left" Width="347" VerticalAlignment="Top"/>
+        <Button x:Name="btnSignUp" Content="Sign Up" BorderBrush="#00707070" ClipToBounds="True" Background="#01F4F7FC" Foreground="White" HorizontalAlignment="Left" Width="346" Height="41" VerticalAlignment="Top" Margin="1534,551,0,0" Style="{DynamicResource ButtonStyle1}" />
+        <Label x:Name="lblIGN" Content="" HorizontalAlignment="Left" Height="35" Margin="488,262,0,0" VerticalAlignment="Top" Width="200" Foreground="White" FontSize="18"/>
+        <TextBox x:Name="txtSearch" HorizontalAlignment="Left" Height="30" Margin="663,80,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="257"/>
+        <Button x:Name="btnsearch" Content="Button" HorizontalAlignment="Left" Height="30" Margin="952,80,0,0" VerticalAlignment="Top" Width="59"/>
+        <TextBox x:Name="txtname" HorizontalAlignment="Left" Height="24" Margin="54,158,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="164"/>
+        <Image x:Name="imglogo" HorizontalAlignment="Left" Height="231" Margin="411,262,0,0" VerticalAlignment="Top" Width="259"/>
+        <Button Content="Button" HorizontalAlignment="Left" Height="162" Margin="98,331,0,0" VerticalAlignment="Top" Width="238" Click="Button_Click"/>
+
 
     </Grid>
 </Window>
index 86d563efcbab9230ea342f4c87f4715da4b0d0f7..754a0aff709af297e5b2c75aec5d4a589f13d91d 100644 (file)
@@ -1,6 +1,9 @@
-Public Class Store
-    Private Sub BtnSearch_Click(sender As Object, e As RoutedEventArgs) Handles btnSearch.Click
-        Dim id As String
+Imports System.IO
+Imports System.Drawing
+Public Class Store
+    Dim id As String
+    Private Sub BtnSearch_Click(sender As Object, e As RoutedEventArgs) Handles btnsearch.Click
+
         Dim ds As New NEADataSet
         Dim dr As System.Data.DataRow
         Dim da As New NEADataSetTableAdapters.GamesTableAdapter
         da.Fill(dt)
         For Each dr In dt.Rows
             If String.Compare(dr("Name"), txtSearch.Text) = 0 Then
-                MsgBox(txtSearch.Text & " was found in the database")
+
 
                 Dim Q As String = "[Name] =  '" & txtSearch.Text & "'"
                 Dim result() As NEADataSet.GamesRow = dt.Select(Q)
 
                 id = result(0).GameID
-                MsgBox(ID)
+
 
                 GoTo LineBreak
             End If
 LineBreak:
         ds.Dispose()
 
-        Dim ds2 As New NEADataSet
-        Dim dr2 As System.Data.DataRow
-        Dim da2 As New NEADataSetTableAdapters.GamesTableAdapter
-        Dim dt2 As System.Data.DataTable
-        dt2 = ds2.Tables("Games")
-        da2.Fill(dt2)
-        For Each dr2 In dt2.Rows
-            String.Compare(dr2("GameID"), id) 
-                MsgBox(txtSearch.Text & " was found in the database")
+        For Each dr In dt.Rows
+            If String.Compare(dr("GameID"), id) = 0 Then
+                txtname.AppendText(dr.Item("Name"))
+
+
 
 
+                Dim bytes As [Byte]() = dr.Item("Icon")
+                Dim ms As New MemoryStream(bytes)
 
-                GoTo LineBreak2
+                Dim bi As New BitmapImage()
+                bi.BeginInit()
+                bi.StreamSource = ms
+                bi.EndInit()
+
+                imglogo.Source = bi
+            End If
 
         Next
-        MsgBox("The game you entered is not in the database", vbExclamation)
-LineBreak2:
-        ds2.Dispose()
+    End Sub
+
+    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
+        Dim a As New AddGame()
+        a.Show()
+
     End Sub
 End Class
index aa9f94984ce3ceea3044fd9dfc009d7f86d877bb..d285c85aea4e5efd1bcd0cf992b9796e357173c8 100644 (file)
@@ -20,8 +20,6 @@ Class MainWindow
                 Else
                     Dim A = New Store()
                     A.Show()
-                    Dim P = New fmProfile()
-                    P.Show()
                     Me.Close()
                 End If
                 GoTo LineBreak
@@ -38,27 +36,4 @@ LineBreak:
         Me.Close()
     End Sub
 
-    '    Private Sub txtUserName_MouseEnter(sender As Object, e As MouseEventArgs) Handles txtUserName.MouseEnter
-    '   If txtUserName.Text = "Username" Then
-    '          txtUserName.Text = ""
-    ' End If
-    'End Sub
-    '
-    '   Private Sub txtUserName_MouseLeave(sender As Object, e As MouseEventArgs) Handles txtUserName.MouseLeave
-    '  If txtUserName.Text = "" Then
-    '         txtUserName.Text = "Username"
-    'End If
-    'End Sub
-
-    '    Private Sub txtPassword_MouseEnter(sender As Object, e As MouseEventArgs) Handles txtPassword.MouseEnter
-    '   If txtPassword.Text = "Password" Then
-    '          txtPassword.Text = ""
-    ' End If
-    'End Sub
-
-    '   Private Sub txtPassword_MouseLeave(sender As Object, e As MouseEventArgs) Handles txtPassword.MouseLeave
-    '  If txtPassword.Text = "" Then
-    '         txtPassword.Text = "Password"
-    'End If
-    '  End Sub
 End Class
diff --git a/NEA/search.png b/NEA/search.png
new file mode 100644 (file)
index 0000000..4bd33bc
Binary files /dev/null and b/NEA/search.png differ
diff --git a/Pictures/GarethGames Full.png b/Pictures/GarethGames Full.png
new file mode 100644 (file)
index 0000000..df0305c
Binary files /dev/null and b/Pictures/GarethGames Full.png differ
diff --git a/Pictures/GarethGames.png b/Pictures/GarethGames.png
new file mode 100644 (file)
index 0000000..65df956
Binary files /dev/null and b/Pictures/GarethGames.png differ
diff --git a/Pictures/search.png b/Pictures/search.png
new file mode 100644 (file)
index 0000000..4bd33bc
Binary files /dev/null and b/Pictures/search.png differ