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

📄 frmstation.frm

📁 自己写的物流管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmStation 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "车站管理"
   ClientHeight    =   4830
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5700
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4830
   ScaleWidth      =   5700
   Begin VB.TextBox txtId 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   3600
      TabIndex        =   6
      Top             =   3240
      Visible         =   0   'False
      Width           =   1275
   End
   Begin VB.TextBox txtStation 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   360
      TabIndex        =   5
      Top             =   840
      Width           =   2000
   End
   Begin VB.ListBox LisStation 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   3000
      Left            =   360
      TabIndex        =   4
      Top             =   1560
      Width           =   2955
   End
   Begin VB.CommandButton Command3 
      Caption         =   "删  除"
      Height          =   375
      Left            =   4080
      TabIndex        =   3
      Top             =   2040
      Width           =   1005
   End
   Begin VB.CommandButton Command2 
      Caption         =   "修  改"
      Height          =   375
      Left            =   4080
      TabIndex        =   2
      Top             =   1440
      Width           =   1005
   End
   Begin VB.CommandButton Command1 
      Caption         =   "新  增"
      Height          =   375
      Left            =   4080
      TabIndex        =   1
      Top             =   840
      Width           =   1005
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "车  站  管  理"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   2040
      TabIndex        =   0
      Top             =   240
      Width           =   2190
   End
End
Attribute VB_Name = "frmStation"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim arrstation

Private Sub Command1_Click()

    '检查是否为空
    If Trim(txtStation.Text) <> "" Then
        '检查是否重复
        Dim i As Integer
        Dim isfind As Boolean
        isfind = False
        For i = 0 To UBound(arrstation)
            If txtStation.Text = arrstation(i) Then
               isfind = True
            End If
        Next
        If isfind = False Then
            '取得最大ID
            Dim inum As Integer
            Dim strsql As String
            Dim DB As New clsDataBase
            Dim rs As New ADODB.Recordset
            
            strsql = "SELECT MAX(ID) AS MAXID FROM STATION"
            Set rs = sys.DB.OpenRecordSet(strsql)
            If Not IsNull(rs(0)) Then
                ID = rs(0) + 1
            Else
                ID = 0
            End If
            txtID.Text = ID
            MyVar = MsgBox("确认增加?", vbOKCancel, "信息提示")
            If MyVar = vbOK Then
            '插入数据
            strsql = "INSERT INTO STATION (ID,NAME) VALUES (" & sys.TextTolong(txtID) & "," & sys.StrToInsert(txtStation) & ")"
            sys.DB.ExecuteSQL (strsql)
            MsgBox "操作成功!"
            Unload Me
            End If
        Else
            MsgBox "已经存在该车站名!"
        End If
    Else
        MsgBox "车站名不能为空!"
    End If
End Sub

Private Sub Command2_Click()
    '检查是否为空
    If Trim(txtStation.Text) <> "" Then
        '检查是否重复
        Dim i As Integer
        Dim isfind As Boolean
        isfind = False
        For i = 0 To UBound(arrstation)
            If txtStation.Text = arrstation(i) Then
               isfind = True
            End If
        Next
        If isfind = False Then
            MyVar = MsgBox("确认修改?", vbOKCancel, "信息提示")
            If MyVar = vbOK Then
                '更新数据
                strsql = "UPDATE STATION SET NAME= " & sys.StrToInsert(txtStation) & " WHERE ID =" & sys.TextTolong(txtID)
                sys.DB.ExecuteSQL (strsql)
                MsgBox "操作成功!"
                Unload Me
            End If
        Else
            MsgBox "已经存在该车站名!"
        End If
    Else
        MsgBox "车站名不能为空!"
    End If

End Sub

Private Sub Command3_Click()

    '检查是否为空
    If Trim(txtStation.Text) <> "" Then
        '检查数据库是否使用该记录
        strsql = "SELECT COUNT(SENDSTATION) AS SSTATION,COUNT(RECEIVESTATION) AS RSTATION FROM TRAFFIC WHERE (SENDSTATION =" & sys.TextTolong(txtID) & ") OR (RECEIVESTATION =" & sys.TextTolong(txtID) & ")"
        Set rs = sys.DB.OpenRecordSet(strsql)
        If sys.TextTolong(rs("SSTATION")) + sys.TextTolong(rs("RSTATION")) > 0 Then
            MsgBox "对不起,系统中有运单使用该站名,该站不能删除!"
        Else
            MyVar = MsgBox("确认删除?", vbOKCancel, "信息提示")
            If MyVar = vbOK Then
                '删除数据
                strsql = "DELETE FROM STATION WHERE ID =" & sys.TextTolong(txtID)
                sys.DB.ExecuteSQL (strsql)
                MsgBox "操作成功!"
                Unload Me
            End If
        End If

    Else
        MsgBox "车站名不能为空!"
    End If

End Sub

Private Sub Form_Load()
    
    Me.Top = 0
    Me.Left = 0
    Me.Width = MainForm.Width * 0.4
    Me.Height = MainForm.Height * 0.6
    '初始化车站
    Dim inum As Integer
    Dim strsql As String
    Dim DB As New clsDataBase
    Dim rs As New ADODB.Recordset
    ReDim arrstation(0) As String
    
    strsql = "SELECT * FROM STATION"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            ReDim Preserve arrstation(inum)
            arrstation(inum) = rs("NAME")
            LisStation.AddItem (rs("NAME"))
            LisStation.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
End Sub

Private Sub LisStation_Click()
    
    If LisStation.ListIndex <> -1 Then
        
        txtID.Text = LisStation.ItemData(LisStation.ListIndex)
        txtStation.Text = LisStation.Text
    End If
End Sub

⌨️ 快捷键说明

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