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

📄 frmaddexpendable.frm

📁 一个vb编的计算机机房管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmAddExpendable 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "消耗品登记"
   ClientHeight    =   3855
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5655
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3855
   ScaleWidth      =   5655
   Begin VB.Frame Frame1 
      Height          =   2655
      Left            =   600
      TabIndex        =   5
      Top             =   120
      Width           =   4455
      Begin VB.ComboBox cmbStoreID 
         Height          =   315
         Left            =   1800
         Style           =   2  'Dropdown List
         TabIndex        =   14
         Top             =   1920
         Width           =   855
      End
      Begin VB.TextBox txtEName 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   10
         TabIndex        =   8
         Top             =   480
         Width           =   1575
      End
      Begin VB.TextBox txtPrice 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   9
         TabIndex        =   7
         Top             =   960
         Width           =   1575
      End
      Begin VB.TextBox txtECount 
         Appearance      =   0  'Flat
         Height          =   375
         Left            =   1800
         MaxLength       =   5
         TabIndex        =   6
         Top             =   1440
         Width           =   1575
      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        =   13
         Top             =   480
         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        =   12
         Top             =   960
         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        =   11
         Top             =   1440
         Width           =   945
      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        =   10
         Top             =   1920
         Width           =   945
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "元"
         Height          =   195
         Left            =   3480
         TabIndex        =   9
         Top             =   1080
         Width           =   180
      End
   End
   Begin VB.CommandButton cmdSearch 
      Caption         =   "查询"
      Height          =   375
      Left            =   3480
      TabIndex        =   4
      Top             =   3120
      Width           =   975
   End
   Begin VB.CommandButton cmdModi 
      Caption         =   "修改"
      Height          =   375
      Left            =   1200
      TabIndex        =   3
      Top             =   3120
      Width           =   975
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   375
      Left            =   4560
      TabIndex        =   2
      Top             =   3120
      Width           =   975
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除"
      Height          =   375
      Left            =   2280
      TabIndex        =   1
      Top             =   3120
      Width           =   975
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加"
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   3120
      Width           =   975
   End
End
Attribute VB_Name = "frmAddExpendable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'ENAME Not VarChar(30), --消耗品名称
'price Not Money, --价格
'ECOUNT INT NULL,  --数量
'STOREID CHAR(1) REFERENCES STORE(STOREID))   --存储地点
Private objExpendable As New clsExpendable


Private Sub cmdAdd_Click()
'添加消耗品
    
    If checkForm() Then
        Call getFormValues
        If objExpendable.AddNew() Then
            MsgBox "数据添加成功!"
        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 Trim(Me.txtEName.Text) = "" Then
        MsgBox "请填写消耗品名称!"
        Me.txtEName.SetFocus
        Exit Sub
    End If
    objExpendable.ENAME = Trim(Me.txtEName.Text)
    If objExpendable.Delete() Then
        MsgBox "数据删除成功!"
    Else
        MsgBox "数据删除失败!"
    End If
    Call resetForm(Me)
End Sub

Private Sub cmdModi_Click()
'修改消耗品
    
    If checkForm() Then
        Call getFormValues
        If objExpendable.Modi() Then
            MsgBox "数据修改成功!"
        Else
            MsgBox "数据修改失败!"
        End If
    Else
        Exit Sub
    End If
Call resetForm(Me)
End Sub

Private Sub cmdSearch_Click()
'查询消耗品
    Dim strCondition As String
    Dim rsq As New ADODB.Recordset
    Dim i As Integer
    If Trim(Me.txtEName.Text) = "" Then
        MsgBox "请填写消耗品名称!"
        Me.txtEName.SetFocus
        Exit Sub
    End If
    objExpendable.ENAME = Trim(Me.txtEName.Text)
    strCondition = "EName='" & Trim(Me.txtEName.Text) & "'"
    Set rsq = objDBOpt.getRecord("Expendable", "*", strCondition)
    If rsq Is Nothing Then
        MsgBox "查询失败!"
    ElseIf rsq.EOF And rsq.BOF Then
        MsgBox "没有符合条件的记录!"
    Else
        Me.txtECount.Text = setNotNull(rsq.Fields("ECount").value, 0)
        Me.txtPrice.Text = setNotNull(rsq.Fields("Price").value, 0)
         For i = 0 To Me.cmbStoreID.ListCount
            If Me.cmbStoreID.Text = Trim(setNotNull(rsq.Fields("Storeid").value, 0)) Then
                Me.cmbStoreID.ListIndex = i
                Exit For
            End If
         Next
    End If
    
End Sub

Private Sub Form_Load()
    Call resetForm(Me)
'获取仓库列表
    Dim rs1 As New ADODB.Recordset
    'Set rs1 = objDBOpt.getRecords("select distinct STOREID from store where ltrim(storeid)<>'' and not(storeid is null)")
    Set rs1 = objDBOpt.getRecords("select storeid from store")
'    If rs.State = adStateClosed Then
'     MsgBox "rs is nothing"
'     Exit Sub
'    End If
    Me.cmbStoreID.Clear
    Do While Not rs1.EOF
        Me.cmbStoreID.AddItem rs1.Fields("storeid")
        rs1.MoveNext
    Loop
    'While Not rs.EOF
        'Me.cmbStoreID.AddItem rs.Fields("storeid").value
        'rs.MoveNext
    'Wend
    If Me.cmbStoreID.ListCount > 0 Then
        Me.cmbStoreID.ListIndex = 0
    End If
    
End Sub
Private Sub getFormValues()

   objExpendable.ENAME = setValue(Me.txtEName.Text)
   objExpendable.ECOUNT = setValue(Me.txtECount.Text, 0)
   objExpendable.Price = setValue(Me.txtPrice.Text, 0)
   objExpendable.STOREID = setValue(Me.cmbStoreID.Text, 0)

End Sub
Private Function checkForm() As Boolean
    If Trim(Me.txtEName.Text) = "" Then
        MsgBox "消耗品名称不能为空!"
        Me.txtEName.SetFocus
        checkForm = False
        Exit Function
    End If
    If IsNumeric(Me.txtECount.Text) = False Or InStr(1, Me.txtECount.Text, ".", vbTextCompare) > 0 Or InStr(1, Me.txtECount.Text, "-", vbTextCompare) > 0 Then
        MsgBox "消耗品数量应该为整数!"
        Me.txtECount.SetFocus
        checkForm = False
        Exit Function
    End If
    If IsNumeric(Me.txtPrice.Text) = False Or InStr(1, Me.txtPrice.Text, "-", vbTextCompare) > 0 Then
        MsgBox "消耗品价格应该为数字!"
        Me.txtPrice.SetFocus
        checkForm = False
        Exit Function
    End If
    
    checkForm = True
End Function

⌨️ 快捷键说明

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