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

📄 frmsupmod.frm

📁 超市的管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   960
      End
   End
End
Attribute VB_Name = "frmSupMOD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Private Sub CmdExit_Click()

    Unload Me

End Sub

Private Sub CmdSave_Click()

    Dim str As String
    
    '判断各文本框输入是否为空

    If TxtName = "" Then
        
        MsgBox "厂商名称输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtName.Text = ""
        
        TxtName.SetFocus
        
        Exit Sub
            
    End If
    
    If TxtAddress.Text = "" Then
    
        MsgBox "地址输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtAddress.Text = ""
        
        TxtAddress.SetFocus
        
        Exit Sub
            
    End If
    
    If TxtCity.Text = "" Then
    
        MsgBox "城市输入不能为空,请重输!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtName.Text = ""
        
        TxtName.SetFocus
        
        Exit Sub
            
    End If
    
    If TxtState.Text = "" Then
    
        MsgBox "省份输入能为空,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtState.Text = ""
        
        TxtState.SetFocus
        
        Exit Sub
        
    End If
    
    If TxtPhone.Text = "" Then
    
        MsgBox "电话号码输入能为空,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtPhone.Text = ""
        
        TxtPhone.SetFocus
        
        Exit Sub
        
    End If
    
    If TxtBA.Text = "" Then
    
        MsgBox "银行帐号输入能为空,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
        
        TxtBA.Text = ""
        
        TxtBA.SetFocus
        
        Exit Sub
        
    End If
    
    If MsgBox("确认要保存到数据库吗?", vbInformation + vbOKCancel, "保存确认!") = vbOK Then
       
        str = "update suppliers set companyname= " & "'" & TxtName.Text & "'" & "," & "address=" & "'" & TxtAddress.Text & "'" & _
           "," & "city=" & "'" & TxtCity.Text & "'" & "," & "state=" & "'" & TxtState.Text & "'" & "," & "phone=" & _
           "'" & TxtPhone.Text & "'" & "," & "bankaccounts=" & "'" & TxtBA.Text & "'" & "where suppliersid=" & "'" & TxtID.Text & "'"
        
        QueryXFInfo (str)
        
        MsgBox "已成功到数据库!", vbInformation + vbOKOnly, "保存提示!"
           
    Else
    
        Exit Sub
        
    End If

End Sub

Private Sub Form_Load()
    
    '窗体运行时表格中显示需修改记录的各项属性
    
    TxtID.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 1)
    
    TxtName.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 2)
    
    TxtAddress.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 3)
    
    TxtCity.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 4)
    
    TxtState.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 5)
    
    TxtPhone.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 6)
    
    TxtBA.Text = frmQSupplier.MSFlexGrid1.TextMatrix(frmQSupplier.MSFlexGrid1.Row, 7)
    
    TxtID.Enabled = False

End Sub

'判断各文本框的输入合法性

Private Sub TxtAddress_LostFocus()

    If TxtAddress.Text <> "" Then
    
        If IsChar(TxtAddress.Text) = False Then
        
             MsgBox "厂商地址输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
             
             TxtAddress.Text = ""
             
             TxtAddress.SetFocus
             
             Exit Sub
             
        End If
        
    End If

End Sub



Private Sub TxtBA_LostFocus()

    If TxtBA.Text <> "" Then
    
        If IsNumber(TxtBA.Text) = False Then
        
            MsgBox "银行帐号输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
        
            TxtBA.Text = ""
        
            TxtBA.SetFocus
        
            Exit Sub
        
        End If
        
    End If

End Sub



Private Sub TxtName_LostFocus()

    If TxtName.Text <> "" Then
    
        If IsChar(TxtName.Text) = False Then
        
            MsgBox "厂商名称输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
            
            TxtName.Text = ""
            
            TxtName.SetFocus
            
            Exit Sub
            
        End If
        
    End If
    
End Sub


Private Sub TxtCity_LostFocus()

    If TxtCity.Text <> "" Then
    
        If IsChar(TxtCity.Text) = False Then
        
            MsgBox "城市输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
            
            TxtCity.Text = ""
            
            TxtCity.SetFocus
            
            Exit Sub
            
        End If
        
    End If

End Sub

Private Sub TxtState_LostFocus()

    If TxtState.Text <> "" Then
    
        If IsChar(TxtState.Text) = False Then
        
            MsgBox "省份输入不合法,请重新输入!", vbInformation + vbOKOnly, "输入提示!"
            
            TxtState.Text = ""
            
            TxtState.SetFocus
            
            Exit Sub
            
        End If
        
    End If

End Sub

Private Sub TxtPhone_LostFocus()

    Dim str As String

    str = TxtPhone.Text

    Dim i As Integer
    
    Dim intindex As Integer
    
    intindex = 0
    
    Dim length As Integer
    
    length = Len(str)
    
    For i = 1 To length
    
        If Left(str, 1) >= "0" And Left(str, 1) <= "9" Or Left(str, 1) = "-" Then
        
            If Left(str, 1) = "-" Then
            
                intindex = intindex + 1
                
            End If
        
        Else
            
            MsgBox "电话号码输入不合法,请重新输入", vbInformation + vbOKOnly, "输入提示!"
        
            TxtPhone.Text = ""
            
            TxtPhone.SetFocus
            
            Exit Sub
                
        End If
        
        str = Right(str, Len(str) - 1)                                               '此处的str动态变化!!
        
    Next i
    
    If intindex > 1 Then
    
        MsgBox "电话号码输入不合法,请重新输入", vbInformation + vbOKOnly, "输入提示!"
        
        TxtPhone.Text = ""
        
        TxtPhone.SetFocus
        
        Exit Sub
        
    End If

End Sub

⌨️ 快捷键说明

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