【VB开源代码栏目提醒】:网学会员,鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“frmdouble_client.frm”一文,供大家参考学习!
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmdouble_client
Caption = "输入客人资料"
ClientHeight = 8280
ClientLeft = 60
ClientTop = 450
ClientWidth = 10260
LinkTopic = "Form1"
ScaleHeight = 8280
ScaleWidth = 10260
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Height = 1215
Left = 1320
TabIndex = 2
Top = 6600
Width = 8175
Begin VB.CommandButton Command5
Caption = "退出"
Height = 375
Left = 6720
TabIndex = 7
Top = 480
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "取消"
Height = 375
Left = 5040
TabIndex = 6
Top = 480
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "删除记录"
Height = 375
Left = 3360
TabIndex = 5
Top = 480
Width = 1215
End
Begin
VB.CommandButton Command2
Caption = "修改记录"
Height = 375
Left = 1800
TabIndex = 4
Top = 480
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "新增记录"
Height = 375
Left = 240
TabIndex = 3
Top = 480
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "团队入住"
Height = 5655
Left = 480
TabIndex = 0
Top = 600
Width = 9375
Begin MSDataGridLib.DataGrid DataGrid1
Height = 4815
Left = 240
TabIndex = 1
Top = 480
Width = 8895
_ExtentX = 15690
_ExtentY = 8493
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "frmdouble_client"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs_dclient As New ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo adderror
If Command1.Caption = "新增记录" Then '当此按钮的状态为为“增加记录”时
Command1.Caption = "确定" '按钮名称改为“确定”
Command2.Enabled = False '删除与修改按钮不可用
Command3.Enabled = False
Command4.Enabled = True '取消按钮可用
DataGrid1.AllowAddNew = True
DataGrid1.AllowUpdate = True '设定datagrid可以增加记录
Else
If Not IsNull(DataGrid1.Bookmark) Then
If Trim(DataGrid1.Columns("团队名称").CellText(DataGrid1.Bookmark)) = "" Then
MsgBox "团队名称不能为空!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
If Trim(DataGrid1.Columns("负责人").CellText(DataGrid1.Bookmark)) = "" Then
MsgBox "负责人不能为空!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
If Trim(DataGrid1.Columns("证件号码").CellText(DataGrid1.Bookmark)) = "" Then
MsgBox "证件号码不能为空!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
If Trim(DataGrid1.Columns("房间号码").CellText(DataGrid1.Bookmark)) = "" Then
MsgBox "房间号码!", vbOKOnly + vbExclamation, ""
Exit Sub
End If
rs_dclient.Update
MsgBox "添加信息成功!", vbOKOnly + vbExclamation, ""
DataGrid1.AllowAddNew = False
DataGrid1.AllowUpdate = False
Else
MsgBox "没有添加信息!", vbOKOnly + vbExclamation, ""
End If
Command1.Caption = "新增记录"
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
End If
adderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Private Sub Command2_Click()
Dim answer As String
On Error GoTo cmdmodify
If Command2.Caption = "修改记录" Then
answer = MsgBox("确定要修改吗?", vbYesNo, "")
If answer = vbYes Then
Command2.Caption = "确定"
Command1.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
DataGrid1.AllowUpdate = True
Else
Exit Sub
End If
Else
If Not IsNull(DataGrid1.Bookmark) Then
rs_dclient.Update
End If
Command2.Caption = "修改记录"
Command1.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
DataGrid1.AllowUpdate = False
MsgBox "修改成功!", vbOKOnly + vbExclamation, ""
End If
cm