这是第二遍写这篇博客:十天前特别高兴的写博客是因为第二天就回家了,写完放在草稿箱里回家这周在家发表。哎,周日上csdn一看就惊呆了,没了,竟然没了。怎么能这样?
没有办法的事再写。心情真是不一样了。
当时想的不多就点了点给的系统,感觉貌似是知道了,就敲了。
想法:
1.这个窗体主要是上边选择结账人下边对应显示对应的此人的各个表。
2.下边显示出的表代码都是一样的,对应好数据库表名,条件都是未结账的此结账人。。就显示一个的代码吧 购卡 看下边:
Dim txtSQLs As String
Dim MsgText As String
Dim mrcs As ADODB.Recordset
'从Student_Info表中调出数据。
txtSQLs = "select * from Student_Info where UserID='" & cmbName.Text & "'and IsCheck='未结账'"
Set mrcs = ExecuteSQL(txtSQLs, MsgText)
With MSHFlexGrid1
.CellAlignment = 4
.Cols = 4
.Rows = 1
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "卡号"
.TextMatrix(0, 2) = "日期"
.TextMatrix(0, 3) = "时间"
End With
If mrcs.RecordCount <> 0 Then
Do While mrcs.EOF = False
With MSHFlexGrid1
.CellAlignment = 4
.Cols = 4
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 0) = mrcs.Fields(1)
.TextMatrix(.Rows - 1, 1) = mrcs.Fields(0)
.TextMatrix(.Rows - 1, 2) = mrcs.Fields(12)
.TextMatrix(.Rows - 1, 3) = mrcs.Fields(13)
mrcs.MoveNext
End With
Loop
End If
3.结账首先将表中涉及到状态的改成未结账,别忘了条件是此结账人。还有是退卡数是将退卡表中的此结账人未结账的退卡人的总和。别的都是出不多的。代码显示看下边:
Dim txtSQLCan As String
Dim MsgText As String
Dim mrcCan As ADODB.Recordset
'调CancelCard_Info表结账人退卡人数
txtSQLCan = "select count(*) from CancelCard_Info where UserID='" & cmbName.Text & "'and status='未结账'"
Set mrcCan = ExecuteSQL(txtSQLCan, MsgText)
If mrcCan.RecordCount = 0 Then
txtBackCardNumber.Text = "0"
Else
txtBackCardNumber.Text = mrcCan.Fields(0)
'退卡数
End If
mrcCan.Close '关表
Dim txtSQLCanc As String
Dim mrcCanc As ADODB.Recordset
'调CancelCard_Info表结账人退卡的金额。
txtSQLCanc = "select sum(CancelCash) from CancelCard_Info where UserID='" & cmbName.Text & "'and status='未结账'"
Set mrcCanc = ExecuteSQL(txtSQLCanc, MsgText)
If IsNull(mrcCanc.Fields(0)) Then
txtBackMoney.Text = "0"
Else
txtBackMoney.Text = mrcCanc.Fields(0) '退卡金额
End If
mrcCanc.Close
Dim txtSQLStudent As String
Dim mrcStudent As ADODB.Recordset
'调Student_Info表中结账人售卡的总数
txtSQLStudent = "select count(*) from Student_Info where UserID='" & cmbName.Text & "'and IsCheck='未结账'"
Set mrcStudent = ExecuteSQL(txtSQLStudent, MsgText)
If IsNull(mrcStudent.Fields(0)) Then
txtSumSellCardNumber.Text = "0"
Else
txtSumSellCardNumber.Text = mrcStudent.Fields(0)
'总售卡数
End If
mrcStudent.Close
'售卡数
txtSellCardNumber.Text = Val(txtSumSellCardNumber.Text) - Val(txtBackCardNumber.Text)
Dim txtSQLReCharge As String
Dim mrcReCharge As ADODB.Recordset
'调ReCharge_Info结账人充值的金额。
txtSQLReCharge = "select sum(addmoney) from ReCharge_Info where UserID='" & cmbName.Text & "'and status='未结账'"
Set mrcReCharge = ExecuteSQL(txtSQLReCharge, MsgText)
If IsNull(mrcReCharge.Fields(0)) Then
txtRecharge.Text = "0"
Else
txtRecharge.Text = mrcReCharge.Fields(0) '充值金额
End If
mrcReCharge.Close
Dim txtSQLReCh As String
Dim mrcReCh As ADODB.Recordset
Dim linZHU As Double '临时用户注册时充值的钱。
Dim linTUI As Double '临时用户退卡时的钱。
'调ReCharge_Info表中结账人临时的收费
txtSQLReCh = "select sum(addmoney) from ReCharge_Info where UserID='" & cmbName.Text & "'and type='临时用户' and status='未结账'"
Set mrcReCh = ExecuteSQL(txtSQLReCh, MsgText)
If IsNull(mrcReCh.Fields(0)) Then
linZHU = 0
Else
linZHU = mrcReCh.Fields(0) '临时注册充值
End If
Dim txtSQLCance As String
Dim mrcCance As ADODB.Recordset
'调CancelCard_Info表结账人退卡的金额。
txtSQLCance = "select sum(CancelCash) from CancelCard_Info where UserID='" & cmbName.Text & "'and status='未结账' and type='临时用户'"
Set mrcCance = ExecuteSQL(txtSQLCance, MsgText)
If IsNull(mrcCance.Fields(0)) Then
linTUI = 0
Else
linTUI = mrcCance.Fields(0) '退卡金额
End If
'临时收费是临时用户注册的减去退卡的。
txtTemCharge.Text = linZHU - linTUI
'应收金额。
txtAmountReceivable.Text = Val(txtRecharge.Text) - Val(txtBackMoney.Text)
这个窗体是最后敲的敲完就去让师父们验了。
不足的:
1.界面都太丑
2.结账的逻辑不太对,想的太少了。汇总时就等于结账了,结账时却清空了。
3.当结完账,再点前边的表就没有数据了,因为条件已经是结账了。这样也不对的。就把代码写在单击选择结账人时。改是好改,关键是没有想到。