📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Form2
Caption = "销假"
ClientHeight = 2685
ClientLeft = 60
ClientTop = 450
ClientWidth = 6855
LinkTopic = "Form2"
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 2685
ScaleWidth = 6855
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 3960
TabIndex = 9
Top = 2160
Width = 855
End
Begin VB.CommandButton Command1
Caption = "销假"
Height = 375
Left = 1920
TabIndex = 8
Top = 2160
Width = 735
End
Begin VB.Frame Frame1
Caption = "基本信息"
Height = 1695
Left = 120
TabIndex = 0
Top = 120
Width = 6615
Begin VB.ComboBox Combo3
Height = 300
Left = 4920
TabIndex = 10
Top = 1080
Width = 1335
End
Begin VB.TextBox Text2
Height = 375
Left = 4920
TabIndex = 7
Top = 360
Width = 1335
End
Begin VB.ComboBox Combo2
Height = 300
Left = 1440
TabIndex = 5
Top = 397
Width = 1455
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1440
TabIndex = 1
Top = 1080
Width = 1455
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "销假日期"
Height = 180
Left = 3840
TabIndex = 6
Top = 450
Width = 720
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "请假日期"
Height = 180
Left = 480
TabIndex = 4
Top = 457
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓名"
Height = 180
Left = 4080
TabIndex = 3
Top = 1200
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "班级"
Height = 180
Left = 600
TabIndex = 2
Top = 1200
Width = 360
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo2_Click()
Dim mr As ADODB.Recordset
Dim msgtext As String
Dim txtSQL As String
txtSQL = "select 班级 from 请假 where 日期='" & Trim(Combo2) & "'"
Set mr = ExecuteSQL(txtSQL, msgtext)
Combo1.Clear
Do While Not mr.EOF
Combo1.AddItem mr.Fields(0)
mr.MoveNext
Loop
Combo1.Enabled = True
End Sub
Private Sub Combo3_click()
Dim mr3 As ADODB.Recordset
Dim msgtext As String
Dim txtSQL As String
txtSQL = "select 备注 from 请假 where 日期='" & Trim(Combo2) & "' and 班级='" & Trim(Combo1) & "' and 姓名='" & Trim(Combo3) & "'"
Set mr3 = ExecuteSQL(txtSQL, msgtext)
If Not mr3.EOF Then
Frame1.Caption = "基本信息-------" & Trim(mr3.Fields(0))
End If
End Sub
Private Sub Command1_Click()
Dim mr2 As ADODB.Recordset
Dim a, b As String
Dim msgtext As String
Dim txtSQL As String
If Combo2 = "" Then
MsgBox "选择日期", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If Combo1 = "" Then
MsgBox "选择班级", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
If Combo3 = "" Then
MsgBox "选择姓名", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
txtSQL = "update 请假 set 销假='1', 日期2='" & Trim(Text2.Text) & "' where 日期='" & Trim(Combo2) & "' and 班级='" & Trim(Combo1) & "' and 姓名='" & Trim(Combo3) & "'"
Set mr2 = ExecuteSQL(txtSQL, msgtext)
txtSQL = "select 日期 from 请假 where 日期='" & Trim(Combo2) & "' and 班级='" & Trim(Combo1) & "' and 姓名='" & Trim(Combo3) & "'"
Set mr2 = ExecuteSQL(txtSQL, msgtext)
If Not mr2.EOF Then
a = mr2.Fields(0)
b = DateDiff("d", a, Text2.Text)
End If
MsgBox "请假共计" & b & "天(注意:包括双休日),销假信息已经录入到数据库", vbOKOnly, "提示"
Unload Me
Form2.Show
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = MDIForm1.Top + 500
Me.Left = MDIForm1.Left + 500
Me.Height = 3195
Me.Width = 6975
Dim mrcc As ADODB.Recordset
Dim msgtext As String
Dim txtSQL As String
txtSQL = "select distinct(日期) from 请假"
Set mrcc = ExecuteSQL(txtSQL, msgtext)
Do While Not mrcc.EOF
Combo2.AddItem Format(mrcc.Fields(0), "yyyy-mm-dd")
mrcc.MoveNext
Loop
Text2.Text = Format(Now, "yyyy-mm-dd")
Combo1.Enabled = False
Combo3.Enabled = False
End Sub
Private Sub Combo1_Click()
Dim mr1 As ADODB.Recordset
Dim msgtext As String
Dim txtSQL As String
txtSQL = "select 姓名 from 请假 where 日期='" & Trim(Combo2) & "' and 班级='" & Trim(Combo1) & "'"
Set mr1 = ExecuteSQL(txtSQL, msgtext)
Combo3.Clear
Do While Not mr1.EOF
Combo3.AddItem mr1.Fields(0)
mr1.MoveNext
Loop
Combo3.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -