📄 form11.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form11
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
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
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
Friend WithEvents DateTimePicker2 As System.Windows.Forms.DateTimePicker
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.Button1 = New System.Windows.Forms.Button
Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.DateTimePicker2 = New System.Windows.Forms.DateTimePicker
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.GroupBox1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.Button1)
Me.GroupBox1.Controls.Add(Me.DateTimePicker1)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.DateTimePicker2)
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(464, 72)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "统计条件"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(360, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(62, 30)
Me.Button1.TabIndex = 3
Me.Button1.Text = "统计"
'
'DateTimePicker1
'
Me.DateTimePicker1.CalendarMonthBackground = System.Drawing.SystemColors.Info
Me.DateTimePicker1.Location = New System.Drawing.Point(133, 15)
Me.DateTimePicker1.Name = "DateTimePicker1"
Me.DateTimePicker1.Size = New System.Drawing.Size(171, 20)
Me.DateTimePicker1.TabIndex = 2
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(13, 44)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(99, 21)
Me.Label2.TabIndex = 1
Me.Label2.Text = "截至日期:"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(13, 15)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(99, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "开始日期:"
'
'DateTimePicker2
'
Me.DateTimePicker2.CalendarMonthBackground = System.Drawing.SystemColors.Info
Me.DateTimePicker2.Location = New System.Drawing.Point(133, 45)
Me.DateTimePicker2.Name = "DateTimePicker2"
Me.DateTimePicker2.Size = New System.Drawing.Size(171, 20)
Me.DateTimePicker2.TabIndex = 2
'
'DataGrid1
'
Me.DataGrid1.BackColor = System.Drawing.SystemColors.Info
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(0, 96)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(496, 240)
Me.DataGrid1.TabIndex = 1
'
'Form11
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.LightSteelBlue
Me.ClientSize = New System.Drawing.Size(488, 333)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.GroupBox1)
Me.MaximizeBox = False
Me.Name = "Form11"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "数据信息统计列表"
Me.GroupBox1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim cn As New SqlConnection("data source=(Local);initial catalog=酒店管理系统;uid=sa;pwd=;")
Dim cm As New SqlCommand
Dim da As New SqlDataAdapter(cm)
Dim ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
ds.Tables.Clear()
cm.Connection = cn
cm.CommandText = "select * from 月统计v where 统计日期 between '" & Format(DateTimePicker1.Value, "yyyy - MM - dd") & "' and '" & Format(DateTimePicker2.Value, "yyyy - MM - dd") & "'"
cn.Open()
da.Fill(ds)
cn.Close()
DataGrid1.DataSource = ds.Tables(0)
Catch ex As Exception
cn.Close()
MsgBox(ex.Message)
End Try
End Sub
Private Sub Form11_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -