main_jhgl_gys.frm

来自「完整的物资管理系统源码」· FRM 代码 · 共 965 行 · 第 1/3 页

FRM
965
字号
         Begin VB.Label Label7 
            BackStyle       =   0  'Transparent
            Caption         =   "邮政编码"
            Height          =   195
            Left            =   6435
            TabIndex        =   23
            Top             =   1575
            Width           =   750
         End
         Begin VB.Label Label6 
            BackStyle       =   0  'Transparent
            Caption         =   "电话"
            Height          =   195
            Left            =   2685
            TabIndex        =   22
            Top             =   1560
            Width           =   525
         End
         Begin VB.Label Label5 
            BackStyle       =   0  'Transparent
            Caption         =   "传真"
            Height          =   195
            Left            =   690
            TabIndex        =   21
            Top             =   1575
            Width           =   360
         End
         Begin VB.Label Label4 
            BackStyle       =   0  'Transparent
            Caption         =   "地址"
            Height          =   195
            Left            =   660
            TabIndex        =   20
            Top             =   1230
            Width           =   390
         End
         Begin VB.Label Label3 
            BackStyle       =   0  'Transparent
            Caption         =   "简称"
            Height          =   195
            Left            =   660
            TabIndex        =   19
            Top             =   900
            Width           =   390
         End
         Begin VB.Label Label2 
            BackStyle       =   0  'Transparent
            Caption         =   "供应商全称"
            Height          =   195
            Left            =   75
            TabIndex        =   18
            Top             =   585
            Width           =   975
         End
         Begin VB.Label Label1 
            BackStyle       =   0  'Transparent
            Caption         =   "供应商编号"
            Height          =   195
            Left            =   90
            TabIndex        =   17
            Top             =   255
            Width           =   900
         End
      End
      Begin MSComctlLib.ImageList ImageList1 
         Left            =   -75000
         Top             =   2550
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   32
         ImageHeight     =   32
         MaskColor       =   12632256
         _Version        =   393216
         BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
            NumListImages   =   11
            BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":0059
               Key             =   ""
            EndProperty
            BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":0933
               Key             =   ""
            EndProperty
            BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":120D
               Key             =   ""
            EndProperty
            BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":1AE7
               Key             =   ""
            EndProperty
            BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":23C1
               Key             =   ""
            EndProperty
            BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":2C9B
               Key             =   ""
            EndProperty
            BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":3575
               Key             =   ""
            EndProperty
            BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":3863
               Key             =   ""
            EndProperty
            BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":3BC9
               Key             =   ""
            EndProperty
            BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":3F2F
               Key             =   ""
            EndProperty
            BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "main_jhgl_gys.frx":4295
               Key             =   ""
            EndProperty
         EndProperty
      End
   End
End
Attribute VB_Name = "main_jhgl_gys"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer, myval As Integer     '定义整型变量
Dim rs1 As ADODB.Recordset             '定义数据集对象
Dim mybookmark                         '定义书签
Public blnadd1 As Boolean              '定义布尔型变量
Sub view_data()     '设计显示数据的过程
  If Adodc1.Recordset.RecordCount > 0 Then
     With DataGrid1
         For i = 0 To 13
            If .Columns(i) <> "" Then txt1(i) = .Columns(i) Else txt1(i) = ""
         Next i
     End With
  End If
End Sub
Private Sub Form_Activate()
  If sql1 <> "" Then
     Adodc1.RecordSource = sql1 & " order by 供应商编号"
     Adodc1.Refresh
     Call view_data     '调用过程
     If Adodc1.Recordset.RecordCount = 0 Then
        MsgBox "没有找到符合条件的记录!", , "提示窗口"
     End If
  End If
End Sub
Private Sub Form_Load()
  Me.Caption = text
  tlbState Toolbar1, False
  view_data
End Sub
Private Sub DataCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyReturn Then DataCombo2.SetFocus
End Sub
Private Sub DataCombo2_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyReturn Then txt1(14).SetFocus
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  sql1 = ""
End Sub
Private Sub txt1_GotFocus(Index As Integer)
  txt1(Index).BackColor = &HFFFF80
  txt1(Index).SelStart = 0
  txt1(Index).SelLength = Len(txt1(Index))
End Sub
Private Sub txt1_LostFocus(Index As Integer)
  txt1(Index).BackColor = &HFFFFFF
End Sub
Private Sub txt1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyReturn And Index < 13 Then txt1(Index + 1).SetFocus '回车获得焦点
  If KeyCode = vbKeyUp And Index > 1 Then txt1(Index - 1).SetFocus
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
  If Adodc1.Recordset.RecordCount > 0 Then
     If SSTab1.Tab = 1 And Toolbar1.Buttons(1).Enabled = False Then
        MsgBox "您正在处理数据,请取消数据处理,再执行本操作!", , "提示窗口"
        SSTab1.Tab = 0
     End If
  End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  Select Case Button.Key
    Case "add"
       blnadd1 = True
       tlbState Toolbar1, True
       '自动创建供应商编号
       Dim bh As Integer
       Set rs1 = New ADODB.Recordset
       rs1.Open "tb_gys order by 供应商编号", cnn, adOpenKeyset
       If rs1.RecordCount > 0 Then
          If rs1.EOF = False Then rs1.MoveLast
          If rs1.Fields("供应商编号") <> "" Then
             bh = Val(Right(rs1.Fields("供应商编号"), 4)) + 1
             txt1(0).text = "gys" & Format(bh, "0000")
          End If
       Else
          txt1(0).text = "gys0001"
       End If
       rs1.Close     '关闭数据集对象
       For i = 1 To txt1.UBound
         txt1(i).Enabled = True
         txt1(i).text = ""
       Next i
       For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = False
       Next i
       SSTab1.Tab = 0
       txt1(1).SetFocus
     Case "modify"
       If Adodc1.Recordset.RecordCount > 0 Then
         blnadd1 = False
         For i = 1 To txt1.UBound
             txt1(i).Enabled = True
         Next i
         tlbState Toolbar1, True
         For i = 8 To 11
             Toolbar1.Buttons(i).Enabled = False
         Next i
         mybookmark = DataGrid1.Bookmark
       Else
         MsgBox "系统没有要修改的数据!", , "提示窗口"
       End If
     Case "delete"
       If Adodc1.Recordset.RecordCount > 0 Then
          myval = MsgBox("您确实要删除这条数据吗?", vbYesNo, "提示窗口")
          If myval = vbYes Then
            Adodc1.Recordset.Delete
            Adodc1.Refresh
            view_data
          End If
       Else
         MsgBox "系统没有要删除的数据!", , "提示窗口"
       End If
    Case "save"
      If txt1(1) = "" Then
         MsgBox "系统不允许供应商全称为空!", , "提示窗口"
         Exit Sub
      End If
      On Error GoTo SaveErr
      If blnadd1 = False Then
        Set rs1 = New ADODB.Recordset
        rs1.Open "select * from tb_gys where 供应商编号='" + txt1(0) + "'order by 供应商编号", cnn, adOpenKeyset
        If rs1.RecordCount > 0 Then
           myval = MsgBox("您确实要修改这条数据吗?", vbYesNo, "提示窗口")
           If myval = vbYes Then
              cnn.Execute ("update tb_gys set 供应商全称='" + txt1(1) + "',简称='" + txt1(2) + "',地址='" + txt1(3) + _
              "',传真='" + txt1(4) + "',电话='" + txt1(5) + "',邮政编码='" + txt1(6) + "',法人代表='" + txt1(7) + _
              "',营业执照='" + txt1(8) + "',税务登记号='" + txt1(9) + "',银行账号='" + txt1(10) + "',开户银行='" + txt1(11) + _
              "',企业状况='" + txt1(12) + "',备注='" + txt1(13) + "'where 供应商编号='" + txt1(0) + "'")
              Adodc1.Refresh
              DataGrid1.Bookmark = mybookmark
              view_data
           End If
        End If
        rs1.Close
      Else
        Set rs1 = New ADODB.Recordset
        rs1.Open "tb_gys", cnn, adOpenKeyset, adLockOptimistic
        '添加供应商信息
        rs1.AddNew
        For i = 0 To txt1.UBound
           rs1.Fields(i) = Trim(txt1(i).text)
        Next i
        rs1.Update     '更新数据库
        Adodc1.Refresh
        Adodc1.Recordset.MoveLast
        view_data
        rs1.Close
      End If
      For i = 0 To txt1.UBound
        txt1(i).Enabled = False
      Next i
      tlbState Toolbar1, False
      For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = True
      Next i
      Exit Sub
SaveErr:
      MsgBox Err.Description
    Case "cancel"
      view_data
      For i = 0 To txt1.UBound
         txt1(i).Enabled = False
      Next i
      tlbState Toolbar1, False
      For i = 8 To 11
          Toolbar1.Buttons(i).Enabled = True
      Next i
    Case "find"
      tb1 = "tb_gys"
      Load main_fzfind
      main_fzfind.Show 1
    Case "first"     '移到第一条记录
      If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
      Call view_data     '调用过程
    Case "previous"     '移到上一条记录
      If Adodc1.Recordset.RecordCount > 0 Then
         If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
         If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
      End If
      Call view_data     '调用过程
    Case "next"    '移到下一条记录
      If Adodc1.Recordset.RecordCount > 0 Then
         If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
         If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
      End If
      Call view_data     '调用过程
    Case "last"     '移到最后一条记录
      If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
      Call view_data     '调用过程
    Case "close"
      Unload Me
  End Select
End Sub

⌨️ 快捷键说明

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