EOF=FalseThen
MsgBox"已经存在相同机舱等级的记录!",vbOKOnly+vbExclamation,"警告"
txtItem(1).SetFocus
ExitSub
EndIf
'先删除已有记录
txtSQL="deletefromserviceInfowhereserviceNO='"&Trim(txtItem(0))&"'"
Setmrc=ExecuteSQL(txtSQL,MsgText)
'再加入新记录
txtSQL="select*fromserviceInfo"
Setmrc=ExecuteSQL(txtSQL,MsgText)
mrc.AddNew
ForintCount=0To1
mrc.Fields(intCount)=Trim(txtItem(intCount))
NextintCount
ForintCount=0To7
mrc.Fields(intCount+2)=Trim(Combo1(intCount))
NextintCount
mrc.Fields(10)=Trim(txtItem(2))
'更新数据集内容
mrc.Update
'关闭数据集内容
mrc.Close
IfgintSmode=1Then
MsgBox"添加记录成功!",vbOKOnly+vbExclamation,"添加记录"
ForintCount=0To1
txtItem(intCount)=""
NextintCount
ForintCount=0To3
Combo1(intCount).ListIndex=0
NextintCount
txtItem(2)=""
mblChange=False
UnloadfrmService
frmService.txtSQL="select*fromserviceInfo"
frmService.Show
ElseIfgintSmode=2Then
UnloadMe
UnloadfrmService
frmService.txtSQL="select*fromserviceInfo"
frmService.Show
EndIf
EndSub
6.3修改舱位等级信息
在舱位等级信息列表中选择需要修改的记录,然后单击"修改"按钮,将出现如图9-13所示的窗体。选择记录的内容将显示在窗体中,可以进行修改,最后保存修改后的记录。代码如下:
PrivateSubcmdModify_Click()
DimintCountAsInteger
判断列表中是否有记录
IffrmService.msgList.Rows>1Then
'改变状态变量
gintSmode=2
'记录选择记录位置
intCount=msgList.Row
IfintCount>0Then
frmService1.txtSQL="select*fromserviceInfowhereserviceNO='"&Trim(msgList.TextMatrix(intCount,1))&"'"
frmService1.Show1
Else
MsgBox"警告",vbOKOnly+vbExclamation,"请首先选择需要修改的记录!"
EndIf
EndIf
EndSub
6.4删除舱位等级信息
在舱位等级信息列表中选择需要删除的记录,然后单击"删除"按钮,将删除当前记录,代码如下:
PrivateSubcmdDelete_Click()
DimtxtSQLAsString
DimintCountAsInteger
DimmrcAsADODB.Recordset
DimMsgTextAsString
'判断信息列表中内容是否为空
IfmsgList.Rows>1Then
'提示信息
IfMsgBox("真的要删除机舱等级为"&Trim(msgList.TextMatrix(msgList.Row,2))&"的记录吗?",vbOKCancel+vbExclamation,"警告")=vbOKThen
'记录选择记录位置
intCount=msgList.Row
'删除重复记录
txtSQL="deletefromserviceInfowhereserviceNO='"&Trim(msgList.TextMatrix(intCount,1))&"'"
Setmrc=ExecuteSQL(txtSQL,MsgText)
'卸载窗体
UnloadfrmService
'重新载入记录并显示
frmService.txtSQL="select*fromserviceInfo"
frmService.Show
EndIf
EndIf
EndSub
7客机信息管理模块的创建
客机信息管理模块主要实现如下功能:
*添加客机信息。
*修改客机信息。
*删除客机信息。
*查询客机信息。
7.1显示客机信息窗体的创建
选择"航线信息管理|客机信息"菜单,将出现如图9-14所示的窗体。所有客机信息都将显示出来。窗体的Load事件调用ShowTitle、ShowData函数,将所有记录显示出来。
图9-14显示客机信息列表窗体
7.2添加客机信息窗体的创建
单击客机信息列表中的"添加"按钮,将出现如图9-15所示的窗体。
图9-15添加客机信息列表
输入内容完毕,单击"保存"按钮,将首先判断输入内容是否满足要求,然后将记录添加到数据库中,代码如下:
PrivateSubcmdSave_Click()
DimintCountAsInteger
DimsMegAsString
DimMsgTextAsString
'判断输入内容是否为空
ForintCount=0To6
IfTrim(txtItem(intCount)&"")=""Then
SelectCaseintCount
Case0
sMeg="客机编号"
Case1
sMeg="客机型号"
Case2
sMeg="购买时间"
Case3
sMeg="服役时间"
Case4
sMeg="经济舱座位数量"
Case5
sMeg="公务舱座位数量"
Case6
sMeg="头等舱座位数量"
EndSelect
sMeg=sMeg&"不能为空!"
MsgBoxsMeg,vbOKOnly+vbExclamation,"警告"
txtItem(intCount).SetFocus
ExitSub
EndIf
NextintCount
'判断输入内容为数字
ForintCount=4To6
IfNotIsNumeric(Trim(txtItem(intCount)))Then
sMeg="座位数量"
sMeg=sMeg&"请输入数字!"
MsgBoxsMeg,vbOKOnly+vbExclamation,"警告"
txtItem(intCount).SetFocus
EndIf
NextintCount
'判断输入内容是否为日期
ForintCount=2To3
IfIsDate(txtItem(intCount))Then
txtItem(intCount)=Format(txtItem(intCount),"yyyy-mm-dd")
Else
MsgBox"时间应输入日期(yyyy-mm-dd)!",vbOKOnly+vbExclamation,"警告"
txtItem(intCount).SetFocus
ExitSub
EndIf
NextintCount
'添加判断是否有相同的ID记录
IfgintPmode=1Then
txtSQL="select*fromplaneInfowhereplaneNO='"&Trim(txtItem(0))&"'"
Setmrc=ExecuteSQL(txtSQL,MsgText)
Ifmrc.EOF=FalseThen
MsgBox"已经存在此编号的记录!",vbOKOnly+vbExclamation,"警告"
txtItem(0).SetFocus
ExitSub
EndIf
mrc.Close
EndIf
'先删除已有记录
txtSQL="deletefromplaneInfowhereplaneNO='"&Trim(txtItem(0))&"'"
Setmrc=ExecuteSQL(txtSQL,MsgText)
'再加入新记录
txtSQL="select*fromplaneInfo"
Setmrc=ExecuteSQL(txtSQL,MsgText)
mrc.AddNew
ForintCount=0To7
mrc.Fields(intCount)=Trim(txtItem(intCount))
NextintCount
'更新数据集
mrc.Update
'关闭数据集对象
mrc.Close
IfgintPmode=1Then
MsgBox"添加记录成功!",vbOKOnly+vbExclamation,"添加记录"
ForintCount=0To7
txtItem(intCount)=""
NextintCount
mblChange=False
UnloadfrmPlane
frmPlane.txtSQL="select*fromplaneInfo"
frmPlane.Show
ElseIfgintPmode=2Then
UnloadMe
UnloadfrmPlane
frmPlane.txtSQL="select*fromplaneInfo"
frmPlane.Show
EndIf
EndSub
7.3修改客机信息
在客机信息列表中选择记录,然后单击"修改"按钮。当前记录将显示在如图9-15所示的窗体中,可以进行修改。代码如下:
PrivateSubcmdModify_Click()
DimintCountAsInteger
'判断列表内容是否为空
IffrmPlane.msgList.Rows>1Then
gintPmode=2
'记载选择记录的位置
intCount=msgList.Row
IfintCount>0Then
frmPlane1.txtSQL="select*fromplaneInfowhereplaneNO='"&Trim(msgList.TextMatrix(intCount,1))&"'"
frmPlane1.Show1
Else
MsgBox"警告",vbOKOnly+vbExclamation,"请首先选择需要修改的记录!"
EndIf
EndIf
EndSub
7.4删除客机信息
在客机信息列表中选择记录,然后单击"删除"按钮,当前记录将被删除。代码如下:
PrivateSubcmdDelete_Click()
DimtxtSQLAsString
DimintCountAsInteger
DimmrcAsADODB.Recordset
DimMsgTextAsString
'判断列表内容是否为空
IfmsgList.Rows>1Then
IfMsgBox("真的要删除客机编号为"&Trim(msgList.TextMatrix(msgList.Row,1))&"的型号为"&Trim(msgList.TextMatrix(msgList.Row,2))&"的客机记录吗?",vbOKCancel+vbExclamation,"警告")=vbOKThen
'记载选择记录的位置
intCount=msgList.Row
txtSQL="deletefromplaneInfowhereplaneNO='"&Trim(msgList.Text
上一篇:
VB航空公司管理信息系统(毕业论文+程序)(论文和程序)
下一篇:
医学论文英语标题写作的修辞原则