忙活了这么长时间,今天终于把结账这块是搞明白了。
首先为大家介绍一下窗体吧
首先是添加操作者的用户名
txtSQL = "select * from User_info where level='" & "操作员" & "' " '选择用户级别
Set mrc = ExecuteSQL(txtSQL, Msgtext)
Do While mrc.EOF = False '如国表中有数据
Combo1.AddItem mrc.Fields(0) '通过循环进行添加操作员名称
mrc.MoveNext
Loop
If SSCounts.Tab = 0 Then
'根据用户名来查询卡张数情况
txtSQL = "select * from student_info where teacher = '" & Trim(Combo1.Text) & "'"
Set mrc = ExecuteSQL(txtSQL, Msgtext)
With myflexgrid1
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
Do While mrc.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
.TextMatrix(.Rows - 1, 1) = mrc.Fields(0)
.TextMatrix(.Rows - 1, 2) = mrc.Fields(12)
.TextMatrix(.Rows - 1, 3) = mrc.Fields(13)
txtTotalcard.Text = mrc.RecordCount '获取得到的卡数
mrc.MoveNext
Loop
End With
mrc.Close
End If
If SSCounts.Tab = 1 Then '充值记录的显示
'根据用户名来查询充值情况
txtSQL = "select * from charge_info where teacher = '" & Trim(Combo1.Text) & "'"
Set mrcCharge = ExecuteSQL(txtSQL, Msgtext)
'向表中添加记录
With MyFlexGrid2
.CellAlignment = 4
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "充值金额"
.TextMatrix(0, 3) = "日期"
.TextMatrix(0, 4) = "时间"
Do While mrcCharge.EOF = False
.Rows = .Rows + 1
.CellAlignment = 4
'.TextMatrix(.Rows - 1, 0) = mrcCharge.Fields(7)
.TextMatrix(.Rows - 1, 1) = mrcCharge.Fields(0)
.TextMatrix(.Rows - 1, 2) = mrcCharge.Fields(1)
.TextMatrix(.Rows - 1, 3) = mrcCharge.Fields(4)
.TextMatrix(.Rows - 1, 4) = mrcCharge.Fields(5)
allcharge = allcharge + mrcCharge!addmoney '充值金额计算
mrcCharge.MoveNext
Loop
txtcharge.Text = Trim(allcharge) '显示充值金额
End With
mrcCharge.Close
End If
退卡方式一样,就不再赘述了,而且通过其实通过前边的购卡、充值、退卡,汇总的信息基本也都统计出来了,那么下面就为大家介绍一下结账吧,就是把信息保存到日结账单中的数据库的表中。
txtSQL = "select * from checkday " Set mrc = ExecuteSQL(txtSQL, Msgtext)
因为在查询的时候都需要用日期和状态来查询,所以就没有一直在注释
'获取当日充值金额
txtSQL = "select * from charge_info where chargedate= '" & Format(Now, "yyyy/mm/dd") & "' and status= '未结账'"
Set mrcCharge = ExecuteSQL(txtSQL, Msgtext)
nowCharge = nowCharge + Val(Trim(mrcCharge!addmoney)) 计算当日金额
'获取当日消费金额
txtSQL = "select * from line_info where lineday= '" & Format(Now, "yyyy/mm/dd") & "' and status= '未结账'"
Set mrcSum = ExecuteSQL(txtSQL, Msgtext)
expense = exepnse + mrcSum!expense '计算消费金额
'当日退款金额
txtSQL = "select * from Cancelcard_info where date= '" & Format(Now, "yyyy/mm/dd") & "' and status= '未结账'"
Set mrcDel = ExecuteSQL(txtSQL, Msgtext)
backMoney = backMoney + mrcDel!charge '计算退卡金额
chargeMoney = nowCharge - expense - backMoney
'获取上次余额
mrc.MoveLast
lastCharge = mrc.Fields(5)
mrc.MoveFirst
mrc.AddNew
mrc.Fields(0) = lastCharge
mrc.Fields(1) = nowCharge
mrc.Fields(2) = expense
mrc.Fields(3) = backMoney
mrc.Fields(5) = chargeMoney
mrc.Fields(4) = Date
mrc.Update
mrc.Close
MsgBox "结账成功"
东西长了点,大家有什么意见一定要告诉我啊