Public Class NewDatabase
    Inherits System.Windows.Forms.Form

    Public request As New IFormData()
    Public response As New IFormData()


#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

    Public Sub New(ByVal anyRequest As IFormData)
        MyBase.New()

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

        'Add any initialization after the InitializeComponent() call
        Me.request = anyRequest
        txtServer.Text = request.serverName
        txtServer.ForeColor = Color.Black
    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 Label1 As System.Windows.Forms.Label
    Friend WithEvents txtServer As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtDatabase As System.Windows.Forms.TextBox
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
    Friend WithEvents txtLogin As System.Windows.Forms.TextBox
    Friend WithEvents txtPassword As System.Windows.Forms.TextBox
    Friend WithEvents btnAccept As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents lblPassword As System.Windows.Forms.Label
    Friend WithEvents lblLogin As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtServer = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtDatabase = New System.Windows.Forms.TextBox()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.txtPassword = New System.Windows.Forms.TextBox()
        Me.lblPassword = New System.Windows.Forms.Label()
        Me.txtLogin = New System.Windows.Forms.TextBox()
        Me.lblLogin = New System.Windows.Forms.Label()
        Me.RadioButton2 = New System.Windows.Forms.RadioButton()
        Me.RadioButton1 = New System.Windows.Forms.RadioButton()
        Me.btnAccept = New System.Windows.Forms.Button()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 19)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(136, 16)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Server:"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txtServer
        '
        Me.txtServer.Enabled = False
        Me.txtServer.Location = New System.Drawing.Point(160, 16)
        Me.txtServer.Name = "txtServer"
        Me.txtServer.Size = New System.Drawing.Size(240, 20)
        Me.txtServer.TabIndex = 1
        Me.txtServer.Text = ""
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(16, 42)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(136, 16)
        Me.Label2.TabIndex = 2
        Me.Label2.Text = "New Database Name:"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txtDatabase
        '
        Me.txtDatabase.Location = New System.Drawing.Point(160, 40)
        Me.txtDatabase.Name = "txtDatabase"
        Me.txtDatabase.Size = New System.Drawing.Size(240, 20)
        Me.txtDatabase.TabIndex = 3
        Me.txtDatabase.Text = ""
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtPassword, Me.lblPassword, Me.txtLogin, Me.lblLogin, Me.RadioButton2, Me.RadioButton1})
        Me.GroupBox1.Location = New System.Drawing.Point(16, 72)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(384, 128)
        Me.GroupBox1.TabIndex = 4
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Authentication"
        '
        'txtPassword
        '
        Me.txtPassword.Enabled = False
        Me.txtPassword.Location = New System.Drawing.Point(176, 96)
        Me.txtPassword.MaxLength = 20
        Me.txtPassword.Name = "txtPassword"
        Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtPassword.Size = New System.Drawing.Size(192, 20)
        Me.txtPassword.TabIndex = 5
        Me.txtPassword.Text = ""
        '
        'lblPassword
        '
        Me.lblPassword.Enabled = False
        Me.lblPassword.Location = New System.Drawing.Point(64, 96)
        Me.lblPassword.Name = "lblPassword"
        Me.lblPassword.Size = New System.Drawing.Size(100, 16)
        Me.lblPassword.TabIndex = 4
        Me.lblPassword.Text = "Password:"
        Me.lblPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'txtLogin
        '
        Me.txtLogin.Enabled = False
        Me.txtLogin.Location = New System.Drawing.Point(176, 72)
        Me.txtLogin.MaxLength = 20
        Me.txtLogin.Name = "txtLogin"
        Me.txtLogin.Size = New System.Drawing.Size(192, 20)
        Me.txtLogin.TabIndex = 3
        Me.txtLogin.Text = ""
        '
        'lblLogin
        '
        Me.lblLogin.Enabled = False
        Me.lblLogin.Location = New System.Drawing.Point(64, 72)
        Me.lblLogin.Name = "lblLogin"
        Me.lblLogin.Size = New System.Drawing.Size(100, 16)
        Me.lblLogin.TabIndex = 2
        Me.lblLogin.Text = "Login Name:"
        Me.lblLogin.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'RadioButton2
        '
        Me.RadioButton2.Location = New System.Drawing.Point(16, 40)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(352, 24)
        Me.RadioButton2.TabIndex = 1
        Me.RadioButton2.Text = "Use SQL Server Authentication"
        '
        'RadioButton1
        '
        Me.RadioButton1.Checked = True
        Me.RadioButton1.Location = New System.Drawing.Point(16, 16)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(352, 24)
        Me.RadioButton1.TabIndex = 0
        Me.RadioButton1.TabStop = True
        Me.RadioButton1.Text = "Use Secure Login  (NT Integrated Security)"
        '
        'btnAccept
        '
        Me.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.btnAccept.Enabled = False
        Me.btnAccept.Location = New System.Drawing.Point(240, 216)
        Me.btnAccept.Name = "btnAccept"
        Me.btnAccept.TabIndex = 5
        Me.btnAccept.Text = "Ok"
        '
        'btnCancel
        '
        Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnCancel.Location = New System.Drawing.Point(328, 216)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.TabIndex = 6
        Me.btnCancel.Text = "Cancel"
        '
        'NewDatabase
        '
        Me.AcceptButton = Me.btnAccept
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.CancelButton = Me.btnCancel
        Me.ClientSize = New System.Drawing.Size(416, 246)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnAccept, Me.GroupBox1, Me.txtDatabase, Me.Label2, Me.txtServer, Me.Label1})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "NewDatabase"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "New Database"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
        With response
            .databaseName = txtDatabase.Text
            .serverAuthentication = RadioButton1.Checked
            .windowsAuthentication = RadioButton2.Checked
            .userId = txtLogin.Text
            .password = txtPassword.Text
        End With
        Me.DialogResult = DialogResult.OK
    End Sub

    Private Sub txtDatabase_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDatabase.TextChanged
        If txtDatabase.Text.Length() < 1 Then
            Me.btnAccept.Enabled = False
        Else
            Me.btnAccept.Enabled = True
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        RefreshControls(RadioButton2.Checked)
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        RefreshControls(RadioButton2.Checked)
    End Sub

    Private Sub RefreshControls(ByVal isEnabled As Boolean)
        Me.lblLogin.Enabled = isEnabled
        Me.txtLogin.Enabled = isEnabled
        Me.lblPassword.Enabled = isEnabled
        Me.txtPassword.Enabled = isEnabled
    End Sub
End Class


#Region " Form.Response Definition "

Public Class IFormData
    Dim _serverName As String
    Dim _databaseName As String
    Dim _windowsAuthentication As Boolean
    Dim _serverAuthentication As Boolean
    Dim _userId As String
    Dim _password As String
    Property serverName()
        Get
            Return _serverName
        End Get
        Set(ByVal Value)
            _serverName = Value
        End Set
    End Property
    Property databaseName()
        Get
            Return _databaseName
        End Get
        Set(ByVal Value)
            _databaseName = Value
        End Set
    End Property
    Property windowsAuthentication()
        Get
            Return _windowsAuthentication
        End Get
        Set(ByVal Value)
            _windowsAuthentication = Value
        End Set
    End Property
    Property serverAuthentication()
        Get
            Return _serverAuthentication
        End Get
        Set(ByVal Value)
            _serverAuthentication = Value
        End Set
    End Property
    Property userId()
        Get
            Return _userId
        End Get
        Set(ByVal Value)
            _userId = Value
        End Set
    End Property
    Property password()
        Get
            Return _password
        End Get
        Set(ByVal Value)
            _password = Value
        End Set
    End Property

End Class
#End Region