VB+SQL书店图书管理系统(任务书+开题报告+论文) 第12页

VB+SQL书店图书管理系统(任务书+开题报告+论文) 第12页
模块原型:Private Sub CmdSellBook_Click()
代码:
Private Sub CmdSellBook_Click()
On Error GoTo errEnd
Dim QD As Integer

CmdSellBook.Enabled = False

If TxtShuLiang.Text = "" Then
    MsgBox "请输入交易的数量!", vbOKOnly + vbExclamation, "填写数量"
    TxtShuLiang.SetFocus
    CmdSellBook.Enabled = True
    Exit Sub
End If
If GetKuCun(TuShuBianHao) <= 0 Or GetKuCun(TuShuBianHao) < TxtShuLiang.Text Then
    MsgBox "该类图书库存量不足,请与仓库管理员联系!", vbOKOnly + vbExclamation, "库存不足"
    TxtShuLiang.SetFocus
    CmdSellBook.Enabled = True
    Exit Sub
End If
If TxtZheKou.Text = "" Then
    MsgBox "请输入交易的实际折扣率!", vbOKOnly + vbExclamation, "填写折扣"
    TxtZheKou.SetFocus
    CmdSellBook.Enabled = True
    Exit Sub
End If
If TxtZheKou.Text <= 0 Or TxtZheKou.Text > 1 Then
    MsgBox "实际折扣率填写错误!请在 0 与 1 之间选择.", vbOKOnly + vbExclamation, "填写折扣"
    TxtZheKou.SetFocus
    CmdSellBook.Enabled = True
    Exit Sub
End If
If TxtSJJinE.Text = "" Then
    MsgBox "请输入交易的实际金额!", vbOKOnly + vbExclamation, "填写金额"
    TxtSJJinE.SetFocus
    CmdSellBook.Enabled = True
    Exit Sub
End If
If TxtMemo.Text = "" Then TxtMemo.Text = "无"

QD = MsgBox("确定入帐吗?", vbOKCancel + vbQuestion, "确认入帐")
If QD = vbCancel Then
    CmdSellBook.Enabled = True
    Exit Sub
End If
'售书入帐
Screen.MousePointer = 11
BeginTrans

Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "售书记录"
Adodc1.Refresh

Adodc1.Recordset.AddNew
Adodc1.Recordset!图书编号 = TuShuBianHao
Adodc1.Recordset!数量 = TxtShuLiang.Text
Adodc1.Recordset!会员卡号 = HuiYuanKaHao
Adodc1.Recordset!实际打折 = TxtZheKou.Text
Adodc1.Recordset!实收金额 = TxtSJJinE.Text
Adodc1.Recordset!日期 = Year(Now) & "-" & Month(Now) & "-" & Day(Now) & "."
Adodc1.Recordset!备注 = TxtMemo.Text
Adodc1.Recordset.Update

Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from [Book] where [图书编号]=""" & TuShuBianHao & """"
Adodc1.Refresh

If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.MoveFirst
    Adodc1.Recordset!库存量 = Adodc1.Recordset!库存量 - TxtShuLiang.Text
    Adodc1.Recordset.Update
Else
    Rollback
    Screen.MousePointer = vbDefault
    MsgBox "图书资料丢失,请与仓库管理员联系!", vbOKOnly + vbExclamation, "交易失败"
    CmdSellBook.Enabled = True
    Exit Sub
End If

If HYShengJi(HuiYuanKaHao) Then Rollback

CommitTrans

Screen.MousePointer = vbDefault
MsgBox "恭喜您,交易成功!", vbOKOnly + vbInformation, "交易成功"
Unload Me

Exit Sub

errEnd:
    Rollback
    Screen.MousePointer = vbDefault
    MsgBox Err.Description, vbOKOnly + vbExclamation, "操作数据库出错 交易失败"
    CmdSellBook.Enabled = True
End Sub

8.5.3 (三)系统模块详解
模块名:checkGYSID
模块原型:Public Function checkGYSID(UID As String) As Boolean
代码:
Public Function checkGYSID(UID As String) As Boolean
Dim userDB As Database
Dim userRD As Recordset
Dim dbName As String
Dim STRSQL As String

Screen.MousePointer = 11

On Error GoTo errEnd

dbName = App.Path
If Right(dbName, 1) <> "\" Then dbName = dbName + "\"
dbName = dbName + "DataBase\WFSSDataBase.mdb"
STRSQL = "select [图书分类] from [图书分类] where [图书分类号]=""" & UID & """"

 << 上一页  [11] [12] [13] [14] [15] [16] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有