addstudin.frm

来自「简单的数据库系统」· FRM 代码 · 共 891 行 · 第 1/2 页

FRM
891
字号
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   8
      Left            =   4800
      TabIndex        =   23
      Top             =   2880
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "入校时间"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   7
      Left            =   240
      TabIndex        =   22
      Top             =   3960
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "团员与否"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   6
      Left            =   240
      TabIndex        =   21
      Top             =   2760
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "出生日期"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   5
      Left            =   240
      TabIndex        =   20
      Top             =   3360
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "宿舍电话号码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   4
      Left            =   4800
      TabIndex        =   19
      Top             =   1680
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "宿舍号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   3
      Left            =   4800
      TabIndex        =   18
      Top             =   1200
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "性别"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   2
      Left            =   240
      TabIndex        =   17
      Top             =   1815
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   "姓名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   240
      TabIndex        =   16
      Top             =   1155
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   "学号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   735
   End
End
Attribute VB_Name = "addstudentin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   Combo2.SetFocus
End If
End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   Combo3.SetFocus
End If
End Sub

Private Sub Combo3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   Text3.SetFocus
End If
End Sub

Private Sub Command1_Click()
If Command1.Caption = "确定" Then
   If Not Testtxt(Text1.Text) Then
      MsgBox "请输入学号!", 48, "提示"
      Text1.SetFocus
      Exit Sub
    End If
   If Not Testtxt(Text2.Text) Then
      MsgBox "请输入姓名!", 48, "提示"
      Text2.SetFocus
      Exit Sub
   End If
   If Not Testtxt(Combo1.Text) Then
      MsgBox "请选择性别!", 48, "提示"
      Combo1.SetFocus
      Exit Sub
   End If
   If Not Testtxt(Combo2.Text) Then
     MsgBox "请选择民族!", 48, "提示"
     Combo2.SetFocus
     Exit Sub
   End If
   If Not Testtxt(Combo3.Text) Then
     MsgBox "请选择团员与否 !", 48, "提示"
     Combo3.SetFocus
     Exit Sub
   End If
   If Not Testtxt(Text3.Text) Then
     MsgBox "请输入出生日期 !", 48, "提示"
     Text3.SetFocus
     Exit Sub
   End If
   If Not Testtxt(Text4.Text) Then
      MsgBox "请输入入校时间!", 48, "提示"
      Text4.SetFocus
      Exit Sub
   End If
   If Not Testtxt(Text5.Text) Then
      MsgBox "请输入班级!", 48, "提示"
      Text5.SetFocus
      Exit Sub
   End If
   If Not Testtxt(Text6.Text) Then
      MsgBox "请输入宿舍号!", 48, "提示"
      Text6.SetFocus
      Exit Sub
   End If
   If Not Testtxt(Text7.Text) Then
      MsgBox "请输入家庭住址!", 48, "提示"
      Text7.SetFocus
      Exit Sub
   End If
   
    '=============================================
    '+++++++++++++++++++++++++++++++++++++++++++++++++
    txtSQL = "select * from student "
    Set dream = ExecuteSQL(txtSQL, Msgtext)
    dream.MoveFirst
    'number exist ?
    While (dream.EOF = False)
       If (dream.Fields(0)) = Trim(Text1.Text) Then
         MsgBox "学号已经存在!", 48, "提示"
         Text1.SetFocus
         Exit Sub
          'Text1.Text = ""
         'Text1.SetFocus
       Else
         dream.MoveNext
      End If
    Wend
    dream.AddNew
    dream.Fields(0) = Trim(Text1.Text)
    dream.Fields(1) = Trim(Text2.Text)
    dream.Fields(2) = Trim(Combo1.Text)
    dream.Fields(3) = Trim(Combo2.Text)
    dream.Fields(4) = Trim(Combo3.Text)
    dream.Fields(5) = Trim(Text3.Text)
    dream.Fields(6) = Trim(Text4.Text)
    dream.Fields(7) = Trim(Text5.Text)
    dream.Fields(8) = Trim(Text6.Text)
    dream.Fields(9) = Trim(Text7.Text)
    dream.Fields(10) = Trim(Text8.Text)
    dream.Fields(11) = Trim(Text9.Text)
    dream.Fields(12) = Trim(Text10.Text)
    dream.Fields(13) = Trim(Text11.Text)
    dream.Fields(14) = Trim(Text12.Text)
    dream.UpdateBatch
    '=================================================
    MsgBox "添加学生信息成功!", 48, "提示"
    Command1.Enabled = True
    Command2.Enabled = True
    Command3.Enabled = True
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text10.Text = ""
    Text11.Text = ""
    Text12.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Combo3.Text = ""
 Else
 
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text10.Text = ""
    Text11.Text = ""
    Text12.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Combo3.Text = ""
    Combo1.AddItem "男"
    Combo1.AddItem "女"
    Combo2.AddItem "汉族"
    Combo2.AddItem "回族"
    Combo2.AddItem "彝族"
    Combo2.AddItem "布依族"
    Combo3.AddItem "是"
    Combo3.AddItem "否"
  End If
End Sub

Private Sub Command2_Click()
Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text10.Text = ""
    Text11.Text = ""
    Text12.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Combo3.Text = ""
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Command4_Click()
On Error Resume Next
Dim openfilename As String
CommonDialog1.CancelError = True
CommonDialog1.Filter = "*.bmp|*.gif|*.jpg|所有文件(*.*)|*.*"
CommonDialog1.InitDir = "f:\schoolgroup\picture"
CommonDialog1.Flags = &H200000
CommonDialog1.Action = 1
CommonDialog1.ShowOpen
If err.Number = 32755 Then Exit Sub
openfilename = CommonDialog1.FileName
Picture1.Picture = LoadPicture("f:\schoolgroup\picture\123.jpg")
End Sub

Private Sub Form_Activate()
Text1.SetFocus
End Sub

Private Sub Form_Load()
 
   Combo1.AddItem "男"
   Combo1.AddItem "女"
   Combo2.AddItem "汉族"
   Combo2.AddItem "回族"
   Combo2.AddItem "彝族"
   Combo2.AddItem "布依族"
   Combo3.AddItem "是"
   Combo3.AddItem "否"
End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   Text2.SetFocus
 End If
End Sub

Private Sub Text10_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text11.SetFocus
 End If
End Sub

Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text12.SetFocus
 End If
End Sub

Private Sub Text12_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Call Command1_Click
 End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
   Combo1.SetFocus
 End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   Text4.SetFocus
 End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text5.SetFocus
 End If
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text6.SetFocus
 End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text7.SetFocus
 End If
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text8.SetFocus
 End If
End Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text9.SetFocus
 End If
End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  Text10.SetFocus
 End If
End Sub

⌨️ 快捷键说明

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