1. 程式人生 > >機房收費系統總結篇(三)

機房收費系統總結篇(三)

              結賬是我敲機房遇到問題最多的地方,無論是介面的設計還是程式碼遇到的問題都比較多,機房驗收了兩遍結賬這個窗體還是存在問題。現在終於差不多沒什麼大問題了。我就來總結總結我所遇到的問題吧!

       

     開始我一直不知道這是個什麼東東,我以為是畫一張frame框架,然後在上邊新增一個按鈕,我簡直是太天真了。這原來是一個叫做sstab的控制元件。

       

     

    第一遍驗機房的時候我只是添加了操作員,但是師傅說管理員也結過賬,管理員收的金額,管理員退的卡怎麼辦?要麼你就不讓管理員收取金額,要麼就再新增管理員。所以我還是選擇後者再新增管理員吧!上述介面的功能是,點操作員按鈕,操作員可選,點管理員按鈕,管理員可選。師傅說我設計的還不錯。

    下面看我的程式碼設計部分:

     首先我們屢清一下思路,購卡,充值,退卡,臨時使用者用到的表分別是student——info,recharge——info,cancelcard——info,student——info。

    如果你選擇購卡,則出現購卡的資訊:

If SSTab1.Caption = "購卡" Then
  myflexgrid2.Visible = True
   With myflexgrid2
    .Rows = 1
    .CellAlignment = 4
    .TextMatrix(0, 0) = "學號"
    .TextMatrix(0, 1) = "卡號"
    .TextMatrix(0, 2) = "日期"
    .TextMatrix(0, 3) = "時間"
    End With
    'myflexgrid1.Visible = False
          
    'myflexgrid1.Visible = True
   txtSQL = "select * from student_Info where userID = '" & Combo1.Text & "'"
    Set mrcc = executeSQL(txtSQL, msgText)
   
    With myflexgrid2
    .Rows = 1
       Do While Not mrcc.EOF
       
       .Rows = .Rows + 1
       .CellAlignment = 4
       .AllowUserResizing = flexResizeColumns
       .TextMatrix(.Rows - 1, 0) = Trim(mrcc.Fields(1))
       .TextMatrix(.Rows - 1, 1) = Trim(mrcc.Fields(0))
       .TextMatrix(.Rows - 1, 2) = Trim(mrcc.Fields(12))
       .TextMatrix(.Rows - 1, 3) = Trim(mrcc.Fields(13))
       mrcc.MoveNext
       'a = a + 1
    Loop
      
    End With
    mrcc.CloseIf SSTab1.Caption = "購卡" Then
  myflexgrid2.Visible = True
   With myflexgrid2
    .Rows = 1
    .CellAlignment = 4
    .TextMatrix(0, 0) = "學號"
    .TextMatrix(0, 1) = "卡號"
    .TextMatrix(0, 2) = "日期"
    .TextMatrix(0, 3) = "時間"
    End With
    'myflexgrid1.Visible = False
          
    'myflexgrid1.Visible = True
   txtSQL = "select * from student_Info where userID = '" & Combo1.Text & "'"
    Set mrcc = executeSQL(txtSQL, msgText)
   
    With myflexgrid2
    .Rows = 1
       Do While Not mrcc.EOF
       
       .Rows = .Rows + 1
       .CellAlignment = 4
       .AllowUserResizing = flexResizeColumns
       .TextMatrix(.Rows - 1, 0) = Trim(mrcc.Fields(1))
       .TextMatrix(.Rows - 1, 1) = Trim(mrcc.Fields(0))
       .TextMatrix(.Rows - 1, 2) = Trim(mrcc.Fields(12))
       .TextMatrix(.Rows - 1, 3) = Trim(mrcc.Fields(13))
       mrcc.MoveNext
       'a = a + 1
    Loop
      
    End With
    mrcc.Close
      那麼最重要的一塊便是我們的結賬了。

      1.做到使用者名稱和姓名的同步:

Private Sub Command1_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim msgtext As String
Combo1.Enabled = True
Combo2.Enabled = True
txtSQL = "select * from User_Info where level='操作員'"
Set mrc = executeSQL(txtSQL, msgtext)

Do While Not mrc.EOF
Combo1.AddItem Trim(mrc.Fields(0))
'Combo2.AddItem Trim(mrc.Fields(3))
mrc.MoveNext
Loop
mrc.Close
End Sub
Private Sub Combo1_Click()
Dim txtSQL1 As String
Dim msgtext As String
Dim mrc As ADODB.Recordset
txtSQL1 = "select * from User_Info where userID= '" & Trim(Combo1.Text) & "'"
Set mrc = executeSQL(txtSQL1, msgtext)
Combo2.Text = Trim(mrc.Fields(3))

End Sub
     2.應收金額:固定使用者:充值金額-退卡金額

        臨時使用者:充值金額+臨時消費金額-退卡金額

        總售卡張數:售卡張數-退卡張數

If SSTab1.Caption = "彙總" Then
  cmdCheckout.Visible = True
   '售卡張數
     txtSQL = "select * from student_Info where UserID='" & Trim(Combo1.Text) & "'"
     Set mra = executeSQL(txtSQL, msgtext)
    Text2.Text = mra.RecordCount
   '退卡張數
     txtSQL = "select * from CancelCard_Info where UserID='" & Trim(Combo1.Text) & "' and status='" & "未結賬" & "'"
     Set mrb = executeSQL(txtSQL, msgtext)
    Text1.Text = mrb.RecordCount
   '充值金額
    txtSQL = "select sum(addmoney) from Recharge_Info where UserID='" & Trim(Combo1.Text) & "'and status='" & "未結賬" & "'"
    Set mrd = executeSQL(txtSQL, msgtext)
    If IsNull(mrd.Fields(0)) Then
            Text3.Text = 0
        Else
            Text3.Text = mrd.Fields(0)
        End If
  '退卡金額
     txtSQL = "select sum(CancelCash) from CancelCard_Info where UserID='" & Trim(Combo1.Text) & "'and status='" & "未結賬" & "'"
     Set rst = executeSQL(txtSQL, msgtext)
     If IsNull(rst.Fields(0)) Then
         Text5.Text = 0
     Else
         Text5.Text = rst.Fields(0)
     End If
  '臨時收費金額
'     txtSQL = "select sum(addmoney) from ReCharge_Info where type ='臨時使用者'and status='未結賬'and UserID='" & Val(Trim(Comboname.Text)) & "'"
      txtSQL = "select sum(addmoney) from ReCharge_Info where status='未結賬'and UserID='" & Val(Trim(Combo1.Text)) & "'"
     Set mraa = executeSQL(txtSQL, msgtext)
     If IsNull(mraa.Fields(0)) Then
       Text4.Text = 0
     Else
        Text4.Text = mraa.Fields(0)
     End If
   '總售卡數
   Text6.Text = Val(Text2.Text) - Val(Text1.Text)
   '應收金額
   Text7.Text = Val(Text3.Text) - Val(Text5.Text)
   
     對於結賬之後更新各個表的狀態我還是沒有很好的弄明白,所以後續再說。