📄 database_testform.atcs
字号:
<#@ Imports
using System;
using TwoLKit.nTierBuilder.Api.DbDom;
##>
<#@ InstanceMembers
private IDatabase Database
{
get { return (IDatabase)Environment["Database"]; }
}
public override string RelativeFilePath
{
get { return "TestForm.vb"; }
}
private string GetTableClassName(ITable table)
{
return table.CodeName + "Collection";
}
private ITable GetFirstTable()
{
return 0 == Database.Tables.Count ? null : Database.Tables[0];
}
##>
Public Class TestForm
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 _listBox As System.Windows.Forms.ListBox
Friend WithEvents _getAllButton As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me._listBox = New System.Windows.Forms.ListBox()
Me._getAllButton = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'_listBox
'
Me._listBox.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me._listBox.HorizontalScrollbar = True
Me._listBox.Location = New System.Drawing.Point(8, 8)
Me._listBox.Name = "_listBox"
Me._listBox.Size = New System.Drawing.Size(472, 238)
Me._listBox.TabIndex = 0
'
'_getAllButton
'
Me._getAllButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)
Me._getAllButton.Location = New System.Drawing.Point(248, 256)
Me._getAllButton.Name = "_getAllButton"
Me._getAllButton.Size = New System.Drawing.Size(232, 24)
Me._getAllButton.TabIndex = 1
Me._getAllButton.Text = "call GetAll method for a table"
'
'TestForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(488, 291)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me._getAllButton, Me._listBox})
Me.Name = "TestForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Test Form"
Me.ResumeLayout(False)
End Sub
#End Region
' Read data from a table and add it to the list.
Private Sub _getAllButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _getAllButton.Click
Dim db As <#= SharedUtils.GetDbTierNamespace(Database)
#>.<#= Database.CodeName #> = New <#=
SharedUtils.GetDbTierNamespace(Database) #>.<#= Database.CodeName #>()
Try
<# ITable firstTable = GetFirstTable();
if(null == firstTable)
{ ##>
System.Windows.Forms.MessageBox.Show("Database is empty. Add a table, regenerate DBtier code, and try again.")
<# }
else
{ ##>
Dim records As Object() = db.<#= GetTableClassName(firstTable) #>.GetAll()
_listBox.Items.Clear()
If 0 = records.Length Then
_listBox.Items.Add("<TABLE '<#= firstTable.Name #>' IS EMPTY>")
Else
_listBox.Items.AddRange(records)
End If
<# } ##>
Finally
db.Close()
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -