来了来了,来来来上上!!! 这次是注册
Private Sub cmdStorage_Click()
Dim mrc As ADODB.Recordset
Dim MsgText As String
Dim txtSQL As String
txtSQL = "select * from student_Info " '查询学生表
Set mrc = ExecuteSQL(txtSQL, MsgText) '赋值
If Not (mrc.EOF And mrc.BOF) Then '数据库里一定有数据
mrc.MoveFirst '指针移动到第一条数据
End If
While (mrc.EOF = False) '这条数据在这个表中存在
If (Trim(mrc.Fields(0)) = Trim(txtCardNumber.Text)) Then '用文本框的卡号查询
MsgBox "卡号已经存在,请重新输入卡号!", vbOKOnly + vbExclamation, "警告"
txtCardNumber.Text = "" '清空
txtCardNumber.SetFocus '获取焦点
Exit Sub
Else
mrc.MoveNext
End If
Wend
mrc.AddNew
mrc.Fields(0) = Trim(txtClassno.Text)
mrc.Fields(7) = Trim(txtMoney.Text)
mrc.Fields(1) = Trim(txtStudentID.Text)
mrc.Fields(2) = Trim(txtName.Text)
mrc.Fields(3) = Trim(cboSex.Text)
mrc.Fields(4) = Trim(txtSystem.Text)
mrc.Fields(5) = Trim(txtgrade.Text)
mrc.Fields(6) = Trim(txtclass.Text)
mrc.Fields(10) = Trim(txtState.Text)
mrc.Fields(14) = Trim(cboType.Text)
mrc.Fields(8) = Trim(txtNotes.Text)
If Not Testtxt(txtCardNumber.Text) Then
MsgBox "请输入教室房间号!", vbOKOnly + vbExclamation, "警告"
txtCardNumber.SetFocus
Exit Sub
End If
If Not Testtxt(txtMoney.Text) Then
MsgBox "请输入充值金额!", vbOKOnly + vbExclamation, "警告"
txtMoney.SetFocus
Exit Sub
End If
If Not Testtxt(txtStudentID.Text) Then
MsgBox "请输入学号!", vbOKOnly + vbExclamation, "警告"
txtStudentID.SetFocus
Exit Sub
End If
If Not Testtxt(txtName.Text) Then
MsgBox "请输入姓名!", vbOKOnly + vbExclamation, "警告"
txtName.SetFocus
Exit Sub
End If
If Not Testtxt(cboSex.Text) Then
MsgBox "请选择性别!", vbOKOnly + vbExclamation, "警告"
cboSex.SetFocus
Exit Sub
End If
If Not Testtxt(txtSystem.Text) Then
MsgBox "请输入系别!", vbOKOnly + vbExclamation, "警告"
txtSystem.SetFocus
Exit Sub
End If
If Not Testtxt(txtgrade.Text) Then
MsgBox "请输入年级!", vbOKOnly + vbExclamation, "警告"
txtgrade.SetFocus
Exit Sub
End If
If Not Testtxt(txtclass.Text) Then
MsgBox "请输入班级!", vbOKOnly + vbExclamation, "警告"
txtclass.SetFocus
Exit Sub
End If
If Not Testtxt(cboType.Text) Then
MsgBox "请选择类型!", vbOKOnly + vbExclamation, "警告"
cboType.SetFocus
Exit Sub
End If
End Sub