【VB开源代码栏目提醒】:本文主要为网学会员提供frmclient.frm,希望对需要frmclient.frm网友有所帮助,学习一下!
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmonly_client
Caption = "输入客人资料"
ClientHeight = 8160
ClientLeft = 60
ClientTop = 450
ClientWidth = 10005
LinkTopic = "Form1"
ScaleHeight = 8160
ScaleWidth = 10005
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Height = 1095
Left = 960
TabIndex = 2
Top = 6360
Width = 8175
Begin VB.CommandButton Command5
Caption = "退出"
Height = 375
Left = 6600
TabIndex = 7
Top = 360
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "取消"
Height = 375
Left = 4920
TabIndex = 6
Top = 360
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "删除记录"
Height = 375
Left = 3360
TabIndex = 5
Top = 360
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "修改记录"
Height = 375
Left = 1800
TabIndex = 4
Top = 360
Width = 1095
End
Begin
VB.CommandButton Command1
Caption = "新增记录"
Height = 375
Left = 240
TabIndex = 3
Top = 360
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "散客入住"
Height = 5295
Left = 240
TabIndex = 0
Top = 360
Width = 9495
Begin MSDataGridLib.DataGrid DataGrid1
Height = 4695
Left = 120
TabIndex = 1
Top = 480
Width = 9255
_ExtentX = 16325
_ExtentY = 8281
_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 = "frmonly_client"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs_client 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
If Not IsDate(Trim(DataGrid1.Columns("抵达日").CellText(DataGrid1.Bookmark))) Then
MsgBox "请按照格式hh-mm输入抵达日", vbOKOnly + vbExclamation, ""
Exit Sub
End If
If Not IsDate(Trim(DataGrid1.Columns("离店日").CellText(DataGrid1.Bookmark))) Then
MsgBox "请按照格式hh-mm输入离店日", vbOKOnly + vbExclamation, ""
Exit Sub
End If
rs_client.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