上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:8k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form YM_FrmNmjz 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "年末结帐"
  5.    ClientHeight    =   2370
  6.    ClientLeft      =   2760
  7.    ClientTop       =   3750
  8.    ClientWidth     =   4425
  9.    Icon            =   "月末结帐_年末结帐.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   2370
  14.    ScaleWidth      =   4425
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   2  '屏幕中心
  17.    Begin VB.CommandButton Command1 
  18.       Caption         =   "关闭(&C)"
  19.       Height          =   300
  20.       Left            =   3000
  21.       TabIndex        =   1
  22.       Top             =   1710
  23.       Width           =   1120
  24.    End
  25.    Begin VB.CommandButton cmdExecute 
  26.       Caption         =   "结帐(&E)"
  27.       Height          =   300
  28.       Left            =   1800
  29.       TabIndex        =   0
  30.       Top             =   1710
  31.       Width           =   1120
  32.    End
  33.    Begin VB.Line Line1 
  34.       Index           =   2
  35.       X1              =   240
  36.       X2              =   4110
  37.       Y1              =   1260
  38.       Y2              =   1260
  39.    End
  40.    Begin VB.Line Line2 
  41.       BorderColor     =   &H00FFFFFF&
  42.       Index           =   2
  43.       X1              =   240
  44.       X2              =   4170
  45.       Y1              =   1290
  46.       Y2              =   1290
  47.    End
  48.    Begin VB.Label Lab_jzyf 
  49.       Caption         =   "2003年年末结帐"
  50.       BeginProperty Font 
  51.          Name            =   "宋体"
  52.          Size            =   12
  53.          Charset         =   134
  54.          Weight          =   700
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       ForeColor       =   &H00000000&
  60.       Height          =   255
  61.       Left            =   1290
  62.       TabIndex        =   2
  63.       Top             =   420
  64.       Width           =   1845
  65.    End
  66. End
  67. Attribute VB_Name = "YM_FrmNmjz"
  68. Attribute VB_GlobalNameSpace = False
  69. Attribute VB_Creatable = False
  70. Attribute VB_PredeclaredId = True
  71. Attribute VB_Exposed = False
  72. '********************************************************************
  73. '*    模 块 名 称 :年末结帐
  74. '*    功 能 描 述 :执行年末的结帐
  75. '*    程序员姓名  :奚俊峰
  76. '*    最后修改人  :奚俊峰
  77. '*    最后修改时间:2001-12-10
  78. '*    备        注:
  79. '********************************************************************
  80. Dim Int_Year As Integer    '当前会计年度
  81. Dim Ztxxrec As Recordset   '临时记录集
  82. Const str_Info = "百利/ERP5.0-财务总帐"
  83. Private Sub cmdExecute_Click()
  84.     If Fun_JzCheck = True Then Unload Me
  85. End Sub
  86. Private Sub Command1_Click()
  87.     Unload Me
  88. End Sub
  89. Private Sub Form_Activate()
  90.     On Error GoTo ErrHandle
  91.     Lab_jzyf.Caption = "年末结帐"
  92.     
  93.     '取出当前的会计期间
  94.     Set Ztxxrec = Cw_DataEnvi.DataConnect.Execute("Select kjyear=isnull(max(kjyear),0) From gy_kjrlb Where Cwzzjzbz=1")
  95.     If Ztxxrec(0) > 0 Then
  96.         Int_Year = Ztxxrec("kjyear")
  97.         Lab_jzyf.Caption = Trim(Str(Int_Year)) + "年末结帐"
  98.     Else
  99.         MsgBox "此时不能进行年末结帐!", vbInformation, str_Info
  100.         Unload Me
  101.         Exit Sub
  102.     End If
  103.     
  104. ErrHandle:
  105.     
  106. End Sub
  107. '月末结帐过程处理
  108. Private Function Fun_JzCheck() As Boolean                         '月末结帐前检查
  109.     Dim RecTemp As New ADODB.Recordset   '临时使用动态集
  110.     Dim rs As Recordset
  111.     Dim str_Sql As String
  112.     Dim str_CurrentYear As String        '当前会计年
  113.     Dim str_NextYear As String           '下一会计年
  114.     
  115.     str_CurrentYear = CStr(Int_Year)
  116.     str_NextYear = CStr(Int_Year + 1)
  117.     
  118.     
  119.     On Error GoTo ErrHandle
  120.     Cw_DataEnvi.DataConnect.BeginTrans
  121.     
  122.     
  123.     Set Ztxxrec = Cw_DataEnvi.DataConnect.Execute("Select * From gy_kjrlb Where Cwzzjzbz=1 and period=12 and kjyear=" & Int_Year)
  124.     If Ztxxrec.EOF Then
  125.         MsgBox Int_Year & "年12月未进行月末结帐!", vbCritical, str_Info
  126.         Cw_DataEnvi.DataConnect.RollbackTrans
  127.         Exit Function
  128.     End If
  129.     
  130.     Set Ztxxrec = Cw_DataEnvi.DataConnect.Execute("Select * From cwzz_accsum Where year=" & (Int_Year + 1))
  131.     If Not Ztxxrec.EOF Then
  132.         MsgBox Int_Year & "年末已经结帐!", vbInformation, str_Info
  133.         Cw_DataEnvi.DataConnect.RollbackTrans
  134.         Exit Function
  135.     End If
  136.     
  137.     '检测是否存在当前会计日历表
  138.     str_Sql = "select * from gy_kjrlb where kjyear='" & str_CurrentYear & "'"
  139.     Set rs = Cw_DataEnvi.DataConnect.Execute(str_Sql)
  140.     If rs.EOF Then
  141.         MsgBox "请先设置" & str_CurrentYear & "年度的会计日历表!", vbInformation, str_Info
  142.         Cw_DataEnvi.DataConnect.RollbackTrans
  143.         Exit Function
  144.     End If
  145.     
  146.     '设置总帐下年度的金额、数量、外币余额
  147.     
  148.     str_Sql = "insert into cwzz_accsum(ccode,year,period,ycye,ycsl,ycwb) " & _
  149.     "select a.ccode,'" & str_NextYear & "',a.period," & _
  150.     "ycye=(select b.qmye from cwzz_accsum b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "')," & _
  151.     "ycsl=(select b.qmsl from cwzz_accsum b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "')," & _
  152.     "ycwb=(select b.qmwb from cwzz_accsum b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "') " & _
  153.     "From cwzz_accsum a " & _
  154.     "where a.year='" & str_CurrentYear & "'"
  155.     Cw_DataEnvi.DataConnect.Execute str_Sql
  156.     
  157.     str_Sql = "update cwzz_accsum set qcye=ycye,qmye=ycye,qcsl=ycsl,qmsl=ycsl,qcwb=ycwb,qmwb=ycwb where year='" & str_NextYear & "'"
  158.     Cw_DataEnvi.DataConnect.Execute str_Sql
  159.     
  160.     '设置总帐辅助帐下年度的金额、数量、外币余额'
  161.     Dim tStr As String
  162.     tStr = "and isnull(a.personcode,'')=isnull(b.personcode,'') and isnull(a.deptcode,'') = isnull(b.deptcode,'') and isnull(a.cuscode,'') =isnull(b.cuscode,'') and isnull(a.suppliercode,'')=isnull(b.suppliercode,'') and isnull(a.itemclasscode,'')=isnull(b.itemclasscode,'') and isnull(a.itemcode,'')=isnull(b.itemcode,'')"
  163.     
  164.     str_Sql = "insert into cwzz_accsumassi(ccode,personcode,deptcode,cuscode,SupplierCode,itemclasscode,itemcode,year,period,ycye,ycsl,ycwb,ycitemsl) " & _
  165.     "select ccode,personcode,deptcode,cuscode,SupplierCode,itemclasscode,itemcode,'" & str_NextYear & "',period," & _
  166.     "ycye=(select b.qmye from cwzz_accsumassi b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "' " & tStr & ")," & _
  167.     "ycsl=(select b.qmsl from cwzz_accsumassi b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "' " & tStr & ")," & _
  168.     "ycwb=(select b.qmwb from cwzz_accsumassi b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "' " & tStr & ")," & _
  169.     "ycitemsl=(select b.qmitemsl from cwzz_accsumassi b where b.period=12 and a.ccode=b.ccode and b.year='" & str_CurrentYear & "' " & tStr & ") " & _
  170.     "From cwzz_accsumassi a " & _
  171.     "where year='" & str_CurrentYear & "'"
  172.     Cw_DataEnvi.DataConnect.Execute str_Sql
  173.     
  174.     str_Sql = "update cwzz_accsumassi set qcye=ycye,qmye=ycye,qcsl=ycsl,qmsl=ycsl,qcwb=ycwb,qmwb=ycwb,qcitemsl=ycitemsl,qmitemsl=ycitemsl where year='" & str_NextYear & "'"
  175.     Cw_DataEnvi.DataConnect.Execute str_Sql
  176.     
  177.     str_Sql = "update Gy_AccInformation set ItemValue='0' where SystemCode='Cwzz' and ItemCode='Cwzz_Qclrwc'"
  178.     Cw_DataEnvi.DataConnect.Execute str_Sql
  179.     
  180.     Cw_DataEnvi.DataConnect.CommitTrans
  181.     
  182.     MsgBox Int_Year & "年末结帐成功!", vbInformation, str_Info
  183.     
  184.     Fun_JzCheck = True
  185.     Exit Function
  186. ErrHandle:
  187.     Fun_JzCheck = False
  188.     Cw_DataEnvi.DataConnect.RollbackTrans
  189. End Function