Skip to content

Commit

Permalink
Produktregistrering og endring ferdig
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhist committed Apr 30, 2012
1 parent 6e04728 commit 5f62435
Show file tree
Hide file tree
Showing 24 changed files with 932 additions and 142 deletions.
11 changes: 11 additions & 0 deletions Program/Program.vbproj
Expand Up @@ -89,6 +89,12 @@
<Compile Include="gui\frmBrukerbehandling.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="gui\frmDialogProduktPris.Designer.vb">
<DependentUpon>frmDialogProduktPris.vb</DependentUpon>
</Compile>
<Compile Include="gui\frmDialogProduktPris.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="gui\frmEndreBruker.Designer.vb">
<DependentUpon>frmEndreBruker.vb</DependentUpon>
</Compile>
Expand Down Expand Up @@ -178,7 +184,9 @@
</Compile>
<Compile Include="Sql.vb" />
<Compile Include="sys\Bruker.vb" />
<Compile Include="sys\ComboBoxValue.vb" />
<Compile Include="sys\Login.vb" />
<Compile Include="sys\Pris.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="frmDatabasetest.resx">
Expand All @@ -187,6 +195,9 @@
<EmbeddedResource Include="gui\frmBrukerbehandling.resx">
<DependentUpon>frmBrukerbehandling.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="gui\frmDialogProduktPris.resx">
<DependentUpon>frmDialogProduktPris.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="gui\frmEndreBruker.resx">
<DependentUpon>frmEndreBruker.vb</DependentUpon>
</EmbeddedResource>
Expand Down
28 changes: 23 additions & 5 deletions Program/Sql.vb
Expand Up @@ -33,9 +33,6 @@ Public Class Sql
con.Open()
Catch ex As MySqlException
Throw New ConnectionException
Finally
con.Close()
con.Dispose()
End Try
End Sub

Expand All @@ -49,6 +46,29 @@ Public Class Sql
End Try
End Sub

Public Function executeQuery(ByVal sql As String) As Integer
Try
If Not (con.State = ConnectionState.Open) Then
kobleTil()
End If

Dim myData As New DataTable
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
myCommand.Connection = con
myCommand.CommandText = sql & ";Select LAST_INSERT_ID();"

myAdapter.SelectCommand = myCommand
myAdapter.Fill(myData)

Return myData.Rows.Item(0)("LAST_INSERT_ID()")
Catch ex As MySqlException
MessageBox.Show("Tilkobling til databasen har feilet " & ex.Message)
End Try

Return 0
End Function

'Utfører en spørring mot databasen
Public Function Query(ByVal sql As String) As DataTable
Dim myData As New DataTable
Expand All @@ -68,8 +88,6 @@ Public Class Sql
myAdapter.Fill(myData)
Catch ex As MySqlException
MessageBox.Show("Tilkobling til databasen har feilet " & ex.Message)
Finally
con.Dispose()
End Try

Return myData
Expand Down
5 changes: 5 additions & 0 deletions Program/gui/frmBrukerbehandling.vb
Expand Up @@ -46,4 +46,9 @@
Private Sub btnLagre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLagre.Click
Me.DialogResult = DialogResult.OK
End Sub

Private Sub frmBrukerbehandling_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
oppkobling.kobleFra()
Me.Dispose()
End Sub
End Class
123 changes: 123 additions & 0 deletions Program/gui/frmDialogProduktPris.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 120 additions & 0 deletions Program/gui/frmDialogProduktPris.resx
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
20 changes: 20 additions & 0 deletions Program/gui/frmDialogProduktPris.vb
@@ -0,0 +1,20 @@
Public Class frmDialogProduktPris
Public pris As Pris

Private Sub btnLagre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLagre.Click
If Not IsNumeric(txtPris.Text) Or Not IsNumeric(txtVarighet.Text) Then
MessageBox.Show("Skriv inn tall", "Feilmelding", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
pris = New Pris(Convert.ToSingle(txtPris.Text), Convert.ToInt32(txtVarighet.Text))
Me.DialogResult = DialogResult.OK
End If
End Sub

Private Sub btnAvbryt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAvbryt.Click
Me.DialogResult = DialogResult.Cancel
End Sub

Private Sub frmDialogProduktPris_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Me.Dispose()
End Sub
End Class
7 changes: 7 additions & 0 deletions Program/gui/frmEndreBruker.vb
Expand Up @@ -21,6 +21,9 @@
Next
Catch ex As Exception
MessageBox.Show("Fikk ikke hentet inn eksisterende brukere", "Feilmelding", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DialogResult = DialogResult.Abort
Finally
oppkobling.kobleFra()
End Try
End Sub

Expand All @@ -38,4 +41,8 @@
MessageBox.Show("Velg bruker", "Feilmelding", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

Private Sub frmEndreBruker_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Me.Dispose()
End Sub
End Class
3 changes: 3 additions & 0 deletions Program/gui/frmEndreKunde.vb
@@ -1,3 +1,6 @@
Public Class frmEndreKunde

Private Sub frmEndreKunde_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Me.Dispose()
End Sub
End Class
3 changes: 3 additions & 0 deletions Program/gui/frmEndrePakke.vb
@@ -1,3 +1,6 @@
Public Class frmEndrePakke

Private Sub frmEndrePakke_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Me.Dispose()
End Sub
End Class

0 comments on commit 5f62435

Please sign in to comment.