Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb

Public Class frmShowOrders
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnFind As System.Windows.Forms.Button
    Friend WithEvents grdOrders As System.Windows.Forms.DataGrid
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents dsCustOrders As System.Data.DataSet
    Friend WithEvents daCustomers As System.Data.SqlClient.SqlDataAdapter
    Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
    Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
    Friend WithEvents daOrders As System.Data.OleDb.OleDbDataAdapter
    Friend WithEvents txtCustID As System.Windows.Forms.TextBox
    Friend WithEvents lstCustomer As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txtCustID = New System.Windows.Forms.TextBox
        Me.btnFind = New System.Windows.Forms.Button
        Me.grdOrders = New System.Windows.Forms.DataGrid
        Me.lstCustomer = New System.Windows.Forms.ListBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.dsCustOrders = New System.Data.DataSet
        Me.daCustomers = New System.Data.SqlClient.SqlDataAdapter
        Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
        Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
        Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
        Me.daOrders = New System.Data.OleDb.OleDbDataAdapter
        Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
        Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
        CType(Me.grdOrders, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dsCustOrders, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'txtCustID
        '
        Me.txtCustID.Location = New System.Drawing.Point(16, 24)
        Me.txtCustID.Name = "txtCustID"
        Me.txtCustID.Size = New System.Drawing.Size(64, 20)
        Me.txtCustID.TabIndex = 0
        Me.txtCustID.Text = "TextBox1"
        '
        'btnFind
        '
        Me.btnFind.Location = New System.Drawing.Point(88, 24)
        Me.btnFind.Name = "btnFind"
        Me.btnFind.TabIndex = 1
        Me.btnFind.Text = "Znajdź"
        '
        'grdOrders
        '
        Me.grdOrders.DataMember = ""
        Me.grdOrders.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.grdOrders.Location = New System.Drawing.Point(176, 24)
        Me.grdOrders.Name = "grdOrders"
        Me.grdOrders.Size = New System.Drawing.Size(472, 336)
        Me.grdOrders.TabIndex = 2
        '
        'lstCustomer
        '
        Me.lstCustomer.Location = New System.Drawing.Point(16, 80)
        Me.lstCustomer.Name = "lstCustomer"
        Me.lstCustomer.Size = New System.Drawing.Size(144, 277)
        Me.lstCustomer.TabIndex = 3
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 64)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(104, 16)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "Klient:"
        '
        'dsCustOrders
        '
        Me.dsCustOrders.DataSetName = "NewDataSet"
        Me.dsCustOrders.Locale = New System.Globalization.CultureInfo("pl-PL")
        '
        'daCustomers
        '
        Me.daCustomers.DeleteCommand = Me.SqlDeleteCommand1
        Me.daCustomers.InsertCommand = Me.SqlInsertCommand1
        Me.daCustomers.SelectCommand = Me.SqlSelectCommand1
        Me.daCustomers.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "tblKlienci", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("Imie", "Imie"), New System.Data.Common.DataColumnMapping("Nazwisko", "Nazwisko"), New System.Data.Common.DataColumnMapping("Firma", "Firma"), New System.Data.Common.DataColumnMapping("Adres", "Adres"), New System.Data.Common.DataColumnMapping("Miasto", "Miasto"), New System.Data.Common.DataColumnMapping("Wojewodztwo", "Wojewodztwo"), New System.Data.Common.DataColumnMapping("KodPocztowy", "KodPocztowy"), New System.Data.Common.DataColumnMapping("Telefon", "Telefon"), New System.Data.Common.DataColumnMapping("Faks", "Faks"), New System.Data.Common.DataColumnMapping("Email", "Email"), New System.Data.Common.DataColumnMapping("NazwiskoSoundex", "NazwiskoSoundex")})})
        Me.daCustomers.UpdateCommand = Me.SqlUpdateCommand1
        '
        'SqlDeleteCommand1
        '
        Me.SqlDeleteCommand1.CommandText = "DELETE FROM tblKlienci WHERE (ID = @Original_ID) AND (Adres = @Original_Adres OR " & _
        "@Original_Adres IS NULL AND Adres IS NULL) AND (Email = @Original_Email OR @Orig" & _
        "inal_Email IS NULL AND Email IS NULL) AND (Faks = @Original_Faks OR @Original_Fa" & _
        "ks IS NULL AND Faks IS NULL) AND (Firma = @Original_Firma OR @Original_Firma IS " & _
        "NULL AND Firma IS NULL) AND (Imie = @Original_Imie OR @Original_Imie IS NULL AND" & _
        " Imie IS NULL) AND (KodPocztowy = @Original_KodPocztowy OR @Original_KodPocztowy" & _
        " IS NULL AND KodPocztowy IS NULL) AND (Miasto = @Original_Miasto OR @Original_Mi" & _
        "asto IS NULL AND Miasto IS NULL) AND (Nazwisko = @Original_Nazwisko OR @Original" & _
        "_Nazwisko IS NULL AND Nazwisko IS NULL) AND (NazwiskoSoundex = @Original_Nazwisk" & _
        "oSoundex OR @Original_NazwiskoSoundex IS NULL AND NazwiskoSoundex IS NULL) AND (" & _
        "Telefon = @Original_Telefon OR @Original_Telefon IS NULL AND Telefon IS NULL) AN" & _
        "D (Wojewodztwo = @Original_Wojewodztwo OR @Original_Wojewodztwo IS NULL AND Woje" & _
        "wodztwo IS NULL)"
        Me.SqlDeleteCommand1.Connection = Me.SqlConnection1
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Adres", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Adres", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Email", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Email", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Faks", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Faks", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Firma", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Firma", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Imie", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Imie", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_KodPocztowy", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KodPocztowy", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Miasto", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Miasto", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Nazwisko", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Nazwisko", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NazwiskoSoundex", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NazwiskoSoundex", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Telefon", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Telefon", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Wojewodztwo", System.Data.SqlDbType.VarChar, 3, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Wojewodztwo", System.Data.DataRowVersion.Original, Nothing))
        '
        'SqlConnection1
        '
        Me.SqlConnection1.ConnectionString = "workstation id=WER;packet size=4096;integrated security=SSPI;data source=WER;pers" & _
        "ist security info=False;initial catalog=Nowinki"
        '
        'SqlInsertCommand1
        '
        Me.SqlInsertCommand1.CommandText = "INSERT INTO tblKlienci(Imie, Nazwisko, Firma, Adres, Miasto, Wojewodztwo, KodPocz" & _
        "towy, Telefon, Faks, Email, NazwiskoSoundex) VALUES (@Imie, @Nazwisko, @Firma, @" & _
        "Adres, @Miasto, @Wojewodztwo, @KodPocztowy, @Telefon, @Faks, @Email, @NazwiskoSo" & _
        "undex); SELECT ID, Imie, Nazwisko, Firma, Adres, Miasto, Wojewodztwo, KodPocztow" & _
        "y, Telefon, Faks, Email, NazwiskoSoundex FROM tblKlienci WHERE (ID = @@IDENTITY)" & _
        ""
        Me.SqlInsertCommand1.Connection = Me.SqlConnection1
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Imie", System.Data.SqlDbType.VarChar, 20, "Imie"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Nazwisko", System.Data.SqlDbType.VarChar, 30, "Nazwisko"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Firma", System.Data.SqlDbType.VarChar, 50, "Firma"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Adres", System.Data.SqlDbType.VarChar, 50, "Adres"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Miasto", System.Data.SqlDbType.VarChar, 30, "Miasto"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Wojewodztwo", System.Data.SqlDbType.VarChar, 3, "Wojewodztwo"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@KodPocztowy", System.Data.SqlDbType.VarChar, 6, "KodPocztowy"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Telefon", System.Data.SqlDbType.VarChar, 15, "Telefon"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Faks", System.Data.SqlDbType.VarChar, 15, "Faks"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Email", System.Data.SqlDbType.VarChar, 100, "Email"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NazwiskoSoundex", System.Data.SqlDbType.VarChar, 4, "NazwiskoSoundex"))
        '
        'SqlSelectCommand1
        '
        Me.SqlSelectCommand1.CommandText = "SELECT ID, Imie, Nazwisko, Firma, Adres, Miasto, Wojewodztwo, KodPocztowy, Telefo" & _
        "n, Faks, Email, NazwiskoSoundex FROM tblKlienci"
        Me.SqlSelectCommand1.Connection = Me.SqlConnection1
        '
        'SqlUpdateCommand1
        '
        Me.SqlUpdateCommand1.CommandText = "UPDATE tblKlienci SET Imie = @Imie, Nazwisko = @Nazwisko, Firma = @Firma, Adres =" & _
        " @Adres, Miasto = @Miasto, Wojewodztwo = @Wojewodztwo, KodPocztowy = @KodPocztow" & _
        "y, Telefon = @Telefon, Faks = @Faks, Email = @Email, NazwiskoSoundex = @Nazwisko" & _
        "Soundex WHERE (ID = @Original_ID) AND (Adres = @Original_Adres OR @Original_Adre" & _
        "s IS NULL AND Adres IS NULL) AND (Email = @Original_Email OR @Original_Email IS " & _
        "NULL AND Email IS NULL) AND (Faks = @Original_Faks OR @Original_Faks IS NULL AND" & _
        " Faks IS NULL) AND (Firma = @Original_Firma OR @Original_Firma IS NULL AND Firma" & _
        " IS NULL) AND (Imie = @Original_Imie OR @Original_Imie IS NULL AND Imie IS NULL)" & _
        " AND (KodPocztowy = @Original_KodPocztowy OR @Original_KodPocztowy IS NULL AND K" & _
        "odPocztowy IS NULL) AND (Miasto = @Original_Miasto OR @Original_Miasto IS NULL A" & _
        "ND Miasto IS NULL) AND (Nazwisko = @Original_Nazwisko OR @Original_Nazwisko IS N" & _
        "ULL AND Nazwisko IS NULL) AND (NazwiskoSoundex = @Original_NazwiskoSoundex OR @O" & _
        "riginal_NazwiskoSoundex IS NULL AND NazwiskoSoundex IS NULL) AND (Telefon = @Ori" & _
        "ginal_Telefon OR @Original_Telefon IS NULL AND Telefon IS NULL) AND (Wojewodztwo" & _
        " = @Original_Wojewodztwo OR @Original_Wojewodztwo IS NULL AND Wojewodztwo IS NUL" & _
        "L); SELECT ID, Imie, Nazwisko, Firma, Adres, Miasto, Wojewodztwo, KodPocztowy, T" & _
        "elefon, Faks, Email, NazwiskoSoundex FROM tblKlienci WHERE (ID = @ID)"
        Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Imie", System.Data.SqlDbType.VarChar, 20, "Imie"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Nazwisko", System.Data.SqlDbType.VarChar, 30, "Nazwisko"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Firma", System.Data.SqlDbType.VarChar, 50, "Firma"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Adres", System.Data.SqlDbType.VarChar, 50, "Adres"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Miasto", System.Data.SqlDbType.VarChar, 30, "Miasto"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Wojewodztwo", System.Data.SqlDbType.VarChar, 3, "Wojewodztwo"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@KodPocztowy", System.Data.SqlDbType.VarChar, 6, "KodPocztowy"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Telefon", System.Data.SqlDbType.VarChar, 15, "Telefon"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Faks", System.Data.SqlDbType.VarChar, 15, "Faks"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Email", System.Data.SqlDbType.VarChar, 100, "Email"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@NazwiskoSoundex", System.Data.SqlDbType.VarChar, 4, "NazwiskoSoundex"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Adres", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Adres", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Email", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Email", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Faks", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Faks", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Firma", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Firma", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Imie", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Imie", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_KodPocztowy", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KodPocztowy", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Miasto", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Miasto", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Nazwisko", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Nazwisko", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_NazwiskoSoundex", System.Data.SqlDbType.VarChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "NazwiskoSoundex", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Telefon", System.Data.SqlDbType.VarChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Telefon", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Wojewodztwo", System.Data.SqlDbType.VarChar, 3, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Wojewodztwo", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4, "ID"))
        '
        'daOrders
        '
        Me.daOrders.DeleteCommand = Me.OleDbDeleteCommand1
        Me.daOrders.InsertCommand = Me.OleDbInsertCommand1
        Me.daOrders.SelectCommand = Me.OleDbSelectCommand1
        Me.daOrders.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "tblZamowienia", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("DataZamowienia", "DataZamowienia"), New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("IDKlienta", "IDKlienta"), New System.Data.Common.DataColumnMapping("KwotaZamowienia", "KwotaZamowienia")})})
        Me.daOrders.UpdateCommand = Me.OleDbUpdateCommand1
        '
        'OleDbDeleteCommand1
        '
        Me.OleDbDeleteCommand1.CommandText = "DELETE FROM tblZamowienia WHERE (ID = ?) AND (DataZamowienia = ? OR ? IS NULL AND" & _
        " DataZamowienia IS NULL) AND (IDKlienta = ? OR ? IS NULL AND IDKlienta IS NULL) " & _
        "AND (KwotaZamowienia = ? OR ? IS NULL AND KwotaZamowienia IS NULL)"
        Me.OleDbDeleteCommand1.Connection = Me.OleDbConnection1
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_DataZamowienia", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DataZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_DataZamowienia1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DataZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_IDKlienta", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IDKlienta", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_IDKlienta1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IDKlienta", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_KwotaZamowienia", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KwotaZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_KwotaZamowienia1", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KwotaZamowienia", System.Data.DataRowVersion.Original, Nothing))
        '
        'OleDbConnection1
        '
        Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
        "ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\kod\Rozdział 7\kod\Pr" & _
        "zypadekBiznesowy7\Nowinki.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Globa" & _
        "l Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System databa" & _
        "se=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New " & _
        "Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy L" & _
        "ocale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Ad" & _
        "min;Jet OLEDB:Encrypt Database=False"
        '
        'OleDbInsertCommand1
        '
        Me.OleDbInsertCommand1.CommandText = "INSERT INTO tblZamowienia(DataZamowienia, IDKlienta, KwotaZamowienia) VALUES (?, " & _
        "?, ?)"
        Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("DataZamowienia", System.Data.OleDb.OleDbType.DBDate, 0, "DataZamowienia"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("IDKlienta", System.Data.OleDb.OleDbType.Integer, 0, "IDKlienta"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("KwotaZamowienia", System.Data.OleDb.OleDbType.Currency, 0, "KwotaZamowienia"))
        '
        'OleDbSelectCommand1
        '
        Me.OleDbSelectCommand1.CommandText = "SELECT DataZamowienia, ID, IDKlienta, KwotaZamowienia FROM tblZamowienia"
        Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
        '
        'OleDbUpdateCommand1
        '
        Me.OleDbUpdateCommand1.CommandText = "UPDATE tblZamowienia SET DataZamowienia = ?, IDKlienta = ?, KwotaZamowienia = ? W" & _
        "HERE (ID = ?) AND (DataZamowienia = ? OR ? IS NULL AND DataZamowienia IS NULL) A" & _
        "ND (IDKlienta = ? OR ? IS NULL AND IDKlienta IS NULL) AND (KwotaZamowienia = ? O" & _
        "R ? IS NULL AND KwotaZamowienia IS NULL)"
        Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("DataZamowienia", System.Data.OleDb.OleDbType.DBDate, 0, "DataZamowienia"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("IDKlienta", System.Data.OleDb.OleDbType.Integer, 0, "IDKlienta"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("KwotaZamowienia", System.Data.OleDb.OleDbType.Currency, 0, "KwotaZamowienia"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_ID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_DataZamowienia", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DataZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_DataZamowienia1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DataZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_IDKlienta", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IDKlienta", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_IDKlienta1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "IDKlienta", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_KwotaZamowienia", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KwotaZamowienia", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_KwotaZamowienia1", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "KwotaZamowienia", System.Data.DataRowVersion.Original, Nothing))
        '
        'frmShowOrders
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(664, 381)
        Me.Controls.Add(Me.lstCustomer)
        Me.Controls.Add(Me.grdOrders)
        Me.Controls.Add(Me.btnFind)
        Me.Controls.Add(Me.txtCustID)
        Me.Controls.Add(Me.Label1)
        Me.Name = "frmShowOrders"
        Me.Text = "Wyświetlanie zamówień"
        CType(Me.grdOrders, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dsCustOrders, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private dvOrders As New DataView

    Private Sub frmShowOrders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim rel As DataRelation

        ' Wypełnianie tabel danymi pochodzącymi z baz danych
        daCustomers.Fill(dsCustOrders, "Klienci")
        daOrders.Fill(dsCustOrders, "Zamowienia")

        ' Tworzenie relacji między tabelami
        rel = dsCustOrders.Relations.Add("relKlienciZamowienia", _
          dsCustOrders.Tables("Klienci").Columns("ID"), _
          dsCustOrders.Tables("Zamowienia").Columns("IDKlienta"))

        ' Ustawianie klucza podstawowego tabeli Klienci
        Dim pk(0) As DataColumn
        pk(0) = dsCustOrders.Tables("Klienci").Columns("ID")
        dsCustOrders.Tables("Klienci").PrimaryKey = pk

        ' Ustawianie domyślnego sortowania (dzięki temu będzie działać
        ' metoda Find
        dsCustOrders.Tables("Klienci").DefaultView.Sort = "ID"

    End Sub

    Private Sub btnFind_Click(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles btnFind.Click
        Dim RowNum As Integer
        Dim dvRow As DataRowView
        Dim i As Integer

        If IsNumeric(txtCustID.Text) Then
            RowNum = dsCustOrders.Tables("Klienci"). _
              DefaultView.Find(txtCustID.Text)
            If RowNum <> -1 Then
                dvRow = dsCustOrders.Tables("Klienci"). _
                  DefaultView(RowNum)
                ' Wypełnianie pola listy polami tabeli Klienci
                lstCustomer.Items.Clear()
                For i = 0 To dsCustOrders.Tables( _
                   "Klienci").Columns.Count - 1
                    lstCustomer.Items.Add(dvRow.Item(i))
                Next
                grdOrders.CaptionText = _
                   "Zamówienia klienta nr " & txtCustID.Text
                ' Pobieranie wierszy podrzędnych wybranego klienta
                dvOrders = dvRow.CreateChildView("relKlienciZamowienia")
                grdOrders.DataSource = dvOrders
            Else
                MessageBox.Show( _
                  "Nie znaleziono klienta  - proszę spróbować jeszcze raz.")
                txtCustID.Clear()
            End If
        Else
            Beep()
        End If
    End Sub

End Class
