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

📄 frmaddfittings.frm

📁 一个vb编的计算机机房管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAddFittings 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "配件登记"
   ClientHeight    =   4950
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5940
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4950
   ScaleWidth      =   5940
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加"
      Height          =   375
      Left            =   240
      TabIndex        =   18
      Top             =   4200
      Width           =   975
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除"
      Height          =   375
      Left            =   2400
      TabIndex        =   17
      Top             =   4200
      Width           =   975
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   375
      Left            =   4680
      TabIndex        =   16
      Top             =   4200
      Width           =   975
   End
   Begin VB.CommandButton cmdModi 
      Caption         =   "修改"
      Height          =   375
      Left            =   1320
      TabIndex        =   15
      Top             =   4200
      Width           =   975
   End
   Begin VB.CommandButton cmdSearch 
      Caption         =   "查询"
      Height          =   375
      Left            =   3600
      TabIndex        =   14
      Top             =   4200
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Height          =   3735
      Left            =   600
      TabIndex        =   0
      Top             =   120
      Width           =   4455
      Begin VB.TextBox txtStoreID 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   15
         TabIndex        =   12
         Top             =   2880
         Width           =   1575
      End
      Begin VB.TextBox txtFCount 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   9
         TabIndex        =   11
         Top             =   2400
         Width           =   1575
      End
      Begin VB.TextBox txtPrice 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   9
         TabIndex        =   10
         Top             =   1920
         Width           =   1575
      End
      Begin VB.TextBox txtFType 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   15
         TabIndex        =   9
         Top             =   1440
         Width           =   1575
      End
      Begin VB.TextBox txtBrand 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   20
         TabIndex        =   8
         Top             =   960
         Width           =   1575
      End
      Begin VB.TextBox txtFName 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   10
         TabIndex        =   7
         Top             =   480
         Width           =   1575
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "元"
         Height          =   195
         Left            =   3480
         TabIndex        =   13
         Top             =   2040
         Width           =   180
      End
      Begin VB.Label Label7 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "位置:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   6
         Top             =   2880
         Width           =   945
      End
      Begin VB.Label Label6 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "数量:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   5
         Top             =   2400
         Width           =   945
      End
      Begin VB.Label Label5 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "价格:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   4
         Top             =   1920
         Width           =   945
      End
      Begin VB.Label Label4 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "型号:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   3
         Top             =   1440
         Width           =   945
      End
      Begin VB.Label Label3 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "品牌:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   2
         Top             =   960
         Width           =   945
      End
      Begin VB.Label Label1 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         Caption         =   "名称:"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   14.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   285
         Left            =   840
         TabIndex        =   1
         Top             =   480
         Width           =   945
      End
   End
End
Attribute VB_Name = "frmAddFittings"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' FNAME Not VarChar(20), --配件名称
' BRAND VarChar(40), --品牌
' FTYPE Not VarChar(30), --型号
' PRICE Not Money, --价格
' FCOUNT INT NOT NULL,   --数量
' STOREID VARCHAR(30))   --存储地点,但个字符表示仓库,其他表示地点

Private objFittings As New fittings


Private Sub cmdAdd_Click()

    If checkForm() = True Then
        Call getFormValues
    
    '添加内容到数据库
        If objFittings.AddNew() Then
            MsgBox "数据添加成功!"
            Call resetForm(Me)
        Else
            MsgBox "数据添加失败!"
        End If
    Else
        Exit Sub
    End If
    Call resetForm(Me)
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdDel_Click()
    
    If Me.txtFName.Text = "" Then
        MsgBox "配件名称不能为空!"
        Me.txtFName.SetFocus
        Exit Sub
    End If
    
    If Me.txtBrand.Text = "" Then
        MsgBox "配件品牌不能为空!"
        Me.txtBrand.SetFocus
        Exit Sub
    End If
    
    If Me.txtFType.Text = "" Then
        MsgBox "配件型号不能为空!"
        Me.txtFType.SetFocus
        Exit Sub
    End If
    Call getFormValues
    
    If MsgBox("确认要删除该记录吗?", vbOKCancel) Then
        If objFittings.Delete() = True Then
            MsgBox "数据删除成功!"
        Else
            MsgBox "数据删除失败!"
        End If
    End If
    Call resetForm(Me)
    
End Sub

Private Sub cmdModi_Click()
    
    If checkForm() = True Then
        Call getFormValues
        If objFittings.Modify() Then
            MsgBox "数据修改成功!"
            Call resetForm(Me)
        Else
            MsgBox "数据修改失败!"
        End If
    Else
        Exit Sub
    End If
    Call resetForm(Me)
End Sub

Private Sub cmdSearch_Click()
    Dim rsS As ADODB.Recordset
    Dim strCondition As String
    
    
    If Me.txtFName.Text = "" Then
        MsgBox "配件名称不能为空!"
        Me.txtFName.SetFocus
        Exit Sub
    End If
    If Me.txtBrand.Text = "" Then
        MsgBox "配件品牌不能为空!"
        Me.txtBrand.SetFocus
        Exit Sub
    End If
    If Me.txtFType.Text = "" Then
        MsgBox "配件型号不能为空!"
        Me.txtFType.SetFocus
        Exit Sub
    End If
    
    objFittings.fname = Me.txtFName.Text
    objFittings.brand = Me.txtBrand.Text
    objFittings.ftype = Me.txtFType.Text
    
    strCondition = "fname='" & objFittings.fname & "' and FTYPE = '" & objFittings.ftype & "' and brand='" & objFittings.brand & "'"
    Set rsS = objDBOpt.getRecord("fittings", "*", strCondition)
    If rsS Is Nothing Then
        MsgBox "数据查询失败!"
        Exit Sub
    End If
    If rsS.EOF And rsS.BOF Then
        MsgBox "没有符合条件的数据!"
        rsS.Close
        Exit Sub
    End If
    Me.txtFName.Text = setNotNull(rsS.Fields("fname").Value)
    Me.txtBrand.Text = setNotNull(rsS.Fields("brand").Value)
    Me.txtFType.Text = setNotNull(rsS.Fields("ftype").Value)
    Me.txtPrice.Text = setNotNull(rsS.Fields("price").Value)
    Me.txtFCount.Text = setNotNull(rsS.Fields("fcount").Value)
    Me.txtStoreID.Text = setNotNull(rsS.Fields("storeid").Value)
    
    rsS.Close
End Sub

Private Sub Form_Load()
    Call resetForm(Me)
End Sub
Private Sub getFormValues()
'将页面输入框中的值读入到类属性中
    
    objFittings.fname = setValue(Trim(Me.txtFName.Text))
    objFittings.brand = setValue(Trim(Me.txtBrand.Text))
    objFittings.ftype = setValue(Trim(Me.txtFType.Text))
    objFittings.Price = setValue(Trim(Me.txtPrice.Text), 0)
    objFittings.fcount = setValue(Trim(Me.txtFCount.Text), 0)
    objFittings.STOREID = setValue(Trim(Me.txtStoreID.Text), 0)
    
End Sub
Private Function checkForm() As Boolean
    If Me.txtFName.Text = "" Then
        MsgBox "配件名称不能为空!"
        Me.txtFName.SetFocus
        checkForm = False
        Exit Function
    End If
    If Me.txtBrand.Text = "" Then
        MsgBox "配件品牌不能为空!"
        Me.txtBrand.SetFocus
        checkForm = False
        Exit Function
    End If
    If Me.txtFType.Text = "" Then
        MsgBox "配件型号不能为空!"
        Me.txtFType.SetFocus
        checkForm = False
        Exit Function
    End If
    
    If Me.txtPrice.Text = "" Then
        MsgBox "配件价格不能为空!"
        Me.txtPrice.SetFocus
        checkForm = False
        Exit Function
    End If
    If Not (IsNumeric(Me.txtPrice.Text) And InStr(1, Me.txtPrice.Text, "-", vbTextCompare) < 1) Then
        MsgBox "配件价格应该为数字!"
        Me.txtPrice.SetFocus
        checkForm = False
        Exit Function
    End If
    If Me.txtFCount.Text = "" Then
        MsgBox "配件数量不能为空!"
        Me.txtFCount.SetFocus
        checkForm = False
        Exit Function
    End If
    If Not (IsNumeric(Me.txtFCount.Text) And (InStr(1, CStr(Me.txtFCount.Text), ".", vbTextCompare) < 1) And (InStr(1, CStr(Me.txtFCount.Text), ".", vbTextCompare) < 1)) Then
        MsgBox "配件数量应该为数字!"
        Me.txtFCount.SetFocus
        checkForm = False
        Exit Function
    End If
    checkForm = True
End Function

⌨️ 快捷键说明

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