实验2《软件项目的设计》实验报告 - 图文(6)

2019-08-28 23:39

End Sub

Private Sub munReadRegist_Click()

CheckConnect 'Reference function to make objcon break if connection is open Load frmReadRegist frmReadRegist.Show End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmAdmin frmAdmin.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmVipReg frmVipReg.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmVipQuery frmVipQuery.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmBookReg frmBookReg.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmBookQuery frmBookQuery.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmReadRegist frmReadRegist.Show Case \

CheckConnect 'Reference function to make objcon break if connection is open Load frmReadQuery frmReadQuery.Show End Select End Sub

操作员管理界面如图5.3所示。

23

图5.3 操作员管理界面

代码如下:

Option Explicit Sub SetTextEmpty()

'This function is set all text to empty txtOpID.Text = \ txtOpName.Text = \ txtOpPwd.Text = \ cboOpGrade.Text = \ txtOpAddTime.Text = \End Sub

Sub RefreshOperator()

'This function is to Refresh text

txtOpID.Text = objRs.Fields(0).Value txtOpName.Text = objRs.Fields(1).Value txtOpPwd.Text = objRs.Fields(2).Value cboOpGrade.Text = objRs.Fields(3).Value ' txtOpAddTime.Text = objRs.Fields(4).Value End Sub

Private Sub cmdAdd_Click()

24

txtOpID.Enabled = True 'You don't change datagrid untill you add data finish dgdOp.Enabled = False

If cmdAdd.Caption = \添加\ cmdAdd.Caption = \确定\

SetTextEmpty ' reference settextempty founction to set empty cmdDel.Enabled = False cmdModify.Enabled = False cmdRefresh.Enabled = False txtOpID.SetFocus Else

If Trim(txtOpName.Text) = \

MsgBox \name must not null ,please input operator name !\vbInformation + vbOKOnly

txtOpName.SetFocus Exit Sub

ElseIf Trim(txtOpID.Text) = \

MsgBox \ID must not null ,please input operator ID !\vbInformation + vbOKOnly

txtOpID.SetFocus Exit Sub

ElseIf Trim(txtOpPwd.Text) = \

MsgBox \password must not null ,please input operator password !\vbInformation + vbOKOnly

txtOpPwd.SetFocus Exit Sub Else

With objRs

checkAddNew = True

.Filter = \ If .RecordCount > 0 Then

MsgBox \ txtOpID.Text = \ txtOpID.SetFocus

.Filter = \

cmdRefresh.Value = True 'To executer refresh once checkAddNew = False cmdDel.Enabled = True cmdModify.Enabled = True cmdAdd.Caption = \添加(&A)\ txtOpID.Enabled = False cmdRefresh.Enabled = True dgdOp.Enabled = True

25

checkAddNew = False Exit Sub End If

checkAddNew = True .AddNew

.Fields(0).Value = Trim(txtOpID.Text) .Fields(1).Value = Trim(txtOpName.Text) .Fields(2).Value = Trim(txtOpPwd.Text) .Fields(3).Value = Trim(cboOpGrade.Text) .Fields(4).Value = Trim(txtOpAddTime.Text) .Update

MsgBox \ .Filter = \

cmdRefresh.Value = True 'To executer refresh once End With

checkAddNew = False

'----There will reference a founction to set empty txtOpID.Enabled = False cmdDel.Enabled = True cmdModify.Enabled = True cmdRefresh.Enabled = True cmdAdd.Caption = \添加\

dgdOp.Enabled = True 'You can use datagrid after add finish End If End If End Sub

Private Sub cmdDel_Click()

If Empty_Check = True Then Exit Sub 'Reference function to check if your database is null If Not objRs.EOF And objRs.RecordCount > 0 Then

If MsgBox(\= vbYes Then

objRs.Delete End If End If End Sub

Private Sub cmdModify_Click()

If Empty_Check = True Then Exit Sub 'Reference function to check if your database is null dgdOp.Enabled = False

If txtOpID.Text <> objRs.Fields(0).Value Then Exit Sub 'To check operator ID If cmdModify.Caption = \修改\ cmdModify.Caption = \确定\ cmdDel.Enabled = False

26

cmdAdd.Enabled = False Else

With objRs

.Fields(0).Value = Trim(txtOpID.Text) .Fields(1).Value = Trim(txtOpName.Text) .Fields(2).Value = Trim(txtOpPwd.Text) .Fields(3).Value = Trim(cboOpGrade.Text) .Update End With

cmdModify.Caption = \修改\ cmdDel.Enabled = True cmdAdd.Enabled = True dgdOp.Enabled = True End If End Sub

Private Sub cmdExit_Click() Unload Me End Sub

Private Sub cmdRefresh_Click()

RefreshOperator 'Reference function is to Refresh text End Sub

Private Sub dgdOp_RowColChange(LastRow As Variant, ByVal LastCol As Integer) If checkAddNew = True Then Exit Sub cmdRefresh.Value = True End Sub

Private Sub Form_Activate()

FormMiddle frmAdmin 'Reference function to make form in MDIForm'mddile cboOpGrade.ListIndex = 1

If ConnectToServer = True Then

Set objRs = New ADODB.Recordset StrSql = \

GetData StrSql 'Reference function to get data Set dgdOp.DataSource = objRs cmdRefresh.Value = True End If End Sub

Private Sub txtOpAddTime_KeyPress(KeyAscii As Integer) 'CheckInputNum 'Reference function to check input

If Not (KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _ Or KeyAscii = vbKeyBack _ Or KeyAscii = Asc(\

27


实验2《软件项目的设计》实验报告 - 图文(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:第七讲 当代生态环境问题分析 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: