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

📄 frmmodifycheck.frm

📁 该系统的最终用户是访问本系统的工作人员
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   Begin VB.Line Line1 
      X1              =   120
      X2              =   10440
      Y1              =   1920
      Y2              =   1920
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "日期           栋号          寝室号         评分1          评分2          评分3         总分           平均分"
      Height          =   375
      Left            =   360
      TabIndex        =   14
      Top             =   2160
      Width           =   10455
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "添加与修改检查信息"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   18
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3240
      TabIndex        =   8
      Top             =   240
      Width           =   3615
   End
End
Attribute VB_Name = "frmmodifycheck"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mrc As ADODB.Recordset
Dim myBookmark As Variant
Dim mcclean As Boolean

Public Sub viewData()
    Text1(0).Text = mrc.Fields(0)
    Text2.Text = mrc.Fields(1)
    Text3.Text = mrc.Fields(2)
    Text4.Text = mrc.Fields(3)
    Text5.Text = mrc.Fields(4)
    Text6.Text = mrc.Fields(5)
    Text7.Text = mrc.Fields(6)
    Text8.Text = mrc.Fields(7)
    
End Sub


Private Sub cancelCommand_Click()
 
  If Not mcclean Then
       
        firstCommand.Enabled = True
        previousCommand.Enabled = True
        nextCommand.Enabled = True
        lastCommand.Enabled = True
            
        Text1(0).Enabled = False
        Text2.Enabled = False
        Text3.Enabled = False
        Text4.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
        Text7.Enabled = False
        Text8.Enabled = False
        
        mrc.Bookmark = myBookmark
        Call viewData
    Else
        MsgBox "什么都没有修改,有什么好取消的!", vbOKOnly + vbExclamation, "警告"
    End If
 
 
 
End Sub

Private Sub comCancle_Click()
Unload Me

End Sub

Private Sub cominqure_Click()
Dim txtSQL As String
    Dim MsgText As String
    Dim dd(4) As Boolean
    Dim mrc As ADODB.Recordset
    Dim rs As Boolean
    rs = True
    txtSQL = "select * from hygiene_check where "
    If Check1.Value Then
        If Trim(Combo1.Text) = "" Then
            sMeg = "栋号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo1.SetFocus
            Exit Sub
        Else
            If Not IsNumeric(Trim(Combo1.Text)) Then
                MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
                Exit Sub
                Combo1.SetFocus
            End If
            dd(0) = True
            txtSQL = txtSQL & "栋号 = '" & Val(Trim(Combo1.Text)) & "'"
            Set mrc = ExecuteSQL(txtSQL, MsgText)
              If mrc.EOF Then
                 rs = False
                 MsgBox "你输入的栋号不存在,请重新输入!!", vbOKOnly + vbExclamation, "警告"
                 Combo1.Text = ""
                 Combo1.SetFocus
                 
              End If
        End If
  
    End If
    
    If Check2.Value Then
        If Trim(Combo2.Text) = "" Then
            sMeg = "栋号和寝室号不能为空"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            Combo2.SetFocus
            Exit Sub
        Else
            dd(1) = True
            If dd(0) Then
                txtSQL = txtSQL & "and 寝室号= '" & Combo2.Text & "'"
                Set mrc = ExecuteSQL(txtSQL, MsgText)
                  If mrc.EOF Then
                    rs = False
                    MsgBox "你输入的寝室不存在,请重新输入!!", vbOKOnly + vbExclamation, "警告"
                    Combo2.Text = ""
                    Combo2.SetFocus
                  End If
            Else
                txtSQL = txtSQL & " 寝室号= '" & Combo2.Text & "'"
            End If
        End If
    End If
    
    If Check3.Value Then
        If Trim(txttime.Text) = "" Then
            sMeg = "请输入时间"
            MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
            txttime.SetFocus
            Exit Sub
        Else
            dd(2) = True
            If dd(0) Or dd(1) Then
                txtSQL = txtSQL & "and 日期= '" & txttime.Text & "'"
            Else
                txtSQL = txtSQL & " 日期 = '" & txttime.Text & "'"
            End If
        End If
     If Not IsDate(txttime.Text) Then
        MsgBox "输入日期应输入日期格式(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
        txttime.SetFocus
     Else
       txttime = Format(txttime, "yyyy-mm-dd")
     End If
    End If
   
    
    If Not (dd(0) Or dd(1) Or dd(2) Or dd(3)) Then
        MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If rs = True Then
       txtSQL = txtSQL & " order by 寝室号"
        Set mrc = ExecuteSQL(txtSQL, MsgText)
        Text1(0).Text = mrc.Fields(0)
        Text2.Text = mrc.Fields(1)
        Text3.Text = mrc.Fields(2)
        Text5.Text = mrc.Fields(4)
        Text6.Text = mrc.Fields(5)
        Text7.Text = mrc.Fields(6)
        Text8.Text = mrc.Fields(7)
        mrc.Close
     End If
End Sub

Private Sub comOK_Click()
  Dim mrc As ADODB.Recordset
    Dim txtSQL As String
    Dim MsgText As String
    
    If Not Testtxt(Text9.Text) Then
        MsgBox "请输入检查日期!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text10.Text) Then
        MsgBox "请选择栋号!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text11.Text) Then
        MsgBox "请输入寝室号!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text12.Text) Then
        MsgBox "请输入评分1!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text13.Text) Then
        MsgBox "请输入评分2!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text14.Text) Then
        MsgBox "请输入评分3!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    If Not Testtxt(Text15.Text) Then
        MsgBox "请输入总分!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    If Not Testtxt(Text16.Text) Then
        MsgBox "请输入平均分!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    txtSQL = "select * from hygiene_check where 日期 = '" & Text9.Text & "' and 栋号= '" & Text10.Text & "' and 寝室号 = '" & Text11.Text & "'"
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    If mrc.EOF = False Then
        MsgBox "有相同纪录,请重新输入信息!", vbOKOnly + vbExclamation, "警告"
          Text9.Text = ""
        Text10.Text = ""
         Text11.Text = ""
         Text12.Text = ""
         Text13.Text = ""
         Text14.Text = ""
         Text15.Text = ""
         Text16.Text = ""
         Text9.SetFocus
         
        
        mrc.Close
    Else
        mrc.AddNew
        mrc.Fields(0) = Text9.Text
        mrc.Fields(1) = Text10.Text
        mrc.Fields(2) = Text11.Text
        mrc.Fields(3) = Text12.Text
        mrc.Fields(4) = Text13.Text
        mrc.Fields(5) = Text14.Text
        mrc.Fields(6) = Text15.Text
        mrc.Fields(7) = Text16.Text
        mrc.Update
        mrc.Close
        MsgBox "添加检查信息成功!", vbOKOnly + vbExclamation, "警告"
        Text9.Text = ""
        Text10.Text = ""
         Text11.Text = ""
         Text12.Text = ""
         Text13.Text = ""
         Text14.Text = ""
         Text15.Text = ""
         Text16.Text = ""
         Text9.SetFocus
         
    End If
    
End Sub

Private Sub deleteCommand_Click()
myBookmark = mrc.Bookmark
    str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
    If str2$ = vbOK Then
            mrc.MoveNext
            If mrc.EOF Then
                mrc.MoveFirst
                myBookmark = mrc.Bookmark
                mrc.MoveLast
                mrc.Delete
                mrc.Bookmark = myBookmark
                Call viewData
            Else
                myBookmark = mrc.Bookmark
                mrc.MovePrevious
                mrc.Delete
                mrc.Bookmark = myBookmark
                Call viewData
            End If
    Else
        mrc.Bookmark = myBookmark
        Call viewData
    End If
End Sub

Private Sub editCommand_Click()
mcclean = False
    
    firstCommand.Enabled = False
    previousCommand.Enabled = False
    nextCommand.Enabled = False
    lastCommand.Enabled = False
        
    Text1(0).Enabled = True
    Text2.Enabled = True
    Text3.Enabled = True
    Text4.Enabled = True
    Text5.Enabled = True
    Text6.Enabled = True
    Text7.Enabled = True
    Text8.Enabled = True
   
    
    myBookmark = mrc.Bookmark
End Sub

Private Sub firstCommand_Click()

     mrc.MoveFirst
    Call viewData
End Sub

Private Sub Form_Load()
Dim txtSQL As String
    Dim MsgText As String
    
     Text1(0).Enabled = False
    Text2.Enabled = False
     Text3.Enabled = False
     Text4.Enabled = False
     Text5.Enabled = False
     Text6.Enabled = False
     Text7.Enabled = False
     Text8.Enabled = False
     
    txtSQL = "select * from hygiene_check "
    Set mrc = ExecuteSQL(txtSQL, MsgText)
    mrc.MoveFirst
    Call viewData
    myBookmark = mrc.Bookmark
    mcclean = True
End Sub

Private Sub lastCommand_Click()
mrc.MoveLast
    Call viewData
End Sub

Private Sub nextCommand_Click()
 mrc.MoveNext
    If mrc.EOF Then
        mrc.MoveFirst
    End If
    Call viewData
End Sub

Private Sub previousCommand_Click()
mrc.MovePrevious
    If mrc.BOF Then
        mrc.MoveLast
    End If
    Call viewData
End Sub

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

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

Private Sub Text12_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text13.SetFocus
End Sub

Private Sub Text13_KeyPress(KeyAscii As Integer)
 If KeyAscii = 13 Then Text14.SetFocus
End Sub

Private Sub Text14_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then Text15.SetFocus
End Sub

Private Sub Text15_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then Text16.SetFocus
End Sub

Private Sub Text16_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then comOK.SetFocus
End Sub

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

Private Sub updateCommand_Click()
Dim txtSQL As String
    Dim MsgText As String
    Dim mrcc As ADODB.Recordset
    
    If mcclean Then
        MsgBox "请先修改信息!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    
    If Not Testtxt(Text3.Text) Then
        MsgBox "请输入寝室号!", vbOKOnly + vbExclamation, "警告"
        Text3.SetFocus
        Exit Sub
    End If
    
    If Not IsNumeric(Trim(Text2.Text)) Then
        MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
        Text2.SetFocus
    End If
    
        
    If Not Testtxt(Text7.Text) Then
        MsgBox "请输入总分!", vbOKOnly + vbExclamation, "警告"
        comboGrade.SetFocus
        
        Exit Sub
    End If
    
    If Not Testtxt(Text8.Text) Then
        MsgBox "请输入平均分,以便测评!", vbOKOnly + vbExclamation, "警告"
        txtDirector.SetFocus
        Exit Sub
    End If
    
    
    If Not Testtxt(Text4.Text) Then
        MsgBox "请输入评分!", vbOKOnly + vbExclamation, "警告"
        Text4.SetFocus
        Exit Sub
    End If
    
    mrc.Delete
    txtSQL = "select * from hygiene_check where 寝室号 = '" & Trim(Text3.Text) & "'"
    Set mrcc = ExecuteSQL(txtSQL, MsgText)
   ' If mrcc.EOF = False Then
       ' MsgBox "寝室号重复,请重新输入!", vbOKOnly + vbExclamation, "警告"
       ' mrcc.Close
       ' Text3.SetFocus
  '  Else
        mrcc.Close
        mrc.AddNew
        mrc.Fields(0) = Trim(Text1(0).Text)
        mrc.Fields(1) = Trim(Text2.Text)
        mrc.Fields(2) = Trim(Text3.Text)
        mrc.Fields(3) = Trim(Text4.Text)
        mrc.Fields(4) = Trim(Text5.Text)
        mrc.Fields(5) = Trim(Text6.Text)
        mrc.Fields(6) = Trim(Text7.Text)
        mrc.Fields(7) = Trim(Text8.Text)
        mrc.Update
        MsgBox "修改信息成功!", vbOKOnly + vbExclamation, "警告"
        mrc.Bookmark = myBookmark
        Call viewData
        
        firstCommand.Enabled = True
        previousCommand.Enabled = True
        nextCommand.Enabled = True
        lastCommand.Enabled = True
        
        Text1(0).Enabled = False
        Text2.Enabled = False
        Text3.Enabled = False
        Text4.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
        Text7.Enabled = False
        Text8.Enabled = False
                
        mcclean = True
    'End If
End Sub

⌨️ 快捷键说明

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