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

企业管理

开发平台:

Visual Basic

  1.         For Coljsq = Qslz To WglrGrid.Cols - 1
  2.             Call Sjhj(Coljsq)
  3.         Next Coljsq
  4.         
  5.         '重新显示辅助核算信息
  6.         Call Sub_ShowMemo(WglrGrid.Row)
  7.         
  8.     End If
  9. End Sub
  10. Private Sub Kmfzhsx(Lng_GridRow As Long)                  '调用科目辅助核算项
  11.     '过程函数;Lng_gridrow当前网格调入辅助核算行
  12.     Dim Kjqstop#, Kjqsleft#, Kjjg#, Ctzxgd#, Kjxsgs%, jsqte%
  13.     Dim rectemp As New ADODB.Recordset     '临时使用动态集
  14.     Kjqstop = 300          '控件显示起始高度
  15.     Kjqsleft = 300         '控件显示起始左边界
  16.     Kjjg = 450             '控件显示间隔
  17.     Kjxsgs = 0             '控件显示个数
  18.     Ctzxgd = 1500          '窗体显示最小高度
  19.     With AutoTran_PzAss          '辅助核算项目窗体
  20.         .Caption = "辅助核算项目_" + Trim(WglrGrid.TextMatrix(Lng_GridRow, Sydz("003", GridStr(), Szzls)))
  21.         For jsqte = 0 To Int_AssCount - 1
  22.             If Bln_AssShow(jsqte) Then
  23.                 .TsLabel(jsqte).Visible = True
  24.                 .TsLabel(jsqte).Move Kjqsleft, Kjqstop + Kjxsgs * Kjjg
  25.                 .LrText(jsqte).Visible = True
  26.                 .LrText(jsqte).Move .TsLabel(jsqte).Left + .TsLabel(jsqte).Width + 50, .TsLabel(jsqte).Top - 100
  27.                 If Bln_AssHelp(jsqte) Then
  28.                     .Ydcommand1(jsqte).Visible = True
  29.                     .Ydcommand1(jsqte).Move .LrText(jsqte).Left + .LrText(jsqte).Width, .LrText(jsqte).Top, .Ydcommand1(jsqte).Width, .LrText(jsqte).Height
  30.                 End If
  31.                 Kjxsgs = Kjxsgs + 1
  32.                 Select Case jsqte
  33.                 Case 0     '结算方式
  34.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 1))
  35.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 2))
  36.                 Case 1     '票号
  37.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 3))
  38.                 Case 2     '发生日期
  39.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 4))
  40.                 Case 3     '数量
  41.                     .LrText(jsqte).Text = WglrGrid.TextMatrix(Lng_GridRow, 5)
  42.                     .Lab_Measure = Trim(WglrGrid.TextMatrix(Lng_GridRow, 7))
  43.                     .Lab_Measure.Move .LrText(jsqte).Left + .LrText(jsqte).Width + 50, .LrText(jsqte).Top + 100
  44.                 Case 4     '单价
  45.                     If Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) <> 0 And Val(WglrGrid.TextMatrix(Lng_GridRow, 5)) <> 0 Then
  46.                         .LrText(jsqte).Text = Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) / Val(WglrGrid.TextMatrix(Lng_GridRow, 5))
  47.                     Else
  48.                         If Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) <> 0 And Val(WglrGrid.TextMatrix(Lng_GridRow, 5)) <> 0 Then
  49.                             .LrText(jsqte).Text = Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) / Val(WglrGrid.TextMatrix(Lng_GridRow, 5))
  50.                         End If
  51.                     End If
  52.                 Case 5     '外币金额
  53.                     .LrText(jsqte).Text = WglrGrid.TextMatrix(Lng_GridRow, 10)
  54.                     .Lab_ForeignName.Caption = "(" + Trim(WglrGrid.TextMatrix(Lng_GridRow, 9)) + ")"
  55.                     .Lab_ForeignName.Move .LrText(jsqte).Left + .LrText(jsqte).Width + 50, .LrText(jsqte).Top + 100
  56.                 Case 6     '汇率
  57.                     .LrText(jsqte).Text = WglrGrid.TextMatrix(Lng_GridRow, 11)
  58.                 Case 7     '部门
  59.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 12))
  60.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 13))
  61.                 Case 8     '客户
  62.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 14))
  63.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 15))
  64.                 Case 9     '个人
  65.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 16))
  66.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 17))
  67.                 Case 10     '项目
  68.                     .Lab_ItemClass.Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 18))
  69.                     .Lab_ItemClass.Caption = "(" + Trim(WglrGrid.TextMatrix(Lng_GridRow, 19)) + ")"
  70.                     .Lab_ItemClass.Move .LrText(jsqte).Left + .LrText(jsqte).Width + 400, .LrText(jsqte).Top + 100
  71.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 20))
  72.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 21))
  73.                     SqlStr = "select * from Cwzz_item where ItemClassCode='" & .Lab_ItemClass.Tag & "' and ItemCode='" & Trim(.LrText(10).Tag) & "'"
  74.                     Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  75.                     If Not rectemp.EOF Then
  76.                         If rectemp.Fields("QuantityFlag") Then
  77.                             .LrText(11).Text = WglrGrid.TextMatrix(Lng_GridRow, 22)
  78.                             .Lab_ItemMeasure = Trim(rectemp.Fields("Measure"))
  79.                         End If
  80.                     End If
  81.                 Case 11
  82.                     .Lab_ItemMeasure.Move .LrText(11).Left + .LrText(11).Width + 50, .LrText(11).Top + 50
  83.                 Case 12      '供应商
  84.                     .LrText(jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 25))
  85.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 26))
  86.                 Case 13      '经办人
  87.                     .LrText(jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 24))
  88.                 End Select
  89.             Else
  90.                 .TsLabel(jsqte).Visible = False
  91.                 .LrText(jsqte).Visible = False
  92.                 If Bln_AssHelp(jsqte) Then
  93.                     .Ydcommand1(jsqte).Visible = False
  94.                 End If
  95.             End If
  96.         Next jsqte
  97.         If Kjqstop * 3 + Kjxsgs * Kjjg > Ctzxgd Then
  98.             .Height = Kjqstop * 3 + Kjxsgs * Kjjg
  99.         Else
  100.             .Height = Ctzxgd
  101.         End If
  102.         
  103.         '加锁
  104.         changelock = True
  105.         .Show 1
  106.         changelock = False
  107.     End With
  108. End Sub
  109. Private Sub Sub_ShowMemo(Lng_GridRow)                                    '显示网格备注项
  110.     '函数参数:网格行
  111.     
  112.     Dim Str_Memo As String
  113.     Str_Memo = ""
  114.     With WglrGrid
  115.         If Len(Trim(.TextMatrix(Lng_GridRow, 2))) <> 0 Then
  116.             Str_Memo = Str_Memo + "结算方式:" + Trim(.TextMatrix(Lng_GridRow, 2)) + Space(2)
  117.         End If
  118.         If Len(Trim(.TextMatrix(Lng_GridRow, 3))) <> 0 Then
  119.             Str_Memo = Str_Memo + "票号:" + Trim(.TextMatrix(Lng_GridRow, 3)) + Space(2)
  120.         End If
  121.         If Len(Trim(.TextMatrix(Lng_GridRow, 4))) <> 0 Then
  122.             Str_Memo = Str_Memo + "发生日期:" + Trim(.TextMatrix(Lng_GridRow, 4)) + Space(2)
  123.         End If
  124.         If Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
  125.             Str_Memo = Str_Memo + "数量:" + Format(Trim(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtslxsws, "0")) + Trim(.TextMatrix(Lng_GridRow, 7)) + Space(2)
  126.         End If
  127.         
  128.         '显示单价
  129.         If Val(.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) <> 0 And Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
  130.             Str_Memo = Str_Memo + "单价:" + Format(Val(.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) / Val(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtdjxsws, "0"))
  131.         Else
  132.             If Val(.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) <> 0 And Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
  133.                 Str_Memo = Str_Memo + "单价:" + Format(Val(.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) / Val(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtdjxsws, "0"))
  134.             End If
  135.         End If
  136.         
  137.         If Val(.TextMatrix(Lng_GridRow, 10)) <> 0 Then
  138.             Str_Memo = Str_Memo + "外币:" + Format(Trim(.TextMatrix(Lng_GridRow, 10)), "#,##0." + String(Xtjexsws, "0")) + Trim(WglrGrid.TextMatrix(Lng_GridRow, 9)) + Space(2)
  139.         End If
  140.         If Val(.TextMatrix(Lng_GridRow, 11)) <> 0 Then
  141.             Str_Memo = Str_Memo + "汇率:" + Trim(.TextMatrix(Lng_GridRow, 11)) + Space(2)
  142.         End If
  143.         If Len(Trim(.TextMatrix(Lng_GridRow, 13))) <> 0 Then
  144.             Str_Memo = Str_Memo + "部门:" + Trim(.TextMatrix(Lng_GridRow, 13)) + Space(2)
  145.         End If
  146.         If Len(Trim(.TextMatrix(Lng_GridRow, 15))) <> 0 Then
  147.             Str_Memo = Str_Memo + "客户:" + Trim(.TextMatrix(Lng_GridRow, 15)) + Space(2)
  148.         End If
  149.         If Len(Trim(.TextMatrix(Lng_GridRow, 26))) <> 0 Then
  150.             Str_Memo = Str_Memo + "供应商:" + Trim(.TextMatrix(Lng_GridRow, 26)) + Space(2)
  151.         End If
  152.         If Len(Trim(.TextMatrix(Lng_GridRow, 17))) <> 0 Then
  153.             Str_Memo = Str_Memo + "个人:" + Trim(.TextMatrix(Lng_GridRow, 17)) + Space(2)
  154.         End If
  155.         If Len(Trim(.TextMatrix(Lng_GridRow, 21))) <> 0 Then
  156.             Str_Memo = Str_Memo + "项目类别:" + Trim(.TextMatrix(Lng_GridRow, 19)) + Space(2) + "核算项目:" + Trim(.TextMatrix(Lng_GridRow, 21)) + Space(2)
  157.         End If
  158.         If Val(.TextMatrix(Lng_GridRow, 22)) <> 0 Then
  159.             Str_Memo = Str_Memo + "项目数量:" + Trim(.TextMatrix(Lng_GridRow, 22)) + Trim(.TextMatrix(Lng_GridRow, 23)) + Space(2)
  160.         End If
  161.         If Len(Trim(.TextMatrix(Lng_GridRow, 24))) <> 0 Then
  162.             Str_Memo = Str_Memo + "经办人:" + Trim(.TextMatrix(Lng_GridRow, 24))
  163.         End If
  164.         Lab_Memo(0).Caption = Str_Memo
  165.         Lab_Memo(0).Refresh
  166.     End With
  167. End Sub
  168. Private Sub Sub_AbandonBill()                                              '放弃对当前单据的操作
  169.     '先关闭录入载体
  170.     changelock = True
  171.     Valilock = True
  172.     Call Ycwbk
  173.     changelock = False
  174.     Valilock = False
  175.     
  176.     Select Case Trim(Lab_OperStatus.Caption)
  177.         
  178.         
  179.     Case "2"         '修改状态
  180.         
  181.         '重新显示当前单据
  182.         
  183.         Call Sub_ShowBill
  184.         
  185.         '设置操作状态重新置为新增状态
  186.         Lab_OperStatus = "2"
  187.         Call Sub_OperStatus("30")
  188.         
  189.     End Select
  190. End Sub
  191. Private Sub Combo_Kjqj_Click()                                           '会计期间发生变化则自动计算单据编号
  192.     Call Sub_JsVouchNo
  193. End Sub
  194. Private Sub Sub_JsVouchNo()                                              '自动计算新增单据编号
  195.     Dim rectemp As New ADODB.Recordset     '临时使用动态集
  196.     
  197.     '单据为新增时才有效
  198.     If Lab_OperStatus <> "2" Then
  199.         Exit Sub
  200.     End If
  201.     
  202.     SqlStr = "Select MAX(VouchNo) AS MVouchNo FROM  Cwzz_AccVouchMain Where Year='" & Int_Year & "'  AND Period='" & Int_Period & "'" & _
  203.     " AND VouchClassCode='" & Trim(LrText(0).Text) & "'"
  204.     Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  205.     TextChangeLock = True
  206.     If Not IsNull(rectemp.Fields("MVouchNo")) Then
  207.         LrText(3).Text = Mid(Trim(Str(10000 + rectemp.Fields("MVouchNo") + 1)), 2, 4)
  208.     Else
  209.         LrText(3).Text = "0001"
  210.     End If
  211.     TextChangeLock = False
  212. End Sub
  213. Private Function Sub_SaveBill() As Boolean                   '保 存 单 据
  214.     Dim Recfind As New ADODB.Recordset           '有效性判断动态集
  215.     Dim Rec_AccVouchMain As New ADODB.Recordset  '凭证主表动态集
  216.     Dim Rec_AccVouch As New ADODB.Recordset      '凭证子表动态集
  217.     Dim Rec_Ass As New ADODB.Recordset          '辅助项目记录集
  218.     
  219.     Dim jsqte As Integer                         '临时计数器
  220.     Dim Rowjsq As Long           '网格行计数器
  221.     Dim Coljsq As Long           '网格列计数器
  222.     Dim Int_RowCount As Integer  '有效数据行计数器
  223.     Dim Bln_AssVali As Boolean   '辅助核算错误标识
  224.     Dim Lrywlz As Long           '录入有误列值
  225.     Dim Dbl_Jfhj As Double       '借方合计
  226.     Dim Dbl_Dfhj As Double       '贷方合计
  227.     Dim int_sUreVouchId As Integer
  228.     
  229.     int_sUreVouchId = 0
  230.     For jsqte = 0 To Max_Text_Index
  231.         If Textint(jsqte, 8) = 1 Then     '字段不能为空
  232.             If Len(Trim(LrText(jsqte).Text)) = 0 Then
  233.                 Tsxx = Textstr(jsqte, 7) & "不能为空!"
  234.                 Call Xtxxts(Tsxx, 0, 1)
  235.                 If LrText(jsqte).Enabled = True Then LrText(jsqte).SetFocus
  236.                 Sub_SaveBill = False
  237.                 Exit Function
  238.             End If
  239.         Else
  240.             If Textint(jsqte, 8) = 2 Then   '字段不能为零
  241.                 If Val(Trim(LrText(jsqte).Text)) = 0 Then
  242.                     Tsxx = Textstr(jsqte, 7) & "不能为零!"
  243.                     Call Xtxxts(Tsxx, 0, 1)
  244.                     If LrText(jsqte).Enabled = True Then LrText(jsqte).SetFocus
  245.                     Sub_SaveBill = False
  246.                     Exit Function
  247.                 End If
  248.             End If
  249.         End If
  250.     Next jsqte
  251.     
  252.     
  253.     
  254.     '对需要进行事后判断的文本框录入内容进行有效性判断 (固定不变)
  255.     For jsqte = 0 To Max_Text_Index
  256.         If Textint(jsqte, 9) = 0 Or Textint(jsqte, 9) = 2 Then
  257.             If Not TextYxxpd(jsqte) Then
  258.                 Exit Function
  259.             End If
  260.         End If
  261.     Next jsqte
  262.     
  263.     '[判断用户所选会计期间是否有效(非结帐月份),且制单日期必须和所选会计期间一致
  264.     SqlStr = "Select * FROM  gy_Kjrlb Where KjYear=" & Mid(Combo_Kjqj.Text, 1, 4) & " AND period=" & Mid(Combo_Kjqj.Text, 6, 2)
  265.     Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  266.     With rectemp
  267.         If Not .EOF Then
  268.             If .Fields("Cwzzjzbz") Then
  269.                 Tsxx = "所选会计期间已经结帐,不能再填制凭证!"
  270.                 Call Xtxxts(Tsxx, 0, 1)
  271.                 Combo_Kjqj.SetFocus
  272.                 Exit Function
  273.             End If
  274.             If Not (Format(CDate(LrText(1).Text), "yyyy-mm-dd") >= Format(.Fields("Qsrq"), "yyyy-mm-dd") And Format(CDate(LrText(1).Text), "yyyy-mm-dd") <= Format(.Fields("Zzrq"), "yyyy-mm-dd")) Then
  275.                 Tsxx = "制单日期应在所选会计期间范围内!"
  276.                 Call Xtxxts(Tsxx, 0, 1)
  277.                 LrText(1).SetFocus
  278.                 Exit Function
  279.             End If
  280.         End If
  281.     End With
  282.     
  283.     '下面将对所有有效数据行进行有效性判断
  284.     Int_RowCount = 0
  285.     Dbl_Jfhj = 0
  286.     Dbl_Dfhj = 0
  287.     With WglrGrid
  288.         For Rowjsq = .FixedRows To .Rows
  289.             '带*号者为有效数据行
  290.             If .TextMatrix(Rowjsq, 0) <> "*" Then
  291.                 Exit For
  292.             Else
  293.                 Int_RowCount = Int_RowCount + 1
  294.             End If
  295.             
  296.             '1.首先进行为空或为零判断(固定不变)
  297.             For Coljsq = Qslz To .Cols - 1
  298.                 If (GridInt(Coljsq, 5) = 1 And Len(Trim(.TextMatrix(Rowjsq, Coljsq))) = 0) Or (GridInt(Coljsq, 5) = 2 And Val(Trim(.TextMatrix(Rowjsq, Coljsq))) = 0) Then
  299.                     Tsxx = GridStr(Coljsq, 2)
  300.                     Lrywlz = Coljsq
  301.                     GoTo Lrcwcl
  302.                     Exit For
  303.                 End If
  304.             Next Coljsq
  305.             
  306.             '2.[自定义判断(补丁)
  307.             If Val(Trim(.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))) = 0 And Val(Trim(.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))) = 0 Then
  308.                 Tsxx = "借方和贷方金额不能同时为零!"
  309.                 Lrywlz = Sydz("004", GridStr(), Szzls)
  310.                 GoTo Lrcwcl
  311.             End If
  312.             
  313.             If Val(Trim(.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))) <> 0 And Val(Trim(.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))) <> 0 Then
  314.                 Tsxx = "借方和贷方金额不能同时不为零!"
  315.                 Lrywlz = Sydz("004", GridStr(), Szzls)
  316.                 GoTo Lrcwcl
  317.             End If
  318.             
  319.             '判断转帐类别是否已停用
  320.             SqlStr = "Select * FROM Cwzz_VouchClass where VouchClassCode='" & Trim(LrText(0).Text) & "'"
  321.             Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  322.             If rectemp.EOF = True Then
  323.                 Tsxx = "该凭证的凭证类别不存在,不能保存!"
  324.                 Call Xtxxts(Tsxx, 0, 1)
  325.                 Exit Function
  326.             End If
  327.             '判断辅助核算项目是否填写并是否有效
  328.             
  329.             SqlStr = "Select * FROM Cwzz_AccCode Where Ccode='" & Trim(.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls))) & "'"
  330.             
  331.             Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  332.             With rectemp
  333.                 If .EOF Then
  334.                     Tsxx = "此科目不存在!"
  335.                     GoTo Lrcwcl
  336.                 End If
  337.                 If Not .Fields("EndFlag") Then
  338.                     Tsxx = "此科目非末级科目!"
  339.                     GoTo Lrcwcl
  340.                 End If
  341.                 If .Fields("StopFlag") Then
  342.                     Tsxx = "此科目已停用!"
  343.                     GoTo Lrcwcl
  344.                 End If
  345.                 
  346.                 '对于银行科目,如结算方式不为空则结算方式必须有效
  347.                 
  348.                 If Trim(rectemp.Fields("Cproperty")) = "银行" And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
  349.                     Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select SSCode FROM Gy_Settlement Where SSCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 1)) & "'")
  350.                     If Recfind.EOF Then
  351.                         Tsxx = "此结算方式不存在!"
  352.                         Lrywlz = Sydz("002", GridStr(), Szzls)
  353.                         Bln_AssVali = True
  354.                         GoTo Lrcwcl
  355.                     End If
  356.                 End If
  357.                 
  358.                 '如有数量核算且用户选择数量不能为零则数量项不能为零
  359.                 
  360.                 If rectemp.Fields("QuantityFlag") And Chk_Quantity.Value = 1 And Val(WglrGrid.TextMatrix(Rowjsq, 5)) = 0 Then
  361.                     Tsxx = "此科目需要数量核算,数量项不能为零!"
  362.                     Lrywlz = Sydz("002", GridStr(), Szzls)
  363.                     Bln_AssVali = True
  364.                     GoTo Lrcwcl
  365.                 End If
  366.                 
  367.                 
  368.                 '部门核算则部门不能为空且有效
  369.                 If rectemp.Fields("DeptFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) = 0 Then
  370.                     Tsxx = "此科目需要部门核算,部门项不能为空!"
  371.                     Lrywlz = Sydz("002", GridStr(), Szzls)
  372.                     Bln_AssVali = True
  373.                     GoTo Lrcwcl
  374.                 Else
  375.                     If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
  376.                         Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select DeptCode FROM Gy_Department Where DeptCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 12)) & "'")
  377.                         If Recfind.EOF Then
  378.                             Tsxx = "此部门不存在!"
  379.                             Lrywlz = Sydz("002", GridStr(), Szzls)
  380.                             Bln_AssVali = True
  381.                             GoTo Lrcwcl
  382.                         End If
  383.                     End If
  384.                 End If
  385.                 
  386.                 '往来单位核算则往来单位不能为空
  387.                 If rectemp.Fields("CusFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) = 0 Then
  388.                     Tsxx = "此科目需要往来单位核算,往来单位项不能为空"
  389.                     Lrywlz = Sydz("002", GridStr(), Szzls)
  390.                     Bln_AssVali = True
  391.                     GoTo Lrcwcl
  392.                 Else
  393.                     If rectemp.Fields("CusFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
  394.                         Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select CusCode,StopFlag FROM Gy_Customer Where CusCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 14)) & "'")
  395.                         If Recfind.EOF Then
  396.                             Tsxx = "此往来单位不存在!"
  397.                             Lrywlz = Sydz("002", GridStr(), Szzls)
  398.                             Bln_AssVali = True
  399.                             GoTo Lrcwcl
  400.                         Else
  401.                             If Recfind.Fields("StopFlag") = True Then
  402.                                 Tsxx = "此往来单位已停用!"
  403.                                 Lrywlz = Sydz("002", GridStr(), Szzls)
  404.                                 Bln_AssVali = True
  405.                                 GoTo Lrcwcl
  406.                             End If
  407.                         End If
  408.                     End If
  409.                 End If
  410.                 
  411.                 '个人往来核算则个人项不能为空
  412.                 If rectemp.Fields("PersonFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) = 0 Then
  413.                     Tsxx = "此科目需要个人往来核算,个人项不能为空!"
  414.                     Lrywlz = Sydz("002", GridStr(), Szzls)
  415.                     Bln_AssVali = True
  416.                     GoTo Lrcwcl
  417.                 Else
  418.                     If rectemp.Fields("PersonFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
  419.                         Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select PersonCode FROM Gy_Person Where PersonCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 16)) & "'")
  420.                         If Recfind.EOF Then
  421.                             Tsxx = "此个人不存在!"
  422.                             Lrywlz = Sydz("002", GridStr(), Szzls)
  423.                             Bln_AssVali = True
  424.                             GoTo Lrcwcl
  425.                         End If
  426.                     End If
  427.                 End If
  428.                 
  429.                 '项目核算则项目不能为空
  430.                 If rectemp.Fields("ItemFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) = 0 Then
  431.                     Tsxx = "此科目需要项目核算,核算项目不能为空!"
  432.                     Lrywlz = Sydz("002", GridStr(), Szzls)
  433.                     Bln_AssVali = True
  434.                     GoTo Lrcwcl
  435.                 Else
  436.                     If rectemp.Fields("ItemFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
  437.                         Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select ItemCode,QuantityFlag,EndFlag FROM Cwzz_Item Where ItemClassCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 18)) & "' And ItemCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 20)) & "'")
  438.                         If Recfind.EOF Then
  439.                             Tsxx = "此核算项目不存在!"
  440.                             Lrywlz = Sydz("002", GridStr(), Szzls)
  441.                             Bln_AssVali = True
  442.                             GoTo Lrcwcl
  443.                         Else
  444.                             If Recfind.Fields("QuantityFlag") And Val(WglrGrid.TextMatrix(Rowjsq, 22)) = 0 Then
  445.                                 Tsxx = "此项目需数量核算,则项目数量不能为零!"
  446.                                 Lrywlz = Sydz("002", GridStr(), Szzls)
  447.                                 Bln_AssVali = True
  448.                                 GoTo Lrcwcl
  449.                             End If
  450.                             If Recfind.Fields("EndFlag") = True Then
  451.                                 Tsxx = "此非末级项目!"
  452.                                 Lrywlz = Sydz("002", GridStr(), Szzls)
  453.                                 Bln_AssVali = True
  454.                                 GoTo Lrcwcl
  455.                             End If
  456.                         End If
  457.                     End If
  458.                 End If
  459.             End With
  460.             '计算借贷方合计数据
  461.             
  462.             Dbl_Jfhj = Dbl_Jfhj + Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))
  463.             
  464.             Dbl_Dfhj = Dbl_Dfhj + Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))
  465.             
  466.         Next Rowjsq
  467.         
  468.         '会计分录行数不能为零
  469.         
  470.         If Int_RowCount = 0 Then
  471.             Tsxx = "凭证会计分录行数为零,不能存盘!"
  472.             Call Xtxxts(Tsxx, 0, 1)
  473.             Exit Function
  474.         End If
  475.         
  476.         '凭证借贷双方合计必须平衡
  477.         
  478.         If Abs(Dbl_Jfhj - Dbl_Dfhj) >= 0.01 Then
  479.             Tsxx = "凭证借贷不平衡!"
  480.             Call Xtxxts(Tsxx, 0, 1)
  481.             Exit Function
  482.         End If
  483.     End With  '网格
  484.     
  485.     Int_VouchNo = Val(LrText(3).Text)  '凭证号
  486.     
  487.     '如果以上有效性检查均顺利通过,则执行存盘动作
  488.     
  489.     On Error GoTo Swcwcl
  490.     Cw_DataEnvi.DataConnect.BeginTrans
  491.     
  492.     
  493.     '写正式凭证
  494.     '1.判断凭证号是否重复,如重复则取最大值+1为当前凭证号,否则以当前凭证号存盘
  495.     SqlStr = "Select VouchNo From Cwzz_AccVouchMain Where Year=" & Int_Year & " and Period=" & Int_Period & " And VouchClassCode='" & Trim(LrText(0).Text) & "' And VouchNo=" & Val(LrText(3).Text)
  496.     Set Rec_AccVouch = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  497.     If Not Rec_AccVouch.EOF Then
  498.         
  499.         If rectemp.State = 1 Then rectemp.Close
  500.         SqlStr = "Select MAX(VouchNo) AS MVouchNo FROM  Cwzz_AccVouchMain Where Year=" & Mid(Combo_Kjqj.Text, 1, 4) & " AND Period=" & Mid(Combo_Kjqj.Text, 6, 2) & _
  501.         " AND VouchClassCode='" & Trim(LrText(0).Text) & "'"
  502.         Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  503.         TextChangeLock = True
  504.         If Not IsNull(rectemp.Fields("MVouchNo")) Then
  505.             LrText(3).Text = Mid(Trim(Str(10000 + rectemp.Fields("MVouchNo") + 1)), 2, 4)
  506.         Else
  507.             LrText(3).Text = "0001"
  508.         End If
  509.         TextChangeLock = False
  510.     Else
  511.         TextChangeLock = True
  512.         LrText(3).Text = "0001"
  513.         TextChangeLock = False
  514.     End If
  515.     
  516.     '打开凭证主表动态集
  517.     If Rec_AccVouchMain.State = 1 Then Rec_AccVouchMain.Close
  518.     Rec_AccVouchMain.Open "Select * From Cwzz_AccVouchMain Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  519.     With Rec_AccVouchMain
  520.         .AddNew
  521.         .Fields("VouchID") = CreatBillID("0101")
  522.         .Fields("Year") = Int_Year                                                                   '会计年度
  523.         .Fields("Period") = Int_Period                                                               '会计期间
  524.         .Fields("Ddate") = CDate(LrText(1).Text)                                                     '制单日期
  525.         .Fields("VouchClassCode") = Trim(LrText(0).Text)                                             '凭证类别
  526.         .Fields("VouchNo") = Val(Trim(LrText(3).Text))                                                            '凭证号
  527.         .Fields("Doc") = Val(LrText(2).Text)                                                         '附单据数
  528.         .Fields("Bill") = Trim(Lab_Bill.Caption)                                                     '制单人
  529.         .Fields("CheckFlag") = 0                                                                     '审核标志置"0"
  530.         .Fields("BookFlag") = 0        '记帐标志置"0"
  531.         .Fields("VouchSource") = Pub_VouchSource
  532.         .Update
  533.         int_sUreVouchId = .Fields("VouchID")
  534.         
  535.     End With
  536.     
  537.     '打开凭证子表动态集
  538.     If Rec_AccVouch.State = 1 Then Rec_AccVouch.Close
  539.     Rec_AccVouch.Open "Select * From Cwzz_AccVouchSub Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  540.     For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows
  541.         If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
  542.             Exit For
  543.         End If
  544.         With Rec_AccVouch
  545.             .AddNew
  546.             .Fields("SerialID") = Rowjsq
  547.             .Fields("VouchID") = Rec_AccVouchMain.Fields("VouchId")                                      '凭证ID
  548.             .Fields("Digest") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)))         '摘要
  549.             .Fields("Ccode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)))          '会计科目
  550.             .Fields("Jfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))            '借方金额
  551.             .Fields("Dfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))            '贷方金额
  552.             If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  553.                 .Fields("Jfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '借方数量
  554.             Else
  555.                 .Fields("Dfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '贷方数量
  556.             End If
  557.             '如为外币核算则原币编码为外币编码否则填充本位币编码,同时填充原币金额
  558.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 8))) <> 0 And Trim(WglrGrid.TextMatrix(Rowjsq, 8)) <> XtSCurrCode Then
  559.                 .Fields("ForeignCurrCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 8))                         '外币编码
  560.                 .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, 11))                                 '记帐汇率
  561.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  562.                     .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '本币借方金额
  563.                 Else
  564.                     .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '本币贷方金额
  565.                 End If
  566.             Else
  567.                 .Fields("ForeignCurrCode") = XtSCurrCode                                                  '原币编码
  568.                 .Fields("AccRate") = 1                                                                    '记帐汇率
  569.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  570.                     .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))    '原币借方金额
  571.                 Else
  572.                     .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))    '原币贷方金额
  573.                 End If
  574.             End If
  575.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 4))) <> 0 Then
  576.                 .Fields("BillDate") = CDate(Trim(WglrGrid.TextMatrix(Rowjsq, 4)))                         '发生日期(银行)
  577.             End If
  578.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
  579.                 .Fields("SScode") = Trim(WglrGrid.TextMatrix(Rowjsq, 1))                                  '结算方式(银行)
  580.             End If
  581.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 3))) <> 0 Then
  582.                 .Fields("BillNo") = Trim(WglrGrid.TextMatrix(Rowjsq, 3))                                  '票号(银行)
  583.             End If
  584.             .Fields("BCheckFlag") = 0                                                                    '银行核对标志置0
  585.             .Fields("BDelete") = 0                                                                       '银行帐核销标志置0
  586.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
  587.                 .Fields("PersonCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 16))                             '职员编码
  588.             End If
  589.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
  590.                 .Fields("DeptCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 12))                               '部门编码
  591.             End If
  592.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
  593.                 .Fields("CusCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 14))                                '往来客户编码
  594.             End If
  595.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 25))) <> 0 Then
  596.                 .Fields("Suppliercode") = Trim(WglrGrid.TextMatrix(Rowjsq, 25))                          '往来供应商编码
  597.             End If
  598.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 18))) <> 0 Then
  599.                 .Fields("ItemClassCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 18))                          '项目大类编码
  600.             End If
  601.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
  602.                 .Fields("ItemCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 20))                               '项目编码
  603.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  604.                     .Fields("ItemJfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                            '项目借方数量
  605.                 Else
  606.                     .Fields("ItemDfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                            '项目贷方数量
  607.                 End If
  608.             End If
  609.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 24))) <> 0 Then
  610.                 .Fields("TranPerson") = Trim(WglrGrid.TextMatrix(Rowjsq, 24))                             '经办人
  611.             End If
  612.             .Update
  613.         End With
  614.     Next Rowjsq
  615.     
  616.     '写临时凭证开始 '与 Save_VouchTemp 基本相同
  617.     '[写入临时凭证主表
  618.     If Rec_VouchMainTemp.State = 1 Then Rec_VouchMainTemp.Close
  619.     Rec_VouchMainTemp.Open "Select * From Cwzz_AccVouchMainTemp Where VouchId='" & Val(Trim(Lab_VouchId.Caption)) & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  620.     With Rec_VouchMainTemp
  621.         .Fields("Year") = Int_Year                                                                   '会计年度
  622.         .Fields("Period") = Int_Period                                                               '会计期间
  623.         .Fields("Ddate") = CDate(LrText(1).Text)                                                     '制单日期
  624.         .Fields("VouchClassCode") = Trim(LrText(0).Text)                                             '凭证类别
  625.         .Fields("Doc") = Val(LrText(2).Text)                                                         '附单据数
  626.         .Fields("Bill") = Trim(Lab_Bill.Caption)                                                     '制单人
  627.         .Fields("VouchNo") = Int(Int_VouchNo)                                                 '若已生成正式凭证应记录生成的凭证号
  628.         .Fields("SureVouchId") = int_sUreVouchId
  629.         .Update
  630.     End With
  631.     
  632.     '写临时凭证辅表
  633.     Cw_DataEnvi.DataConnect.Execute "delete from Cwzz_AccVouchSubTemp where VouchId='" & Lab_VouchId & "'"
  634.     If Rec_VouchTemp.State = 1 Then Rec_VouchTemp.Close
  635.     Rec_VouchTemp.Open "Select * From Cwzz_AccVouchSubTemp Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  636.     For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows
  637.         If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
  638.             Exit For
  639.         End If
  640.         With Rec_VouchTemp
  641.             .AddNew
  642.             .Fields("SerialID") = Rowjsq
  643.             .Fields("VouchId") = Int(Trim(Lab_VouchId.Caption))                                      '凭证ID
  644.             .Fields("Digest") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)))         '摘要
  645.             .Fields("Ccode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)))          '会计科目
  646.             .Fields("Jfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))            '借方金额
  647.             .Fields("Dfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))            '贷方金额
  648.             If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  649.                 .Fields("Jfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '借方数量
  650.             Else
  651.                 .Fields("Dfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '贷方数量
  652.             End If
  653.             
  654.             '如为外币核算则原币编码为外币编码否则填充本位币编码,同时填充原币金额
  655.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 8))) <> 0 And Trim(WglrGrid.TextMatrix(Rowjsq, 8)) <> XtSCurrCode Then
  656.                 .Fields("ForeignCurrCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 8))                         '外币编码
  657.                 .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, 11))                                 '记帐汇率
  658.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  659.                     .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '原币借方金额
  660.                 Else
  661.                     .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '原币贷方金额
  662.                 End If
  663.             Else
  664.                 .Fields("ForeignCurrCode") = XtSCurrCode                                                  '原币编码
  665.                 .Fields("AccRate") = 1                                                                    '记帐汇率
  666.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  667.                     .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))    '原币借方金额
  668.                 Else
  669.                     .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))    '原币贷方金额
  670.                 End If
  671.             End If
  672.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 4))) <> 0 Then
  673.                 .Fields("BillDate") = CDate(Trim(WglrGrid.TextMatrix(Rowjsq, 4)))                         '发生日期(银行)
  674.             End If
  675.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
  676.                 .Fields("SScode") = Trim(WglrGrid.TextMatrix(Rowjsq, 1))                                  '结算方式(银行)
  677.             End If
  678.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 3))) <> 0 Then
  679.                 .Fields("BillNo") = Trim(WglrGrid.TextMatrix(Rowjsq, 3))                                  '票号(银行)
  680.             End If
  681.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
  682.                 .Fields("PersonCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 16))                             '职员编码
  683.             End If
  684.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
  685.                 .Fields("DeptCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 12))                               '部门编码
  686.             End If
  687.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
  688.                 .Fields("CusCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 14))                                '往来客户编码
  689.             End If
  690.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 25))) <> 0 Then
  691.                 .Fields("Suppliercode") = Trim(WglrGrid.TextMatrix(Rowjsq, 25))                          '往来供应商编码
  692.             End If
  693.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 18))) <> 0 Then
  694.                 .Fields("ItemClassCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 18))                          '项目大类编码
  695.             End If
  696.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
  697.                 .Fields("ItemCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 20))                               '项目编码
  698.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  699.                     .Fields("ItemJfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                             '项目借方数量
  700.                 Else
  701.                     .Fields("ItemDfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                             '项目贷方数量
  702.                 End If
  703.             End If
  704.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 24))) <> 0 Then
  705.                 .Fields("TranPerson") = Trim(WglrGrid.TextMatrix(Rowjsq, 24))                             '经办人
  706.             End If
  707.             .Update
  708.         End With
  709.     Next Rowjsq
  710.     ']写临时凭证结束
  711.     
  712.     
  713.     Lab_Succeed.Visible = True
  714.     Lab_Succeed.Caption = "已生成"
  715.     
  716.     Cw_DataEnvi.DataConnect.CommitTrans
  717.     Sub_SaveBill = True
  718.     Tsxx = "凭证号:" & Trim(LrText(0).Text) & "--" & Trim(LrText(3).Text) & "保存完毕! "
  719.     Call Xtxxts(Tsxx, 0, 4)
  720.     
  721.     '标识单据发生改动
  722.     Bln_BillChange = True
  723.     
  724.     '设置操作状态为浏览
  725.     Lab_OperStatus = "1"
  726.     Call Sub_OperStatus("11")
  727.     
  728.     Exit Function
  729. Swcwcl:
  730.     Cw_DataEnvi.DataConnect.RollbackTrans
  731.     Lab_Succeed.Caption = ""
  732.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  733.     Call Xtxxts(Tsxx, 0, 1)
  734.     Exit Function
  735. Lrcwcl:        '录入错误处理
  736.     With WglrGrid
  737.         Call Xtxxts("(第 " + Trim(Str(Int_RowCount)) + " 条会计分录)-" + Tsxx, 0, 1)
  738.         changelock = True
  739.         .Select Rowjsq, Lrywlz
  740.         WglrGrid.SetFocus
  741.         changelock = False
  742.         Exit Function
  743.     End With
  744. End Function
  745. Private Sub Chk_DeleteMess_Click()                   '删行是否提示(点击)
  746.     If Chk_DeleteMess.Value = 1 Then
  747.         Shsfts = True
  748.     Else
  749.         Shsfts = False
  750.     End If
  751. End Sub
  752. '选择首张,上张,下张,末张
  753. Private Sub Sub_First()             '首 张
  754.     If Val(Lab_VouchId.Caption) = Min_VouchIdTemp Then   'Lab_VouchId用于标识临时凭证主表和辅表的关联Id
  755.         Exit Sub
  756.     End If
  757.     If Lab_Succeed.Caption = "" Then         '首先保存该凭证到临时表中
  758.         Call Save_VouchTemp
  759.     End If
  760.     Rec_TranMainTemp.MoveFirst
  761.     Lab_VouchId.Caption = Trim(Rec_TranMainTemp.Fields("VouchId"))
  762.     Call Sub_ShowBill
  763. End Sub
  764. Private Sub Sub_Prev()             '上 张
  765.     If Val(Lab_VouchId.Caption) = Min_VouchIdTemp Then
  766.         Exit Sub
  767.     End If
  768.     If Lab_Succeed.Caption = "" Then         '首先保存该凭证到临时表中
  769.         Call Save_VouchTemp
  770.     End If
  771.     Rec_TranMainTemp.MovePrevious
  772.     If Rec_TranMainTemp.BOF = True Then
  773.         Rec_TranMainTemp.MoveNext
  774.     End If
  775.     Lab_VouchId.Caption = Trim(Rec_TranMainTemp.Fields("VouchId"))
  776.     Call Sub_ShowBill
  777. End Sub
  778. Private Sub Sub_next()             '下 张
  779.     If Val(Lab_VouchId.Caption) = Max_VouchIdTemp Then
  780.         Exit Sub
  781.     End If
  782.     If Lab_Succeed.Caption = "" Then         '首先保存该凭证到临时表中
  783.         Call Save_VouchTemp
  784.     End If
  785.     Rec_TranMainTemp.MoveNext
  786.     If Rec_TranMainTemp.EOF = True Then
  787.         Rec_TranMainTemp.MovePrevious
  788.     End If
  789.     Lab_VouchId.Caption = Trim(Rec_TranMainTemp.Fields("VouchId"))
  790.     Call Sub_ShowBill
  791. End Sub
  792. Private Sub Sub_Last()              '末 张
  793.     If Val(Lab_VouchId.Caption) = Max_VouchIdTemp Then
  794.         Exit Sub
  795.     End If
  796.     If Lab_Succeed.Caption = "" Then         '首先保存该凭证到临时表中
  797.         Call Save_VouchTemp
  798.     End If
  799.     Rec_TranMainTemp.MoveLast
  800.     Lab_VouchId.Caption = Trim(Rec_TranMainTemp.Fields("VouchId"))
  801.     Call Sub_ShowBill
  802. End Sub
  803. Public Sub Sub_Scpzbb(Cxsjwg As vsFlexGrid)                            '生成预览凭证报表
  804.     
  805.     '过程参数:输出数据网格
  806.     
  807.     Dim Yxhzjsq%, Yxlzjsq%       '有效列值计数器,有效行值计数器
  808.     Dim Rowjsq As Long           '临时行计数器
  809.     Dim Sjhjsq As Long           '数据行计数器
  810.     Dim Int_Pzmyhs As Integer    '凭证每页数据行数
  811.     Dim Dbl_Jfhj As Double       '借方合计
  812.     Dim Dbl_Dfhj As Double       '贷方合计
  813.     
  814.     '生成有效数据表
  815.     With DY_Tybbyldy.DyylGrid
  816.         .FontName = Cxsjwg.FontName
  817.         .FontSize = Cxsjwg.FontSize
  818.         .FixedRows = Cxsjwg.FixedRows
  819.         .MergeCells = flexMergeFixedOnly
  820.         For jsqte = 0 To .FixedRows - 1
  821.             .MergeRow(jsqte) = True
  822.         Next jsqte
  823.         .WordWrap = True
  824.         
  825.         '重置数据列
  826.         Yxlzjsq = 4
  827.         .Cols = Yxlzjsq
  828.         
  829.         .ColAlignment(2) = Cxsjwg.ColAlignment(Sydz("004", GridStr(), Szzls))
  830.         .ColAlignment(3) = Cxsjwg.ColAlignment(Sydz("005", GridStr(), Szzls))
  831.         .ColWidth(0) = Cxsjwg.ColWidth(Sydz("001", GridStr(), Szzls))
  832.         .ColWidth(1) = Cxsjwg.ColWidth(Sydz("002", GridStr(), Szzls)) + Cxsjwg.ColWidth(Sydz("003", GridStr(), Szzls))
  833.         .ColWidth(2) = Cxsjwg.ColWidth(Sydz("004", GridStr(), Szzls))
  834.         .ColWidth(3) = Cxsjwg.ColWidth(Sydz("005", GridStr(), Szzls))
  835.         .ColFormat(2) = Cxsjwg.ColFormat(Sydz("004", GridStr(), Szzls))
  836.         .ColFormat(3) = Cxsjwg.ColFormat(Sydz("005", GridStr(), Szzls))
  837.         
  838.         For Yxlzjsq = 0 To 3
  839.             .MergeCol(Yxlzjsq) = True
  840.         Next Yxlzjsq
  841.         
  842.         '重置数据行
  843.         
  844.         Yxhzjsq = 0
  845.         For Rowjsq = 0 To Cxsjwg.Rows - 1
  846.             If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
  847.                 Yxhzjsq = Yxhzjsq + 1
  848.             End If
  849.         Next Rowjsq
  850.         .Rows = Yxhzjsq
  851.         
  852.         
  853.         .TextMatrix(0, 0) = Cxsjwg.TextMatrix(0, Sydz("001", GridStr(), Szzls))
  854.         .TextMatrix(0, 1) = "科  目  名  称"
  855.         .TextMatrix(0, 2) = Cxsjwg.TextMatrix(0, Sydz("004", GridStr(), Szzls))
  856.         .TextMatrix(0, 3) = Cxsjwg.TextMatrix(0, Sydz("005", GridStr(), Szzls))
  857.         .RowHeight(0) = Cxsjwg.RowHeight(0)
  858.         
  859.         
  860.         Yxhzjsq = Cxsjwg.FixedRows
  861.         
  862.         For Rowjsq = Cxsjwg.FixedRows To Cxsjwg.Rows - 1
  863.             If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
  864.                 
  865.                 '摘要
  866.                 .TextMatrix(Yxhzjsq, 0) = Cxsjwg.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))
  867.                 
  868.                 '输出科目名称
  869.                 If Chk_CodeOutput.Value = 1 Then
  870.                     .TextMatrix(Yxhzjsq, 1) = Cxsjwg.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)) + " " + Cxsjwg.TextMatrix(Rowjsq, Sydz("003", GridStr(), Szzls))
  871.                 Else
  872.                     .TextMatrix(Yxhzjsq, 1) = Cxsjwg.TextMatrix(Rowjsq, Sydz("003", GridStr(), Szzls))
  873.                 End If
  874.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 2)) <> "" Then    '结算方式
  875.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 2))
  876.                 End If
  877.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 3)) <> "" Then    '票号
  878.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 3))
  879.                 End If
  880.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 4)) <> "" Then    '发生日期
  881.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 4))
  882.                 End If
  883.                 If Val(Cxsjwg.TextMatrix(Rowjsq, 5)) <> 0 Then      '数量
  884.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 5)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 7))
  885.                 End If
  886.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 9)) <> "" Then    '外币名称
  887.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 10)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 9))
  888.                 End If
  889.                 If Val(Cxsjwg.TextMatrix(Rowjsq, 11)) <> 0 Then      '记帐汇率
  890.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + "汇率:" + Trim(Cxsjwg.TextMatrix(Rowjsq, 11))
  891.                 End If
  892.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 13)) <> "" Then    '部门
  893.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 13))
  894.                 End If
  895.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 15)) <> "" Then    '往来客户
  896.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 15))
  897.                 End If
  898.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 26)) <> "" Then    '往来供应商
  899.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 26))
  900.                 End If
  901.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 17)) <> "" Then    '职员
  902.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 17))
  903.                 End If
  904.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 19)) <> "" Then    '项目大类
  905.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 19))
  906.                 End If
  907.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 21)) <> "" Then    '项目名称
  908.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 21))
  909.                 End If
  910.                 If Val(Cxsjwg.TextMatrix(Rowjsq, 22)) <> 0 Then      '项目数量单位
  911.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 22)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 23))
  912.                 End If
  913.                 If Trim(Cxsjwg.TextMatrix(Rowjsq, 24)) <> "" Then    '经办人
  914.                     .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + "经办人:" + Trim(Cxsjwg.TextMatrix(Rowjsq, 24))
  915.                 End If
  916.                 
  917.                 '借方金额
  918.                 .TextMatrix(Yxhzjsq, 2) = Cxsjwg.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))
  919.                 
  920.                 '贷方金额
  921.                 .TextMatrix(Yxhzjsq, 3) = Cxsjwg.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls))
  922.                 
  923.                 .RowHeight(Yxhzjsq) = Cxsjwg.RowHeight(Rowjsq)
  924.                 Yxhzjsq = Yxhzjsq + 1
  925.             End If
  926.         Next Rowjsq
  927.         
  928.         '补空行和添加分页合计
  929.         Int_Pzmyhs = 6
  930.         
  931.         If .Rows - .FixedRows = 0 Then
  932.             Exit Sub
  933.         Else
  934.             If (.Rows - .FixedRows) Mod Int_Pzmyhs <> 0 Then
  935.                 For jsqte = 1 To Int_Pzmyhs - ((.Rows - .FixedRows) Mod Int_Pzmyhs)
  936.                     .AddItem ""
  937.                     .RowHeight(.Rows - 1) = Sjhgd
  938.                 Next jsqte
  939.             End If
  940.         End If
  941.         
  942.         Dbl_Jfhj = 0
  943.         Dbl_Dfhj = 0
  944.         Sjhjsq = 1
  945.         Rowjsq = .FixedRows
  946.         Do While Rowjsq <= .Rows - 1
  947.             
  948.             Dbl_Jfhj = Dbl_Jfhj + Val(.TextMatrix(Rowjsq, 2))
  949.             Dbl_Dfhj = Dbl_Dfhj + Val(.TextMatrix(Rowjsq, 3))
  950.             
  951.             If Sjhjsq Mod Int_Pzmyhs = 0 Then
  952.                 Rowjsq = Rowjsq + 1
  953.                 .AddItem "", Rowjsq
  954.                 .RowHeight(Rowjsq) = Sjhgd
  955.                 .TextMatrix(Rowjsq, 0) = "合 计"
  956.                 .TextMatrix(Rowjsq, 2) = Format(Dbl_Jfhj, "##." + String(Xtjexsws, "0"))
  957.                 .TextMatrix(Rowjsq, 3) = Format(Dbl_Dfhj, "##." + String(Xtjexsws, "0"))
  958.                 
  959.                 '最后合计输出金额大写
  960.                 If Rowjsq = .Rows - 1 Then
  961.                     .TextMatrix(Rowjsq, 1) = Fun_Jezh(Dbl_Jfhj)
  962.                 End If
  963.             End If
  964.             
  965.             Sjhjsq = Sjhjsq + 1
  966.             Rowjsq = Rowjsq + 1
  967.             
  968.         Loop
  969.     End With
  970.     
  971. End Sub
  972. Public Sub Read_Data()                  '从临时凭证主表中读本批临时凭证记录集
  973.     If Rec_TranMainTemp.State = 1 Then Rec_TranMainTemp.Close
  974.     
  975.     SqlStr = "select * from Cwzz_AccVouchMainTemp Where OperationNo='" & Lab_OperNum.Caption & "' ORDER BY VouchId"
  976.     Set Rec_TranMainTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  977.     If Not Rec_TranMainTemp.EOF Then
  978.         Rec_TranMainTemp.MoveFirst
  979.         Min_VouchIdTemp = Rec_TranMainTemp.Fields("VouchId")    '最小值
  980.         Rec_TranMainTemp.MoveLast
  981.         Max_VouchIdTemp = Rec_TranMainTemp.Fields("VouchId")    '最大值
  982.         Lab_VouchId.Caption = Trim(Rec_TranMainTemp.Fields("VouchId"))
  983.         Lab_VouchSource.Caption = Trim(Rec_TranMainTemp.Fields("VouchSource"))
  984.     End If
  985. End Sub
  986. Private Sub Save_VouchTemp()            '写临时凭证
  987.     On Error GoTo Swcwcl
  988.     '写临时凭证,与Save_Bill中的写临时凭证程序片段相同
  989.     '写入临时凭证主表
  990.     Cw_DataEnvi.DataConnect.BeginTrans
  991.     If Rec_VouchMainTemp.State = 1 Then Rec_VouchMainTemp.Close
  992.     Rec_VouchMainTemp.Open "Select * From Cwzz_AccVouchMainTemp Where VouchId='" & Val(Trim(Lab_VouchId.Caption)) & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  993.     With Rec_VouchMainTemp
  994.         .Fields("Year") = Int_Year                                                                   '会计年度
  995.         .Fields("Period") = Int_Period                                                               '会计期间
  996.         .Fields("Ddate") = CDate(LrText(1).Text)                                                     '制单日期
  997.         .Fields("VouchClassCode") = Trim(LrText(0).Text)                                             '凭证类别
  998.         .Fields("Doc") = Val(LrText(2).Text)                                                         '附单据数
  999.         .Fields("Bill") = Trim(Lab_Bill.Caption)                                                     '制单人
  1000.         '与SaveBill的不同之处是不填写"VouchNo"的值
  1001.         .Update
  1002.     End With
  1003.     
  1004.     '写临时凭证辅表
  1005.     Cw_DataEnvi.DataConnect.Execute "delete from Cwzz_AccVouchSubTemp where VouchId='" & Val(Trim(Lab_VouchId.Caption)) & "'"
  1006.     If Rec_VouchTemp.State = 1 Then Rec_VouchTemp.Close
  1007.     Rec_VouchTemp.Open "Select * From Cwzz_AccVouchSubTemp Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1008.     For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows
  1009.         If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
  1010.             Exit For
  1011.         End If
  1012.         With Rec_VouchTemp
  1013.             .AddNew
  1014.             .Fields("SerialID") = Rowjsq
  1015.             .Fields("VouchId") = Int(Trim(Lab_VouchId.Caption))                                      '凭证ID
  1016.             .Fields("Digest") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)))         '摘要
  1017.             If Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls))) = "" Then
  1018.                 .Fields("Ccode") = Null
  1019.             Else
  1020.                 .Fields("Ccode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)))          '会计科目
  1021.             End If
  1022.             .Fields("Jfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))            '借方金额
  1023.             .Fields("Dfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))            '贷方金额
  1024.             If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  1025.                 .Fields("Jfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '借方数量
  1026.             Else
  1027.                 .Fields("Dfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5))                                     '贷方数量
  1028.             End If
  1029.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 8))) <> 0 Then
  1030.                 .Fields("ForeignCurrCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 8))                         '外币编码
  1031.                 .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, 11))                                 '记帐汇率
  1032.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  1033.                     .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '外币借方金额
  1034.                 Else
  1035.                     .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10))                               '外币贷方金额
  1036.                 End If
  1037.             End If
  1038.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 4))) <> 0 Then
  1039.                 .Fields("BillDate") = CDate(Trim(WglrGrid.TextMatrix(Rowjsq, 4)))                         '发生日期(银行)
  1040.             End If
  1041.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
  1042.                 .Fields("SScode") = Trim(WglrGrid.TextMatrix(Rowjsq, 1))                                  '结算方式(银行)
  1043.             End If
  1044.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 3))) <> 0 Then
  1045.                 .Fields("BillNo") = Trim(WglrGrid.TextMatrix(Rowjsq, 3))                                  '票号(银行)
  1046.             End If
  1047.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
  1048.                 .Fields("PersonCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 16))                             '职员编码
  1049.             End If
  1050.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
  1051.                 .Fields("DeptCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 12))                               '部门编码
  1052.             End If
  1053.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
  1054.                 .Fields("CusCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 14))                                '往来客户编码
  1055.             End If
  1056.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 25))) <> 0 Then
  1057.                 .Fields("Suppliercode") = Trim(WglrGrid.TextMatrix(Rowjsq, 25))                          '往来供应商编码
  1058.             End If
  1059.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 18))) <> 0 Then
  1060.                 .Fields("ItemClassCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 18))                          '项目大类编码
  1061.             End If
  1062.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
  1063.                 .Fields("ItemCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 20))                               '项目编码
  1064.                 If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
  1065.                     .Fields("ItemJfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                             '项目借方数量
  1066.                 Else
  1067.                     .Fields("ItemDfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22))                             '项目贷方数量
  1068.                 End If
  1069.             End If
  1070.             If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 24))) <> 0 Then
  1071.                 .Fields("TranPerson") = Trim(WglrGrid.TextMatrix(Rowjsq, 24))                             '经办人
  1072.             End If
  1073.             .Update
  1074.         End With
  1075.     Next Rowjsq
  1076.     Cw_DataEnvi.DataConnect.CommitTrans
  1077.     Exit Sub
  1078. Swcwcl:
  1079.     Cw_DataEnvi.DataConnect.RollbackTrans
  1080.     Lab_Succeed.Caption = ""
  1081.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  1082.     Call Xtxxts(Tsxx, 0, 1)
  1083.     Exit Sub
  1084. End Sub
  1085. Private Sub Quit()  '退出自动转帐程序
  1086.     '判断是否有没有存盘的转帐凭证
  1087.     SqlStr = "Select 1 from Cwzz_AccVouchMainTemp Where (VouchNo is Null or VouchNo=0) and OperationNo='" & Lab_OperNum.Caption & "' order by VouchId"
  1088.     Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1089.     If rectemp.EOF = False Then         '若有
  1090.         'AutoTran_NoSaveList.Show 1(区别于自动转帐,无转帐编码提示)
  1091.         Tsxx = "凭证没有全部保存,退出吗?"
  1092.         If Xtxxts(Tsxx, 1, 2) = 6 Then  '若退出
  1093.             GoTo zy
  1094.         End If
  1095.     Else
  1096.         GoTo zy
  1097.     End If
  1098.     Exit Sub
  1099. zy:
  1100.     Unload Me
  1101.     Exit Sub
  1102. End Sub
  1103. Private Sub Sub_FillPeriTran()
  1104.     '填充转帐会计日历
  1105.     SqlStr = "select * from Cwzz_V_AccVouchTempCh where OperationNo='" & Lab_OperNum.Caption & "' and VouchId='" & Val(Trim(Lab_VouchId.Caption)) & "' "
  1106.     Set rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1107.     If rectemp.EOF = True Then
  1108.         Exit Sub
  1109.     End If
  1110.     Call Sub_FillPeriod(Combo_Kjqj, rectemp.Fields("Year"), rectemp.Fields("period"))
  1111. End Sub
  1112. '**************************************************************************************'
  1113. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改======================='
  1114. Private Sub Sub_AdjustGrid()
  1115.     '调 整 网 格
  1116.     With WglrGrid
  1117.         '加 1 保持一行录入行
  1118.         If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  1119.             .Rows = Pmbcsjhs + .FixedRows + Fzxwghs + 1
  1120.             For jsqte = .FixedRows To .Rows - 1
  1121.                 .RowHeight(jsqte) = Sjhgd
  1122.             Next jsqte
  1123.         Else
  1124.             '判断是否有辅助行和录入行,如没有则加行
  1125.             Do While .TextMatrix(.Rows - 1 - Fzxwghs, 0) = "*"
  1126.                 .AddItem ""
  1127.                 .RowHeight(.Rows - 1) = Sjhgd
  1128.             Loop
  1129.         End If
  1130.     End With
  1131. End Sub
  1132. Private Sub Lrzdbz()                                                      '录入字段帮助
  1133.     If Not Ydcommand.Visible Then
  1134.         Exit Sub
  1135.     End If
  1136.     Valilock = True
  1137.     With WglrGrid
  1138.         
  1139.         '[>>会计科目编码帮助单独处理
  1140.         If .Col = Sydz("002", GridStr(), Szzls) Then
  1141.             Xtcdcs = Trim(Ydtext.Text)
  1142.             PZ_FrmKjkmcz.Show 1
  1143.             If Len(Xtfhcs) <> 0 Then
  1144.                 Ydtext.Text = Xtfhcs
  1145.             End If
  1146.         Else
  1147.             
  1148.             '处理通用部分
  1149.             changelock = True        '调入另外窗体必须加锁
  1150.             Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  1151.             changelock = False
  1152.             If Len(Xtfhcs) <> 0 Then
  1153.                 If GridInt(.Col, 7) = 0 Then
  1154.                     Ydtext.Text = Xtfhcs
  1155.                 Else
  1156.                     Ydtext.Text = Xtfhcsfz
  1157.                 End If
  1158.             End If
  1159.         End If
  1160.         '[>>处理完毕
  1161.         
  1162.         Valilock = False
  1163.         If Ydtext.Visible Then
  1164.             Ydtext.SetFocus
  1165.         End If
  1166.     End With
  1167. End Sub
  1168. Private Sub Cshhjwg()                                                     '初始化合计网格(*对合计网格来说,录入网格为容器)
  1169.     Dim Lrwglkd As Double
  1170.     Dim Hjwgpyl As Integer
  1171.     With HjGrid
  1172.         If Not Sfxshjwg Then
  1173.             .Visible = False
  1174.             Exit Sub
  1175.         Else
  1176.             .Visible = True
  1177.         End If
  1178.         .Enabled = False
  1179.         .Appearance = flexFlat
  1180.         .BorderStyle = flexBorderNone
  1181.         .ScrollBars = flexScrollBarNone
  1182.         .Width = WglrGrid.Width
  1183.         .FixedRows = 0
  1184.         .Rows = 1
  1185.         .Cols = WglrGrid.Cols
  1186.         .LeftCol = WglrGrid.LeftCol
  1187.         .TextMatrix(0, Qslz) = "合  计"
  1188.         For jsqte = 0 To WglrGrid.Cols - 1
  1189.             .ColHidden(jsqte) = WglrGrid.ColHidden(jsqte)
  1190.             .ColWidth(jsqte) = WglrGrid.ColWidth(jsqte)
  1191.             .ColAlignment(jsqte) = WglrGrid.ColAlignment(jsqte)
  1192.             .ColFormat(jsqte) = WglrGrid.ColFormat(jsqte)
  1193.         Next jsqte
  1194.         .ColAlignment(Qslz) = flexAlignCenterTop
  1195.         For jsqte = .FixedRows To .Rows - 1
  1196.             .RowHeight(jsqte) = .Height / .Rows
  1197.         Next jsqte
  1198.         .Move 0, WglrGrid.Height - .Height, WglrGrid.Width, .Height
  1199.     End With
  1200. End Sub
  1201. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  1202.     Call Cxxswbk
  1203. End Sub
  1204. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  1205.     Fun_Drfrmyxxpd = True
  1206.     With WglrGrid
  1207.         
  1208.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  1209.         
  1210.         If Ydtext.Visible Or YdCombo.Visible Then
  1211.             Call Lrsjhx
  1212.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1213.                 Fun_Drfrmyxxpd = False
  1214.                 Exit Function
  1215.             End If
  1216.         End If
  1217.         
  1218.         '进行行有效性判断
  1219.         If Not Sjhzyxxpd(.Row) Then
  1220.             Fun_Drfrmyxxpd = False
  1221.             Exit Function
  1222.         End If
  1223.         
  1224.     End With
  1225. End Function
  1226. Private Sub WglrGrid_AfterUserResize(ByVal Row As Long, ByVal Col As Long)       '调整列宽
  1227.     If HjGrid.Visible Then
  1228.         With HjGrid
  1229.             .ColWidth(Col) = WglrGrid.ColWidth(Col)
  1230.         End With
  1231.     End If
  1232. End Sub
  1233. Private Sub WglrGrid_EnterCell()                                    '显示当前数据行相关信息
  1234.     With WglrGrid
  1235.         If .Row >= .FixedRows Then
  1236.             Lab_Row = Trim(Str(.Row - .FixedRows + 1))
  1237.             
  1238.             '显示备注信息
  1239.             Call Sub_ShowMemo(WglrGrid.Row)
  1240.         End If
  1241.     End With
  1242. End Sub
  1243. Private Sub WglrGrid_GotFocus()                                     '网格得到焦点
  1244.     
  1245.     '网格得到焦点,如果当前选择行为非数据行
  1246.     '则调整当前焦点至有效数据行
  1247.     
  1248.     With WglrGrid
  1249.         If .Row < .FixedRows And .Rows > .FixedRows Then
  1250.             changelock = True
  1251.             .Select .FixedRows, .Col
  1252.             changelock = False
  1253.         End If
  1254.         If .Col < Qslz Then
  1255.             changelock = True
  1256.             .Select .Row, Qslz
  1257.             changelock = False
  1258.         End If
  1259.     End With
  1260.     
  1261. End Sub
  1262. Private Sub WglrGrid_LostFocus()                                    '录入网格失去焦点
  1263.     
  1264.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  1265.     If changelock Then
  1266.         Exit Sub
  1267.     End If
  1268.     
  1269.     '引发网格RowcolChange事件
  1270.     With WglrGrid
  1271.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1272.             .Select 0, 0
  1273.         End If
  1274.     End With
  1275.     
  1276. End Sub
  1277. Private Sub WglrGrid_Scroll()                                       '限制用户在录入过程中滚动鼠标
  1278.     If Gdtlock Then
  1279.         Exit Sub
  1280.     End If
  1281.     With WglrGrid
  1282.         If Ydtext.Visible Or YdCombo.Visible Then
  1283.             Gdtlock = True
  1284.             .TopRow = Dqtoprow
  1285.             .LeftCol = Dqleftcol
  1286.             Gdtlock = False
  1287.             Exit Sub
  1288.         End If
  1289.         HjGrid.LeftCol = .LeftCol
  1290.     End With
  1291. End Sub
  1292. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  1293.     If changelock Then
  1294.         Exit Sub
  1295.     End If
  1296.     
  1297.     '记录刚刚离开网格单元的行列值
  1298.     Dqlkwgh = WglrGrid.Row
  1299.     Dqlkwgl = WglrGrid.Col
  1300.     
  1301.     '判断是否需要录入数据回写
  1302.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1303.         Exit Sub
  1304.     End If
  1305.     Call Lrsjhx
  1306. End Sub
  1307. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  1308.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  1309.     With WglrGrid
  1310.         If changelock Then
  1311.             Exit Sub
  1312.         End If
  1313.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1314.             Exit Sub
  1315.         End If
  1316.         If .Row <> Dqlkwgh Then
  1317.             If Not Sjhzyxxpd(Dqlkwgh) Then
  1318.                 Exit Sub
  1319.             End If
  1320.         End If
  1321.     End With
  1322.     Call fhyxh
  1323.     Call Xldql
  1324. End Sub
  1325. Private Sub WglrGrid_DblClick()          '鼠标双击网格显示文本框
  1326.     With WglrGrid
  1327.         Call xswbk
  1328.     End With
  1329. End Sub
  1330. Private Sub Ycwbk()                      '隐藏文本框,帮助按钮,列表组合框
  1331.     Valilock = True
  1332.     Ydtext.Visible = False
  1333.     YdCombo.Visible = False
  1334.     Ydcommand.Visible = False
  1335. End Sub
  1336. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  1337.     With WglrGrid
  1338.         Select Case KeyCode
  1339.         Case vbKeyEscape                'ESC 键放弃录入
  1340.             Valilock = True
  1341.             .SetFocus
  1342.             Call Ycwbk
  1343.             Valilock = False
  1344.         Case vbKeyReturn                '回 车 键 =13
  1345.             KeyCode = 0
  1346.             .SetFocus
  1347.             Call Lrsjhx
  1348.             Rowjsq = .Row
  1349.             Coljsq = .Col + 1
  1350.             If Coljsq > .Cols - 1 Then
  1351.                 If Rowjsq < .Rows - 1 Then
  1352.                     Rowjsq = Rowjsq + 1
  1353.                 End If
  1354.                 Coljsq = Qslz
  1355.             End If
  1356.             Do While Rowjsq <= .Rows - 1
  1357.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1358.                     Coljsq = Coljsq + 1
  1359.                     If Coljsq > .Cols - 1 Then
  1360.                         Rowjsq = Rowjsq + 1
  1361.                         Coljsq = Qslz
  1362.                     End If
  1363.                 Else
  1364.                     Exit Do
  1365.                 End If
  1366.             Loop
  1367.             .Select Rowjsq, Coljsq
  1368.         Case vbKeyLeft                  '左 箭 头 =37
  1369.             If .Col - 1 = Qslz Then
  1370.                 If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1371.                     GoTo jzzx
  1372.                 End If
  1373.             End If
  1374.             If .Col > Qslz Then
  1375.                 KeyCode = 0
  1376.                 .SetFocus
  1377.                 Call Lrsjhx
  1378.                 Coljsq = .Col - 1
  1379.                 Do While Coljsq > Qslz
  1380.                     If Coljsq - 1 = Qslz Then
  1381.                         If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1382.                             GoTo jzzx
  1383.                         End If
  1384.                     End If
  1385.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1386.                         Coljsq = Coljsq - 1
  1387.                     Else
  1388.                         Exit Do
  1389.                     End If
  1390.                 Loop
  1391.                 .Select .Row, Coljsq
  1392.             End If
  1393.             
  1394.         Case vbKeyRight                 '右 箭 头 =39
  1395.             KeyCode = 0
  1396.             .SetFocus
  1397.             Call Lrsjhx
  1398.             Rowjsq = .Row
  1399.             Coljsq = .Col + 1
  1400.             If Coljsq > .Cols - 1 Then
  1401.                 If Rowjsq < .Rows - 1 Then
  1402.                     Rowjsq = Rowjsq + 1
  1403.                 End If
  1404.                 Coljsq = Qslz
  1405.             End If
  1406.             Do While Rowjsq <= .Rows - 1
  1407.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1408.                     Coljsq = Coljsq + 1
  1409.                     If Coljsq > .Cols - 1 Then
  1410.                         Rowjsq = Rowjsq + 1
  1411.                         Coljsq = Qslz
  1412.                     End If
  1413.                 Else
  1414.                     Exit Do
  1415.                 End If
  1416.             Loop
  1417.             .Select Rowjsq, Coljsq
  1418.         Case Else
  1419.         End Select
  1420.         
  1421. jzzx:
  1422.     End With
  1423. End Sub
  1424. Private Sub YdCombo_LostFocus()
  1425.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  1426.         If Not Valilock Then                           '为TRUE
  1427.             Call Lrsjhx
  1428.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1429.                 Exit Sub
  1430.             End If
  1431.         End If
  1432.     End With
  1433. End Sub
  1434. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1435.     Call Lrzdbz
  1436. End Sub
  1437. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  1438.     Dim Rowjsq As Long, Coljsq As Long
  1439.     With WglrGrid
  1440.         Select Case KeyCode
  1441.         Case vbKeyF2
  1442.             Call Lrzdbz
  1443.         Case vbKeyEscape                'ESC 键放弃录入
  1444.             Valilock = True
  1445.             Call Ycwbk
  1446.             .SetFocus
  1447.         Case vbKeyReturn                '回 车 键 =13
  1448.             KeyCode = 0
  1449.             .SetFocus
  1450.             Call Lrsjhx
  1451.             Rowjsq = .Row
  1452.             Coljsq = .Col + 1
  1453.             If Coljsq > .Cols - 1 Then
  1454.                 If Rowjsq < .Rows - 1 Then
  1455.                     Rowjsq = Rowjsq + 1
  1456.                 End If
  1457.                 Coljsq = Qslz
  1458.             End If
  1459.             Do While Rowjsq <= .Rows - 1
  1460.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1461.                     Coljsq = Coljsq + 1
  1462.                     If Coljsq > .Cols - 1 Then
  1463.                         Rowjsq = Rowjsq + 1
  1464.                         Coljsq = Qslz
  1465.                     End If
  1466.                 Else
  1467.                     Exit Do
  1468.                 End If
  1469.             Loop
  1470.             .Select Rowjsq, Coljsq
  1471.         Case vbKeyUp                    '上 箭 头 =38
  1472.             KeyCode = 0
  1473.             .SetFocus
  1474.             Call Lrsjhx
  1475.             If .Row > .FixedRows Then
  1476.                 .Row = .Row - 1
  1477.             End If
  1478.         Case vbKeyDown                  '下 箭 头 =40
  1479.             KeyCode = 0
  1480.             .SetFocus
  1481.             Call Lrsjhx
  1482.             If .Row < .Rows - 1 Then
  1483.                 .Row = .Row + 1
  1484.             End If
  1485.         Case vbKeyLeft                  '左 箭 头 =37
  1486.             If .Col - 1 = Qslz Then
  1487.                 If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1488.                     GoTo jzzx
  1489.                 End If
  1490.             End If
  1491.             If Ydtext.SelStart = 0 And .Col > Qslz Then
  1492.                 KeyCode = 0
  1493.                 .SetFocus
  1494.                 Call Lrsjhx
  1495.                 Coljsq = .Col - 1
  1496.                 Do While Coljsq > Qslz
  1497.                     If Coljsq - 1 = Qslz Then
  1498.                         If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1499.                             GoTo jzzx
  1500.                         End If
  1501.                     End If
  1502.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1503.                         Coljsq = Coljsq - 1
  1504.                     Else
  1505.                         Exit Do
  1506.                     End If
  1507.                 Loop
  1508.                 .Select .Row, Coljsq
  1509.             End If
  1510. jzzx:
  1511.         Case vbKeyRight                 '右 箭 头 =39
  1512.             wblong = Len(Ydtext.Text)
  1513.             If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  1514.                 KeyCode = 0
  1515.                 .SetFocus
  1516.                 Call Lrsjhx
  1517.                 Rowjsq = .Row
  1518.                 Coljsq = .Col + 1
  1519.                 If Coljsq > .Cols - 1 Then
  1520.                     If Rowjsq < .Rows - 1 Then
  1521.                         Rowjsq = Rowjsq + 1
  1522.                     End If
  1523.                     Coljsq = Qslz
  1524.                 End If
  1525.                 Do While Rowjsq <= .Rows - 1
  1526.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1527.                         Coljsq = Coljsq + 1
  1528.                         If Coljsq > .Cols - 1 Then
  1529.                             Rowjsq = Rowjsq + 1
  1530.                             Coljsq = Qslz
  1531.                         End If
  1532.                     Else
  1533.                         Exit Do
  1534.                     End If
  1535.                 Loop
  1536.                 .Select Rowjsq, Coljsq
  1537.             End If
  1538.         Case Else
  1539.         End Select
  1540.     End With
  1541. End Sub
  1542. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  1543.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1544.     If KeyAscii <> 0 Then
  1545.         Call Xyxhbz(Dqlrwgh)
  1546.     End If
  1547. End Sub
  1548. Private Sub ydtext_Change()                              '录入事中变化处理
  1549.     
  1550.     '防止程序改变但不进行处理
  1551.     
  1552.     If Wbkbhlock Then
  1553.         Exit Sub
  1554.     End If
  1555.     
  1556.     With WglrGrid
  1557.         
  1558.         '限制字段录入长度
  1559.         Wbkbhlock = True
  1560.         Select Case GridInt(.Col, 1)
  1561.         Case 8
  1562.             Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  1563.         Case 9
  1564.             Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  1565.         Case 10
  1566.             Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1567.         Case Else
  1568.             If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  1569.                 Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  1570.             End If
  1571.         End Select
  1572.         Wbkbhlock = False
  1573.     End With
  1574. End Sub
  1575. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  1576.     With WglrGrid
  1577.         If Not Valilock Then
  1578.             Call Lrsjhx
  1579.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1580.                 Exit Sub
  1581.             End If
  1582.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1583.                 Exit Sub
  1584.             End If
  1585.         End If
  1586.     End With
  1587. End Sub
  1588. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  1589.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  1590.     
  1591.     '如果单据操作状态为浏览状态则不能显示录入载体
  1592.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1593.         Exit Sub
  1594.     End If
  1595.     
  1596.     '显示文本框前返回有效行列(解决滚动条问题)
  1597.     Call Xldqh
  1598.     Call Xldql
  1599.     
  1600.     '隐藏文本框,帮助按钮,列表组合框
  1601.     Call Ycwbk
  1602.     
  1603.     With WglrGrid
  1604.         Dqlrwgh = .Row
  1605.         Dqlrwgl = .Col
  1606.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1607.             Exit Sub
  1608.         End If
  1609.         
  1610.         Wbkpy = 30
  1611.         Wbkpy1 = 15
  1612.         
  1613.         If GridBoolean(.Col, 3) Then
  1614.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1615.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1616.             YdCombo.Width = .CellWidth - Wbkpy1
  1617.             Call Wbkcl
  1618.             YdCombo.Visible = True
  1619.             YdCombo.SetFocus
  1620.             Ydcommand.Visible = False
  1621.             Ydtext.Visible = False
  1622.         Else
  1623.             If GridBoolean(.Col, 2) Then
  1624.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1625.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1626.                 Ydcommand.Visible = True
  1627.             Else
  1628.                 Ydcommand.Visible = False
  1629.             End If
  1630.             
  1631.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1632.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1633.             If Ydcommand.Visible Then
  1634.                 If Sfblbzkd Then
  1635.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1636.                 Else
  1637.                     Ydtext.Width = .CellWidth - Wbkpy1
  1638.                 End If
  1639.             Else
  1640.                 Ydtext.Width = .CellWidth - Wbkpy1
  1641.             End If
  1642.             Ydtext.Height = .CellHeight - Wbkpy1
  1643.             
  1644.             If GridInt(.Col, 2) <> 0 Then
  1645.                 Ydtext.MaxLength = GridInt(.Col, 2)
  1646.             Else
  1647.                 Ydtext.MaxLength = 3000
  1648.             End If
  1649.             
  1650.             Call Wbkcl
  1651.             
  1652.             Ydtext.Visible = True
  1653.             Ydtext.SetFocus
  1654.         End If
  1655.         Dqtoprow = .TopRow
  1656.         Dqleftcol = .LeftCol
  1657.         
  1658.         '重置锁值
  1659.         Valilock = False
  1660.         Wbkbhlock = False
  1661.     End With
  1662. End Sub
  1663. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1664.     
  1665.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1666.     Wbkpy = 30
  1667.     Wbkpy1 = 15
  1668.     With WglrGrid
  1669.         If YdCombo.Visible Then
  1670.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1671.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1672.             YdCombo.Width = .CellWidth - Wbkpy1
  1673.         End If
  1674.         If Ydcommand.Visible Then
  1675.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1676.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1677.         End If
  1678.         If Ydtext.Visible Then
  1679.             If Ydcommand.Visible Then
  1680.                 If Sfblbzkd Then
  1681.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1682.                 Else
  1683.                     Ydtext.Width = .CellWidth - Wbkpy1
  1684.                 End If
  1685.             Else
  1686.                 Ydtext.Width = .CellWidth - Wbkpy1
  1687.             End If
  1688.             
  1689.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1690.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1691.             Ydtext.Height = .CellHeight - Wbkpy1
  1692.         End If
  1693.     End With
  1694.     
  1695. End Sub
  1696. Private Sub Lrsjhx()                                                   '文本框录入数据回写
  1697.     With WglrGrid
  1698.         If YdCombo.Visible Then
  1699.             .Text = Trim(YdCombo.Text)
  1700.         End If
  1701.         If Ydtext.Visible Then
  1702.             .Text = Trim(Ydtext.Text)
  1703.         End If
  1704.         
  1705.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  1706.         If Zdlrqnr <> Trim(.Text) Then
  1707.             Yxxpdlock = False
  1708.             Hyxxpdlock = False
  1709.         End If
  1710.         
  1711.         '如果字段录入内容不为空则写数据行有效性标志
  1712.         
  1713.         If Len(Trim(.Text)) <> 0 Then
  1714.             Call Xyxhbz(.Row)
  1715.         End If
  1716.         
  1717.         '隐藏文本框,帮助按钮,列表组合框
  1718.         Call Ycwbk
  1719.         
  1720.     End With
  1721. End Sub
  1722. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)    '网格录入增行,删行快捷键
  1723.     
  1724.     '如果单据操作状态为浏览状态则不能显示录入载体
  1725.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1726.         Exit Sub
  1727.     End If
  1728.     
  1729.     Select Case KeyCode
  1730.     Case vbKeyDelete               '删行
  1731.         Call Scdqfl
  1732.     Case vbKeyInsert               '增行
  1733.         Call zjlrfl
  1734.     End Select
  1735. End Sub
  1736. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                     '网格接受键盘录入
  1737.     Dim Str_ChangeTe As String    '临时交换内容
  1738.     Dim Coljsq As Long            '临时列计数器
  1739.     Dim Int_SaveKey As Integer    '保存KeyAscii值
  1740.     
  1741.     '如果单据操作状态为浏览状态则不能显示录入载体
  1742.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1743.         Exit Sub
  1744.     End If
  1745.     
  1746.     Int_SaveKey = KeyAscii
  1747.     
  1748.     With WglrGrid
  1749.         '屏 蔽 回 车 键
  1750.         If KeyAscii = vbKeyReturn Then
  1751.             KeyAscii = 0
  1752.             Rowjsq = .Row
  1753.             Coljsq = .Col + 1
  1754.             If Coljsq > .Cols - 1 Then
  1755.                 If Rowjsq < .Rows - 1 Then
  1756.                     Rowjsq = Rowjsq + 1
  1757.                 End If
  1758.                 Coljsq = Qslz
  1759.             End If
  1760.             Do While Rowjsq <= .Rows - 1
  1761.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1762.                     Coljsq = Coljsq + 1
  1763.                     If Coljsq > .Cols - 1 Then
  1764.                         Rowjsq = Rowjsq + 1
  1765.                         Coljsq = Qslz
  1766.                     End If
  1767.                 Else
  1768.                     Exit Do
  1769.                 End If
  1770.             Loop
  1771.             .Select Rowjsq, Coljsq
  1772.             Exit Sub
  1773.         End If
  1774.         '接受用户录入
  1775.         Select Case KeyAscii
  1776.         Case 0 To 32
  1777.             
  1778.             '[>>开始 当用户输入空格时,如果在摘要列则自动填入上条记录录入的摘要内容
  1779.             ' 如果在金额列则交换借贷内容,此段程序不要求有效性判断,否则应另行处理
  1780.             Select Case GridStr(.Col, 1)
  1781.             Case "001"   '摘要
  1782.                 If Len(Trim(WglrGrid.TextMatrix(.Row, .Col))) = 0 And Len(Trim(Str_Digest)) <> 0 Then
  1783.                     
  1784.                     WglrGrid.TextMatrix(.Row, .Col) = Str_Digest
  1785.                     
  1786.                     '写有效行数据标志,并打开行有效性判断锁
  1787.                     Call Xyxhbz(.Row)
  1788.                     Hyxxpdlock = False
  1789.                 End If
  1790.             Case "004", "005"  '借方金额,贷方金额
  1791.                 If Val(WglrGrid.TextMatrix(.Row, .Col)) = 0 Then
  1792.                     Str_ChangeTe = WglrGrid.TextMatrix(.Row, Sydz("004", GridStr(), Szzls))
  1793.                     
  1794.                     WglrGrid.TextMatrix(.Row, Sydz("004", GridStr(), Szzls)) = WglrGrid.TextMatrix(.Row, Sydz("005", GridStr(), Szzls))
  1795.                     
  1796.                     WglrGrid.TextMatrix(.Row, Sydz("005", GridStr(), Szzls)) = Str_ChangeTe
  1797.                     
  1798.                     '写有效行数据标志,并打开行有效性判断锁
  1799.                     Call Xyxhbz(.Row)
  1800.                     Hyxxpdlock = False
  1801.                     
  1802.                     '计算合计数据
  1803.                     For Coljsq = Qslz To .Cols - 1
  1804.                         Call Sjhj(Coljsq)
  1805.                     Next Coljsq
  1806.                 End If
  1807.             End Select
  1808.             
  1809.             '完毕<<]
  1810.             
  1811.             
  1812.             '显示录入载体
  1813.             Call xswbk
  1814.             
  1815.         Case Else
  1816.             
  1817.             '防止非编辑字段SendKeys()出现死循环
  1818.             If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1819.                 Exit Sub
  1820.             End If
  1821.             
  1822.             If GridBoolean(.Col, 3) Then
  1823.                 
  1824.                 '列表框录入
  1825.                 Call xswbk
  1826.                 
  1827.             Else
  1828.                 
  1829.                 '[>>开始 如果用户在借贷金额位置按"="且当前行金额为零则自动计算借贷合计差额填入录入文本框
  1830.                 If Chr(KeyAscii) = "=" And (Val(.TextMatrix(.Row, Sydz("004", GridStr(), Szzls))) = 0 And Val(.TextMatrix(.Row, Sydz("005", GridStr(), Szzls))) = 0) Then
  1831.                     Select Case GridStr(.Col, 1)
  1832.                     Case "004"   '借方金额
  1833.                         Ydtext.Text = ""
  1834.                         Call Xyxhbz(.Row)
  1835.                         Call xswbk
  1836.                         Ydtext.Text = Format(Val(HjGrid.TextMatrix(0, Sydz("005", GridStr(), Szzls))) - Val(HjGrid.TextMatrix(0, .Col)), "##." + String(Xtjexsws, "0"))
  1837.                     Case "005"   '贷方金额
  1838.                         Ydtext.Text = ""
  1839.                         Call Xyxhbz(.Row)
  1840.                         Call xswbk
  1841.                         Ydtext.Text = Format(Val(HjGrid.TextMatrix(0, Sydz("004", GridStr(), Szzls))) - Val(HjGrid.TextMatrix(0, .Col)), "##." + String(Xtjexsws, "0"))
  1842.                         
  1843.                     End Select
  1844.                     
  1845.                     '完毕<<]
  1846.                 Else
  1847.                     
  1848.                     Ydtext.Text = ""
  1849.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1850.                     If KeyAscii = 0 Then
  1851.                         Exit Sub
  1852.                     End If
  1853.                     
  1854.                     '写有效行数据标志
  1855.                     Call Xyxhbz(.Row)
  1856.                     Call xswbk
  1857.                     Ydtext.Text = ""
  1858.                     Valilock = True
  1859.                     SendKeys Chr(KeyAscii), wait
  1860.                     DoEvents
  1861.                     Valilock = False
  1862.                 End If
  1863.                 
  1864.             End If
  1865.         End Select
  1866.     End With
  1867. End Sub
  1868. Private Sub zjlrfl()                                                    '增加录入分录
  1869.     
  1870.     '判断当前凭证是否允许修改
  1871.     
  1872.     With WglrGrid
  1873.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1874.             If Not Fun_Drfrmyxxpd Then
  1875.                 Exit Sub
  1876.             End If
  1877.         Else
  1878.             Exit Sub
  1879.         End If
  1880.         If .Row < .FixedRows Then
  1881.             Exit Sub
  1882.         End If
  1883.         .AddItem "", .Row
  1884.         .RowHeight(.Row) = Sjhgd
  1885.         If .Row <> .Rows - 1 Then
  1886.             If .TextMatrix(.Row + 1, 0) = "*" Then
  1887.                 .TextMatrix(.Row, 0) = "*"
  1888.             Else
  1889.                 .RemoveItem .Rows - 1
  1890.             End If
  1891.         End If
  1892.         Call Xldqh
  1893.         Call Xldql
  1894.         Hyxxpdlock = False
  1895.     End With
  1896. End Sub
  1897. Private Sub Scdqfl()                                                    '删除当前分录
  1898.     '判断当前凭证是否允许修改
  1899.     Dim Answer As Integer, Scqwghz As Long, Scqwglz As Long, Hjlzte As Long, Sflrzt As Boolean
  1900.     With WglrGrid
  1901.         Scqwghz = .Row
  1902.         Scqwglz = .Col
  1903.         If .TextMatrix(.Row, 0) = "*" Then
  1904.             
  1905.             '判断是否为录入状态
  1906.             If Ydtext.Visible Or YdCombo.Visible Then
  1907.                 Sflrzt = True
  1908.                 Validate = True
  1909.                 Call Lrsjhx
  1910.                 Validate = False
  1911.             End If
  1912.             
  1913.             Call Xldqh
  1914.             changelock = True
  1915.             .Select .Row, 0
  1916.             changelock = False
  1917.             If Shsfts Then
  1918.                 .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = QBColor(12)
  1919.                 Tsxx = "请确认是否删除当前记录?"
  1920.                 yhAnswer = Xtxxts(Tsxx, 2, 2)
  1921.                 If yhAnswer = 2 Then
  1922.                     .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = &H80000005
  1923.                     changelock = True
  1924.                     .Select Scqwghz, Scqwglz
  1925.                     changelock = False
  1926.                     
  1927.                     '如为录入状态,则恢复录入
  1928.                     If Sflrzt Then
  1929.                         Call xswbk
  1930.                     End If
  1931.                     
  1932.                     Exit Sub
  1933.                 End If
  1934.             End If
  1935.             .RemoveItem .Row
  1936.             If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  1937.                 .AddItem ""
  1938.                 .RowHeight(.Rows - 1) = Sjhgd
  1939.             End If
  1940.             changelock = True
  1941.             .Select .Row, Scqwglz
  1942.             changelock = False
  1943.             
  1944.             '重新计算合计数据
  1945.             For Hjlzte = Qslz To .Cols - 1
  1946.                 Call Sjhj(Hjlzte)
  1947.             Next Hjlzte
  1948.             
  1949.         End If
  1950.     End With
  1951. End Sub
  1952. Private Sub Sjhj(Hjwgl As Long)                                         '网格列数据合计
  1953.     Dim Hjjg As Double
  1954.     If Not (GridBoolean(Hjwgl, 4) And HjGrid.Visible) Then
  1955.         Exit Sub
  1956.     End If
  1957.     With WglrGrid
  1958.         Hjjg = 0
  1959.         For jsqte = .FixedRows To .Rows - 1
  1960.             If .TextMatrix(jsqte, 0) = "*" Then
  1961.                 Hjjg = Hjjg + Val(.TextMatrix(jsqte, Hjwgl))
  1962.             End If
  1963.         Next jsqte
  1964.         If GridBoolean(Hjwgl, 5) And Hjjg = 0 Then
  1965.             HjGrid.TextMatrix(0, Hjwgl) = ""
  1966.         Else
  1967.             HjGrid.TextMatrix(0, Hjwgl) = Hjjg
  1968.         End If
  1969.     End With
  1970. End Sub
  1971. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1972.     If Not GridBoolean(Sjl, 5) Then
  1973.         Exit Sub
  1974.     End If
  1975.     With WglrGrid
  1976.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
  1977.             .TextMatrix(sjh, Sjl) = ""
  1978.         End If
  1979.     End With
  1980. End Sub
  1981. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1982.     With WglrGrid
  1983.         If .Row >= .FixedRows Then
  1984.             If .TextMatrix(.Row, 0) <> "*" Then
  1985.                 For Rowjsq = .FixedRows To .Rows - 1
  1986.                     If .TextMatrix(Rowjsq, 0) <> "*" Then
  1987.                         Exit For
  1988.                     End If
  1989.                 Next Rowjsq
  1990.                 If Rowjsq <= .Rows - 1 Then
  1991.                     changelock = True
  1992.                     .Select Rowjsq, .Col
  1993.                     changelock = False
  1994.                 Else
  1995.                     changelock = True
  1996.                     .Select .Rows - 1, .Col
  1997.                     changelock = False
  1998.                 End If
  1999.             End If
  2000.             Call Xldqh
  2001.         End If
  2002.     End With
  2003. End Sub
  2004. Private Sub Xldqh()                                                      '显露当前行
  2005.     Dim Toprowte As Long
  2006.     With WglrGrid
  2007.         Toprowte = 0
  2008.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  2009.             Toprowte = .TopRow
  2010.             .TopRow = .TopRow + 1
  2011.         Loop
  2012.         Toprowte = 0
  2013.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  2014.             Toprowte = .TopRow
  2015.             .TopRow = .TopRow - 1
  2016.         Loop
  2017.     End With
  2018. End Sub
  2019. Private Sub Xldql()                                                     '显露当前列
  2020.     Dim Leftcolte As Long
  2021.     With WglrGrid
  2022.         If .Col >= Qslz Then
  2023.             If .LeftCol > .Col Then
  2024.                 .LeftCol = .Col
  2025.             End If
  2026.             Leftcolte = 0
  2027.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  2028.                 Leftcolte = .LeftCol
  2029.                 .LeftCol = .LeftCol + 1
  2030.             Loop
  2031.         End If
  2032.     End With
  2033. End Sub
  2034. Private Function pdhwk(sjh As Long)                                     '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
  2035.     With WglrGrid
  2036.         For Coljsq = Qslz To .Cols - 1
  2037.             If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
  2038.                 pdhwk = False
  2039.                 Exit Function
  2040.             End If
  2041.         Next Coljsq
  2042.         pdhwk = True
  2043.     End With
  2044. End Function
  2045. Private Sub Xyxhbz(sjh As Long)                                         '写行有效性标志,并判断是否增行
  2046.     With WglrGrid
  2047.         If .TextMatrix(sjh, 0) = "*" Then
  2048.             Exit Sub
  2049.         End If
  2050.         .TextMatrix(sjh, 0) = "*"
  2051.         If sjh >= .Rows - Fzxwghs - 1 Then
  2052.             .AddItem ""
  2053.             .RowHeight(.Rows - 1) = Sjhgd
  2054.         End If
  2055.     End With
  2056. End Sub
  2057. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   '表格格式设置(通用)
  2058.     Select Case Button.Key
  2059.     Case "bcgs"                              '保存表格格式
  2060.         Call Bcwggs(WglrGrid, GridCode, GridStr)
  2061.     Case "hfmrgs"                            '恢复默认格式
  2062.         Call Hfmrgs(WglrGrid, GridCode, GridStr)
  2063.     End Select
  2064. End Sub
  2065. Private Sub bbyl(bbylte As Boolean)                                     '打印预览(通用)
  2066.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  2067.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  2068.     Bbxbtgs = 1                                  '报 表 小 标 题 行 数
  2069.     Bbbwhgs = 1                                  '报 表 表 尾 行 数
  2070.     ReDim Bbxbt(1 To Bbxbtgs)
  2071.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  2072.     If Bbbwhgs <> 0 Then
  2073.         ReDim Bbbwh(1 To Bbbwhgs)
  2074.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  2075.     End If
  2076.     Bbzbt = ReportTitle
  2077.     
  2078.     Bbxbt(1) = Space(45) + Fun_FormatOutPut("制单日期:" + Trim(LrText(1).Text), 30)
  2079.     Bbxbt(1) = Bbxbt(1) + Fun_FormatOutPut("凭证字号:" + Trim(LrText(0).Text) + "-" + Trim(LrText(3).Text), 26)
  2080.     Bbbwh(1) = Fun_FormatOutPut("会计主管:", 18) + Fun_FormatOutPut("记帐:" + Lab_Book, 18)
  2081.     Bbbwh(1) = Bbbwh(1) + Fun_FormatOutPut("出纳:", 18) + Fun_FormatOutPut("审核:" + Lab_Checker, 18)
  2082.     Bbbwh(1) = Bbbwh(1) + Fun_FormatOutPut("制单:" + Lab_Bill, 18) + Trim(Fun_FormatOutPut("附单据数:" + Trim(LrText(2).Text), 23))
  2083.     
  2084.     bbxbtzzxs(1) = 0                             '报表行组织形式(0-居左 1-居中 2-居右)
  2085.     Bbbwhzzxs(1) = 1
  2086.     Call Sub_Scpzbb(WglrGrid)                    '生成报表数据(自定义程序)
  2087.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  2088.     If Not bbylte Then
  2089.         Unload DY_Tybbyldy
  2090.     End If
  2091. End Sub
  2092. '************以下为文本框录入处理程序(固定不变部分)*************'
  2093. Private Sub Wbklrwbcl(Index As Integer)    '文本框录入事后处理程序
  2094.     
  2095.     '以下为依据实际情况自定义部分[
  2096.     
  2097.     '在此填写文本框录入事后处理程序
  2098.     
  2099.     ']以上为依据实际情况自定义部分
  2100. End Sub
  2101. Private Sub LrText_Change(Index As Integer)
  2102.     
  2103.     '屏蔽程序改变控制
  2104.     If TextChangeLock Then
  2105.         Exit Sub
  2106.     End If
  2107.     
  2108.     TextValiJudgeLock(Index) = False    '打开有效性判断锁
  2109.     
  2110.     '限制字段录入长度
  2111.     
  2112.     TextChangeLock = True  '加锁(防止执行Lrtext_Change)
  2113.     Select Case Textint(Index, 1)
  2114.     Case 8           '金额型
  2115.         Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
  2116.     Case 9           '数量型
  2117.         Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
  2118.     Case 10          '单价型
  2119.         Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  2120.     Case Else        '其他小数类型控制
  2121.         If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
  2122.             Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
  2123.         End If
  2124.     End Select
  2125.     
  2126.     '[>>随时计算最新单据号
  2127.     If Index = 0 Then
  2128.         Call Sub_JsVouchNo
  2129.     End If
  2130.     '<<]
  2131.     
  2132.     TextChangeLock = False '解锁
  2133.     
  2134. End Sub
  2135. Private Sub LrText_GotFocus(Index As Integer)                                                 '文本框得到焦点,显示相应信息
  2136.     Call TextShow(Index)
  2137. End Sub
  2138. Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)            '字段按F2键提供帮助
  2139.     Select Case KeyCode
  2140.     Case vbKeyF2
  2141.         Call Text_Help(Index)
  2142.     End Select
  2143. End Sub
  2144. Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer)                            '文本框录入事中控制
  2145.     Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
  2146. End Sub
  2147. Private Sub LrText_LostFocus(Index As Integer)                                                '文本框失去焦点进行有效性判断及相应处理
  2148.     If Textint(Index, 9) = 0 Or Textint(Index, 9) = 1 Then '事中判断
  2149.         Call TextYxxpd(Index)
  2150.     End If
  2151. End Sub
  2152. Private Sub Ydcommand1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2153.     Call Text_Help(Ydcommand1.Tag)
  2154. End Sub
  2155. Private Sub Text_Help(Index As Integer)                                                       '录入字段帮助
  2156.     If Not Ydcommand1.Visible Then
  2157.         Exit Sub
  2158.     End If
  2159.     TextValiLock = True
  2160.     Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
  2161.     If Len(Xtfhcs) <> 0 Then
  2162.         If Textint(Index, 3) = 1 Then
  2163.             LrText(Index).Text = Xtfhcsfz
  2164.             LrText(Index).Tag = Xtfhcs
  2165.         Else
  2166.             LrText(Index).Text = Xtfhcs
  2167.             LrText(Index).Tag = Xtfhcsfz
  2168.         End If
  2169.         
  2170.     End If
  2171.     TextValiLock = False
  2172.     '   LrText(Index).SetFocus
  2173. End Sub
  2174. Private Sub TextShow(Index As Integer)        '文本框得到焦点,显示相应信息
  2175.     If Textboolean(Index, 1) Then
  2176.         Ydcommand1.Visible = True
  2177.         Ydcommand1.Move LrText(Index).Left + LrText(Index).Width, LrText(Index).Top
  2178.         Ydcommand1.Tag = Index
  2179.     Else
  2180.         Ydcommand1.Tag = ""
  2181.         Ydcommand1.Visible = False
  2182.     End If
  2183. End Sub
  2184. Private Sub Wbkcsh()                          '录入文本框初始化
  2185.     
  2186.     '最大录入文本框索引值
  2187.     Max_Text_Index = Textvar(1)
  2188.     
  2189.     ReDim TextValiJudgeLock(Max_Text_Index)
  2190.     For jsqte = 0 To Max_Text_Index
  2191.         If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
  2192.             TextChangeLock = True
  2193.             LrText(jsqte).Text = ""
  2194.             LrText(jsqte).Tag = ""
  2195.             If Textint(jsqte, 5) <> 0 Then
  2196.                 LrText(jsqte).MaxLength = Textint(jsqte, 5)
  2197.             End If
  2198.             TextChangeLock = False
  2199.         End If
  2200.         TextValiJudgeLock(jsqte) = True
  2201.     Next jsqte
  2202. End Sub
  2203. Private Function TextYxxpd(Index As Integer) As Boolean           '文本框有效性判断
  2204.     Dim SqlStr As String
  2205.     Dim Findrec As New ADODB.Recordset
  2206.     
  2207.     '按帮助不进行有效性判断
  2208.     
  2209.     If TextValiLock Then
  2210.         TextValiLock = False
  2211.         TextYxxpd = True
  2212.         Exit Function
  2213.     End If
  2214.     
  2215.     '文本框内容未曾改变不进行有效性判断
  2216.     
  2217.     If TextValiJudgeLock(Index) Then
  2218.         Ydcommand1.Visible = False
  2219.         TextYxxpd = True
  2220.         Exit Function
  2221.     End If
  2222.     If Trim(LrText(Index)) = "" Then
  2223.         LrText(Index).Tag = ""
  2224.         Call Wbklrwbcl(Index)
  2225.         Ydcommand1.Visible = False
  2226.         TextValiJudgeLock(Index) = True
  2227.         TextYxxpd = True
  2228.         
  2229.         '[>>如果凭证类别清空,则字号应清空
  2230.         If Index = 0 Then
  2231.             TextChangeLock = True
  2232.             LrText(3).Text = ""
  2233.             TextChangeLock = False
  2234.         End If
  2235.         '<<]
  2236.         
  2237.         Exit Function
  2238.     End If
  2239.     Select Case Textint(Index, 4)
  2240.     Case 1      '编码型
  2241.         SqlStr = Trim(Textstr(Index, 5))
  2242.         SqlStr = Replace(SqlStr, "@", "'" + Trim(LrText(Index).Text) + "'")
  2243.         Set Findrec = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  2244.         If Findrec.EOF Then
  2245.             Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
  2246.             LrText(Index).SetFocus
  2247.             Exit Function
  2248.         Else
  2249.             Select Case Textint(Index, 3)
  2250.             Case 0
  2251.                 If Len(Trim(Textstr(Index, 2))) <> 0 Then
  2252.                     LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  2253.                 End If
  2254.                 If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  2255.                     LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  2256.                 End If
  2257.             Case 1
  2258.                 If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  2259.                     LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  2260.                 End If
  2261.                 If Len(Trim(Textstr(Index, 2))) <> 0 Then
  2262.                     LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  2263.                 End If
  2264.             End Select
  2265.         End If
  2266.         
  2267.         '[>>凭证类别如有效,且内容已经发生改变则自动计算类别字号
  2268.         If Index = 0 Then
  2269.             Call Sub_JsVouchNo
  2270.         End If
  2271.         '<<]
  2272.         
  2273.     Case 2      '日期型
  2274.         If IsDate(LrText(Index).Text) Then
  2275.             LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
  2276.         Else
  2277.             Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
  2278.             Call Xtxxts(Tsxx, 0, 1)
  2279.             LrText(Index).SetFocus
  2280.             Exit Function
  2281.         End If
  2282.     Case 3      '其他类型
  2283.     End Select
  2284.     Ydcommand1.Visible = False
  2285.     TextValiJudgeLock(Index) = True
  2286.     TextYxxpd = True
  2287. End Function