⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frminputstuinfor.frm

📁 sql+vb实现招生管理系统
💻 FRM
📖 第 1 页 / 共 4 页
字号:
         Width           =   735
      End
      Begin VB.Label Label6 
         BackColor       =   &H0000FFFF&
         Caption         =   "籍贯"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2280
         TabIndex        =   18
         Top             =   840
         Width           =   855
      End
      Begin VB.Label Label5 
         BackColor       =   &H0000FFFF&
         Caption         =   "政治面貌"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   16
         Top             =   840
         Width           =   855
      End
      Begin VB.Label Label4 
         BackColor       =   &H0000FFFF&
         Caption         =   "户口所在地"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   5880
         TabIndex        =   14
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label3 
         BackColor       =   &H0000FFFF&
         Caption         =   "性别"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4320
         TabIndex        =   12
         Top             =   240
         Width           =   615
      End
      Begin VB.Label Label2 
         BackColor       =   &H0000FFFF&
         Caption         =   "姓名"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2280
         TabIndex        =   10
         Top             =   240
         Width           =   735
      End
      Begin VB.Label Label1 
         BackColor       =   &H0000FFFF&
         Caption         =   "准考证号"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Width           =   855
      End
   End
End
Attribute VB_Name = "FrmInputStuInfor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs_Stu As New ADODB.Recordset
Dim rs_Grade As New ADODB.Recordset
Dim rs_Wish As New ADODB.Recordset
Dim rs_Study As New ADODB.Recordset
Dim rs_Relation As New ADODB.Recordset
Dim rs1_Relation As New ADODB.Recordset
Dim sql1_Relation As String
Dim rs_check As New ADODB.Recordset '用于检测添加记录时是否有重复的准考证号
Public MyConnection As ADODB.Connection
Public ConString As String


Private Sub AddCommand_Click()
   '先检测是否添了一些必要信息
   Dim i As Integer
   Dim j As Integer
    If IsNumeric(Text1(0).Text) = False Then
      MsgBox "准考证号应该为数字!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
   For i = 0 To 6
      If Text1(i).Text = "" Then
         MsgBox "考生基本信息不可为空!", vbOKOnly + vbInformation, "注意"
         Exit Sub
      End If
   Next i
   '检测年龄是否为数字
   If IsNumeric(Text1(5).Text) = False Then
      MsgBox "年龄必须为数字!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
   '检测日期书写是否正确
   If IsDate(Text1(6).Text) = False Then
      MsgBox "出生日期书写不对,应为2000-1-1这样的格式!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
     '检测考生成绩是否已输入并且是否为数字
   For i = 0 To 3
      If Text2(i).Text = "" Then
         MsgBox "考生分数信息不可为空!", vbOKOnly + vbInformation, "注意"
         Exit Sub
      End If
      If IsNumeric(Text2(i).Text) = False Then
         MsgBox "考生分数应为数字!", vbOKOnly + vbInformation, "注意"
         Exit Sub
      End If
   Next i
   '检测考生第一志愿学校是否为空
   If Text3(0).Text = "" Then
      MsgBox "考生志愿信息不可为空!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
   '检测考生个人简历是否为空
   For i = 0 To 2
      If Text4(i).Text = "" Then
         MsgBox "考生个人简历信息不可为空!", vbOKOnly + vbInformation, "注意 "
         Exit Sub
      End If
   Next i
   '检测日期书写是否正确
   If IsDate(Text4(2)) = False Then
      MsgBox "毕业日期书写不对,应为2000-1-1这样的格式!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
   '亲属信息可以不可为空,而且必须有两个
   If Text5(0).Text = "" Or Text5(1).Text = "" Then
      MsgBox "亲属信息不能为空!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
   If Text5(7).Text = "" Or Text5(8).Text = "" Then
      MsgBox "第二个亲属信息也不能为空!", vbOKOnly + vbInformation, "注意"
      Exit Sub
   End If
  
   '计算总成绩
   Dim sum As Integer
   sum = 0
   For i = 0 To 4
      sum = sum + Val(Text2(i).Text)
   Next i
   '总分等于各科分数之和
   Text2(5).Text = sum
   
   '检测输入的准考证号是否已存在,如果存在则提示用户输入另一个
   Dim sqlCheck As String
   sqlCheck = "select * from StuBasicInfor where CandidatesID= " & Val(Text1(0).Text)
   rs_check.Open sqlCheck, MyConnection, adOpenStatic, adLockOptimistic
   If Not rs_check.EOF Then
       MsgBox "该准考证号已经存在,请重填一个!", vbOKOnly + vbInformation, "注意"
       rs_check.Close
       Exit Sub
   End If
   rs_check.Close
   
   '把用户输入信息添加入各表
   rs_Stu.AddNew
   rs_Stu.Fields(0) = Val(Text1(0).Text)
   rs_Stu.Fields(1) = Text1(1).Text
   rs_Stu.Fields(2) = Combo1.Text
   For i = 2 To 4
      rs_Stu.Fields(i + 1) = (Text1(i).Text)
   Next i
   rs_Stu.Fields(6) = Val(Text1(5).Text)
   rs_Stu.Fields(7) = Text1(6).Text
   rs_Stu.Update
   
    '下面的加入成绩表为了简约代码,分成3部分完成
   rs_Grade.AddNew
   rs_Grade.Fields(0) = Val(Text1(0).Text)
   rs_Grade.Fields(1) = Text1(1).Text  '准考证号的姓名使用考生基本信息表中的
   For i = 0 To 5
      rs_Grade.Fields(i + 2) = Val(Text2(i).Text)
   Next i
   rs_Grade.Fields(8) = Combo2.Text
   rs_Grade.Fields(9) = Combo3.Text
   rs_Grade.Update
   
   rs_Wish.AddNew
   rs_Wish.Fields(0) = Val(Text1(0).Text)
   rs_Wish.Fields(1) = Text1(1).Text
   For i = 0 To 5
      rs_Wish.Fields(i + 2) = Text3(i).Text
   Next i
   rs_Wish.Update
   
   rs_Study.AddNew
   rs_Study.Fields(0) = Val(Text1(0).Text)
   rs_Study.Fields(1) = Text1(1).Text
   For i = 0 To 3
      rs_Study.Fields(i + 2) = Text4(i).Text
   Next i
   rs_Study.Update
   
   rs_Relation.AddNew
   rs_Relation.Fields(0) = Val(Text1(0).Text)
   rs_Relation.Fields(1) = Text1(1).Text
   For i = 0 To 13
      rs_Relation.Fields(i + 2) = Text5(i).Text
   Next i
   rs_Relation.Update
   
   MsgBox "添加考生信息成功!", vbOKOnly + vbExclamation, "注意"
   
   '置空所有textbox便于输入另一信息
   For i = 0 To 6
      Text1(i).Text = ""
   Next i
   For i = 0 To 4
      Text2(i).Text = ""
   Next i
   For i = 0 To 5
      Text3(i).Text = ""
   Next i
   For i = 0 To 3
      Text4(i).Text = ""
   Next i
   For i = 0 To 12
      Text5(i).Text = ""
   Next i
End Sub



Private Sub CancelCommand_Click()
   Unload Me
End Sub

Private Sub ResetCommand_Click()
   '置空所有textbox控件
   For i = 0 To 6
      Text1(i).Text = ""
   Next i
   For i = 0 To 4
      Text2(i).Text = ""
   Next i
   For i = 0 To 5
      Text3(i).Text = ""
   Next i
   For i = 0 To 3
      Text4(i).Text = ""
   Next i
   For i = 0 To 13
      Text5(i).Text = ""
   Next i
End Sub


Private Sub Form_Load()
   '先设置各个ComboBox的默认值
   Combo1.ListIndex = 0
   Combo2.ListIndex = 0
   Combo3.ListIndex = 0
   '设置总分一栏不可写
   Text2(5).Enabled = False
   Dim sql_Stu As String
   Dim sql_Grade As String
   Dim sql_Wish As String
   Dim sql_Study As String
   Dim sql_Relation As String
   
   Set MyConnection = New ADODB.Connection
ConString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Education_Maneger_System"
MyConnection.Open ConString

   
   
   '在from_laod()方法中打开5个考生信息表
   sql_Stu = "select * from StuBasicInfor"
   rs_Stu.CursorLocation = adUseClient
   rs_Stu.Open sql_Stu, MyConnection, adOpenStatic, adLockOptimistic
   
   sql_Grade = "select * from StudentGrade"
   rs_Grade.CursorLocation = adUseClient
   rs_Grade.Open sql_Grade, MyConnection, adOpenStatic, adLockOptimistic
   
   sql_Wish = "select * from StuVolunteers"
   rs_Wish.CursorLocation = adUseClient
   rs_Wish.Open sql_Wish, MyConnection, adOpenStatic, adLockOptimistic
   
   sql_Study = "select * from StuExperience"
   rs_Study.CursorLocation = adUseClient
   rs_Study.Open sql_Study, MyConnection, adOpenStatic, adLockOptimistic
   
   sql_Relation = "select * from Sturelation"
   rs_Relation.CursorLocation = adUseClient
   rs_Relation.Open sql_Relation, MyConnection, adOpenStatic, adLockOptimistic
   
   sql1_Relation = "select * from Sturelation"
   rs1_Relation.CursorLocation = adUseClient
   rs1_Relation.Open sql1_Relation, MyConnection, adOpenStatic, adLockOptimistic
End Sub

Private Sub Form_Unload(Cancel As Integer)
   rs_Stu.Close
   rs_Grade.Close
   rs_Wish.Close
   rs_Study.Close
   rs_Relation.Close
   rs1_Relation.Close
   
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -