機房收費系統——註冊窗體
阿新 • • 發佈:2018-11-10
這是機房收費系統的第一個窗體,所以也很基礎,雖然很基礎,但是這些程式碼我們仍然沒有能力去獨立完成,那麼這個時候我們就會藉助很多工具,比如師哥師姐的部落格,百度等等。從他們的部落格裡面我們也就能找到自己的思路了,請看一下我的思路!
以下是程式碼展示:
Option Explicit Private Sub cmdCancel_Click() Me.Hide End Sub Private Sub cmdCheck_Click() InquiryBalance.Show End Sub在這裡插入程式碼片 Private Sub cmdDelete_Click() txtCardNo.Text = "" txtCash.Text = "" txtSID.Text = "" txtName.Text = "" txtGrade.Text = "" txtClass.Text = "" txtDept.Text = "" txtMark.Text = "" comboSex.Text = "" ComboState.Text = "" CombType.Text = "" End Sub Private Sub cmdSave_Click() Dim txtsql As String Dim msgtext As String Dim mrc As ADODB.Recordset Dim mrc1 As ADODB.Recordset Dim mrc2 As ADODB.Recordset '判斷卡號是否為空 If txtCardNo.Text = "" Then MsgBox "請輸入卡號!", 0 + 48, "警告" Else If Not IsNumeric(txtCardNo.Text) Then MsgBox "請輸入數字", 0 + 48, "警告" Exit Sub txtCardNo.SetFocus Else '若卡號存在則建議查詢 txtsql = "select * from student_info where cardno='" & txtCardNo.Text & "'" Set mrc = ExecuteSQL(txtsql, msgtext) If mrc.EOF = False Then MsgBox "此卡號已經存在,您可查詢餘額!", 0 + 48, "警告" txtCardNo.SetFocus txtCardNo.Text = "" Else '若卡號不存在,則輸入基本資訊 If Not testtxt(txtCash.Text) Then MsgBox "請輸入充值金額!", 0 + 48, "警告" Exit Sub End If txtsql = "select * from basicdata_info " Set mrc1 = ExecuteSQL(txtsql, msgtext) If txtCash.Text < Trim(mrc1.Fields(5)) Then MsgBox "金額小於最低餘額充值!", 0 + 48, "警告" Exit Sub End If If Not testtxt(txtSID.Text) Then MsgBox "請輸入學號!", 0 + 48, "警告" Exit Sub End If If Not testtxt(txtName.Text) Then MsgBox "請輸入姓名!", 0 + 48, "警告" Exit Sub End If If Not testtxt(txtGrade.Text) Then MsgBox "請輸入年級!", 0 + 48, "警告" Exit Sub End If If Not testtxt(txtClass.Text) Then MsgBox "請輸入班級!", 48, "警告" Exit Sub End If If Not testtxt(comboSex.Text) Then MsgBox "請選擇性別!", 48, "警告" Exit Sub End If If Not testtxt(txtDept.Text) Then MsgBox "請輸入系別!", 48, "警告" Exit Sub End If If Not testtxt(ComboState.Text) Then MsgBox "請選擇狀態!", 48, "警告" Exit Sub End If If Not testtxt(CombType.Text) Then MsgBox "請選擇型別!", 48, "警告" Exit Sub End If If Not testtxt(txtMark.Text) Then txtMark.Text = "無" End If '往資料庫新增資訊 txtsql = "select * from user_info" Set mrc2 = ExecuteSQL(txtsql, msgtext) mrc.AddNew mrc.Fields(0) = Trim(txtCardNo.Text) mrc.Fields(1) = Trim(txtSID.Text) mrc.Fields(2) = Trim(txtName.Text) mrc.Fields(3) = Trim(comboSex.Text) mrc.Fields(4) = Trim(txtDept.Text) mrc.Fields(5) = Trim(txtGrade.Text) mrc.Fields(6) = Trim(txtClass.Text) mrc.Fields(7) = Trim(txtCash.Text) mrc.Fields(8) = Trim(txtMark.Text) mrc.Fields(9) = mrc2.Fields(0) mrc.Fields(10) = Trim(ComboState.Text) mrc.Fields(11) = "未結賬" mrc.Fields(12) = Date mrc.Fields(13) = Time mrc.Fields(14) = Trim(CombType.Text) mrc.Update mrc.Close MsgBox "註冊成功!", vbOKOnly, "恭喜!" End If End If End If End Sub Private Sub Form_Load() comboSex.AddItem "男" comboSex.AddItem "女" ComboState.AddItem "使用" CombType.AddItem "臨時使用者" CombType.AddItem "固定使用者" End Sub