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

📄 frmzj.frm

📁 小巧的个人股票、资金管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      _ExtentX        =   13203
      _ExtentY        =   926
      ButtonWidth     =   609
      ButtonHeight    =   926
      Style           =   1
      ImageList       =   "ImList"
      _Version        =   393216
      Begin VB.Data d2 
         Caption         =   "Data2"
         Connect         =   "Access"
         DatabaseName    =   ""
         DefaultCursorType=   0  '缺省游标
         DefaultType     =   2  '使用 ODBC
         Exclusive       =   0   'False
         Height          =   285
         Left            =   4200
         Options         =   0
         ReadOnly        =   0   'False
         RecordsetType   =   1  'Dynaset
         RecordSource    =   ""
         Top             =   480
         Visible         =   0   'False
         Width           =   1455
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   6
         Left            =   6000
         TabIndex        =   2
         Text            =   "Text1"
         Top             =   1800
         Width           =   855
      End
      Begin VB.TextBox Text1 
         Height          =   270
         Index           =   3
         Left            =   2520
         TabIndex        =   1
         Text            =   "Text1"
         Top             =   1200
         Width           =   855
      End
   End
   Begin VB.Label lbfs 
      BackStyle       =   0  'Transparent
      Caption         =   "方式:"
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   4920
      TabIndex        =   12
      Top             =   1920
      Width           =   735
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "金额:"
      ForeColor       =   &H00FF0000&
      Height          =   375
      Left            =   4920
      TabIndex        =   7
      Top             =   2640
      Width           =   735
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "时间:"
      ForeColor       =   &H00FF0000&
      Height          =   375
      Left            =   4920
      TabIndex        =   6
      Top             =   1080
      Width           =   735
   End
End
Attribute VB_Name = "frmzj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
'Download by http://www.codefans.net
Attribute VB_Exposed = False
Public dbs As Database
Public rec As Recordset
Public xg As Boolean
Public fl As Double
Public filename As String
Public hjzj As Double
Public gb As Boolean
Public reczj As Recordset
Public hjye As Integer
Public hjk As Integer
Public sy As Integer
Public gprec As Recordset
Private Sub Cmd_Click(Index As Integer)
  da.Visible = True
End Sub
Private Sub CmdNO_Click()
   Unload Me
End Sub
Private Sub CmdOK_Click()
  save
End Sub
Private Sub da_DateDblClick(ByVal DateDblClicked As Date)
  da.Visible = False
  txtsj.Text = da.Value
End Sub
Private Sub Form_Load()
frmzj.Left = 2350
frmzj.Top = 1200
filename = App.Path & "\股票.mdb"
Set dbs = OpenDatabase(filename)
Set rec = dbs.OpenRecordset("投入资金明细")
Set gprec = dbs.OpenRecordset("个股购买记录")
d1.DatabaseName = filename
d2.DatabaseName = filename
d1.RecordSource = "select id as 编号,时间,方式,资金量  from 投入资金明细"
d2.RecordSource = "select 代号,名称,当前价,数量,收益  from 个股购买记录"
 Tlbar.Buttons.add 1, "add", "追加", , "add"
 Tlbar.Buttons.add 2, , , tbrSeparator
 Tlbar.Buttons.add 3, "Edit", "修改", , "Edit"
 Tlbar.Buttons.add 4, "Del", "删除", , "Del"
 Tlbar.Buttons.add 5, , , tbrSeparator
 Tlbar.Buttons.add 6, "Save", "保存", , "Save"
  Tlbar.Buttons.add 7, , , tbrSeparator
 Tlbar.Buttons.add 8, "ye", "余额", , "ye"
 Tlbar.Buttons.add 9, , , tbrSeparator
 Tlbar.Buttons.add 10, "Exit", "退出", , "Exit"
 Tlbar.Buttons(3).Enabled = False
  Tlbar.Buttons(4).Enabled = False
 Tlbar.Buttons(6).Enabled = False
 Sbr.Panels(1).Width = 4600
 countje
 txtsj.Enabled = False
 cmbfs.Enabled = False
 txtje.Enabled = False
 cmbfs.AddItem "追加"
 cmbfs.AddItem "赢利"
 cmbfs.AddItem "亏损"
 cmbfs.ListIndex = 0
 Sbr.Panels(1).Text = "当前资金投入总额:" & hjzj & "元"
 trzj
 countje
End Sub
Private Sub save()
  If txtsj.Text = "" Or cmbfs.Text = "" Or txtje.Text = "" Then
      r = MsgBox("数据不全,保存非法", 0 + 16, "个人股票管理")
      Exit Sub
  End If
  If xg = False Then
     rec.AddNew
     rec.Fields("时间") = txtsj.Text
     rec.Fields("方式") = cmbfs.Text
     rec.Fields("资金量") = Val(txtje.Text)
     rec.Update
     d1.Refresh
     countje
     frmgu.trzjhj
     Sbr.Panels(1).Text = "当前资金投入总额:" & hjzj & "元"
  Else
      rec.Index = "PrimaryKey"
      rec.Seek "=", grid.TextMatrix(grid.Row, 0)
      rec.edit
      rec.Fields("时间") = txtsj.Text
      rec.Fields("方式") = cmbfs.Text
      rec.Fields("资金量") = Val(txtje.Text)
      rec.Update
      d1.Refresh
      countje
      frmgu.trzjhj
      Sbr.Panels(1).Text = "当前资金投入总额:" & hjzj & "元"
  End If
End Sub
Private Sub grid_DblClick()
   If grid.Row = 0 Then Exit Sub
   txtsj.Text = grid.TextMatrix(grid.Row, 1)
   cmbfs.Text = grid.TextMatrix(grid.Row, 2)
   txtje.Text = grid.TextMatrix(grid.Row, 3)
   txtsj.Enabled = False
   cmbfs.Enabled = False
   txtje.Enabled = False
   Tlbar.Buttons(3).Enabled = True
   Tlbar.Buttons(4).Enabled = True
End Sub
Private Sub grid_SelChange()
  grid_DblClick
End Sub
Private Sub Tlbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  Select Case Button.Key
       Case "add"
         add
       Case "Save"
         save
       Case "Del"
         del
       Case "Edit"
         edit
       Case "Exit"
         Unload Me
       Case "ye"
         ye
  End Select
End Sub
Private Sub txtje_GotFocus()
   Tlbar.Buttons(6).Enabled = True
End Sub
Private Sub add()
  txtsj.Text = ""
  txtje.Text = ""
  txtsj.Enabled = True
  cmbfs.Enabled = True
  txtje.Enabled = True
  txtsj.SetFocus
  txtsj.Text = Date
  xg = False
End Sub

Private Sub del()
 If txtsj.Text = "" Then Exit Sub
      r = MsgBox("是否确认删除?(Y/N)", 1 + 64, "个人股票管理")
      If r = 1 Then
          dbs.Execute "DELETE * FROM " _
                      & " [投入资金明细]  WHERE ID=" & grid.TextMatrix(grid.Row, 0) & ""
       d1.Refresh
       countje
       frmgu.trzjhj
       trzj
       showzj
       Sbr.Panels(1).Text = "当前资金投入总额:" & hjzj & "元"
     End If
  txtsj.Text = ""
  cmbfs.Text = ""
  txtje.Text = ""
  txtsj.Enabled = False
  cmbfs.Enabled = False
  txtje.Enabled = False
End Sub

Private Sub edit()
 txtsj.Enabled = True
 cmbfs.Enabled = True
 txtje.Enabled = True
 xg = True
End Sub
Public Sub countje()
  Dim sql As String
  Dim sqly As String
  Dim sqlk As String
  Dim sqlyrec As Recordset
  Dim sqlrec As Recordset
  Dim sqlkrec  As Recordset
  Set reczj = dbs.OpenRecordset("资金")
  sql = "select sum(资金量) as countje from 投入资金明细  where 方式='追加' "
  Set sqlrec = dbs.OpenRecordset(sql)
  hjk = 0
  hjzj = 0
  hjye = 0
  sqly = "select sum(资金量) as countje from 投入资金明细  where 方式='赢利' "
  Set sqlyrec = dbs.OpenRecordset(sqly)
    sqlk = "select sum(资金量) as countje from 投入资金明细  where 方式='亏损' "
    Set sqlkrec = dbs.OpenRecordset(sqlk)
   If IsNull(sqlkrec.Fields(0)) Then
     hjk = 0
   Else
     hjk = sqlkrec.Fields(0)
   End If
   If IsNull(sqlyrec.Fields(0)) Then
     hjye = 0
    Else
     hjye = sqlyrec.Fields(0)
   End If
  If IsNull(sqlrec.Fields(0)) Then
     hjzj = 0
  Else
      hjzj = sqlrec.Fields(0)
      reczj.edit
      reczj.Fields("资金投量") = hjzj
      reczj.Update
     hjzj = sqlrec.Fields(0) + hjye + hjk
     
  End If
  sy = hjye + hjk
  reczj.edit
  reczj.Fields("资金存量") = hjzj - reczj.Fields("购股金额")
  reczj.Update
 End Sub
Private Sub ye()
    If gb = False Then
      frmye.Visible = True
      Tlbar.Buttons(1).Enabled = False
      Tlbar.Buttons(3).Enabled = False
      Tlbar.Buttons(4).Enabled = False
      Tlbar.Buttons(6).Enabled = False
      Tlbar.Buttons(8).Caption = "记录"
      Tlbar.Buttons(8).Image = "fl"
      gb = True
      trzj
      showzj
   Else
      frmye.Visible = False
      Tlbar.Buttons(1).Enabled = True
      Tlbar.Buttons(3).Enabled = True
      Tlbar.Buttons(4).Enabled = True
      Tlbar.Buttons(6).Enabled = True
      Tlbar.Buttons(8).Caption = "余额"
     Tlbar.Buttons(8).Image = "ye"
     gb = False
     Sbr.Panels(1).Text = "当前资金投入总额:" & reczj.Fields("资金投量") & "元"
     trzj
   End If
End Sub
Private Sub trzj()
  If reczj.RecordCount = 0 Then Exit Sub
   Set reczj = dbs.OpenRecordset("资金")
   reczj.edit
   reczj.Fields("资金投量") = hjzj
   reczj.Update
End Sub
Private Sub showzj()
If reczj.RecordCount = 0 Then Exit Sub
  frmgu.trzjhj
  countje
  Set reczj = dbs.OpenRecordset("资金")
  lbtrje.Caption = "资金帐户投入总金额:" & reczj.Fields("资金投量") & "元"
  gpje.Caption = "购买股票总金额:" & reczj.Fields("购股金额") & "元"
  gpsz.Caption = "股票当前市值:" & reczj.Fields("股票市值") & "元"
  gpyy.Caption = "帐户当前损益:" & sy & "元"
  zjxc.Caption = "资金帐户余额:" & reczj.Fields("资金存量") & "元"
  If reczj.Fields("资金存量") >= 0 Then
     Sbr.Panels(1).Text = "当前资金余额:" & reczj.Fields("资金存量") & "元"
  Else
      Sbr.Panels(1).Text = "当前需要补充资金额:" & reczj.Fields("资金存量") & "元"
  End If
End Sub



⌨️ 快捷键说明

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