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

📄 frmdruginfomanage.frm

📁 我收藏的一套药房管理系统,完整版,功能齐齐全,非常适合2次开发,现在跟各位朋友分享.
💻 FRM
字号:
VERSION 5.00
Begin VB.Form DrugInfoManage 
   Caption         =   "药品基本信息管理"
   ClientHeight    =   2730
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5565
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   2730
   ScaleWidth      =   5565
   Begin VB.Frame Frame1 
      Caption         =   "药品基本信息"
      Height          =   1755
      Left            =   480
      TabIndex        =   17
      Top             =   300
      Width           =   3630
      Begin VB.ComboBox cmbType 
         DataField       =   "种类"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   300
         ItemData        =   "frmDrugInfoManage.frx":0000
         Left            =   2160
         List            =   "frmDrugInfoManage.frx":0016
         TabIndex        =   1
         Text            =   "Combo1"
         Top             =   255
         Width           =   1290
      End
      Begin VB.TextBox txtInfo 
         DataField       =   "厂家"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   270
         Index           =   4
         Left            =   570
         MaxLength       =   50
         TabIndex        =   5
         Top             =   1335
         Width           =   2880
      End
      Begin VB.TextBox txtInfo 
         DataField       =   "进价"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   270
         Index           =   3
         Left            =   2175
         TabIndex        =   4
         Top             =   975
         Width           =   1290
      End
      Begin VB.TextBox txtInfo 
         DataField       =   "售价"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   270
         Index           =   2
         Left            =   585
         TabIndex        =   3
         Top             =   990
         Width           =   1065
      End
      Begin VB.TextBox txtInfo 
         DataField       =   "名称"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   270
         Index           =   1
         Left            =   585
         MaxLength       =   50
         TabIndex        =   2
         Top             =   630
         Width           =   2865
      End
      Begin VB.TextBox txtInfo 
         DataField       =   "编号"
         DataMember      =   "Druginfo"
         DataSource      =   "Drug_Store"
         Height          =   270
         Index           =   0
         Left            =   585
         MaxLength       =   6
         TabIndex        =   0
         Top             =   270
         Width           =   1065
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "种类"
         Height          =   180
         Left            =   1725
         TabIndex        =   23
         Top             =   315
         Width           =   360
      End
      Begin VB.Label lblInfo 
         AutoSize        =   -1  'True
         Caption         =   "厂家"
         Height          =   180
         Index           =   4
         Left            =   165
         TabIndex        =   22
         Top             =   1365
         Width           =   360
      End
      Begin VB.Label lblInfo 
         AutoSize        =   -1  'True
         Caption         =   "进价"
         Height          =   180
         Index           =   3
         Left            =   1725
         TabIndex        =   21
         Top             =   1020
         Width           =   360
      End
      Begin VB.Label lblInfo 
         AutoSize        =   -1  'True
         Caption         =   "售价"
         Height          =   180
         Index           =   2
         Left            =   165
         TabIndex        =   20
         Top             =   1020
         Width           =   360
      End
      Begin VB.Label lblInfo 
         AutoSize        =   -1  'True
         Caption         =   "名称"
         Height          =   180
         Index           =   1
         Left            =   165
         TabIndex        =   19
         Top             =   660
         Width           =   360
      End
      Begin VB.Label lblInfo 
         AutoSize        =   -1  'True
         Caption         =   "编号"
         Height          =   180
         Index           =   0
         Left            =   165
         TabIndex        =   18
         Top             =   315
         Width           =   360
      End
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   300
      Left            =   4260
      TabIndex        =   14
      Top             =   1623
      Width           =   735
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "关闭"
      Height          =   300
      Left            =   4260
      TabIndex        =   15
      Top             =   2040
      Width           =   735
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除"
      Height          =   300
      Left            =   4260
      TabIndex        =   12
      Top             =   791
      Width           =   735
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "添加"
      Height          =   300
      Left            =   4260
      TabIndex        =   11
      Top             =   375
      Width           =   735
   End
   Begin VB.PictureBox picNavigation 
      BorderStyle     =   0  'None
      Height          =   350
      Left            =   495
      ScaleHeight     =   345
      ScaleWidth      =   3630
      TabIndex        =   16
      Top             =   2040
      Width           =   3630
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   1
         Left            =   270
         Picture         =   "frmDrugInfoManage.frx":004A
         Style           =   1  'Graphical
         TabIndex        =   7
         Top             =   0
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   0
         Left            =   -15
         Picture         =   "frmDrugInfoManage.frx":008E
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   0
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   3
         Left            =   3315
         Picture         =   "frmDrugInfoManage.frx":00DB
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   15
         Width           =   300
      End
      Begin VB.CommandButton cmdMove 
         Height          =   270
         Index           =   2
         Left            =   3000
         Picture         =   "frmDrugInfoManage.frx":0127
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   0
         Width           =   300
      End
      Begin VB.TextBox txtNews 
         Height          =   300
         Left            =   540
         Locked          =   -1  'True
         TabIndex        =   8
         TabStop         =   0   'False
         Top             =   -15
         Width           =   2475
      End
   End
   Begin VB.CommandButton cmdRefresh 
      Caption         =   "刷新"
      Height          =   300
      Left            =   4260
      TabIndex        =   13
      Top             =   1207
      Width           =   735
   End
End
Attribute VB_Name = "DrugInfoManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim isAdding As Boolean     '定义添加药品信息状态标志
Private Sub cmdExit_Click()
    Unload Me               '关闭药品信息管理窗体
End Sub

Private Sub cmdRefresh_Click()
    Dim i%
    With Drug_Store.rsDrugInfo
        If .RecordCount > 0 Then
            If isAdding Then .CancelUpdate          '取消未保存的新添加记录
            .Requery                                '刷新记录集
            For i = 0 To 4                          '重新执行数据绑定
                Set txtInfo(i).DataSource = Drug_Store
                txtInfo(i).DataMember = "DrugInfo"
            Next
            txtInfo(0).DataField = "编号"
            txtInfo(1).DataField = "名称"
            txtInfo(2).DataField = "售价"
            txtInfo(3).DataField = "进价"
            txtInfo(4).DataField = "厂家"
            Set cmbType.DataSource = Drug_Store
            cmbType.DataMember = "DrugInfo"
            cmbType.DataField = "种类"
        End If
    End With
    cmdAdd.Enabled = True
    cmdDelete.Enabled = True
    isAdding = False
    picNavigation.Enabled = True
    cmdMove(0).Value = True
End Sub

Private Sub Form_Load()
   cmdMove(0).Value = True
End Sub

Private Sub cmdAdd_Click()
    Drug_Store.rsDrugInfo.AddNew    '添加新记录
    cmbType.ListIndex = 1         '设置默认权限
    txtNews = "记录:" & Drug_Store.rsDrugInfo.AbsolutePosition _
              & "/" & Drug_Store.rsDrugInfo.RecordCount
    isAdding = True
    cmdAdd.Enabled = False          '在保存新记录之前禁用控件
    cmdDelete.Enabled = False
    picNavigation.Enabled = False
End Sub

Private Sub cmdDelete_Click()
    With Drug_Store.rsDrugInfo
        If Not .EOF Then
            If MsgBox("将删除编号为" & Trim(txtInfo(0)) & _
                   "的药品信息数据,是否继续?", vbCritical + vbYesNo, _
                   "药品信息管理") = vbYes Then
                .Delete
                .MoveNext
                If .EOF And .RecordCount > 0 Then .MoveLast
            End If
        End If
    End With
End Sub

Private Sub cmdSave_Click()
    Dim objCopy As New Recordset, i%
    For i = 0 To 3                  '重新执行数据绑定
        If Trim(txtInfo(i)) = "" Then
            MsgBox lblInfo(i).Caption & "不能为空!", vbCritical, "药品信息管理"
            txtInfo(i) = ""
            txtInfo(i).SetFocus
            Exit Sub
        End If
    Next
    If cmbType = "" Then
        MsgBox "药品类型不能为空,可从列表中选择!", vbCritical, "药品信息管理"
        cmbType = ""
        cmbType.SetFocus
        Exit Sub
    End If
    Set objCopy = Drug_Store.rsDrugInfo.Clone
    With objCopy
        If .RecordCount > 0 Then
            .MoveFirst
            .Find "编号='" & Trim(txtInfo(0)) & "'"
            If Not .EOF And .AbsolutePosition <> _
                            Drug_Store.rsDrugInfo.AbsolutePosition Then
                MsgBox "编号:" & Trim(txtInfo(0)) _
                       & "已被使用,请修改药品编号!", _
                       vbCritical, "药品信息管理"
                txtInfo(0).SetFocus
                txtInfo(0).SelStart = 0
                txtInfo(0).SelLength = Len(txtInfo(0))
                Exit Sub
            End If
        End If
    End With
    Drug_Store.rsDrugInfo.Update
    MsgBox "数据保存成功!", vbInformation, "药品信息管理"
    cmdAdd.Enabled = True
    cmdDelete.Enabled = True
    isAdding = False
    picNavigation.Enabled = True
End Sub

Private Sub cmdMove_Click(Index As Integer)
    With Drug_Store.rsDrugInfo
        Select Case Index
            Case 0                              '使第一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then .MoveFirst
            Case 1                              '使上一个记录成为当前记录
                If .RecordCount > 0 And Not .BOF Then
                    .MovePrevious
                    If .BOF Then .MoveFirst
                End If
            Case 2                              '使下一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then
                    .MoveNext
                    If .EOF Then .MoveLast
                End If
            Case 3                               '使最后一个记录成为当前记录
                If .RecordCount > 0 And Not .EOF Then .MoveLast
        End Select
        If .BOF And .EOF Then                    '显示记录提示信息
            txtNews = "记录:无"
        Else
            txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
        End If
    End With
End Sub

Private Sub txtInfo_KeyPress(Index As Integer, KeyAscii As Integer)
    Select Case Index
        Case 0  '验证药品编号输入
            If Not (KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _
                Or KeyAscii >= Asc("a") And KeyAscii <= Asc("z") _
                Or KeyAscii >= Asc("A") And KeyAscii <= Asc("Z") _
                Or KeyAscii = vbKeyBack) Then
                KeyAscii = 0    '输入不是数字、大写英文字母或退格键,取消输入
            Else                '将小写字符转换成大写
                If KeyAscii >= Asc("a") And KeyAscii <= Asc("z") _
                                                Then KeyAscii = KeyAscii - 32
            End If
        Case 2, 3       '验证药品售价和进价输入
           If Not (KeyAscii >= vbKey0 And KeyAscii <= vbKey9 _
                Or KeyAscii = Asc(".") Or KeyAscii = vbKeyBack) Then
                KeyAscii = 0    '输入不是数字、小数点或退格键,取消输入
            End If
    End Select
    picNavigation.Enabled = False   '在修改当前记录数据时禁用导航条
End Sub

⌨️ 快捷键说明

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