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

📄 form_live.frm

📁 运用VB和SQL Server实现
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Caption         =   "支出金额: "
         Height          =   375
         Left            =   -74640
         TabIndex        =   15
         Top             =   2640
         Width           =   975
      End
      Begin VB.Label Label6 
         Caption         =   "日期: "
         Height          =   495
         Left            =   -74640
         TabIndex        =   13
         Top             =   1240
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "账号: "
         Height          =   255
         Left            =   -74640
         TabIndex        =   12
         Top             =   720
         Width           =   975
      End
      Begin VB.Label Label4 
         Caption         =   "备注: "
         Height          =   375
         Left            =   -71520
         TabIndex        =   8
         Top             =   720
         Width           =   1335
      End
      Begin VB.Label Label3 
         Caption         =   "存入金额: "
         Height          =   495
         Left            =   -74640
         TabIndex        =   6
         Top             =   2640
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "日期: "
         Height          =   375
         Left            =   -74640
         TabIndex        =   4
         Top             =   1360
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "账号: "
         Height          =   375
         Left            =   -74640
         TabIndex        =   3
         Top             =   720
         Width           =   1335
      End
   End
   Begin MSDataGridLib.DataGrid DataGrid_Live 
      Bindings        =   "Form_Live.frx":0054
      Height          =   2655
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   7335
      _ExtentX        =   12938
      _ExtentY        =   4683
      _Version        =   393216
      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
End
Attribute VB_Name = "Form_Live"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()    '添加一个存款记录
Dim sqlstr As String
Dim Num As Integer
Dim no As Integer
Dim rsdb As New adodb.Recordset
If Me.Combo1.Text = "" Or Me.DTPicker1.Value = "" Or Me.Text_Live_Cun.Text = "" Or Me.Combo4.Text = "" Then
    MsgBox "不能空白!"
    Exit Sub
End If

If Not IsNumeric(Me.Text_Live_Cun.Text) Then
    MsgBox "存入金额必须是数字"
    Exit Sub
End If

On Error Resume Next
'查找对应账号的编号
rsdb.Open "select * from LiveBank where LiveBankNo=" & "'" & Me.Combo1.Text & _
"'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
            Num = Val(rsdb.Fields("LiveBankID").Value)
    End If
rsdb.Close
'查找对应经手人的编号
rsdb.Open "select * from Family where FamilyName=" & "'" & _
Me.Combo4.Text & "'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
        no = Val(rsdb.Fields("FamilyID").Value)
    End If
rsdb.Close
'添加一个存款记录到数据库
sqlstr = "insert into LiveAction" & _
"(LiveActionNo,LiveActionDate,LiveActionName,LiveActionCun,LiveActionBZ)" & _
        "values(" & Num & "," & _
                    "'" & Me.DTPicker1.Value & "'," & _
                    no & "," & _
                    Val(Me.Text_Live_Cun.Text) & "," & _
                    "'" & Me.Text_Live_BZ1.Text & "');"
                    
RemoteCnn.Execute sqlstr
MsgBox "添加成功"
'更新界面显示
Me.Adodc_Live.Refresh

Me.Combo1.Text = ""
Me.Text_Live_Cun.Text = ""
Me.Combo4.Text = ""
Me.Text_Live_BZ1 = ""
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()    '添加一个取款记录
Dim sqlstr As String
Dim Num As Integer
Dim no As Integer
Dim rsdb As New adodb.Recordset
If Me.Combo2.Text = "" Or Me.DTPicker2.Value = "" Or Me.Text_Live_QU.Text = "" Or Me.Combo5.Text = "" Then
    MsgBox "不能空白!"
    Exit Sub
End If

If Not IsNumeric(Me.Text_Live_QU.Text) Then
    MsgBox "支出金额必须是数字"
    Exit Sub
End If

On Error Resume Next
'查找对应账号的编号
rsdb.Open "select * from LiveBank where LiveBankNo=" & "'" & Me.Combo2.Text & _
"'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
            Num = Val(rsdb.Fields("LiveBankID").Value)
    End If
rsdb.Close
'查找对应经手人的编号
rsdb.Open "select * from Family where FamilyName=" & "'" & Me.Combo5.Text & _
"'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
        no = Val(rsdb.Fields("FamilyID").Value)
    End If
rsdb.Close
'添加一个取款记录到数据库
sqlstr = "insert into LiveAction" & _
"(LiveActionNo,LiveActionDate,LiveActionName,LiveActionQu,LiveActionBZ)" & _
        "values(" & Num & "," & _
                    "'" & Me.DTPicker1.Value & "'," & _
                    no & "," & _
                    Val(Me.Text_Live_QU.Text) & "," & _
                    "'" & Me.Text_Live_BZ2.Text & "');"
                    
RemoteCnn.Execute sqlstr
MsgBox "添加成功"
'更新界面显示
Me.Adodc_Live.Refresh

Me.Combo2.Text = ""
Me.Text_Live_QU.Text = ""
Me.Combo5.Text = ""
Me.Text_Live_BZ2 = ""


End Sub

Private Sub Command4_Click()
Unload Me
End Sub

Private Sub Command5_Click()    '修改一个选定的记录
Dim sqlstr As String
Dim Num As Integer
Dim no As Integer
Dim rsdb As New adodb.Recordset
If Me.Combo3.Text = "" Or Me.DTPicker3.Value = "" Or Me.Combo6.Text = "" Or _
Me.Text_Live_CUN_M.Text = "" Or Me.Text_Live_QU_M.Text = "" Then
    MsgBox "不能空白"
    Exit Sub
End If

If Not IsNumeric(Me.Text_Live_QU_M.Text) Then
    MsgBox "支出金额必须是数字"
    Exit Sub
End If

If Not IsNumeric(Me.Text_Live_CUN_M.Text) Then
    MsgBox "存入金额必须是数字"
    Exit Sub
End If

On Error Resume Next
'查找对应账号的编号
rsdb.Open "select * from LiveBank where LiveBankNo=" & "'" & _
Me.Combo3.Text & "'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
            Num = Val(rsdb.Fields("LiveBankID").Value)
    End If
rsdb.Close
'查找对应经手人的编号
rsdb.Open "select * from Family where FamilyName=" & "'" & _
Me.Combo6.Text & "'", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
        no = Val(rsdb.Fields("FamilyID").Value)
    End If
rsdb.Close
'在数据库中修改选定的记录
sqlstr = "update LiveAction set LiveActionNo=" & Num & "," & _
                        "LiveActionDate=" & "'" & Me.DTPicker3.Value & "'," & _
                        "LiveActionName=" & no & "," & _
                        "LiveActionCun=" & Val(Me.Text_Live_CUN_M.Text) & "," & _
                        "LiveActionQu=" & Val(Me.Text_Live_QU_M.Text) & "," & _
                        "LiveActionBZ=" & "'" & Me.Text_Live_BZ3.Text & "' " & _
                        "where LiveActionID=" & Val(DataGrid_Live.Columns(0).Text)
RemoteCnn.Execute sqlstr
MsgBox "修改成功!"
'界面显示更新
Me.Adodc_Live.Refresh
End Sub

Private Sub Command6_Click()    '删除一个选定的记录
'是否选择了记录
If Me.DataGrid_Live.Row = -1 Then
    MsgBox "没有数据"
    Exit Sub
End If
'删除选定的记录
Me.Adodc_Live.Recordset.Delete
MsgBox "删除成功"
End Sub

Private Sub Command7_Click()
Unload Me
End Sub

Private Sub DataGrid_Live_Click()   '选择一个要编辑的记录
Dim rsdb As New adodb.Recordset
Dim str As String
Dim name As String
On Error Resume Next
'查找对应编号的姓名
rsdb.Open "select * from Family where FamilyID=" & _
Val(DataGrid_Live.Columns(3).Text), RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
        name = rsdb.Fields("FamilyName").Value
    End If
rsdb.Close
'查找对应编号的账号
rsdb.Open "select * from LiveBank where  LiveBankID=" & _
Val(DataGrid_Live.Columns(1).Text), RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.EOF Then rsdb.MoveFirst
        str = rsdb.Fields("LiveBankNo").Value
    End If
rsdb.Close
'将选定的记录在界面上显示
Me.Combo3.Text = str
Me.DTPicker3.Value = DataGrid_Live.Columns(2).Text
Me.Combo6.Text = name
Me.Text_Live_CUN_M.Text = DataGrid_Live.Columns(4).Text
Me.Text_Live_QU_M.Text = DataGrid_Live.Columns(5).Text
Me.Text_Live_BZ3.Text = DataGrid_Live.Columns(6).Text
End Sub

Private Sub Form_Load()   '窗体装载
Dim rsdb As New adodb.Recordset
Dim str As String
Dim I As Integer
On Error Resume Next
'填充账号框
rsdb.Open "select * from LiveBank", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.BOF Then rsdb.MoveFirst
        For I = 1 To rsdb.RecordCount
            Me.Combo1.AddItem rsdb.Fields("LiveBankNo").Value
            Me.Combo2.AddItem rsdb.Fields("LiveBankNo").Value
            Me.Combo3.AddItem rsdb.Fields("LiveBankNo").Value
            If Not rsdb.EOF Then rsdb.MoveNext
        Next I
    End If
rsdb.Close
'填充经手人框
rsdb.Open "select * from Family", RemoteCnn, adOpenStatic, adLockReadOnly, -1
    If rsdb.RecordCount > 0 Then
        If Not rsdb.BOF Then rsdb.MoveFirst
        For I = 1 To rsdb.RecordCount
            Me.Combo4.AddItem rsdb.Fields("FamilyName").Value
            Me.Combo5.AddItem rsdb.Fields("FamilyName").Value
            Me.Combo6.AddItem rsdb.Fields("FamilyName").Value
            If Not rsdb.EOF Then rsdb.MoveNext
        Next I
    End If
rsdb.Close
'打开活期账户操作表并填充表格
Me.Adodc_Live.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=" & _
"False;User ID=" & UID & ";pwd=" & PWD & ";Data Source=" & MyDSN
Adodc_Live.RecordSource = "select LiveActionID as 编号," & _
                             "LiveActionNo as 账户编号," & _
                             "LiveActionDate as 日期," & _
                             "LiveActionName as 经手人," & _
                             "LiveActionCun as 存入金额," & _
                             "LiveActionQu as 支出金额," & _
                             "LiveActionBZ as 备注 from LiveAction"
Adodc_Live.Refresh
End Sub

⌨️ 快捷键说明

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