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

📄 frmfygsbm.frm

📁 一个资金管理系统的成品 开发环境:VB
💻 FRM
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmfygsbm 
   BackColor       =   &H00FF8080&
   Caption         =   "资金归属部门管理"
   ClientHeight    =   5670
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6825
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5670
   ScaleWidth      =   6825
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "添加部门"
      Height          =   375
      Index           =   0
      Left            =   240
      TabIndex        =   9
      Top             =   840
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "修改部门"
      Height          =   375
      Index           =   1
      Left            =   1680
      TabIndex        =   8
      Top             =   840
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "查询部门"
      Height          =   375
      Index           =   2
      Left            =   3120
      TabIndex        =   7
      Top             =   840
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "删除部门"
      Height          =   375
      Index           =   3
      Left            =   4800
      TabIndex        =   6
      Top             =   840
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "下一个"
      Height          =   375
      Index           =   4
      Left            =   240
      TabIndex        =   5
      Top             =   1320
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "上一个"
      Height          =   375
      Index           =   5
      Left            =   1680
      TabIndex        =   4
      Top             =   1320
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "保存"
      Enabled         =   0   'False
      Height          =   375
      Index           =   6
      Left            =   3120
      TabIndex        =   3
      Top             =   1320
      Width           =   1100
   End
   Begin VB.CommandButton cmdkmlb 
      Caption         =   "退出"
      Height          =   375
      Index           =   7
      Left            =   4800
      TabIndex        =   2
      Top             =   1320
      Width           =   1100
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   3015
      Left            =   240
      TabIndex        =   0
      Top             =   1920
      Width           =   5775
      _ExtentX        =   10186
      _ExtentY        =   5318
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSDataListLib.DataCombo Dacomdm 
      Height          =   315
      Left            =   1440
      TabIndex        =   1
      Top             =   240
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   556
      _Version        =   393216
      Enabled         =   0   'False
      Text            =   "DataCombo1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSDataListLib.DataCombo Dacomgsbmmc 
      CausesValidation=   0   'False
      Height          =   315
      Left            =   4560
      TabIndex        =   10
      Top             =   240
      Width           =   1575
      _ExtentX        =   2778
      _ExtentY        =   556
      _Version        =   393216
      Text            =   "DataCombo1"
   End
   Begin VB.Label Labkhmc 
      BackStyle       =   0  'Transparent
      Caption         =   "部门代码"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   12
      Top             =   240
      Width           =   1095
   End
   Begin VB.Label Lablxr 
      BackStyle       =   0  'Transparent
      Caption         =   "部门名称"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3240
      TabIndex        =   11
      Top             =   240
      Width           =   1095
   End
End
Attribute VB_Name = "frmfygsbm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim addrecord As Variant
'Dim usercheck As Boolean
Dim conn As New ADODB.Connection
Dim rsfygsbm As New ADODB.Recordset
'设置费用归属部门管理中按钮的状态
Private Sub setbuttonskh(bval As Boolean)
    For i = 0 To 5
       cmdkmlb(i).Enabled = bval
    Next i
    cmdkmlb(6).Enabled = Not bval
    Dacomdm.Enabled = Not bval
    Dacomgsbmmc.Enabled = Not bval
    DataGrid1.Enabled = bval
    If bval Then
       cmdkmlb(7).Caption = "退出"
    Else
       cmdkmlb(7).Caption = "取消"
    End If
    Exit Sub
End Sub

'费用归属部门管理中记录增加或修改后的字段检验
Private Function gsbmcheck() As Boolean
   Dim id As Integer
   Dim str As String
   Dim note(4) As String
   note(0) = "费用归属部门代码不能为空!"
   note(1) = "费用归属部门名称不能为空!"
   note(2) = "费用归属部门代码或者费用归属部门名称已经存在!"
   note(3) = "此资金科目类别名称已经存在!"
   gsbmcheck = False
   If Dacomdm.Text = "" Then
       MsgBox note(0)
       Dacomdm.SetFocus
       Exit Function
   End If
   If Dacomgsbmmc.Text = "" Then
       MsgBox note(1)
       Dacomgsbmmc.SetFocus
       Exit Function
   End If
   id = rsfygsbm.Fields("xuhao")
   If addrecord = True Then
       str = "select * from fygsbm where dm='" & Dacomdm.Text & "' or gsbmmc='" & Dacomgsbmmc.Text & "'"
       Set rs = conn.Execute(str)
   Else
      str = "select * from fygsbm where (dm='" & Dacomdm.Text & "' or gsbmmc='" & Dacomgsbmmc.Text & "') and xuhao <> '" & id & "'"
      Set rs = conn.Execute(str)
   End If
   If rs.EOF Then
      gsbmcheck = True
   Else
     MsgBox note(2)
     'rsfygsbm.CancelBatch adAffectAllChapters
     Dacomdm.SetFocus
   End If
   Exit Function
End Function
Private Sub cmdkmlb_Click(Index As Integer)
  Dim i As Integer
Dim result As Boolean
Dim m_name As String
Dim bookmark As Variant
On Error GoTo adderr
Select Case Index
  Case 0  '添加按钮
       addrecord = True
       rsfygsbm.AddNew
       setbuttonskh False
       Dacomdm.SetFocus
       Exit Sub
  Case 1   '修改按钮
       addrecord = False
       setbuttonskh False
       Dacomdm.SetFocus
       Exit Sub
  Case 2   '查询按钮
      bookmark = rsfygsbm.bookmark
      m_name = InputBox("请输入费用归属部门代码或费用归属部门名称", "按费用归属部门代码或费用归属部门名称搜索")
      If m_name = "" Then
         Exit Sub
      End If
      rsfygsbm.MoveFirst
      rsfygsbm.Find "dm like '%" & m_name & "%'"
      If rsfygsbm.EOF Then
         rsfygsbm.MoveFirst
         rsfygsbm.Find "gsbmmc like '%" & m_name & "%'"
         If rsfygsbm.EOF Then
            MsgBox "没有该费用归属部门代码或费用归属部门名称!"
            rsfygsbm.bookmark = bookmark
         End If
         'rsfygsbm.MoveFirst
      End If
      Exit Sub
  Case 3   '删除按钮
      If MsgBox("你确认要删除该条记录吗?", vbexclaimation + vbOKCancel, "记录删除") = vbCancel Then
          Exit Sub
      End If
      With rsfygsbm
         '删除该纪录
          .Delete
          .UpdateBatch adAffectCurrent
          'If .RecordCount <= 0 Then
          '   Adodc1.Enabled = False
          '   Exit Sub
          'End If
          '移到下一条
          .MoveNext
          '如果到文件尾,移到最后一条
          If .EOF Then .MoveLast
      End With
      Exit Sub
   Case 4   '下一条
     rsfygsbm.MoveNext
     If rsfygsbm.EOF Then
        MsgBox "这是最后一个记录!"
        rsfygsbm.MovePrevious
     End If
     Exit Sub
  Case 5   '上一条
     rsfygsbm.MovePrevious
     If rsfygsbm.BOF Then
        MsgBox "这是第一个记录!"
        rsfygsbm.MoveNext
     End If
     Exit Sub
  Case 6  '保存按钮
       result = gsbmcheck()
       If result = True Then
           rsfygsbm.UpdateBatch adAffectCurrent
           setbuttonskh True
           MsgBox "保存成功!"
           'Adodc4.Refresh
       End If
       Exit Sub
  Case 7   ' 退出或取消按钮
       If cmdkmlb(Index).Caption = "退出" Then
         Unload Me
       Else
         rsfygsbm.CancelUpdate
         setbuttonskh True
         Exit Sub
       End If
End Select
Exit Sub
adderr:
  MsgBox Err.Description
  Unload Me
End Sub

Private Sub Form_Load()
Dim fieldname(3) As Variant
Dim wide(3) As Variant
Dim str As String
fieldname(0) = "序号"
fieldname(1) = "费用归属部门代码"
fieldname(2) = "费用归属部门名称"
wide(0) = 400
wide(1) = 1400
wide(2) = 1400
'connstring = "Provider=SQLOLEDB.1;Password=db0822;Persist Security Info=True;User ID=sa;Initial Catalog=promotetest;Server=192.168.1.123"
'str = "Provider=SQLOLEDB.1;Password=090309;Persist Security Info=True;User ID=cw;Initial Catalog=ysgl2004;Data Source=CWSERVER"
If conn.State <> 1 Then
    conn.CursorLocation = adUseClient
    conn.Open nowconnectstring
End If
rsfygsbm.Open "select * from fygsbm order by dm", conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rsfygsbm
For i = 0 To 2
    DataGrid1.Columns(i).Caption = fieldname(i)
    DataGrid1.Columns(i).Width = wide(i)
    DataGrid1.Columns(i).DataField = rsfygsbm.Fields(i).Name
Next i
Set Dacomdm.DataSource = rsfygsbm
Dacomdm.DataField = rsfygsbm.Fields("dm").Name
Set Dacomgsbmmc.DataSource = rsfygsbm
Dacomgsbmmc.DataField = rsfygsbm.Fields("gsbmmc").Name
End Sub

Private Sub Form_Unload(Cancel As Integer)
'rs.Close
conn.Close
End Sub


⌨️ 快捷键说明

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