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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form CL_BillChalkitup 
  5.    Caption         =   "单据记帐"
  6.    ClientHeight    =   6660
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   11580
  10.    HelpContextID   =   130401
  11.    Icon            =   "处理_单据记帐.frx":0000
  12.    KeyPreview      =   -1  'True
  13.    LinkTopic       =   "Form2"
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   6660
  16.    ScaleWidth      =   11580
  17.    WindowState     =   2  'Maximized
  18.    Begin VB.Timer Timer1 
  19.       Enabled         =   0   'False
  20.       Interval        =   1
  21.       Left            =   7620
  22.       Top             =   90
  23.    End
  24.    Begin VB.PictureBox Pic_Title 
  25.       BackColor       =   &H00FFFFFF&
  26.       Height          =   1125
  27.       Left            =   0
  28.       Picture         =   "处理_单据记帐.frx":1042
  29.       ScaleHeight     =   1065
  30.       ScaleWidth      =   11715
  31.       TabIndex        =   0
  32.       Top             =   570
  33.       Width           =   11775
  34.       Begin VB.Label Lbl_TitleText 
  35.          AutoSize        =   -1  'True
  36.          BackStyle       =   0  'Transparent
  37.          Caption         =   "仓库"
  38.          ForeColor       =   &H00000000&
  39.          Height          =   195
  40.          Index           =   0
  41.          Left            =   1260
  42.          TabIndex        =   8
  43.          Top             =   780
  44.          Width           =   360
  45.       End
  46.       Begin VB.Label Lbl_TitleMess 
  47.          AutoSize        =   -1  'True
  48.          BackStyle       =   0  'Transparent
  49.          Caption         =   "月份:"
  50.          Height          =   195
  51.          Index           =   0
  52.          Left            =   750
  53.          TabIndex        =   7
  54.          Top             =   780
  55.          Width           =   405
  56.       End
  57.       Begin VB.Label Lab_Title 
  58.          AutoSize        =   -1  'True
  59.          BackColor       =   &H80000018&
  60.          BackStyle       =   0  'Transparent
  61.          Caption         =   "单据列表"
  62.          BeginProperty Font 
  63.             Name            =   "宋体"
  64.             Size            =   12
  65.             Charset         =   134
  66.             Weight          =   700
  67.             Underline       =   0   'False
  68.             Italic          =   0   'False
  69.             Strikethrough   =   0   'False
  70.          EndProperty
  71.          ForeColor       =   &H00000000&
  72.          Height          =   240
  73.          Index           =   4
  74.          Left            =   480
  75.          TabIndex        =   3
  76.          Top             =   210
  77.          Width           =   1020
  78.       End
  79.       Begin VB.Label Lbl_Color 
  80.          Appearance      =   0  'Flat
  81.          BackColor       =   &H00FFFFC0&
  82.          BorderStyle     =   1  'Fixed Single
  83.          ForeColor       =   &H80000008&
  84.          Height          =   195
  85.          Left            =   8970
  86.          TabIndex        =   2
  87.          Top             =   780
  88.          Width           =   225
  89.       End
  90.       Begin VB.Label Label2 
  91.          AutoSize        =   -1  'True
  92.          BackStyle       =   0  'Transparent
  93.          Caption         =   "不允许记帐单据颜色标记"
  94.          Height          =   195
  95.          Left            =   9270
  96.          TabIndex        =   1
  97.          Top             =   780
  98.          Width           =   1980
  99.       End
  100.    End
  101.    Begin MSComctlLib.Toolbar GsToolbar 
  102.       Height          =   525
  103.       Left            =   9330
  104.       TabIndex        =   4
  105.       Top             =   30
  106.       Width           =   2475
  107.       _ExtentX        =   4366
  108.       _ExtentY        =   926
  109.       ButtonWidth     =   1455
  110.       ButtonHeight    =   926
  111.       Appearance      =   1
  112.       Style           =   1
  113.       ImageList       =   "ImageList2"
  114.       _Version        =   393216
  115.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  116.          NumButtons      =   3
  117.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  118.             Caption         =   "保存格式"
  119.             Key             =   "bcgs"
  120.             ImageKey        =   "bcgs"
  121.          EndProperty
  122.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  123.             Caption         =   "默认列宽"
  124.             Key             =   "hfmrgs"
  125.             ImageKey        =   "mrlk"
  126.          EndProperty
  127.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  128.             Caption         =   "显示项目"
  129.             Key             =   "szxsxm"
  130.             ImageKey        =   "xsxm"
  131.          EndProperty
  132.       EndProperty
  133.    End
  134.    Begin VSFlex8Ctl.VSFlexGrid CxbbGrid 
  135.       Height          =   7245
  136.       Left            =   0
  137.       TabIndex        =   5
  138.       Top             =   1770
  139.       Width           =   11775
  140.       _cx             =   5080
  141.       _cy             =   5080
  142.       Appearance      =   1
  143.       BorderStyle     =   1
  144.       Enabled         =   -1  'True
  145.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  146.          Name            =   "宋体"
  147.          Size            =   9
  148.          Charset         =   134
  149.          Weight          =   400
  150.          Underline       =   0   'False
  151.          Italic          =   0   'False
  152.          Strikethrough   =   0   'False
  153.       EndProperty
  154.       MousePointer    =   0
  155.       BackColor       =   16777215
  156.       ForeColor       =   -2147483640
  157.       BackColorFixed  =   13826538
  158.       ForeColorFixed  =   -2147483630
  159.       BackColorSel    =   -2147483635
  160.       ForeColorSel    =   -2147483634
  161.       BackColorBkg    =   -2147483636
  162.       BackColorAlternate=   16777215
  163.       GridColor       =   -2147483633
  164.       GridColorFixed  =   -2147483632
  165.       TreeColor       =   -2147483632
  166.       FloodColor      =   192
  167.       SheetBorder     =   -2147483642
  168.       FocusRect       =   1
  169.       HighLight       =   1
  170.       AllowSelection  =   -1  'True
  171.       AllowBigSelection=   -1  'True
  172.       AllowUserResizing=   0
  173.       SelectionMode   =   0
  174.       GridLines       =   1
  175.       GridLinesFixed  =   2
  176.       GridLineWidth   =   1
  177.       Rows            =   50
  178.       Cols            =   10
  179.       FixedRows       =   1
  180.       FixedCols       =   1
  181.       RowHeightMin    =   0
  182.       RowHeightMax    =   0
  183.       ColWidthMin     =   0
  184.       ColWidthMax     =   0
  185.       ExtendLastCol   =   0   'False
  186.       FormatString    =   ""
  187.       ScrollTrack     =   0   'False
  188.       ScrollBars      =   3
  189.       ScrollTips      =   0   'False
  190.       MergeCells      =   0
  191.       MergeCompare    =   0
  192.       AutoResize      =   -1  'True
  193.       AutoSizeMode    =   0
  194.       AutoSearch      =   0
  195.       AutoSearchDelay =   2
  196.       MultiTotals     =   -1  'True
  197.       SubtotalPosition=   1
  198.       OutlineBar      =   0
  199.       OutlineCol      =   0
  200.       Ellipsis        =   0
  201.       ExplorerBar     =   0
  202.       PicturesOver    =   0   'False
  203.       FillStyle       =   0
  204.       RightToLeft     =   0   'False
  205.       PictureType     =   0
  206.       TabBehavior     =   0
  207.       OwnerDraw       =   0
  208.       Editable        =   0
  209.       ShowComboButton =   1
  210.       WordWrap        =   0   'False
  211.       TextStyle       =   0
  212.       TextStyleFixed  =   0
  213.       OleDragMode     =   0
  214.       OleDropMode     =   0
  215.       DataMode        =   0
  216.       VirtualData     =   -1  'True
  217.       DataMember      =   ""
  218.       ComboSearch     =   3
  219.       AutoSizeMouse   =   -1  'True
  220.       FrozenRows      =   0
  221.       FrozenCols      =   0
  222.       AllowUserFreezing=   0
  223.       BackColorFrozen =   0
  224.       ForeColorFrozen =   0
  225.       WallPaperAlignment=   9
  226.       AccessibleName  =   ""
  227.       AccessibleDescription=   ""
  228.       AccessibleValue =   ""
  229.       AccessibleRole  =   24
  230.       Begin MSComctlLib.ImageList ImageList2 
  231.          Left            =   0
  232.          Top             =   0
  233.          _ExtentX        =   1005
  234.          _ExtentY        =   1005
  235.          BackColor       =   -2147483643
  236.          ImageWidth      =   16
  237.          ImageHeight     =   16
  238.          MaskColor       =   12632256
  239.          _Version        =   393216
  240.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  241.             NumListImages   =   41
  242.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  243.                Picture         =   "处理_单据记帐.frx":35106
  244.                Key             =   "sz"
  245.             EndProperty
  246.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  247.                Picture         =   "处理_单据记帐.frx":354A0
  248.                Key             =   "dy"
  249.             EndProperty
  250.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  251.                Picture         =   "处理_单据记帐.frx":3583A
  252.                Key             =   "yl"
  253.             EndProperty
  254.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  255.                Picture         =   "处理_单据记帐.frx":35BD4
  256.                Key             =   "xg"
  257.             EndProperty
  258.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  259.                Picture         =   "处理_单据记帐.frx":35F6E
  260.                Key             =   "zh"
  261.             EndProperty
  262.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  263.                Picture         =   "处理_单据记帐.frx":36308
  264.                Key             =   "sh"
  265.             EndProperty
  266.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  267.                Picture         =   "处理_单据记帐.frx":366A2
  268.                Key             =   "bc"
  269.             EndProperty
  270.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  271.                Picture         =   "处理_单据记帐.frx":36A3C
  272.                Key             =   "fq"
  273.             EndProperty
  274.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  275.                Picture         =   "处理_单据记帐.frx":36DD6
  276.                Key             =   "bz"
  277.             EndProperty
  278.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  279.                Picture         =   "处理_单据记帐.frx":37170
  280.                Key             =   "tc"
  281.             EndProperty
  282.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  283.                Picture         =   "处理_单据记帐.frx":3750A
  284.                Key             =   "bcgs"
  285.             EndProperty
  286.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  287.                Picture         =   "处理_单据记帐.frx":378A4
  288.                Key             =   "mrlk"
  289.             EndProperty
  290.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  291.                Picture         =   "处理_单据记帐.frx":37C3E
  292.                Key             =   "xsxm"
  293.             EndProperty
  294.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  295.                Picture         =   "处理_单据记帐.frx":37FD8
  296.                Key             =   "first"
  297.             EndProperty
  298.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  299.                Picture         =   "处理_单据记帐.frx":38372
  300.                Key             =   "prev"
  301.             EndProperty
  302.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  303.                Picture         =   "处理_单据记帐.frx":3870C
  304.                Key             =   "next"
  305.             EndProperty
  306.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  307.                Picture         =   "处理_单据记帐.frx":38AA6
  308.                Key             =   "last"
  309.             EndProperty
  310.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  311.                Picture         =   "处理_单据记帐.frx":38E40
  312.                Key             =   "xx"
  313.             EndProperty
  314.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  315.                Picture         =   "处理_单据记帐.frx":391DA
  316.                Key             =   "define"
  317.             EndProperty
  318.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  319.                Picture         =   "处理_单据记帐.frx":39574
  320.                Key             =   "exec"
  321.             EndProperty
  322.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  323.                Picture         =   "处理_单据记帐.frx":3990E
  324.                Key             =   "xz"
  325.             EndProperty
  326.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  327.                Picture         =   "处理_单据记帐.frx":39CA8
  328.                Key             =   "sc"
  329.             EndProperty
  330.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  331.                Picture         =   "处理_单据记帐.frx":3A042
  332.                Key             =   "sx"
  333.             EndProperty
  334.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  335.                Picture         =   "处理_单据记帐.frx":3A3DC
  336.                Key             =   "cx"
  337.             EndProperty
  338.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  339.                Picture         =   "处理_单据记帐.frx":3A776
  340.                Key             =   "zd"
  341.             EndProperty
  342.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  343.                Picture         =   "处理_单据记帐.frx":3AB10
  344.                Key             =   "dz"
  345.             EndProperty
  346.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  347.                Picture         =   "处理_单据记帐.frx":3AEAA
  348.                Key             =   "ph"
  349.             EndProperty
  350.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  351.                Picture         =   "处理_单据记帐.frx":3B244
  352.                Key             =   "fz"
  353.             EndProperty
  354.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  355.                Picture         =   "处理_单据记帐.frx":3B5DE
  356.                Key             =   "dw"
  357.             EndProperty
  358.             BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  359.                Picture         =   "处理_单据记帐.frx":3B978
  360.                Key             =   "hf"
  361.             EndProperty
  362.             BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  363.                Picture         =   "处理_单据记帐.frx":3BD12
  364.                Key             =   "pz"
  365.             EndProperty
  366.             BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  367.                Picture         =   "处理_单据记帐.frx":3C0AC
  368.                Key             =   "check"
  369.             EndProperty
  370.             BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  371.                Picture         =   "处理_单据记帐.frx":3C446
  372.                Key             =   "qs"
  373.             EndProperty
  374.             BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  375.                Picture         =   "处理_单据记帐.frx":3C7E0
  376.                Key             =   "fullcheck"
  377.             EndProperty
  378.             BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  379.                Picture         =   "处理_单据记帐.frx":3CB7A
  380.                Key             =   "qq"
  381.             EndProperty
  382.             BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  383.                Picture         =   "处理_单据记帐.frx":3CF14
  384.                Key             =   "bcw"
  385.             EndProperty
  386.             BeginProperty ListImage37 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  387.                Picture         =   "处理_单据记帐.frx":3D2AE
  388.                Key             =   "ye"
  389.             EndProperty
  390.             BeginProperty ListImage38 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  391.                Picture         =   "处理_单据记帐.frx":3D648
  392.                Key             =   ""
  393.             EndProperty
  394.             BeginProperty ListImage39 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  395.                Picture         =   "处理_单据记帐.frx":3D9E2
  396.                Key             =   "frist"
  397.             EndProperty
  398.             BeginProperty ListImage40 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  399.                Picture         =   "处理_单据记帐.frx":3DD7C
  400.                Key             =   "dj"
  401.             EndProperty
  402.             BeginProperty ListImage41 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  403.                Picture         =   "处理_单据记帐.frx":3E116
  404.                Key             =   "tz"
  405.             EndProperty
  406.          EndProperty
  407.       End
  408.    End
  409.    Begin MSComctlLib.Toolbar SzToolbar 
  410.       Align           =   1  'Align Top
  411.       Height          =   555
  412.       Left            =   0
  413.       TabIndex        =   6
  414.       Top             =   0
  415.       Width           =   11580
  416.       _ExtentX        =   20426
  417.       _ExtentY        =   979
  418.       ButtonWidth     =   820
  419.       ButtonHeight    =   926
  420.       AllowCustomize  =   0   'False
  421.       Appearance      =   1
  422.       Style           =   1
  423.       ImageList       =   "ImageList1"
  424.       _Version        =   393216
  425.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  426.          NumButtons      =   15
  427.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  428.             Caption         =   "设置"
  429.             Key             =   "ymsz"
  430.             ImageKey        =   "sz"
  431.          EndProperty
  432.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  433.             Caption         =   "打印"
  434.             Key             =   "dy"
  435.             ImageKey        =   "dy"
  436.          EndProperty
  437.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  438.             Caption         =   "预览"
  439.             Key             =   "yl"
  440.             ImageKey        =   "yl"
  441.          EndProperty
  442.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  443.             Style           =   3
  444.          EndProperty
  445.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  446.             Caption         =   "查询"
  447.             Key             =   "cx"
  448.             ImageKey        =   "cx"
  449.          EndProperty
  450.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  451.             Caption         =   "单据"
  452.             Key             =   "Bill"
  453.             ImageKey        =   "pz"
  454.          EndProperty
  455.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  456.             Style           =   4
  457.          EndProperty
  458.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  459.             Caption         =   "明细"
  460.             Key             =   "mx"
  461.             ImageKey        =   "mx"
  462.          EndProperty
  463.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  464.             Caption         =   "汇总"
  465.             Key             =   "hz"
  466.             ImageKey        =   "hz"
  467.          EndProperty
  468.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  469.             Style           =   3
  470.          EndProperty
  471.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  472.             Caption         =   "记帐"
  473.             Key             =   "jz"
  474.             ImageKey        =   "jz"
  475.          EndProperty
  476.          BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  477.             Caption         =   "恢复"
  478.             Key             =   "hf"
  479.             ImageKey        =   "hf"
  480.          EndProperty
  481.          BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  482.             Style           =   3
  483.          EndProperty
  484.          BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  485.             Caption         =   "帮助"
  486.             Key             =   "bz"
  487.             ImageKey        =   "bz"
  488.          EndProperty
  489.          BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  490.             Caption         =   "退出"
  491.             Key             =   "fh"
  492.             ImageKey        =   "tc"
  493.          EndProperty
  494.       EndProperty
  495.       BorderStyle     =   1
  496.       Begin MSComctlLib.ImageList ImageList1 
  497.          Left            =   6990
  498.          Top             =   30
  499.          _ExtentX        =   1005
  500.          _ExtentY        =   1005
  501.          BackColor       =   -2147483643
  502.          ImageWidth      =   16
  503.          ImageHeight     =   16
  504.          MaskColor       =   12632256
  505.          _Version        =   393216
  506.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  507.             NumListImages   =   36
  508.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  509.                Picture         =   "处理_单据记帐.frx":3F168
  510.                Key             =   "sz"
  511.             EndProperty
  512.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  513.                Picture         =   "处理_单据记帐.frx":3F502
  514.                Key             =   "dy"
  515.             EndProperty
  516.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  517.                Picture         =   "处理_单据记帐.frx":3F89C
  518.                Key             =   "yl"
  519.             EndProperty
  520.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  521.                Picture         =   "处理_单据记帐.frx":3FC36
  522.                Key             =   "xg"
  523.             EndProperty
  524.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  525.                Picture         =   "处理_单据记帐.frx":3FFD0
  526.                Key             =   "zh"
  527.             EndProperty
  528.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  529.                Picture         =   "处理_单据记帐.frx":4036A
  530.                Key             =   "sh"
  531.             EndProperty
  532.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  533.                Picture         =   "处理_单据记帐.frx":40704
  534.                Key             =   "bc"
  535.             EndProperty
  536.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  537.                Picture         =   "处理_单据记帐.frx":40A9E
  538.                Key             =   "fq"
  539.             EndProperty
  540.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  541.                Picture         =   "处理_单据记帐.frx":40E38
  542.                Key             =   "bz"
  543.             EndProperty
  544.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  545.                Picture         =   "处理_单据记帐.frx":411D2
  546.                Key             =   "tc"
  547.             EndProperty
  548.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  549.                Picture         =   "处理_单据记帐.frx":4156C
  550.                Key             =   "bcgs"
  551.             EndProperty
  552.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  553.                Picture         =   "处理_单据记帐.frx":41906
  554.                Key             =   "mrlk"
  555.             EndProperty
  556.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  557.                Picture         =   "处理_单据记帐.frx":41CA0
  558.                Key             =   "xsxm"
  559.             EndProperty
  560.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  561.                Picture         =   "处理_单据记帐.frx":4203A
  562.                Key             =   "first"
  563.             EndProperty
  564.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  565.                Picture         =   "处理_单据记帐.frx":423D4
  566.                Key             =   "prev"
  567.             EndProperty
  568.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  569.                Picture         =   "处理_单据记帐.frx":4276E
  570.                Key             =   "next"
  571.             EndProperty
  572.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  573.                Picture         =   "处理_单据记帐.frx":42B08
  574.                Key             =   "last"
  575.             EndProperty
  576.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  577.                Picture         =   "处理_单据记帐.frx":42EA2
  578.                Key             =   "xx"
  579.             EndProperty
  580.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  581.                Picture         =   "处理_单据记帐.frx":4323C
  582.                Key             =   "define"
  583.             EndProperty
  584.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  585.                Picture         =   "处理_单据记帐.frx":435D6
  586.                Key             =   "exec"
  587.             EndProperty
  588.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  589.                Picture         =   "处理_单据记帐.frx":43970
  590.                Key             =   "xz"
  591.             EndProperty
  592.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  593.                Picture         =   "处理_单据记帐.frx":43D0A
  594.                Key             =   "sc"
  595.             EndProperty
  596.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  597.                Picture         =   "处理_单据记帐.frx":440A4
  598.                Key             =   "sx"
  599.             EndProperty
  600.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  601.                Picture         =   "处理_单据记帐.frx":4443E
  602.                Key             =   "cx"
  603.             EndProperty
  604.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  605.                Picture         =   "处理_单据记帐.frx":447D8
  606.                Key             =   "zd"
  607.             EndProperty
  608.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  609.                Picture         =   "处理_单据记帐.frx":44B72
  610.                Key             =   "dz"
  611.             EndProperty
  612.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  613.                Picture         =   "处理_单据记帐.frx":44F0C
  614.                Key             =   "ph"
  615.             EndProperty
  616.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  617.                Picture         =   "处理_单据记帐.frx":452A6
  618.                Key             =   "fz"
  619.             EndProperty
  620.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  621.                Picture         =   "处理_单据记帐.frx":45640
  622.                Key             =   "dw"
  623.             EndProperty
  624.             BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  625.                Picture         =   "处理_单据记帐.frx":459DA
  626.                Key             =   "hf"
  627.             EndProperty
  628.             BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  629.                Picture         =   "处理_单据记帐.frx":45D74
  630.                Key             =   "pz"
  631.             EndProperty
  632.             BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  633.                Picture         =   "处理_单据记帐.frx":4610E
  634.                Key             =   "check"
  635.             EndProperty
  636.             BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  637.                Picture         =   "处理_单据记帐.frx":464A8
  638.                Key             =   "mx"
  639.             EndProperty
  640.             BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  641.                Picture         =   "处理_单据记帐.frx":46842
  642.                Key             =   "jz"
  643.             EndProperty
  644.             BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  645.                Picture         =   "处理_单据记帐.frx":46BDC
  646.                Key             =   "hz"
  647.             EndProperty
  648.             BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  649.                Picture         =   "处理_单据记帐.frx":46F76
  650.                Key             =   "tz"
  651.             EndProperty
  652.          EndProperty
  653.       End
  654.    End
  655. End
  656. Attribute VB_Name = "CL_BillChalkitup"
  657. Attribute VB_GlobalNameSpace = False
  658. Attribute VB_Creatable = False
  659. Attribute VB_PredeclaredId = True
  660. Attribute VB_Exposed = False
  661. '**************************************************************************
  662. '*    模 块 名 称 :单据记帐
  663. '*    功 能 描 述 :日常单据入明细帐、总帐
  664. '*    程序员姓名  :白凤英
  665. '*    最后修改人  :白凤英
  666. '*    最后修改时间:2001/11/30
  667. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  668. '**************************************************************************
  669. Dim mStr As String                       '暂估条件
  670. Dim GridColHide() As Boolean             '网格列隐藏
  671. Dim ReportTitle As String                '报表主标题
  672. Dim Str_QueryCondi As String             '用户录入查询条件
  673. Dim Rec_BillID As New ADODB.Recordset    '用户查询单据ID动态集
  674. '以下为固定使用变量
  675. Dim Dyymctbl As New DY_Dyymsz            '打印页面窗体变量
  676. Dim GridCode As String                   '显示网格网格代码
  677. Dim GridInf() As Variant                 '整个网格设置信息
  678. Dim Tsxx As String                       '系统提示信息
  679. Dim Qslz As Long                         '网格隐藏(非操作显示)列数
  680. Dim Sjhgd As Double                      '网格数据行高度
  681. Dim Sfxshjwg As Boolean                  '是否显示合计网格
  682. Dim GridBoolean() As Boolean             '网格列信息(布尔型)
  683. Dim GridStr()  As String                 '网格列信息(字符型)
  684. Dim GridInt() As Integer                 '网格列信息(整型)
  685. Dim Szzls As Integer                     '数组总列数(网格列数-1)
  686. Private Sub Form_Resize()                '根据窗体大小来调整网格,标题栏大小(Fixed)
  687.     On Error Resume Next
  688.     With CxbbGrid
  689.         .Width = Me.Width - 160
  690.         .Height = Me.Height - .Top - 400
  691.     End With
  692.     With Pic_Title
  693.         .Width = Me.Width - 160
  694.     End With
  695.     
  696.     GsToolbar.Left = Me.Width - GsToolbar.Width - 140
  697. End Sub
  698. Private Sub Form_Load()                                                   '窗体装入
  699.   
  700.     '调入打印页面设置窗体
  701.     ReportTitle = "单据列表"
  702.     XtReportCode = "Chhs_BillChalkList"
  703.     Load Dyymctbl
  704.       
  705.     '调整标题栏及网格、格式工具条位置(Fixed)
  706.     Pic_Title.Left = 40
  707.     Pic_Title.Top = SzToolbar.Top + SzToolbar.Height - 10
  708.     CxbbGrid.Left = Pic_Title.Left
  709.     CxbbGrid.Top = Pic_Title.Top + Pic_Title.Height + 20
  710.      
  711.     '调 入 网 格(Fixed)
  712.     GridCode = "Chhs_BillChalkList"
  713.     Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  714.       
  715.     Qslz = GridInf(1)
  716.     Sjhgd = GridInf(2)
  717.     Sfxshjwg = GridInf(7)
  718.     Szzls = CxbbGrid.Cols - 1
  719.     
  720.     Lbl_TitleText(0) = CStr(Xtyear) + "." + CStr(PGNowmon)
  721. End Sub
  722. Private Sub Form_Unload(Cancel As Integer)                                  '窗体卸载
  723.     '卸载条件窗体
  724.     CL_BillChalkitupCond.UnloadCheck.Value = 1
  725.     Unload CL_BillChalkitupCond
  726.     
  727.     '卸载打印页面设置窗体
  728.     Unload Dyymctbl
  729. End Sub
  730. Private Sub CxbbGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
  731.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  732. End Sub
  733. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)                '网格格式调整(Fixed)
  734.   
  735.     Select Case Button.Key
  736.         Case "bcgs"                                          '保存表格格式
  737.             Call Bcwggs(CxbbGrid, GridCode, GridStr())
  738.         Case "hfmrgs"                                        '恢复默认格式
  739.             Call Hfmrgs(CxbbGrid, GridCode, GridStr())
  740.         Case "szxsxm"                                        '设置显示项目
  741.             Call Szxsxm(CxbbGrid, GridCode)
  742.     End Select
  743. End Sub
  744. Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  745.     
  746.     Select Case Button.Key
  747.         Case "ymsz"                                          '页面设置
  748.             Dyymctbl.Show 1
  749.         Case "yl"                                            '预 览
  750.             Call bbyl(True)
  751.         Case "dy"                                            '打 印
  752.             Call bbyl(False)
  753.         Case "cx"                                            '查 询
  754.             CL_BillChalkitupCond.Show 1
  755.         Case "Bill"                                          '单 据
  756.             Call CxbbGrid_DblClick
  757.         Case "mx"                                            '明 细
  758.             Call Sub_Mx
  759.         Case "hz"                                            '汇 总
  760.             Call Sub_Hz
  761.         Case "tz"                                            '调 整
  762.             
  763.         Case "jz"                                            '记 帐
  764.             Call Sub_Chalkitup
  765.         Case "hf"                                            '恢 复
  766.             Call Sub_CancelChalkitup
  767.         Case "bz"                                            '帮 助
  768.             Call F1bz
  769.         Case "fh"                                            '退 出
  770.            Unload Me
  771.     End Select
  772. End Sub
  773. Private Sub Timer1_Timer()                                 '在窗体激活后调入查询程序
  774.     
  775.     Timer1.Enabled = False
  776.     Xt_Wait.Show
  777.     Xt_Wait.Refresh
  778.    
  779.     ReDim GridColHide(CxbbGrid.Cols)
  780.     For Jsqte = Qslz To CxbbGrid.Cols - 1
  781.         GridColHide(Jsqte) = CxbbGrid.ColHidden(Jsqte)
  782.     Next Jsqte
  783.    
  784.     '加快显示速度
  785.     CxbbGrid.Redraw = False
  786.     '生成查询结果
  787.     Call Sub_Mx
  788.    
  789.     CxbbGrid.Redraw = True
  790.     
  791.     Xt_Wait.Hide
  792. End Sub
  793. Private Sub Sub_Query(Int_QueryType As Integer)                              '生成查询结果(Define)  未记帐单据
  794.     
  795.     '过程参数:Int_QueryType 0-"点确定按钮"查询  1-"刷新"查询
  796.     Dim Rec_Query As Recordset                  '查询结果动态集
  797.     Dim Coljsq As Long                          '网格列计数器
  798.     Dim Jsqte As Long                        '临时动态计数器
  799.     Dim Str1 As String
  800.     
  801.     '以下为自定义部分[
  802.  
  803.     If Int_QueryType = 0 Then   '0-"点确定按钮"查询
  804.         With CL_BillChalkitupCond
  805.          
  806.             '生成查询条件
  807.             Str_QueryCondi = " where a.kjyear=" & PGKjYear & " and a.period=" & PGNowmon & " and " & .WhCode
  808.             
  809.             Str_QueryCondi = Str_QueryCondi & " and  chalkitupman='' "
  810.             If .LrText <> "" Then
  811.                 Str_QueryCondi = Str_QueryCondi & " and billdate <= '" & Trim(.LrText.Text) & "'"
  812.             End If
  813.         End With
  814.     End If
  815.      
  816.     SqlStr = "SELECT * FROM Chhs_V_InOut a " & _
  817.              Trim(Str_QueryCondi) & " and chhschecker<>'' Order By a.whcode,a.BillDate,a.InOutFlag desc,a.InoutMainId,a.InOutSubId"
  818.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  819.     With Rec_Query
  820.         CxbbGrid.Rows = CxbbGrid.FixedRows
  821.         Jsqte = CxbbGrid.FixedRows
  822.         Do While Not .EOF
  823.     
  824.             CxbbGrid.AddItem ""
  825.             '[>>自定义填充内容
  826.             CxbbGrid.TextMatrix(Jsqte, 0) = .Fields("InoutMainId")                                            'ID(主要用来查询定位用)
  827.             CxbbGrid.TextMatrix(Jsqte, 1) = .Fields("BillCode")                                                    '单据编码
  828.             CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("BillNum") & "")              '单据号
  829.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("WhName") & "")               '仓库名称
  830.             CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = Format(.Fields("BillDate"), "yyyy-mm-dd")  '入库日期
  831.             If Trim(.Fields("SupplierName") & "") <> "" Then
  832.                 CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("SupplierName") & "")         '供应商
  833.             End If
  834.             If Trim(.Fields("Cusname") & "") <> "" Then
  835.                 CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("Cusname") & "")              '客户
  836.             End If
  837.             CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("Deptname") & "")             '部门
  838.             CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("InoutClassName") & "")       '收发类别
  839.             CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Trim(.Fields("PersonName") & "")           '业务员
  840.             CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(.Fields("Maker") & "")                '制单人
  841.             CxbbGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Trim(.Fields("ChhsChecker") & "")              '审核人
  842.             CxbbGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls)) = Trim(.Fields("ChalkitupMan") & "")         '记帐人
  843.             CxbbGrid.TextMatrix(Jsqte, Sydz("019", GridStr(), Szzls)) = Trim(.Fields("Mnumber") & "")              '存货编码
  844.             CxbbGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Trim(.Fields("MName") & "")                '存货名称
  845.             CxbbGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = Trim(.Fields("Model") & "")                '规格型号
  846.             CxbbGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls)) = Trim(.Fields("PrimaryUnitName") & "")      '主计量单位
  847.             CxbbGrid.TextMatrix(Jsqte, Sydz("020", GridStr(), Szzls)) = Trim(.Fields("kjyear") & "")               '年度
  848.             CxbbGrid.TextMatrix(Jsqte, Sydz("021", GridStr(), Szzls)) = Trim(.Fields("period") & "")               '月份
  849.             CxbbGrid.TextMatrix(Jsqte, Sydz("025", GridStr(), Szzls)) = Trim(.Fields("billname") & "")               '备注
  850.             CxbbGrid.TextMatrix(Jsqte, Sydz("026", GridStr(), Szzls)) = Trim(.Fields("remark") & "")               '备注
  851.             If .Fields("inoutFlag") Then
  852.                 If .Fields("FactReceiptQuan") <> 0 Then                                                                           '数量
  853.                     CxbbGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls)) = .Fields("FactReceiptQuan")
  854.                 End If
  855.                 If Trim(.Fields("pricemode")) = "计划价法" Then
  856.                     If .Fields("PlanPrice") <> 0 Then                                                                      '计划单价
  857.                         CxbbGrid.TextMatrix(Jsqte, Sydz("015", GridStr(), Szzls)) = .Fields("PlanPrice")
  858.                     End If
  859.                     If .Fields("PlanMoney") <> 0 Then                                                                      '计划金额
  860.                         CxbbGrid.TextMatrix(Jsqte, Sydz("016", GridStr(), Szzls)) = .Fields("PlanMoney")
  861.                     End If
  862.                 End If
  863.                 If .Fields("Price") <> 0 Then                                                                          '实际单价
  864.                     CxbbGrid.TextMatrix(Jsqte, Sydz("017", GridStr(), Szzls)) = .Fields("Price")
  865.                 End If
  866.                 If .Fields("Emoney") <> 0 Then                                                                         '实际金额
  867.                     CxbbGrid.TextMatrix(Jsqte, Sydz("018", GridStr(), Szzls)) = .Fields("EMoney")
  868.                 Else
  869.                     CxbbGrid.Cell(flexcpBackColor, Jsqte, Qslz, Jsqte, CxbbGrid.Cols - 1) = &HFFFFC0
  870.                 End If
  871.             Else
  872.                 If .Fields("FactIssueQuan") <> 0 Then                                                                           '数量
  873.                     CxbbGrid.TextMatrix(Jsqte, Sydz("022", GridStr(), Szzls)) = .Fields("FactIssueQuan")
  874.                     
  875.                     If .Fields("FactIssueQuan") < 0 And .Fields("IssueMoney") = 0 Then
  876.                         CxbbGrid.Cell(flexcpBackColor, Jsqte, Qslz, Jsqte, CxbbGrid.Cols - 1) = &HFFFFC0
  877.                     End If
  878.                 End If
  879.                 If .Fields("Price") <> 0 Then                                                                          '实际单价
  880.                     CxbbGrid.TextMatrix(Jsqte, Sydz("023", GridStr(), Szzls)) = .Fields("Price")
  881.                 End If
  882.                 If .Fields("IssueMoney") <> 0 Then                                                                         '实际金额
  883.                     CxbbGrid.TextMatrix(Jsqte, Sydz("024", GridStr(), Szzls)) = .Fields("IssueMoney")
  884.                 End If
  885.             End If
  886.             
  887.             If .Fields("redblueflag") And (Trim(.Fields("pricemode")) = "先进先出法" Or Trim(.Fields("pricemode")) = "后进先出法") Then
  888.                 CxbbGrid.Cell(flexcpBackColor, Jsqte, Qslz, Jsqte, CxbbGrid.Cols - 1) = &HFFFFC0
  889.             End If
  890.             
  891.             '<<]
  892.             '设置数据行高度(Fixed)
  893.             CxbbGrid.RowHeight(Jsqte) = Sjhgd
  894.      
  895.             '动态集指针加1,同时将计数器加1(Fixed)
  896.             .MoveNext
  897.             Jsqte = Jsqte + 1
  898.         Loop
  899.     End With
  900.     
  901.     
  902.     '输入合计
  903.     With CxbbGrid
  904.         If CL_BillChalkitupCond.Chk_Sum.Value <> 0 Then
  905.            .SubtotalPosition = flexSTBelow
  906.            For Jsqte = Qslz To .Cols - 1
  907.                 If GridBoolean(Jsqte, 4) Then
  908.                      .Subtotal flexSTSum, 0, Jsqte, , &HF7F3EC, , , , , True
  909.                 End If
  910.            Next
  911.            
  912.            For Jsqte = .FixedRows To .Rows - 1
  913.                 If .IsSubtotal(Jsqte) Then
  914.                     For Coljsq = Qslz To .Cols - 1
  915.                         If Val(.TextMatrix(Jsqte, Coljsq)) = 0 And GridBoolean(Coljsq, 4) Then
  916.                             .TextMatrix(Jsqte, Coljsq) = ""
  917.                         End If
  918.                     Next
  919.                     .TextMatrix(Jsqte, 0) = .TextMatrix(Jsqte - 1, 0)
  920.                     .TextMatrix(Jsqte, 1) = .TextMatrix(Jsqte - 1, 1)
  921.                     .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = "    合计 "
  922.                     .RowHeight(Jsqte) = Sjhgd
  923.                 End If
  924.            Next
  925.         End If
  926.     End With
  927.     
  928.     ']以上为用户自定义部分
  929.     
  930.     Set Rec_Query = Nothing
  931. End Sub
  932. Private Sub Sub_QueryJz(Int_QueryType As Integer)                            '生成查询结果(Define)  已记帐单据
  933.     
  934.     '过程参数:Int_QueryType 0-"点确定按钮"查询  1-"刷新"查询
  935.     Dim Rec_Query As Recordset                  '查询结果动态集
  936.     Dim Coljsq As Long                          '网格列计数器
  937.     Dim Jsqte As Long                        '临时动态计数器
  938.     Dim Str1 As String
  939.     
  940.     '以下为自定义部分[
  941.  
  942.     If Int_QueryType = 0 Then   '0-"点确定按钮"查询
  943.         With CL_BillChalkitupCond
  944.          
  945.             '生成查询条件
  946.             Str_QueryCondi = " where a.kjyear=" & PGKjYear & " and a.period=" & PGNowmon & " and " & .WhCode & " and a.Billcode in('1202','1203','1204','1205','1206','1212','1301','1302','1303')"
  947.             
  948.             If .LrText <> "" Then
  949.                 Str_QueryCondi = Str_QueryCondi & " and billdate >='" & Trim(.LrText.Text) & "'"
  950.             End If
  951.         End With
  952.     End If
  953.      
  954.     SqlStr = "SELECT * FROM Chhs_V_List a " & Trim(Str_QueryCondi) & _
  955.              "and StartFlag=0  Order By a.whcode,a.BillDate,a.InOutFlag desc,a.InoutMainId,a.InOutSubId"
  956.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  957.     With Rec_Query
  958.         CxbbGrid.Rows = CxbbGrid.FixedRows
  959.         Jsqte = CxbbGrid.FixedRows
  960.         Do While Not .EOF
  961.     
  962.             CxbbGrid.AddItem ""
  963.             '[>>自定义填充内容
  964.             If .Fields("inoutmainid") <> 0 Then
  965.                 CxbbGrid.TextMatrix(Jsqte, 0) = .Fields("InoutMainId")                                            'ID(主要用来查询定位用)
  966.             Else
  967.                 CxbbGrid.TextMatrix(Jsqte, 0) = .Fields("InOutAdjustMainId")                                            'ID(主要用来查询定位用)
  968.             End If
  969.             CxbbGrid.TextMatrix(Jsqte, 1) = Trim(.Fields("BillCode"))                                                    '单据编码
  970.             CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("BillNum") & "")              '单据号
  971.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("WhName") & "")               '仓库名称
  972.             CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = Format(.Fields("BillDate"), "yyyy-mm-dd")  '入库日期
  973.             If Trim(.Fields("SupplierName") & "") <> "" Then
  974.                 CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("SupplierName") & "")         '供应商
  975.             End If
  976.             If Trim(.Fields("Cusname") & "") <> "" Then
  977.                 CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("Cusname") & "")              '客户
  978.             End If
  979.             CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("Deptname") & "")             '部门
  980.             CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("InoutClassName") & "")       '收发类别
  981.             CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Trim(.Fields("PersonName") & "")           '业务员
  982.             CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(.Fields("Maker") & "")                '制单人
  983.             CxbbGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Trim(.Fields("Checker") & "")              '审核人
  984.             CxbbGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls)) = Trim(.Fields("ChalkitupMan") & "")         '记帐人
  985.             CxbbGrid.TextMatrix(Jsqte, Sydz("019", GridStr(), Szzls)) = Trim(.Fields("Mnumber") & "")              '存货编码
  986.             CxbbGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Trim(.Fields("MName") & "")                '存货名称
  987.             CxbbGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = Trim(.Fields("Model") & "")                '规格型号
  988.             CxbbGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls)) = Trim(.Fields("PrimaryUnitName") & "")      '主计量单位
  989.             CxbbGrid.TextMatrix(Jsqte, Sydz("020", GridStr(), Szzls)) = Trim(.Fields("kjyear") & "")               '年度
  990.             CxbbGrid.TextMatrix(Jsqte, Sydz("021", GridStr(), Szzls)) = Trim(.Fields("period") & "")               '月份
  991.             CxbbGrid.TextMatrix(Jsqte, Sydz("025", GridStr(), Szzls)) = Trim(.Fields("billname") & "")               '备注
  992.             CxbbGrid.TextMatrix(Jsqte, Sydz("026", GridStr(), Szzls)) = Trim(.Fields("remark") & "")               '备注
  993.             If .Fields("inoutFlag") Then
  994.                 If .Fields("InQuan") <> 0 Then                                                                           '数量
  995.                     CxbbGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls)) = .Fields("InQuan")
  996.                 End If
  997.                 If Trim(.Fields("pricemode")) = "计划价法" Then
  998.                     If .Fields("InPrice") <> 0 Then                                                                      '计划单价
  999.                         CxbbGrid.TextMatrix(Jsqte, Sydz("015", GridStr(), Szzls)) = .Fields("InPrice")
  1000.                     End If
  1001.                     If .Fields("InMoney") <> 0 Then                                                                      '计划金额
  1002.                         CxbbGrid.TextMatrix(Jsqte, Sydz("016", GridStr(), Szzls)) = .Fields("InMoney")
  1003.                     End If
  1004.                     If .Fields("InQuan") <> 0 Then                                                                        '实际单价
  1005.                         CxbbGrid.TextMatrix(Jsqte, Sydz("017", GridStr(), Szzls)) = (.Fields("InMoney") + .Fields("JfDiff") - .Fields("DfDiff")) / .Fields("InQuan")
  1006.                     End If
  1007.                     If (.Fields("InMoney") + .Fields("JfDiff") - .Fields("DfDiff")) <> 0 Then                                '实际金额
  1008.                         CxbbGrid.TextMatrix(Jsqte, Sydz("018", GridStr(), Szzls)) = .Fields("InMoney") + .Fields("JfDiff") - .Fields("DfDiff")
  1009.                     End If
  1010.                 Else
  1011.                     If .Fields("InPrice") <> 0 Then                                                                      '计划单价
  1012.                         CxbbGrid.TextMatrix(Jsqte, Sydz("017", GridStr(), Szzls)) = .Fields("InPrice")
  1013.                     End If
  1014.                     If .Fields("InMoney") <> 0 Then                                                                      '计划金额
  1015.                         CxbbGrid.TextMatrix(Jsqte, Sydz("018", GridStr(), Szzls)) = .Fields("InMoney")
  1016.                     End If
  1017.                 End If
  1018.             Else
  1019.                 If .Fields("OutQuan") <> 0 Then                                                                           '数量
  1020.                     CxbbGrid.TextMatrix(Jsqte, Sydz("022", GridStr(), Szzls)) = .Fields("OutQuan")
  1021.                 End If
  1022.                 If .Fields("OutPrice") <> 0 Then                                                                          '实际单价
  1023.                     CxbbGrid.TextMatrix(Jsqte, Sydz("023", GridStr(), Szzls)) = .Fields("OutPrice")
  1024.                 End If
  1025.                 If .Fields("OutMoney") <> 0 Then                                                                         '实际金额
  1026.                     CxbbGrid.TextMatrix(Jsqte, Sydz("024", GridStr(), Szzls)) = .Fields("OutMoney")
  1027.                 End If
  1028.             End If
  1029.             
  1030.             '<<]
  1031.             '设置数据行高度(Fixed)
  1032.             CxbbGrid.RowHeight(Jsqte) = Sjhgd
  1033.      
  1034.             '动态集指针加1,同时将计数器加1(Fixed)
  1035.             .MoveNext
  1036.             Jsqte = Jsqte + 1
  1037.         Loop
  1038.     End With
  1039.     
  1040.     
  1041.     '输入合计
  1042.     With CxbbGrid
  1043.         If CL_BillChalkitupCond.Chk_Sum.Value <> 0 Then
  1044.            .SubtotalPosition = flexSTBelow
  1045.            For Jsqte = Qslz To .Cols - 1
  1046.                 If GridBoolean(Jsqte, 4) Then
  1047.                      .Subtotal flexSTSum, 0, Jsqte, , &HF7F3EC, , , , , True
  1048.                 End If
  1049.            Next
  1050.            
  1051.            For Jsqte = .FixedRows To .Rows - 1
  1052.                 If .IsSubtotal(Jsqte) Then
  1053.                     For Coljsq = Qslz To .Cols - 1
  1054.                         If Val(.TextMatrix(Jsqte, Coljsq)) = 0 And GridBoolean(Coljsq, 4) Then
  1055.                             .TextMatrix(Jsqte, Coljsq) = ""
  1056.                         End If
  1057.                     Next
  1058.                     .TextMatrix(Jsqte, 0) = .TextMatrix(Jsqte - 1, 0)
  1059.                     .TextMatrix(Jsqte, 1) = .TextMatrix(Jsqte - 1, 1)
  1060.                     .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = "    合计 "
  1061.                     .RowHeight(Jsqte) = Sjhgd
  1062.                 End If
  1063.            Next
  1064.         End If
  1065.     End With
  1066.     
  1067.     ']以上为用户自定义部分
  1068.     
  1069.     Set Rec_Query = Nothing
  1070. End Sub
  1071. Private Sub Sub_QueryHz(Int_QueryType As Integer)                                     '生成查询结果(Define)
  1072.     
  1073.     '过程参数:Int_QueryType 0-"点确定按钮"查询  1-"刷新"查询
  1074.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  1075.     Dim Coljsq As Long                          '网格列计数器
  1076.     Dim Jsqte As Long                        '临时动态计数器
  1077.     Dim Str As String
  1078.     Dim FindRow As Integer
  1079.     
  1080.     '以下为自定义部分[
  1081.      
  1082.     CxbbGrid.ColHidden(Sydz("001", GridStr(), Szzls)) = True
  1083.     CxbbGrid.ColHidden(Sydz("003", GridStr(), Szzls)) = True
  1084.     CxbbGrid.ColHidden(Sydz("004", GridStr(), Szzls)) = True
  1085.     CxbbGrid.ColHidden(Sydz("005", GridStr(), Szzls)) = True
  1086.     CxbbGrid.ColHidden(Sydz("006", GridStr(), Szzls)) = True
  1087.     CxbbGrid.ColHidden(Sydz("007", GridStr(), Szzls)) = True
  1088.     CxbbGrid.ColHidden(Sydz("008", GridStr(), Szzls)) = True
  1089.     CxbbGrid.ColHidden(Sydz("009", GridStr(), Szzls)) = True
  1090.     CxbbGrid.ColHidden(Sydz("010", GridStr(), Szzls)) = True
  1091.     CxbbGrid.ColHidden(Sydz("020", GridStr(), Szzls)) = True
  1092.     CxbbGrid.ColHidden(Sydz("021", GridStr(), Szzls)) = True
  1093.     CxbbGrid.ColHidden(Sydz("025", GridStr(), Szzls)) = True
  1094.     CxbbGrid.ColHidden(Sydz("026", GridStr(), Szzls)) = True
  1095.     
  1096.     If CL_BillChalkitupCond.Opt_Wjz Then
  1097.         SqlStr = "SELECT a.Whcode, WhName, MNumber, MName, Model, PrimaryUnitName," & _
  1098.                 " SUM(FactReceiptQuan) AS SumInQuan, SUM(PlanMoney) AS SumPlanMoney, " & _
  1099.                 " SUM(EMoney) AS SumEMoney,SUM(FactIssueQuan) AS SumOutQuan, " & _
  1100.                 " SUM(IssueMoney) AS SumOutMoney FROM Chhs_V_InOut a " & Trim(Str_QueryCondi) & _
  1101.                 " and a.chhschecker<>'' GROUP BY a.WhName, a.MNumber, " & _
  1102.                 " a.MName, a.Model, a.PrimaryUnitName, a.WhCode ORDER BY  a.WhCode, a.MNumber "
  1103.     Else
  1104.         CxbbGrid.ColHidden(Sydz("015", GridStr(), Szzls)) = True
  1105.         CxbbGrid.ColHidden(Sydz("016", GridStr(), Szzls)) = True
  1106.         SqlStr = "SELECT a.Whcode, WhName, MNumber, MName, Model, PrimaryUnitName," & _
  1107.                 " SUM(InQuan) AS SumInQuan, 1 AS SumPlanMoney, " & _
  1108.                 " SUM(InMoney) AS SumEMoney,SUM(OutQuan) AS SumOutQuan, " & _
  1109.                 " SUM(OutMoney) AS SumOutMoney FROM Chhs_V_List a " & Trim(Str_QueryCondi) & _
  1110.                 " GROUP BY a.WhName, a.MNumber, " & _
  1111.                 " a.MName, a.Model, a.PrimaryUnitName, a.WhCode ORDER BY a.WhCode, a.MNumber"
  1112.     End If
  1113.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1114.     With Rec_Query
  1115.         CxbbGrid.Rows = CxbbGrid.FixedRows
  1116.         Jsqte = CxbbGrid.FixedRows
  1117.         Do While Not .EOF
  1118.             CxbbGrid.AddItem ""
  1119.             '[>>自定义填充内容
  1120.             
  1121.             CxbbGrid.TextMatrix(Jsqte, 1) = Trim(.Fields("WhCode") & "") + Trim(.Fields("Mnumber") & "")                 '仓库+存货
  1122.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("WhName") & "")                   '仓库
  1123.             CxbbGrid.TextMatrix(Jsqte, Sydz("019", GridStr(), Szzls)) = Trim(.Fields("Mnumber") & "")                  '存货编码
  1124.             CxbbGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Trim(.Fields("MName") & "")                    '存货名称
  1125.             CxbbGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = Trim(.Fields("Model") & "")                    '规格型号
  1126.             CxbbGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls)) = Trim(.Fields("PrimaryUnitName") & "")          '主计量单位
  1127.             If .Fields("SumInQuan") <> 0 Then                                                                            '数量
  1128.                 CxbbGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls)) = .Fields("SumInQuan")
  1129.             End If
  1130.             If .Fields("SumInQuan") <> 0 Then                                                                            '计划单价
  1131.                 CxbbGrid.TextMatrix(Jsqte, Sydz("015", GridStr(), Szzls)) = .Fields("SumPlanMoney") / .Fields("SumInQuan")
  1132.             End If
  1133.             If .Fields("SumPlanMoney") <> 0 Then                                                                       '计划金额
  1134.                 CxbbGrid.TextMatrix(Jsqte, Sydz("016", GridStr(), Szzls)) = .Fields("SumPlanMoney")
  1135.             End If
  1136.             If .Fields("SumInQuan") <> 0 Then                                                                            '实际金额
  1137.                 CxbbGrid.TextMatrix(Jsqte, Sydz("017", GridStr(), Szzls)) = .Fields("SumEMoney") / .Fields("SumInQuan")
  1138.             End If
  1139.             If .Fields("SumEmoney") <> 0 Then                                                                          '实际金额
  1140.                 CxbbGrid.TextMatrix(Jsqte, Sydz("018", GridStr(), Szzls)) = .Fields("SumEMoney")
  1141.             End If
  1142.             If .Fields("SumOutQuan") <> 0 Then                                                                       '计划金额
  1143.                 CxbbGrid.TextMatrix(Jsqte, Sydz("022", GridStr(), Szzls)) = .Fields("SumOutQuan")
  1144.             End If
  1145.             If .Fields("SumOutQuan") <> 0 And .Fields("SumOutMoney") <> 0 Then                                                                            '实际金额
  1146.                 CxbbGrid.TextMatrix(Jsqte, Sydz("023", GridStr(), Szzls)) = .Fields("SumOutMoney") / .Fields("SumOutQuan")
  1147.             End If
  1148.             If .Fields("SumOutMoney") <> 0 Then                                                                          '实际金额
  1149.                 CxbbGrid.TextMatrix(Jsqte, Sydz("024", GridStr(), Szzls)) = .Fields("SumOutMoney")
  1150.             End If
  1151.             '<<]
  1152.             '设置数据行高度(Fixed)
  1153.             CxbbGrid.RowHeight(Jsqte) = Sjhgd
  1154.      
  1155.             '动态集指针加1,同时将计数器加1(Fixed)
  1156.             .MoveNext
  1157.             Jsqte = Jsqte + 1
  1158.         Loop
  1159.     End With
  1160.     
  1161.     '输入合计
  1162.     With CxbbGrid
  1163.         If Not .Rows = .FixedRows Then
  1164.            .SubtotalPosition = flexSTBelow
  1165.            For Jsqte = Qslz To .Cols - 1
  1166.                 If GridBoolean(Jsqte, 4) Then
  1167.                      .Subtotal flexSTSum, 0, Jsqte, , &HF7F3EC, , , , , True
  1168.                      If Val(.TextMatrix(.Rows - 1, Jsqte)) = 0 Then
  1169.                         .TextMatrix(.Rows - 1, Jsqte) = ""
  1170.                      End If
  1171.                 End If
  1172.            Next
  1173.            .RowHeight(.Rows - 1) = Sjhgd
  1174.            .TextMatrix(.Rows - 1, Sydz("002", GridStr(), Szzls)) = " 合计 "
  1175.         End If
  1176.     End With
  1177.     
  1178.     ']以上为用户自定义部分
  1179. End Sub
  1180. Private Sub CxbbGrid_DblClick()                                              '用户双击网格调入相应单据
  1181.     
  1182.     Dim Rectemp As New ADODB.Recordset               '临时使用动态集
  1183.     If CxbbGrid.Rows = CxbbGrid.FixedRows Then Exit Sub
  1184.     
  1185.     '非数据行退出
  1186.     If CxbbGrid.Row < CxbbGrid.FixedRows Or Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) = 0 Then
  1187.         Exit Sub
  1188.     End If
  1189.     
  1190.     If Trim(CxbbGrid.TextMatrix(CxbbGrid.Row, 1)) = "1301" Or Trim(CxbbGrid.TextMatrix(CxbbGrid.Row, 1)) = "1302" Then
  1191.         SqlStr = "SELECT InOutAdjustMainId From Chhs_InOutAdjustMain Where InOutAdjustMainId=" & Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) + 0
  1192.     ElseIf Trim(CxbbGrid.TextMatrix(CxbbGrid.Row, 1)) = "1303" Then
  1193.         SqlStr = "SELECT PlanAdjustMainId From Chhs_PlanAdjustMain Where PlanAdjustMainId=" & Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) + 0
  1194.     Else
  1195.         SqlStr = "SELECT InOutMainId From Gy_InOutMain Where InOutMainId=" & Val(CxbbGrid.TextMatrix(CxbbGrid.Row, 0)) + 0
  1196.     End If
  1197.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1198.     With Rectemp
  1199.         If .EOF Then
  1200.             Tsxx = "此单据已被其他用户删除!"
  1201.             Call Xtxxts(Tsxx, 0, 4)
  1202.             Exit Sub
  1203.         Else
  1204.             
  1205.              '填充查询单据标识
  1206.             XT_BillID = CxbbGrid.TextMatrix(CxbbGrid.Row, 0)
  1207.             Xtcdcsfz = Str_QueryCondi
  1208.             
  1209.             '设置单据处理为列表查询(修改)状态
  1210.             Xtcdcs = "3"
  1211.             
  1212.            '调入单据处理窗体
  1213.             Select Case Trim(CxbbGrid.TextMatrix(CxbbGrid.Row, 1))
  1214.                 Case "1202"
  1215.                     DJ_ProdInBill.Show 1
  1216.                 Case "1203"
  1217.                     DJ_OtherInBill.Show 1
  1218.                 Case "1204"
  1219.                     DJ_MateOutBill.Show 1
  1220.                 Case "1205"
  1221.                     DJ_SellOutBill.Show 1
  1222.                 Case "1206"
  1223.                     DJ_OtherOutBill.Show 1
  1224.                 Case "1212"
  1225.                     DJ_MateInBill.Show 1
  1226.                 Case "1301"
  1227.                     DJ_AdjustInbill.Show 1
  1228.                 Case "1302"
  1229.                     DJ_AdjustOutBill.Show 1
  1230.                 Case "1303"
  1231.                     Xtcdcs = "0"
  1232.                     Xtcdcsfz = XT_BillID
  1233.                     DJ_AdjustPlan.Show 1
  1234.             End Select
  1235.         End If
  1236.     End With
  1237. End Sub
  1238. Private Sub Sub_Mx()                                             '明细
  1239.     
  1240.     '生成查询结果
  1241.     If CL_BillChalkitupCond.Opt_Wjz Then         '未记帐
  1242.         Call Sub_Query(0)
  1243.     Else
  1244.         Call Sub_QueryJz(0)
  1245.     End If
  1246.      '调整工具条
  1247.     With SzToolbar
  1248.         If CxbbGrid.Rows = CxbbGrid.FixedRows Then
  1249.             .Buttons("Bill").Enabled = False
  1250.             .Buttons("mx").Enabled = False
  1251.             .Buttons("hz").Enabled = False
  1252.             .Buttons("jz").Enabled = False
  1253.             .Buttons("hf").Enabled = False
  1254.         Else
  1255.             .Buttons("cx").Enabled = True
  1256.             .Buttons("Bill").Enabled = True
  1257.             .Buttons("hz").Enabled = True
  1258.             .Buttons("mx").Enabled = False
  1259.             If CL_BillChalkitupCond.Opt_Wjz Then
  1260.                 .Buttons("jz").Enabled = True
  1261.                 .Buttons("hf").Enabled = False
  1262.             Else
  1263.                 .Buttons("jz").Enabled = False
  1264.                 .Buttons("hf").Enabled = True
  1265.             End If
  1266.        End If
  1267.         If CL_BillChalkitupCond.Opt_Wjz Then
  1268.             Lbl_Color.Visible = True
  1269.             Label2.Visible = True
  1270.         Else
  1271.             Lbl_Color.Visible = False
  1272.             Label2.Visible = False
  1273.         End If
  1274.     End With
  1275.    
  1276.    If GsToolbar.Enabled = False Then
  1277.         
  1278.         '显示汇总后隐藏的网格列
  1279.         For Jsqte = Qslz To CxbbGrid.Cols - 1
  1280.             CxbbGrid.ColHidden(Jsqte) = GridColHide(Jsqte)
  1281.         Next
  1282.     End If
  1283.     
  1284.     GsToolbar.Enabled = True
  1285.     
  1286. End Sub
  1287. Private Sub Sub_Hz()                                            '汇总
  1288.     
  1289.     If CxbbGrid.Rows = CxbbGrid.FixedRows Then Exit Sub
  1290.     
  1291.        '生成查询结果
  1292.     Call Sub_QueryHz(0)
  1293.     
  1294.     With SzToolbar
  1295.         .Buttons("cx").Enabled = False
  1296.         .Buttons("Bill").Enabled = False
  1297.         .Buttons("jz").Enabled = False
  1298.         .Buttons("hf").Enabled = False
  1299.         .Buttons("hz").Enabled = False
  1300.         .Buttons("mx").Enabled = True
  1301.     End With
  1302.     
  1303.     GsToolbar.Enabled = False
  1304.       
  1305. End Sub
  1306. Private Sub Sub_Chalkitup()               '单据记帐
  1307. Dim Rectemp As Recordset
  1308. Dim RectempId As Recordset
  1309. Dim RecTempFz As New ADODB.Recordset
  1310. Dim RecQuery As New ADODB.Recordset
  1311. Dim RectempMx As New ADODB.Recordset
  1312. Dim RecTempZz As New ADODB.Recordset
  1313. Dim MovePrice As Double                 '移动平均单价  (移动平均)
  1314. Dim SumQuan As Double                   '数量合计      (移动平均)
  1315. Dim SumMoney As Double                  '金额合计      (移动平均)
  1316. Dim OutQuan As Double                   '出库数量  (先进先出 后进先出)
  1317. Dim InQuan As Double                    '入库数量  (先进先出 后进先出)
  1318. Dim OutPrice As Double                  '出库单价  (先进先出 后进先出)
  1319. Dim OutMoney As Double                  '出库总金额(先进先出 后进先出)
  1320. Dim mPeriod As Integer                  '当前会计期间
  1321.     If CxbbGrid.Rows = CxbbGrid.FixedRows Then Exit Sub
  1322.     mPeriod = PGNowmon
  1323.     
  1324.     '系统操作日期不在当前会计年度
  1325.     If Not Xtyear = PGKjYear Then
  1326.         Tsxx = "操作日期不在当前会计年度(" + Trim(Str(PGKjYear)) + ")之内,请重新登录!"
  1327.         Call Xtxxts(Tsxx, 0, 1)
  1328.         Exit Sub
  1329.     End If
  1330.     
  1331.     '系统操作日期是否在当前会计期间
  1332.     If Not Xtmm = mPeriod Then
  1333.         Tsxx = "操作日期不在当前会计期间(" + Trim(Str(PGKjYear)) + "." + Trim(Str(mPeriod)) + ")之内,请重新登录!"
  1334.         Call Xtxxts(Tsxx, 0, 1)
  1335.         Exit Sub
  1336.     End If
  1337.    
  1338.     '期初单据未记帐日常单据不能记帐
  1339.     SqlStr = "select chalkitupman from Chhs_StartInputMain a " & _
  1340.             Trim(Str_QueryCondi) & "and chalkitupman='' "
  1341.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1342.     If Not Rectemp.EOF Then
  1343.         Tsxx = "期初单据未记帐,日常单据不允许记帐!"
  1344.         Call Xtxxts(Tsxx, 0, 1)
  1345.         Exit Sub
  1346.     End If
  1347.     
  1348.     '操作日期大于等于单据录入的最大日期
  1349.     SqlStr = "select max(billdate) as maxdate from Gy_InoutMain a " & Trim(Str_QueryCondi) & " and kjyear=" & Xtyear & " and period=" & Xtmm & " and chhschecker<>''"
  1350.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1351.     If Not Rectemp.EOF Then
  1352.         If Xtrq < Rectemp.Fields("maxdate") Then
  1353.             Tsxx = "操作日期必须>=单据录入日期 " + Format(CStr(Rectemp.Fields("maxdate")), "yyyy-mm-dd")
  1354.             Call Xtxxts(Tsxx, 0, 4)
  1355.             Exit Sub
  1356.         End If
  1357.     End If
  1358.     
  1359.     On Error GoTo Cwcl
  1360.     
  1361.     Tsxx = ""
  1362.     
  1363.     Xt_Wait.Show
  1364.     Xt_Wait.Refresh
  1365.     
  1366.     Cw_DataEnvi.DataConnect.BeginTrans
  1367.     
  1368.     '打开明细帐
  1369.     If RectempMx.State = 1 Then RectempMx.Close
  1370.     RectempMx.Open "select * from Chhs_List where 1=2 ", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1371.     
  1372.     SqlStr = "SELECT * FROM Chhs_V_InOut a " & Trim(Str_QueryCondi) & _
  1373.              " and chhschecker<>'' Order By a.BillDate,a.whcode,a.InOutFlag desc,a.InoutMainId,a.InOutSubId"
  1374.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1375.     
  1376.     '零成本入库单
  1377.     Set RectempId = Cw_DataEnvi.DataConnect.Execute("select distinct inoutmainid from Chhs_V_InOut a " & Trim(Str_QueryCondi) & " and inoutflag=1 and emoney=0")
  1378.     Do While Not Rectemp.EOF
  1379.                 
  1380.         '入库金额为零不允许记帐
  1381.         If Not RectempId.EOF Then
  1382.             RectempId.MoveFirst
  1383.             RectempId.Find "inoutmainid=" & Rectemp.Fields("inoutmainid")
  1384.             If Not RectempId.EOF Then
  1385.                 GoTo MoveNext
  1386.             Else
  1387.                 RectempId.MoveFirst
  1388.             End If
  1389.         End If
  1390.         
  1391.         '以先进先出和后进先出核算的红字入库单不允许记帐
  1392.         If (Trim(Rectemp.Fields("pricemode")) = "先进先出法" Or Trim(Rectemp.Fields("pricemode")) = "后进先出法") And Rectemp.Fields("factreceiptquan") < 0 Then
  1393.             GoTo MoveNext
  1394.         End If
  1395.         
  1396.         '红字出库单金额为零 不允许记帐
  1397.         If Rectemp.Fields("factissuequan") < 0 And Rectemp.Fields("issuemoney") = 0 Then
  1398.             GoTo MoveNext
  1399.         End If
  1400.         
  1401.         With RectempMx
  1402.             .AddNew
  1403.             .Fields("inoutflag") = Rectemp.Fields("inoutflag")
  1404.             .Fields("opertype") = Trim(Rectemp.Fields("opertype"))
  1405.             If Not IsNull(Trim(Rectemp.Fields("operbillnum"))) Then
  1406.                 .Fields("operbillnum") = Trim(Rectemp.Fields("operbillnum"))
  1407.             End If
  1408.             .Fields("billnum") = Trim(Rectemp.Fields("billnum"))
  1409.             .Fields("inoutmainid") = Trim(Rectemp.Fields("inoutmainid"))
  1410.             .Fields("inoutsubid") = Trim(Rectemp.Fields("inoutsubid"))
  1411.             .Fields("billdate") = Trim(Rectemp.Fields("billdate"))
  1412.             .Fields("chalkdate") = Xtrq
  1413.             .Fields("kjyear") = Xtyear
  1414.             .Fields("period") = mPeriod
  1415.             .Fields("billcode") = Trim(Rectemp.Fields("billcode"))
  1416.             If Not IsNull(Trim(Rectemp.Fields("purtypecode"))) Then
  1417.                 .Fields("purtypecode") = Trim(Rectemp.Fields("purtypecode"))
  1418.             End If
  1419.             .Fields("whcode") = Trim(Rectemp.Fields("whcode"))
  1420.             .Fields("mnumber") = Trim(Rectemp.Fields("mnumber"))
  1421.             .Fields("maker") = Trim(Rectemp.Fields("maker"))
  1422.             .Fields("checker") = Trim(Rectemp.Fields("chhschecker"))
  1423.             .Fields("chalkitupman") = Xtczy
  1424.             .Fields("remark") = Trim(Rectemp.Fields("remark") & "")
  1425.             If Not IsNull(Trim(Rectemp.Fields("receiptnum"))) Then
  1426.                 .Fields("receiptnum") = Trim(Rectemp.Fields("receiptnum"))
  1427.             End If
  1428.             If Not IsNull(Trim(Rectemp.Fields("costobjectcode"))) Then
  1429.                 .Fields("CostObjectCode") = Trim(Rectemp.Fields("costobjectcode"))
  1430.             End If
  1431.             If Not IsNull(Trim(Rectemp.Fields("projectcode"))) Then
  1432.                 .Fields("projectcode") = Trim(Rectemp.Fields("projectcode"))
  1433.             End If
  1434.             If Not IsNull(Trim(Rectemp.Fields("deptcode"))) Then
  1435.                 .Fields("deptcode") = Trim(Rectemp.Fields("deptcode"))
  1436.             End If
  1437.             If Not IsNull(Trim(Rectemp.Fields("suppliercode"))) Then
  1438.                 .Fields("suppliercode") = Trim(Rectemp.Fields("suppliercode"))
  1439.             End If
  1440.             If Not IsNull(Trim(Rectemp.Fields("cuscode"))) Then
  1441.                 .Fields("cuscode") = Trim(Rectemp.Fields("cuscode"))
  1442.             End If
  1443.             If Not IsNull(Trim(Rectemp.Fields("inoutclasscode"))) Then
  1444.                 .Fields("inoutclasscode") = Trim(Rectemp.Fields("inoutclasscode"))
  1445.             End If
  1446.             If Not IsNull(Trim(Rectemp.Fields("personcode"))) Then
  1447.                 .Fields("personcode") = Trim(Rectemp.Fields("personcode"))
  1448.             End If
  1449.             
  1450.             '存货科目
  1451.             Xtfhcs = ""
  1452.             Xtfhcsfz = ""
  1453.             Call MaccCode(Trim(Rectemp.Fields("whcode")), Trim(Rectemp.Fields("mnumber")), Trim(Rectemp.Fields("invsortcode")))
  1454.             .Fields("mateacct") = Xtfhcs
  1455.             If Qmclcy And Rectemp.Fields("inoutflag") And Trim(Rectemp.Fields("pricemode")) = "计划价法" Then
  1456.                 .Fields("diffacct") = Xtfhcsfz
  1457.             End If
  1458.             
  1459.             '对方科目
  1460.             Xtfhcs = ""
  1461.             Call DfaccCode(Trim(Rectemp.Fields("inoutclasscode") & ""), Trim(Rectemp.Fields("deptcode") & ""), Trim(Rectemp.Fields("invsortcode")), Trim(Rectemp.Fields("mnumber")))
  1462.             .Fields("dfacct") = Xtfhcs
  1463.             
  1464.              '入库单
  1465.             If Rectemp.Fields("inoutflag") Then
  1466.                 .Fields("inquan") = Rectemp.Fields("factreceiptquan")
  1467.                 Select Case Trim(Rectemp.Fields("pricemode"))
  1468.                     Case "计划价法"
  1469.                         If Qmclcy Then
  1470.                             .Fields("inprice") = Rectemp.Fields("planprice")
  1471.                             .Fields("inmoney") = Rectemp.Fields("planmoney")
  1472.                             If Rectemp.Fields("emoney") - Rectemp.Fields("planmoney") > 0 Then
  1473.                                 .Fields("jfdiff") = Rectemp.Fields("emoney") - Rectemp.Fields("planmoney")
  1474.                             Else
  1475.                                 .Fields("dfdiff") = Rectemp.Fields("planmoney") - Rectemp.Fields("emoney")
  1476.                             End If
  1477.                         Else
  1478.                             .Fields("inprice") = Rectemp.Fields("price")
  1479.                             .Fields("inmoney") = Rectemp.Fields("emoney")
  1480.                         End If
  1481.                         .UpdateBatch
  1482.                     Case "全月平均法"
  1483.                         .Fields("inprice") = Rectemp.Fields("price")
  1484.                         .Fields("inmoney") = Rectemp.Fields("emoney")
  1485.                         .UpdateBatch
  1486.                         
  1487.                     Case "移动平均法"
  1488.                         .Fields("inprice") = Rectemp.Fields("price")
  1489.                         .Fields("inmoney") = Rectemp.Fields("emoney")
  1490.                         .UpdateBatch
  1491.                         
  1492.                     Case "先进先出法", "后进先出法"
  1493.                         .Fields("inprice") = Rectemp.Fields("price")
  1494.                         .Fields("inmoney") = Rectemp.Fields("emoney")
  1495.                         .UpdateBatch
  1496.                         
  1497.                         '入辅助帐
  1498.                         If RecTempFz.State = 1 Then RecTempFz.Close
  1499.                         RecTempFz.Open "select * from Chhs_AssiPrice ", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1500.                         RecTempFz.AddNew
  1501.                         RecTempFz.Fields("inbillnum") = Trim(Rectemp.Fields("billnum"))
  1502.                         RecTempFz.Fields("whcode") = Trim(Rectemp.Fields("whcode"))
  1503.                         RecTempFz.Fields("mnumber") = Trim(Rectemp.Fields("mnumber"))
  1504.                         RecTempFz.Fields("inoutmaininid") = Rectemp.Fields("inoutmainid")
  1505.                         RecTempFz.Fields("inoutsubinid") = Rectemp.Fields("inoutsubid")
  1506.                         RecTempFz.Fields("indate") = Rectemp.Fields("billdate")
  1507.                         RecTempFz.Fields("inbillcode") = Trim(Rectemp.Fields("billcode"))
  1508.                         RecTempFz.Fields("inquan") = Rectemp.Fields("factreceiptquan")
  1509.                         RecTempFz.Fields("inprice") = Rectemp.Fields("price")
  1510.                         RecTempFz.Fields("inmoney") = Rectemp.Fields("emoney")
  1511.                         RecTempFz.Fields("listid") = .Fields("listid")
  1512.                         RecTempFz.Fields("inchalkdate") = Xtrq
  1513.                         RecTempFz.UpdateBatch
  1514.                 End Select
  1515.             Else
  1516.                 '出库单
  1517.                 .Fields("outquan") = Rectemp.Fields("factissuequan")
  1518.                 Select Case Trim(Rectemp.Fields("pricemode"))
  1519.                     Case "计划价法"
  1520.                         .Fields("outprice") = Rectemp.Fields("planprice")
  1521.                         .Fields("outmoney") = Rectemp.Fields("planmoney")
  1522.                     Case "全月平均法"
  1523.                         If Rectemp.Fields("issuemoney") <> 0 And SFjezt Then
  1524.                             .Fields("sfjeztflag") = 1
  1525.                             .Fields("outprice") = Rectemp.Fields("price")
  1526.                             .Fields("outmoney") = Rectemp.Fields("issuemoney")
  1527.                         Else
  1528.                             .Fields("outprice") = 0
  1529.                             .Fields("outmoney") = 0
  1530.                         End If
  1531.                    Case "移动平均法"
  1532.                         
  1533.                         If Rectemp.Fields("issuemoney") <> 0 And SFjezt Then
  1534.                             .Fields("sfjeztflag") = 1
  1535.                             .Fields("outprice") = Rectemp.Fields("price")
  1536.                             .Fields("outmoney") = Rectemp.Fields("issuemoney")
  1537.                         Else
  1538.                             '入库金额汇总
  1539.                             SumQuan = 0
  1540.                             SumMoney = 0
  1541.                             SqlStr = "SELECT StartQuan,StartMoney from Chhs_Mate a where kjyear=" & Xtyear & _
  1542.                                     " and period=" & mPeriod & _
  1543.                                     " and a.whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  1544.                                     " and a.mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' "
  1545.                             Set RecTempFz = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1546.                             If Not RecTempFz.EOF Then
  1547.                                 SumQuan = RecTempFz.Fields("StartQuan")
  1548.                                 SumMoney = RecTempFz.Fields("StartMoney")
  1549.                             End If
  1550.                             SqlStr = "SELECT SUM(InQuan)-SUM(OutQuan) AS SumQuan,SUM(InMoney)- SUM(OutMoney) AS SumMoney  " & _
  1551.                                     " FROM Chhs_List a where a.startflag=0 and kjyear=" & Xtyear & _
  1552.                                     " and period=" & mPeriod & " and inoutmainid<>" & Rectemp.Fields("inoutmainid") & _
  1553.                                     " and a.whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  1554.                                     " and a.mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' "
  1555.                             Set RecTempFz = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1556.                             If Not RecTempFz.EOF Then
  1557.                                 If Not IsNull(RecTempFz.Fields("SumQuan")) Then
  1558.                                     SumQuan = SumQuan + RecTempFz.Fields("SumQuan")
  1559.                                 End If
  1560.                                 If Not IsNull(RecTempFz.Fields("SumMoney")) Then
  1561.                                     SumMoney = SumMoney + RecTempFz.Fields("SumMoney")
  1562.                                 End If
  1563.                             End If
  1564.                             
  1565.                             MovePrice = 0
  1566.                             If SumQuan <> 0 Then
  1567.                                 MovePrice = Format(SumMoney / SumQuan, "####0." + String(Xtdjxsws, "0"))
  1568.                             End If
  1569.                                 
  1570.                             '移动平均单价<=0时,手工输入单价
  1571.                             If MovePrice <= 0 Then
  1572.                                 Xtcdcs = Rectemp.Fields("factissuequan")
  1573.                                 Xtcdcsfz = Trim(Rectemp.Fields("mnumber"))
  1574.                                 CL_BillChalkPrice.Show 1
  1575.                                 MovePrice = CDbl(Xtcdcs)
  1576.                                 If MovePrice <= 0 Then
  1577.                                     Tsxx = "移动平均单价<=0,不允许记帐!"
  1578.                                     GoTo Cwcl
  1579.                                 End If
  1580.                             End If
  1581.                             .Fields("outprice") = MovePrice
  1582.                             .Fields("outmoney") = Format(Rectemp.Fields("factissuequan") * MovePrice, "###0." + String(Xtjexsws, "0"))
  1583.                         End If
  1584.                     Case "先进先出法", "后进先出法"
  1585.                         If Rectemp.Fields("issuemoney") <> 0 And SFjezt Then
  1586.                             .Fields("sfjeztflag") = 1
  1587.                             .Fields("outprice") = Rectemp.Fields("price")
  1588.                             .Fields("outmoney") = Rectemp.Fields("issuemoney")
  1589.                         Else
  1590.                             OutQuan = Rectemp.Fields("factissuequan")
  1591.                             OutMoney = 0
  1592.                             
  1593.                             '辅助帐
  1594.                             If Trim(Rectemp.Fields("pricemode")) = "先进先出法" Then
  1595.                                 SqlStr = "select * from chhs_assiprice where whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  1596.                                         " and mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' and flag=0 " & _
  1597.                                         " order by inoutmaininid,inoutsubinid,assipriceid"
  1598.                             Else
  1599.                                 SqlStr = "select * from chhs_assiprice where whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  1600.                                         " and mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' and flag=0 " & _
  1601.                                         " order by inoutmaininid desc,inoutsubinid desc,assipriceid desc"
  1602.                             End If
  1603.                             If RecQuery.State = 1 Then RecQuery.Close
  1604.                             RecQuery.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1605.                             Do While Not RecQuery.EOF
  1606.                                 If OutQuan = RecQuery.Fields("inquan") Then
  1607.                                 
  1608.                                     '填写入库单对应的出库数量、金额及其它内容
  1609.                                     RecQuery.Fields("outquan") = OutQuan
  1610.                                     RecQuery.Fields("outprice") = RecQuery.Fields("inprice")
  1611.                                     RecQuery.Fields("outmoney") = OutQuan * RecQuery.Fields("inprice")
  1612.                                     OutMoney = OutMoney + RecQuery.Fields("outmoney")
  1613.                                     RecQuery.Fields("outbillnum") = Trim(Rectemp.Fields("billnum"))
  1614.                                     RecQuery.Fields("outdate") = Rectemp.Fields("billdate")
  1615.                                     RecQuery.Fields("inoutmainoutid") = Rectemp.Fields("inoutmainid")
  1616.                                     RecQuery.Fields("inoutsuboutid") = Rectemp.Fields("inoutsubid")
  1617.                                     RecQuery.Fields("outchalkdate") = Xtrq
  1618.                                     RecQuery.Fields("flag") = 1
  1619.                                     RecQuery.UpdateBatch
  1620.                                     Exit Do
  1621.                                 ElseIf OutQuan < RecQuery.Fields("inquan") Then
  1622.                                     
  1623.                                     '保留入库数量
  1624.                                     InQuan = RecQuery.Fields("inquan")
  1625.                                     
  1626.                                     '修改入库数量、金额与出库数量、金额相同 ,填写入库单对应的出库数量、金额及其它内容
  1627.                                     RecQuery.Fields("inquan") = OutQuan
  1628.                                     RecQuery.Fields("inmoney") = OutQuan * RecQuery.Fields("inprice")
  1629.                                     RecQuery.Fields("outquan") = OutQuan
  1630.                                     RecQuery.Fields("outprice") = RecQuery.Fields("inprice")
  1631.                                     RecQuery.Fields("outmoney") = OutQuan * RecQuery.Fields("inprice")
  1632.                                     OutMoney = OutMoney + RecQuery.Fields("outmoney")
  1633.                                     RecQuery.Fields("outbillnum") = Trim(Rectemp.Fields("billnum"))
  1634.                                     RecQuery.Fields("outdate") = Rectemp.Fields("billdate")
  1635.                                     RecQuery.Fields("inoutmainoutid") = Rectemp.Fields("inoutmainid")
  1636.                                     RecQuery.Fields("inoutsuboutid") = Rectemp.Fields("inoutsubid")
  1637.                                     RecQuery.Fields("outchalkdate") = Xtrq
  1638.                                     RecQuery.Fields("flag") = 1
  1639.                                     RecQuery.UpdateBatch
  1640.                                     
  1641.                                     '保留入库单的剩余数量
  1642.                                     If RecTempFz.State = 1 Then RecTempFz.Close
  1643.                                     RecTempFz.Open "select * from Chhs_AssiPrice ", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1644.                                     RecTempFz.AddNew
  1645.                                     RecTempFz.Fields("inbillnum") = Trim(RecQuery.Fields("inbillnum"))
  1646.                                     RecTempFz.Fields("whcode") = Trim(RecQuery.Fields("whcode"))
  1647.                                     RecTempFz.Fields("mnumber") = Trim(RecQuery.Fields("mnumber"))
  1648.                                     RecTempFz.Fields("inoutmaininid") = Trim(RecQuery.Fields("inoutmaininid"))
  1649.                                     RecTempFz.Fields("inoutsubinid") = Trim(RecQuery.Fields("inoutsubinid"))
  1650.                                     RecTempFz.Fields("indate") = RecQuery.Fields("indate")
  1651.                                     RecTempFz.Fields("inbillcode") = Trim(RecQuery.Fields("inbillcode"))
  1652.                                     RecTempFz.Fields("inchalkdate") = Trim(RecQuery.Fields("inchalkdate"))
  1653.                                     RecTempFz.Fields("inquan") = InQuan - OutQuan
  1654.                                     RecTempFz.Fields("inprice") = RecQuery.Fields("inprice")
  1655.                                     RecTempFz.Fields("inmoney") = RecQuery.Fields("inquan") * RecQuery.Fields("inprice")
  1656.                                     RecTempFz.Fields("listid") = Trim(RecQuery.Fields("listid"))
  1657.                                     RecTempFz.UpdateBatch
  1658.                                     Exit Do
  1659.                                 Else
  1660.                                     
  1661.                                     '填写入库单对应的出库数量、金额及其它内容
  1662.                                     OutQuan = Rectemp.Fields("factissuequan") - RecQuery.Fields("inquan")
  1663.                                     
  1664.                                     RecQuery.Fields("outquan") = RecQuery.Fields("inquan")
  1665.                                     RecQuery.Fields("outprice") = RecQuery.Fields("inprice")
  1666.                                     RecQuery.Fields("outmoney") = RecQuery.Fields("inquan") * RecQuery.Fields("inprice")
  1667.                                     OutMoney = OutMoney + RecQuery.Fields("outmoney")
  1668.                                     RecQuery.Fields("outbillnum") = Trim(Rectemp.Fields("billnum"))
  1669.                                     RecQuery.Fields("outdate") = Rectemp.Fields("billdate")
  1670.                                     RecQuery.Fields("inoutmainoutid") = Rectemp.Fields("inoutmainid")
  1671.                                     RecQuery.Fields("inoutsuboutid") = Rectemp.Fields("inoutsubid")
  1672.                                     RecQuery.Fields("outchalkdate") = Xtrq
  1673.                                     RecQuery.Fields("flag") = 1
  1674.                                     RecQuery.UpdateBatch
  1675.                                     
  1676.                                 End If
  1677.                                 
  1678.                                 RecQuery.MoveNext
  1679.                             Loop
  1680.                             
  1681.                             OutPrice = OutMoney / Rectemp.Fields("factissuequan")
  1682.                             If OutPrice <= 0 Then
  1683.                                 
  1684.                                 '根据出库方式设置出库成本
  1685.                                 OutPrice = mOutPrice(Trim(Rectemp.Fields("whcode")), Trim(Rectemp.Fields("mnumber")), Trim(Rectemp.Fields("mname")), Rectemp.Fields("factissuequan"))
  1686.                                 If OutPrice = 0 Then
  1687.                                     Tsxx = Trim(Rectemp.Fields("mname")) + "(" + Trim(Rectemp.Fields("mnumber")) + ")" + "的出库单价<=0,不允许记帐!"
  1688.                                     GoTo Cwcl
  1689.                                 End If
  1690.                                 
  1691.                             End If
  1692.                             
  1693.                             .Fields("outprice") = OutPrice
  1694.                             If OutMoney = 0 Then
  1695.                                 .Fields("outmoney") = .Fields("outquan") * OutPrice
  1696.                             Else
  1697.                                 .Fields("outmoney") = OutMoney
  1698.                             End If
  1699.                         End If
  1700.                 End Select
  1701.                 .UpdateBatch
  1702.                 
  1703.                 '回填出库金额、单价
  1704.                 Cw_DataEnvi.DataConnect.Execute ("update Gy_inoutsub  " & _
  1705.                             " set price =" & .Fields("outprice") & "," & _
  1706.                             " issuemoney =" & .Fields("outmoney") & _
  1707.                             " where inoutmainid='" & Rectemp.Fields("inoutmainid") & "'" & _
  1708.                             " and inoutsubid='" & Rectemp.Fields("inoutsubid") & "'")
  1709.                
  1710.             End If
  1711.         End With
  1712.     
  1713.         '修改单据中的记帐人
  1714.         Cw_DataEnvi.DataConnect.Execute ("update Gy_inoutmain set chalkitupman ='" & Xtczy & "'" & _
  1715.                     " where inoutmainid='" & Rectemp.Fields("inoutmainid") & "'")
  1716. MoveNext:         Rectemp.MoveNext
  1717.     Loop
  1718.     
  1719.     '调整总帐
  1720.     
  1721.     '单据汇总
  1722.     SqlStr = "SELECT WhCode, MNumber,SUM(InQuan) AS SumInQuan,SUM(InMoney) AS SumInMoney, " & _
  1723.             " SUM(JfDiff) AS SumJfDiff, SUM(DfDiff) AS SumDfDiff, SUM(OutQuan) AS SumOutQuan, " & _
  1724.             " SUM(OutMoney) AS SumOutMoney From Chhs_List a " & _
  1725.             " Where KjYear = " & Xtyear & " And Period = " & mPeriod & _
  1726.             " and a.startflag=0 and " & CL_BillChalkitupCond.WhCode & _
  1727.             " GROUP BY WhCode, MNumber ORDER BY WhCode, MNumber "
  1728.     
  1729.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1730.     Do While Not Rectemp.EOF
  1731.                     
  1732.         '打开总帐
  1733.         If RecTempZz.State = 1 Then RecTempZz.Close
  1734.         SqlStr = "select * from chhs_mate where whcode='" & Trim(Rectemp.Fields("whcode")) & "' " & _
  1735.                 " and mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' " & _
  1736.                 " and KjYear = " & Xtyear & " And Period = " & mPeriod
  1737.         RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1738.         With RecTempZz
  1739.             If Not .EOF Then       '修改已存在的仓库+存货
  1740.                 .Fields("inquan") = Rectemp.Fields("suminquan")
  1741.                 .Fields("inmoney") = Rectemp.Fields("suminmoney")
  1742.                 If .Fields("inquan") <> 0 Then
  1743.                     .Fields("inprice") = .Fields("inmoney") / .Fields("inquan")
  1744.                 End If
  1745.                 .Fields("outquan") = Rectemp.Fields("sumoutquan")
  1746.                 .Fields("outmoney") = Rectemp.Fields("sumoutmoney")
  1747.                 If .Fields("outquan") <> 0 Then
  1748.                     .Fields("outprice") = .Fields("outmoney") / .Fields("outquan")
  1749.                 End If
  1750.                 .Fields("jfdiff") = Rectemp.Fields("sumjfdiff")
  1751.                 .Fields("dfdiff") = Rectemp.Fields("sumdfdiff")
  1752.             Else                    '新增仓库+存货
  1753.                 .AddNew
  1754.                 .Fields("whcode") = Trim(Rectemp.Fields("whcode"))
  1755.                 .Fields("mnumber") = Trim(Rectemp.Fields("mnumber"))
  1756.                 .Fields("kjyear") = Xtyear
  1757.                 .Fields("period") = mPeriod
  1758.                 .Fields("inquan") = Rectemp.Fields("suminquan")
  1759.                 .Fields("inmoney") = Rectemp.Fields("suminmoney")
  1760.                 If .Fields("inquan") <> 0 Then
  1761.                     .Fields("inprice") = .Fields("inmoney") / .Fields("inquan")
  1762.                 End If
  1763.                 .Fields("outquan") = Rectemp.Fields("sumoutquan")
  1764.                 .Fields("outmoney") = Rectemp.Fields("sumoutmoney")
  1765.                 If .Fields("outquan") <> 0 Then
  1766.                     .Fields("outprice") = .Fields("outmoney") / .Fields("outquan")
  1767.                 End If
  1768.                 .Fields("jfdiff") = Rectemp.Fields("sumjfdiff")
  1769.                 .Fields("dfdiff") = Rectemp.Fields("sumdfdiff")
  1770.             End If
  1771.             .UpdateBatch
  1772.         End With
  1773.         Rectemp.MoveNext
  1774.     Loop
  1775.     
  1776.     Cw_DataEnvi.DataConnect.CommitTrans
  1777.     
  1778.     Call Sub_Query(1)
  1779.     
  1780.     Xt_Wait.Hide
  1781.     Tsxx = "记帐成功!"
  1782.     Call Xtxxts(Tsxx, 0, 4)
  1783.     Exit Sub
  1784. Cwcl:
  1785.     Xt_Wait.Hide
  1786.     Cw_DataEnvi.DataConnect.RollbackTrans
  1787.     If Tsxx = "" Then Tsxx = "记帐过程中出现未知错误,程序自动恢复记帐前状态!"
  1788.     Call Xtxxts(Tsxx, 0, 1)
  1789.     Exit Sub
  1790.     
  1791. End Sub
  1792. Private Sub Sub_CancelChalkitup()               '恢复记帐
  1793. Dim Rectemp As Recordset
  1794. Dim RecQuery As New ADODB.Recordset
  1795. Dim RecTempFz As New ADODB.Recordset
  1796. Dim RectempMx As New ADODB.Recordset
  1797. Dim RecTempZz As New ADODB.Recordset
  1798. Dim Str_Query As String
  1799. Dim SqlStr As String
  1800. Dim AssiId As Integer                         '辅助表ID
  1801. Dim DiffE As Double
  1802. Dim mPeriod As Integer                       '当前会计期间
  1803.     If CxbbGrid.Rows = CxbbGrid.FixedRows Then Exit Sub
  1804.     mPeriod = PGNowmon
  1805.     '系统操作日期不在当前会计年度
  1806.     If Not Xtyear = PGKjYear Then
  1807.         Tsxx = "系统操作日期不在当前会计年度,请重新注册!"
  1808.         Call Xtxxts(Tsxx, 0, 1)
  1809.         Exit Sub
  1810.     End If
  1811.     
  1812.     '系统操作日期是否在当前会计期间
  1813.     If Not Xtmm = mPeriod Then
  1814.         Tsxx = "系统操作日期不在当前会计期间,请重新注册!"
  1815.         Call Xtxxts(Tsxx, 0, 1)
  1816.         Exit Sub
  1817.     End If
  1818.     
  1819.     SqlStr = "SELECT distinct Vouchid FROM Chhs_V_List a " & _
  1820.              Trim(Str_QueryCondi) & " and Vouchid<>0 "
  1821.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1822.     If Not Rectemp.EOF Then
  1823.         Tsxx = "记帐单据已生成凭证,不允许恢复记帐!"
  1824.         Call Xtxxts(Tsxx, 0, 1)
  1825.         Exit Sub
  1826.     End If
  1827.     
  1828.     On Error GoTo Cwcl
  1829.     
  1830.     Xt_Wait.Show
  1831.     Xt_Wait.Refresh
  1832.     
  1833.     Cw_DataEnvi.DataConnect.BeginTrans
  1834.         
  1835.     '删除明细帐内容
  1836.     SqlStr = "SELECT * FROM Chhs_list a " & Trim(Str_QueryCondi) & _
  1837.             " and a.startflag=0 and a.billcode<>'1305' order by listid desc "
  1838.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1839.     Do While Not Rectemp.EOF
  1840.         If Rectemp.Fields("inoutflag") Or Rectemp.Fields("sfjeztflag") Then
  1841.         
  1842.             If Rectemp.Fields("InOutAdjustMainId") <> 0 And Trim(Rectemp.Fields("billcode")) <> "1303" Then
  1843.                 
  1844.                 '删除调整单据内容
  1845.                 SqlStr = "Select * from chhs_inoutAdjustsub where InOutAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId") & " and adjustmainid<>0 "
  1846.                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1847.                 Do While Not RecTempFz.EOF
  1848.                     DiffE = 0
  1849.                     SqlStr = "SELECT * FROM Chhs_list a " & Trim(Str_QueryCondi) & _
  1850.                                 " and inoutmainid=" & RecTempFz.Fields("adjustmainid") & _
  1851.                                 " and inoutsubid=" & RecTempFz.Fields("adjustsubid")
  1852.                     Set RectempMx = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1853.                     If RectempMx.EOF Then
  1854.                         '调整对应的收发记录表
  1855.                         If RecQuery.State = 1 Then RecQuery.Close
  1856.                         SqlStr = "select factreceiptquan,price, emoney,planmoney from Gy_Inoutsub where inoutmainid=" & RecTempFz.Fields("adjustmainid") & " and inoutsubid=" & RecTempFz.Fields("adjustsubid")
  1857.                         RecQuery.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1858.                         If Not RecQuery.EOF Then
  1859.                             RecQuery.Fields("emoney") = RecQuery.Fields("emoney") - RecTempFz.Fields("emoney")
  1860.                             RecQuery.Fields("price") = RecQuery.Fields("emoney") / RecQuery.Fields("factreceiptquan")
  1861.                             DiffE = RecQuery.Fields("emoney") - RecQuery.Fields("planmoney")
  1862.                             RecQuery.UpdateBatch
  1863.                         End If
  1864.                         
  1865.                         '调整对应的明细帐
  1866.                         If RecQuery.State = 1 Then RecQuery.Close
  1867.                         SqlStr = "select inquan,inprice,inmoney,jfdiff,dfdiff from chhs_list where inoutmainid=" & RecTempFz.Fields("adjustmainid") & " and inoutsubid=" & RecTempFz.Fields("adjustsubid")
  1868.                         RecQuery.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  1869.                         If Not RecQuery.EOF Then
  1870.                             If Qmclcy Then
  1871.                                 If DiffE > 0 Then
  1872.                                     RecQuery.Fields("jfdiff") = DiffE
  1873.                                     RecQuery.Fields("dfdiff") = 0
  1874.                                 Else
  1875.                                     RecQuery.Fields("jfdiff") = 0
  1876.                                     RecQuery.Fields("dfdiff") = Abs(DiffE)
  1877.                                 End If
  1878.                             Else
  1879.                                 RecQuery.Fields("inmoney") = RecQuery.Fields("inmoney") - RecTempFz.Fields("emoney")
  1880.                                 RecQuery.Fields("inprice") = RecQuery.Fields("inmoney") / RecQuery.Fields("inquan")
  1881.                             End If
  1882.                             RecQuery.UpdateBatch
  1883.                         End If
  1884.                     End If
  1885.                     RecTempFz.MoveNext
  1886.                 Loop
  1887.                 
  1888.                 '删除入库调整单子表内容
  1889.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustsub where InOutAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId") & " and InOutAdjustSubId=" & Rectemp.Fields("InOutAdjustSubId"))
  1890.                 
  1891.                 '删除入库调整单主表内容
  1892.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustmain where InOutAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId"))
  1893.             ElseIf Rectemp.Fields("InOutAdjustMainId") <> 0 And Trim(Rectemp.Fields("billcode")) = "1303" Then
  1894.                 
  1895.                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute("select * from Chhs_PlanAdjustMain where planadjustmainid=" & Rectemp.Fields("InOutAdjustMainId"))
  1896.                 If Not RecTempFz.EOF Then
  1897.                     
  1898.                     '恢复收发记录表中未记帐存货的的计划单价
  1899.                     SqlStr = "SELECT Gy_InOutMain.InoutFlag,Gy_InOutMain.InOutMainId, Gy_InOutSub.InOutSubId," & _
  1900.                         "Gy_InOutSub.FactReceiptQuan,Gy_InOutSub.FactIssueQuan, Gy_InOutSub.PlanPrice, " & _
  1901.                         "Gy_InOutSub.PlanMoney,Gy_InOutMain.ChalkitupMan , Gy_InOutMain.KjYear,  " & _
  1902.                         "Gy_InOutMain.Period FROM Gy_InOutMain INNER JOIN Gy_InOutSub ON " & _
  1903.                         "Gy_InOutMain.InOutMainId = Gy_InOutSub.InOutMainId LEFT OUTER JOIN " & _
  1904.                         "Gy_Warehouse ON Gy_InOutMain.WhCode = Gy_Warehouse.WhCode " & _
  1905.                         "WHERE (Gy_Warehouse.PriceMode = '计划价法') " & _
  1906.                         "AND Gy_InOutMain.BillCode<>'1211' AND kjYear=" & Xtyear & " and Period>=" & mPeriod & _
  1907.                         "AND Gy_InOutSub.MNumber = '" & Trim(Rectemp.Fields("mnumber")) & "'"
  1908.                     Set RecQuery = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1909.                     Do While Not RecQuery.EOF
  1910.                         If RecQuery.Fields("InoutFlag") Then
  1911.                             SqlStr = "Update Gy_InOutSub set PlanPrice=" & RecTempFz.Fields("AdjustBeforePrice") & ",PlanMoney=" & Val(RecQuery.Fields("FactReceiptQuan")) * RecTempFz.Fields("AdjustBeforePrice") & " where InOutMainId=" & RecQuery.Fields("InOutMainId") & " and InOutSubId=" & RecQuery.Fields("InOutSubId")
  1912.                         Else
  1913.                             SqlStr = "Update Gy_InOutSub set PlanPrice=" & RecTempFz.Fields("AdjustBeforePrice") & ",PlanMoney=" & Val(RecQuery.Fields("FactIssueQuan")) * RecTempFz.Fields("AdjustBeforePrice") & " where InOutMainId=" & RecQuery.Fields("InOutMainId") & " and InOutSubId=" & RecQuery.Fields("InOutSubId")
  1914.                         End If
  1915.                         Cw_DataEnvi.DataConnect.Execute (SqlStr)
  1916.                         RecQuery.MoveNext
  1917.                     Loop
  1918.                 End If
  1919.                 
  1920.                 '恢复存货档案中的计划单价
  1921.                 Cw_DataEnvi.DataConnect.Execute ("update Gy_Material set planprice=" & RecTempFz.Fields("AdjustBeforePrice") & " where Mnumber='" & Rectemp.Fields("Mnumber") & "'")
  1922.                 
  1923.                 '删除计划价调整单子表内容
  1924.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_Planadjustsub where planAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId") & " and PlanAdjustSubId=" & Rectemp.Fields("InOutAdjustSubId"))
  1925.                 
  1926.                 '删除计划价调整单主表内容
  1927.                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute("select * from Chhs_PlanAdjustSub where planadjustmainid=" & Rectemp.Fields("InOutAdjustMainId"))
  1928.                 If RecTempFz.EOF Then
  1929.                     Cw_DataEnvi.DataConnect.Execute ("delete chhs_planadjustmain where planAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId"))
  1930.                 End If
  1931.                 
  1932.             Else
  1933.                 '修改单据的记帐人
  1934.                 Cw_DataEnvi.DataConnect.Execute ("update Gy_InoutMain set chalkitupman='' where inoutmainid='" & Trim(Rectemp.Fields("inoutmainid")) & "'")
  1935.                  
  1936.                 '删除辅助帐内容
  1937.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_assiprice where listid=" & Rectemp.Fields("listid"))
  1938.             End If
  1939.         Else
  1940.             
  1941.             If Rectemp.Fields("InOutAdjustMainId") <> 0 And Trim(Rectemp.Fields("billcode")) <> "1303" Then
  1942.                 
  1943.                 '删除出库调整单子表内容
  1944.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustsub where InOutAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId") & " and InOutAdjustSubId=" & Rectemp.Fields("InOutAdjustSubId"))
  1945.                 
  1946.                 '删除出库调整单主表内容
  1947.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustmain where InOutAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId"))
  1948.             ElseIf Rectemp.Fields("InOutAdjustMainId") <> 0 And Trim(Rectemp.Fields("billcode")) = "1303" Then
  1949.                 
  1950.                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute("select * from Chhs_PlanAdjustMain where planadjustmainid=" & Rectemp.Fields("InOutAdjustMainId"))
  1951.                 If Not RecTempFz.EOF Then
  1952.                     
  1953.                     '恢复收发记录表中未记帐存货的的计划单价
  1954.                     SqlStr = "SELECT Gy_InOutMain.InoutFlag,Gy_InOutMain.InOutMainId, Gy_InOutSub.InOutSubId," & _
  1955.                         "Gy_InOutSub.FactReceiptQuan,Gy_InOutSub.FactIssueQuan, Gy_InOutSub.PlanPrice, " & _
  1956.                         "Gy_InOutSub.PlanMoney,Gy_InOutMain.ChalkitupMan , Gy_InOutMain.KjYear,  " & _
  1957.                         "Gy_InOutMain.Period FROM Gy_InOutMain INNER JOIN Gy_InOutSub ON " & _
  1958.                         "Gy_InOutMain.InOutMainId = Gy_InOutSub.InOutMainId LEFT OUTER JOIN " & _
  1959.                         "Gy_Warehouse ON Gy_InOutMain.WhCode = Gy_Warehouse.WhCode " & _
  1960.                         "WHERE (Gy_Warehouse.PriceMode = '计划价法')  " & _
  1961.                         "AND Gy_InOutMain.BillCode<>'1211' AND kjYear=" & Xtyear & " and Period>=" & mPeriod & _
  1962.                         "AND Gy_InOutSub.MNumber = '" & Trim(Rectemp.Fields("mnumber")) & "'"
  1963.                     Set RecQuery = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1964.                     Do While Not RecQuery.EOF
  1965.                         If RecQuery.Fields("InoutFlag") Then
  1966.                             SqlStr = "Update Gy_InOutSub set PlanPrice=" & RecTempFz.Fields("AdjustBeforePrice") & ",PlanMoney=" & Val(RecQuery.Fields("FactReceiptQuan")) * RecTempFz.Fields("AdjustBeforePrice") & " where InOutMainId=" & RecQuery.Fields("InOutMainId") & " and InOutSubId=" & RecQuery.Fields("InOutSubId")
  1967.                         Else
  1968.                             SqlStr = "Update Gy_InOutSub set PlanPrice=" & RecTempFz.Fields("AdjustBeforePrice") & ",PlanMoney=" & Val(RecQuery.Fields("FactIssueQuan")) * RecTempFz.Fields("AdjustBeforePrice") & " where InOutMainId=" & RecQuery.Fields("InOutMainId") & " and InOutSubId=" & RecQuery.Fields("InOutSubId")
  1969.                         End If
  1970.                         Cw_DataEnvi.DataConnect.Execute (SqlStr)
  1971.                         RecQuery.MoveNext
  1972.                     Loop
  1973.                 End If
  1974.                 
  1975.                 '恢复存货档案中的计划单价
  1976.                 Cw_DataEnvi.DataConnect.Execute ("update Gy_Material set planprice=" & RecTempFz.Fields("AdjustBeforePrice") & " where Mnumber='" & Trim(Rectemp.Fields("Mnumber")) & "'")
  1977.                 
  1978.                 '删除计划价调整单子表内容
  1979.                 Cw_DataEnvi.DataConnect.Execute ("delete chhs_Planadjustsub where planAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId") & " and PlanAdjustSubId=" & Rectemp.Fields("InOutAdjustSubId"))
  1980.                 
  1981.                 '删除计划价调整单主表内容
  1982.                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute("select * from Chhs_PlanAdjustSub where planadjustmainid=" & Rectemp.Fields("InOutAdjustMainId"))
  1983.                 If RecTempFz.EOF Then
  1984.                     Cw_DataEnvi.DataConnect.Execute ("delete chhs_planadjustmain where planAdjustMainId=" & Rectemp.Fields("InOutAdjustMainId"))
  1985.                 End If
  1986.             Else
  1987.                 '修改单据的记帐人
  1988.                 Cw_DataEnvi.DataConnect.Execute ("update Gy_InoutMain set chalkitupman='' where inoutmainid='" & Trim(Rectemp.Fields("inoutmainid")) & "'")
  1989.                 
  1990.                 If Rectemp.Fields("outmoney") > 0 Then
  1991.                     '清除出库成本
  1992.                     Cw_DataEnvi.DataConnect.Execute ("update Gy_InoutSub set price=0, issuemoney=0 where inoutmainid='" & Trim(Rectemp.Fields("inoutmainid")) & "' and inoutsubid='" & Trim(Rectemp.Fields("inoutsubid")) & "'")
  1993.                 End If
  1994.                 
  1995.                 '清除辅助帐出库内容
  1996.                 Cw_DataEnvi.DataConnect.Execute ("update chhs_assiprice set outbillnum=null,outdate=null,inoutmainoutid=0,inoutsuboutid=0,outbillcode=null,outchalkdate=null,outquan=0,outprice=0,outmoney=0,flag=0 where inoutmainoutid=" & Rectemp.Fields("inoutmainid") & " and inoutsuboutid='" & Rectemp.Fields("inoutsubid") & "'")
  1997.             End If
  1998.         End If
  1999.         
  2000.         '删除明细帐内容
  2001.         Cw_DataEnvi.DataConnect.Execute ("delete chhs_list where listid=" & Rectemp.Fields("listid"))
  2002.         
  2003.         Rectemp.MoveNext
  2004.     Loop
  2005.     
  2006.     '删除调整单据的入库调整单
  2007.     SqlStr = "SELECT * FROM chhs_inoutadjustmain a " & Trim(Str_QueryCondi) & _
  2008.              " order by inoutadjustmainid  "
  2009.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  2010.     Do While Not Rectemp.EOF
  2011.         Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustsub where inoutadjustmainid=" & Rectemp.Fields("inoutadjustmainid"))
  2012.         Cw_DataEnvi.DataConnect.Execute ("delete chhs_inoutadjustmain where  inoutadjustmainid=" & Rectemp.Fields("inoutadjustmainid"))
  2013.         Rectemp.MoveNext
  2014.     Loop
  2015.     
  2016.     '调整辅助帐(合并拆分的入库单)
  2017.     SqlStr = "SELECT InoutMainInId, InoutSubInId, InBillCode, " & _
  2018.             " SUM(InQuan) AS SumInQuan, SUM(InMoney) AS SumInMoney " & _
  2019.             " From Chhs_AssiPrice a where " & Trim(CL_BillChalkitupCond.WhCode) & _
  2020.             " and flag=0 GROUP BY InoutMainInId, InoutSubInId, InBillCode"
  2021.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  2022.     Do While Not Rectemp.EOF
  2023.         If RecTempFz.State = 1 Then RecTempFz.Close
  2024.         RecTempFz.Open "select * from chhs_assiprice where inoutmaininid='" & Trim(Rectemp.Fields("inoutmaininid")) & "' and inoutsubinid='" & Trim(Rectemp.Fields("inoutsubinid")) & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  2025.         If Not Rectemp.Fields("SumInQuan") = RecTempFz.Fields("inquan") Then
  2026.             
  2027.             '合并入库单
  2028.             RecTempFz.MoveFirst
  2029.             AssiId = RecTempFz.Fields("assipriceid")
  2030.             RecTempFz.Fields("inquan") = Rectemp.Fields("SumInQuan")
  2031.             RecTempFz.Fields("inmoney") = Rectemp.Fields("SumInMoney")
  2032.             RecTempFz.UpdateBatch
  2033.             
  2034.             '删除拆分的入库单
  2035.             Cw_DataEnvi.DataConnect.Execute ("delete chhs_assiprice where inoutmaininid=" & Trim(Rectemp.Fields("inoutmaininid")) & " and inoutsubinid=" & Trim(Rectemp.Fields("inoutsubinid")) & " and assipriceid<> " & AssiId)
  2036.             
  2037.         End If
  2038.         Rectemp.MoveNext
  2039.     Loop
  2040.     
  2041.     '删除总帐中无期初数据的仓库
  2042.     Str_Query = Replace(Trim(CL_BillChalkitupCond.WhCode), "a.", "", 1, , vbTextCompare)
  2043.     SqlStr = "delete chhs_mate where " & Str_Query & " and   kjyear =" & Xtyear & " and period =" & mPeriod & " and startquan=0"
  2044.     Cw_DataEnvi.DataConnect.Execute (SqlStr)
  2045.     '重新调整总帐内容
  2046.     SqlStr = "SELECT WhCode, MNumber,SUM(InQuan) AS SumInQuan,SUM(InMoney) AS SumInMoney, " & _
  2047.             " SUM(JfDiff) AS SumJfDiff, SUM(DfDiff) AS SumDfDiff, SUM(OutQuan) AS SumOutQuan, " & _
  2048.             " SUM(OutMoney) AS SumOutMoney From Chhs_List a " & _
  2049.             " Where KjYear = " & Xtyear & " And Period = " & mPeriod & _
  2050.             " and a.startflag=0 and " & CL_BillChalkitupCond.WhCode & _
  2051.             " GROUP BY WhCode, MNumber ORDER BY WhCode, MNumber "            '单据汇总
  2052.     
  2053.     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  2054.     If Rectemp.EOF Then
  2055.         If RecTempZz.State = 1 Then RecTempZz.Close
  2056.         SqlStr = "select * from chhs_mate a where KjYear = " & Xtyear & " And Period = " & mPeriod & " and " & CL_BillChalkitupCond.WhCode
  2057.         RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  2058.         Do While Not RecTempZz.EOF
  2059.             If RecTempZz.Fields("startquan") <> 0 Then
  2060.                 RecTempZz.Fields("inquan") = 0
  2061.                 RecTempZz.Fields("inprice") = 0
  2062.                 RecTempZz.Fields("inmoney") = 0
  2063.                 RecTempZz.Fields("outquan") = 0
  2064.                 RecTempZz.Fields("outprice") = 0
  2065.                 RecTempZz.Fields("outmoney") = 0
  2066.                 RecTempZz.Fields("jfdiff") = 0
  2067.                 RecTempZz.Fields("dfdiff") = 0
  2068.             Else
  2069.                 RecTempZz.Delete
  2070.             End If
  2071.             RecTempZz.UpdateBatch
  2072.             RecTempZz.MoveNext
  2073.         Loop
  2074.     End If
  2075.     Do While Not Rectemp.EOF
  2076.                     
  2077.         '打开总帐
  2078.         If RecTempZz.State = 1 Then RecTempZz.Close
  2079.         SqlStr = "select * from chhs_mate where whcode='" & Trim(Rectemp.Fields("whcode")) & "' " & _
  2080.                 " and mnumber='" & Trim(Rectemp.Fields("mnumber")) & "' " & _
  2081.                 " and KjYear = " & Xtyear & " And Period = " & mPeriod
  2082.         RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  2083.         With RecTempZz
  2084.             If Not .EOF Then       '修改已存在的仓库+存货
  2085.                 .Fields("inquan") = Rectemp.Fields("suminquan")
  2086.                 .Fields("inmoney") = Rectemp.Fields("suminmoney")
  2087.                 If .Fields("inquan") <> 0 Then
  2088.                     .Fields("inprice") = .Fields("inmoney") / .Fields("inquan")
  2089.                 End If
  2090.                 .Fields("outquan") = Rectemp.Fields("sumoutquan")
  2091.                 .Fields("outmoney") = Rectemp.Fields("sumoutmoney")
  2092.                 If .Fields("outquan") <> 0 Then
  2093.                     .Fields("outprice") = .Fields("outmoney") / .Fields("outquan")
  2094.                 End If
  2095.                 .Fields("jfdiff") = Rectemp.Fields("sumjfdiff")
  2096.                 .Fields("dfdiff") = Rectemp.Fields("sumdfdiff")
  2097.             Else                    '新增仓库+存货
  2098.                 .AddNew
  2099.                 .Fields("whcode") = Trim(Rectemp.Fields("whcode"))
  2100.                 .Fields("mnumber") = Trim(Rectemp.Fields("mnumber"))
  2101.                 .Fields("kjyear") = Xtyear
  2102.                 .Fields("period") = mPeriod
  2103.                 .Fields("inquan") = Rectemp.Fields("suminquan")
  2104.                 .Fields("inmoney") = Rectemp.Fields("suminmoney")
  2105.                 If .Fields("inquan") <> 0 Then
  2106.                     .Fields("inprice") = .Fields("inmoney") / .Fields("inquan")
  2107.                 End If
  2108.                 .Fields("outquan") = Rectemp.Fields("sumoutquan")
  2109.                 .Fields("outmoney") = Rectemp.Fields("sumoutmoney")
  2110.                 If .Fields("outquan") <> 0 Then
  2111.                     .Fields("outprice") = .Fields("outmoney") / .Fields("outquan")
  2112.                 End If
  2113.                 .Fields("jfdiff") = Rectemp.Fields("sumjfdiff")
  2114.                 .Fields("dfdiff") = Rectemp.Fields("sumdfdiff")
  2115.             End If
  2116.             .UpdateBatch
  2117.         End With
  2118.         Rectemp.MoveNext
  2119.     Loop
  2120.    
  2121.     Cw_DataEnvi.DataConnect.CommitTrans
  2122.     
  2123.     Call Sub_QueryJz(1)
  2124.     
  2125.     Xt_Wait.Hide
  2126.     Tsxx = "恢复记帐成功!"
  2127.     Call Xtxxts(Tsxx, 0, 4)
  2128.     Exit Sub
  2129.     
  2130. Cwcl:
  2131.     Xt_Wait.Hide
  2132.     Cw_DataEnvi.DataConnect.RollbackTrans
  2133.     Tsxx = "恢复记帐失败!"
  2134.     Call Xtxxts(Tsxx, 0, 1)
  2135.     Exit Sub
  2136. End Sub
  2137. Private Function mOutPrice(WhCode As String, Mnumber As String, Mname As String, OutQuan As Double) As Double            '零成本出库方式
  2138.                             '仓库              '存货编码        '存货名称           '出库数量
  2139. Dim Rectemp As Recordset
  2140.     
  2141.     OutPrice = 0
  2142.     Select Case LcbckFs
  2143.         Case 1          '上次入库成本
  2144.             Set Rectemp = Cw_DataEnvi.DataConnect.Execute("select * from chhs_list where whcode='" & WhCode & "' and mnumber='" & Mnumber & "' and inoutflag=0 and kjyear=" & Xtyear & " and period=" & mPeriod & " order by listid desc")
  2145.             If Not Rectemp.EOF Then
  2146.                 mOutPrice = Rectemp.Fields("inprice")
  2147.             End If
  2148.         Case 2          '上次出库成本
  2149.             Set Rectemp = Cw_DataEnvi.DataConnect.Execute("select * from chhs_list where whcode='" & WhCode & "' and mnumber='" & Mnumber & "' and inoutflag=0 and kjyear=" & Xtyear & " and  period=" & mPeriod & " order by listid desc")
  2150.             If Not Rectemp.EOF Then
  2151.                 mOutPrice = Rectemp.Fields("outprice")
  2152.             End If
  2153.         Case 3          '参考成本
  2154.             Set Rectemp = Cw_DataEnvi.DataConnect.Execute("select consultcost from gy_material where mnumber='" & Mnumber & "' ")
  2155.             If Not Rectemp.EOF Then
  2156.                 mOutPrice = Rectemp.Fields("consultcost")
  2157.             End If
  2158.         Case 4          '结存成本
  2159.             Set Rectemp = Cw_DataEnvi.DataConnect.Execute("select StartQuan + InQuan - OutQuan AS Quan,  StartMoney + InMoney - OutMoney AS Money from chhs_mate where whcode='" & WhCode & "' and mnumber='" & Mnumber & "' and kjyear=" & Xtyear & " and period=" & mPeriod)
  2160.             If Not Rectemp.EOF Then
  2161.                 If Rectemp.Fields("quan") <> 0 Then
  2162.                     mOutPrice = Rectemp.Fields("money") / Rectemp.Fields("quan")
  2163.                 End If
  2164.             End If
  2165.         Case 5          '手工输入
  2166.             Xtcdcs = OutQuan
  2167.             Xtcdcsfz = Mnumber
  2168.             CL_BillChalkPrice.Show 1
  2169.             
  2170.             mOutPrice = CDbl(Xtcdcs)
  2171.             
  2172.     End Select
  2173.     
  2174. End Function
  2175. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  2176.     
  2177.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  2178.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  2179.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  2180.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  2181.     ReDim Bbxbt(1 To Bbxbtgs)
  2182.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  2183.     If Bbbwhgs <> 0 Then
  2184.         ReDim Bbbwh(1 To Bbbwhgs)
  2185.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  2186.     End If
  2187.     Bbzbt = ReportTitle
  2188.     Bbxbt(1) = Fun_FormatOutPut("月份:" + Lbl_TitleText(0), 30)
  2189.     bbxbtzzxs(1) = 0                                     '报表行组织形式(0-居左 1-居中 2-居右)
  2190.     Call Scyxsjb(CxbbGrid)                               '生成报表数据
  2191.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  2192.     If Not bbylte Then
  2193.         Unload DY_Tybbyldy
  2194.     End If
  2195. End Sub