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

企业管理

开发平台:

Visual Basic

  1.                         If Qmclcy Then
  2.                             DiffE = RecTempFz.Fields("emoney") - RecTempFz.Fields("planmoney")
  3.                             
  4.                             '调整明细帐
  5.                             If DiffE > 0 Then
  6.                                 '借方
  7.                                 Cw_DataEnvi.DataConnect.Execute ("update chhs_list set jfdiff=" & DiffE & ",dfdiff=0 where inoutmainid=" & RecTempFz.Fields("inoutmainid") & " and inoutsubid=" & RecTempFz.Fields("inoutsubid"))
  8.                             Else
  9.                                 '贷方
  10.                                 Cw_DataEnvi.DataConnect.Execute ("update chhs_list set jfdiff=0, dfdiff=" & Abs(DiffE) & " where inoutmainid=" & RecTempFz.Fields("inoutmainid") & " and inoutsubid=" & RecTempFz.Fields("inoutsubid"))
  11.                             End If
  12.                             
  13.                             '调整总帐
  14.                             If RecTempZz.State = 1 Then RecTempZz.Close
  15.                             
  16.                             SqlStr = "select * from chhs_mate where kjyear=" & Xtyear & " and period=" & mPeriod & _
  17.                                 " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  18.                                 " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  19.                             RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  20.                             If Not RecTempZz.EOF Then
  21.                                 DiffE = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))
  22.                                 If DiffE > 0 Then
  23.                                     RecTempZz.Fields("jfdiff") = RecTempZz.Fields("jfdiff") + DiffE
  24.                                 Else
  25.                                     RecTempZz.Fields("dfdiff") = RecTempZz.Fields("dfdiff") + Abs(DiffE)
  26.                                 End If
  27.                                 RecTempZz.UpdateBatch
  28.                             End If
  29.                         Else
  30.                             '调整明细帐
  31.                             Cw_DataEnvi.DataConnect.Execute ("update chhs_list set inmoney=" & RecTempFz.Fields("emoney") & ",inprice=" & RecTempFz.Fields("price") & " where inoutmainid=" & RecTempFz.Fields("inoutmainid") & " and inoutsubid=" & RecTempFz.Fields("inoutsubid"))
  32.                         
  33.                             '调整总帐
  34.                             If RecTempZz.State = 1 Then RecTempZz.Close
  35.                             SqlStr = "select * from chhs_mate where kjyear=" & Xtyear & " and period=" & mPeriod & _
  36.                                 " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  37.                                 " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  38.                             RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  39.                             If Not RecTempZz.EOF Then
  40.                                 DiffE = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))
  41.                                 RecTempZz.Fields("inmoney") = RecTempZz.Fields("inmoney") + DiffE
  42.                                 RecTempZz.UpdateBatch
  43.                             End If
  44.                         End If
  45.                     ElseIf PriceMode = "移动平均法" Then
  46.                         SqlStr = "select * from chhs_v_list where whcode='" & Trim(RecTempFz.Fields("whcode")) & "'" & _
  47.                                 " and mnumber='" & Trim(RecTempFz.Fields("mnumber")) & "' " & _
  48.                                 " and billdate>='" & Trim(LrText(1).Text) & "'and InoutFlag=0 and InOutMainId<>0 " & _
  49.                                 " and kjyear=" & Xtyear & " and period=" & mPeriod & " order by billdate,listid"
  50.                         Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  51.                         Do While Not Rectemp.EOF
  52.                         
  53.                             If Not Rectemp.Fields("sfjeztflag") Then
  54.                                 '入库金额汇总
  55.                                 SumQuan = 0
  56.                                 SumMoney = 0
  57.                                 MovePrice = 0
  58.                                 
  59.                                 SqlStr = "SELECT SUM(InQuan) -SUM(OutQuan) AS SumQuan,SUM(InMoney)-SUM(OutMoney)AS SumMoney  " & _
  60.                                         " FROM Chhs_List a where kjyear=" & Xtyear & _
  61.                                         " and period<=" & mPeriod & " and Inoutmainid<> " & Rectemp.Fields("inoutmainid") & _
  62.                                         " and a.whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  63.                                         " and a.mnumber='" & Trim(Rectemp.Fields("mnumber")) & "'" & _
  64.                                         " and a.billdate<='" & Rectemp.Fields("billdate") & "'"
  65.                                 Set RecTempFz = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  66.                                 If Not RecTempFz.EOF Then
  67.                                     If Not IsNull(RecTempFz.Fields("SumQuan")) Then
  68.                                         SumQuan = RecTempFz.Fields("SumQuan")
  69.                                     End If
  70.                                     If Not IsNull(RecTempFz.Fields("SumMoney")) Then
  71.                                         SumMoney = RecTempFz.Fields("SumMoney")
  72.                                     End If
  73.                                 End If
  74.                                 
  75.                                 If SumQuan <> 0 Then
  76.                                     MovePrice = Format(SumMoney / SumQuan, "###0." + String(Xtdjxsws, "0"))
  77.                                 End If
  78.                                 
  79.                                 '移动平均单价<=0时,手工输入单价
  80.                                 If MovePrice <= 0 Then
  81.                                     Tsxx = "移动平均单价<=0,不允许记帐!"
  82.                                     GoTo Mocwcl
  83.                                 End If
  84.                                 
  85.                                 '调整移动平均单价
  86.                                 If RectempMx.State = 1 Then RectempMx.Close
  87.                                 RectempMx.Open "select * from chhs_list where inoutmainid=" & Rectemp.Fields("inoutmainid") & " and inoutsubid=" & Rectemp.Fields("inoutsubid"), Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  88.                                 If Not Rectemp.EOF Then
  89.                                     RectempMx.Fields("outprice") = MovePrice
  90.                                     RectempMx.Fields("outmoney") = Format(RectempMx.Fields("outquan") * MovePrice, "####0." + String(Xtjexsws, "0"))
  91.                                     RectempMx.UpdateBatch
  92.                                     
  93.                                     Cw_DataEnvi.DataConnect.Execute ("update gy_inoutsub set price=" & MovePrice & ",issuemoney=" & Rectemp.Fields("outmoney") & " where inoutmainid=" & Rectemp.Fields("inoutmainid") & " and inoutsubid=" & Rectemp.Fields("inoutsubid"))
  94.                                 Else
  95.                                     GoTo Swcwcl
  96.                                 End If
  97.                             End If
  98.                             Rectemp.MoveNext
  99.                         Loop
  100.                         
  101.                         '调整总帐
  102.                         SqlStr = "SELECT SUM(InQuan) AS SumInQuan,SUM(InMoney) AS SumInMoney,  " & _
  103.                                     "SUM(OutQuan) AS SumOutQuan,SUM(OutMoney) AS SumOutMoney" & _
  104.                                     " FROM Chhs_List a where kjyear=" & Xtyear & _
  105.                                     " and period=" & mPeriod & " and a.StartFlag=0 " & _
  106.                                     " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  107.                                     " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  108.                         Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  109.                         If Not Rectemp.EOF Then
  110.                            If RecTempZz.State = 1 Then RecTempZz.Close
  111.                            RecTempZz.Open "select * from chhs_mate where kjyear=" & Xtyear & _
  112.                                        " and period=" & mPeriod & "  " & _
  113.                                        " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  114.                                        " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  115.                            If Not RecTempZz.EOF Then
  116.                                If Not IsNull(Rectemp.Fields("suminquan")) Then
  117.                                    RecTempZz.Fields("inquan") = Rectemp.Fields("suminquan")
  118.                                Else
  119.                                    RecTempZz.Fields("inquan") = 0
  120.                                End If
  121.                                If Not IsNull(Rectemp.Fields("suminmoney")) Then
  122.                                    RecTempZz.Fields("inmoney") = Rectemp.Fields("suminmoney")
  123.                                Else
  124.                                    RecTempZz.Fields("inmoney") = 0
  125.                                End If
  126.                                If RecTempZz.Fields("inquan") <> 0 And RecTempZz.Fields("inmoney") <> 0 Then
  127.                                    RecTempZz("inprice") = RecTempZz.Fields("inmoney") / RecTempZz("inquan")
  128.                                End If
  129.                                If Not IsNull(Rectemp.Fields("sumoutquan")) Then
  130.                                    RecTempZz.Fields("outquan") = Rectemp.Fields("sumoutquan")
  131.                                Else
  132.                                    RecTempZz.Fields("outquan") = 0
  133.                                End If
  134.                                If Not IsNull(Rectemp.Fields("sumoutquan")) Then
  135.                                    RecTempZz.Fields("outmoney") = Rectemp.Fields("sumoutquan")
  136.                                Else
  137.                                    RecTempZz.Fields("outmoney") = 0
  138.                                End If
  139.                                If RecTempZz.Fields("outquan") <> 0 And RecTempZz.Fields("outmoney") <> 0 Then
  140.                                    RecTempZz("outprice") = RecTempZz.Fields("outmoney") / RecTempZz("outquan")
  141.                                End If
  142.                            End If
  143.                            RecTempZz.UpdateBatch
  144.                         End If
  145.                     End If
  146.                 End If
  147.             Else                           '调整存货
  148.                 .UpdateBatch
  149.                 
  150.                 '调整单入明细帐
  151.                 If RecTempFz.State = 1 Then RecTempFz.Close
  152.                 RecTempFz.Open "select * from chhs_list where 1=2 ", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  153.                 RecTempFz.AddNew
  154.                 RecTempFz.Fields("inoutflag") = 1
  155.                 RecTempFz.Fields("billnum") = Trim(LrText(0).Text)
  156.                 RecTempFz.Fields("billdate") = CDate(LrText(1).Text)
  157.                 RecTempFz.Fields("deptcode") = Trim(LrText(2).Tag)
  158.                 RecTempFz.Fields("whcode") = Trim(LrText(3).Tag)
  159.                 RecTempFz.Fields("inoutclasscode") = Trim(LrText(4).Tag)
  160.                 RecTempFz.Fields("personcode") = Trim(LrText(5).Tag)
  161.                 RecTempFz.Fields("suppliercode") = Trim(LrText(6).Tag)
  162.                 RecTempFz.Fields("remark") = Trim(LrText(7).Text)
  163.                 RecTempFz.Fields("mnumber") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)))
  164.                 RecTempFz.Fields("inoutadjustmainid") = .Fields("inoutadjustmainid")
  165.                 RecTempFz.Fields("inoutadjustsubid") = .Fields("inoutadjustsubid")
  166.                 If Qmclcy And Trim(PriceMode) = "计划价法" Then
  167.                     RecTempFz.Fields("jfdiff") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))
  168.                 Else
  169.                     RecTempFz.Fields("inmoney") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))
  170.                 End If
  171.                 RecTempFz.Fields("billcode") = BillCode
  172.                 RecTempFz.Fields("kjyear") = Xtyear
  173.                 RecTempFz.Fields("period") = mPeriod
  174.                 RecTempFz.Fields("chalkdate") = CDate(LrText(1).Text)
  175.                 RecTempFz.Fields("chalkitupman") = Xtczy
  176.                 RecTempFz.Fields("maker") = Xtczy
  177.                 
  178.                 '存货科目
  179.                 Xtfhcs = ""
  180.                 Xtfhcsfz = ""
  181.                 Call MaccCode(Trim(RecTempFz.Fields("whcode")), Trim(RecTempFz.Fields("mnumber")), Trim(WglrGrid.TextMatrix(Rowjsq, 4)))
  182.                 RecTempFz.Fields("mateacct") = Xtfhcs
  183.                 If Qmclcy Then
  184.                     RecTempFz.Fields("diffacct") = Xtfhcsfz
  185.                 End If
  186.                 
  187.                 '对方科目
  188.                 Xtfhcs = ""
  189.                 Call DfaccCode(Trim(RecTempFz.Fields("inoutclasscode") & ""), Trim(RecTempFz.Fields("deptcode") & ""), Trim(WglrGrid.TextMatrix(Rowjsq, 4)), Trim(RecTempFz.Fields("mnumber")))
  190.                 RecTempFz.Fields("dfacct") = Xtfhcs
  191.                 
  192.                 RecTempFz.UpdateBatch
  193.                 
  194.                 '调整总帐
  195.                 If RecTempZz.State = 1 Then RecTempZz.Close
  196.                 SqlStr = "select * from chhs_mate where kjyear=" & Xtyear & " and period=" & mPeriod & _
  197.                     " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  198.                     " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  199.                 RecTempZz.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  200.                 If Not RecTempZz.EOF Then
  201.                     DiffE = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))
  202.                     If Qmclcy And Trim(PriceMode) = "计划价法" Then
  203.                         RecTempZz.Fields("jfdiff") = RecTempZz.Fields("jfdiff") + DiffE
  204.                     Else
  205.                         RecTempZz.Fields("inmoney") = RecTempZz.Fields("inmoney") + DiffE
  206.                     End If
  207.                     RecTempZz.UpdateBatch
  208.                 End If
  209.                 
  210.                 If PriceMode = "移动平均法" Then
  211.                      SqlStr = "select * from chhs_v_list where whcode='" & Trim(RecTempFz.Fields("whcode")) & "'" & _
  212.                              " and mnumber='" & Trim(RecTempFz.Fields("mnumber")) & "' " & _
  213.                              " and billdate>='" & Trim(LrText(1).Text) & "'and InoutFlag=0 and InOutMainId<>0 " & _
  214.                              " and kjyear=" & Xtyear & " and period=" & mPeriod & " order by billdate,listid"
  215.                      Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  216.                      Do While Not Rectemp.EOF
  217.                      
  218.                         If Not Rectemp.Fields("sfjeztflag") Then
  219.                             '入库金额汇总
  220.                             SumQuan = 0
  221.                             SumMoney = 0
  222.                             MovePrice = 0
  223.                             
  224.                             SqlStr = "SELECT SUM(InQuan)-SUM(OutQuan) AS SumQuan,SUM(InMoney)-SUM(OutMoney)AS SumMoney  " & _
  225.                                     " FROM Chhs_List a where kjyear=" & Xtyear & _
  226.                                     " and period<=" & mPeriod & " and Inoutmainid<> " & Rectemp.Fields("inoutmainid") & _
  227.                                     " and a.whcode='" & Trim(Rectemp.Fields("whcode")) & "'" & _
  228.                                     " and a.mnumber='" & Trim(Rectemp.Fields("mnumber")) & "'" & _
  229.                                     " and a.billdate<='" & Rectemp.Fields("billdate") & "'"
  230.                             Set RecTempFz = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  231.                             If Not RecTempFz.EOF Then
  232.                                 If Not IsNull(RecTempFz.Fields("SumQuan")) Then
  233.                                     SumQuan = RecTempFz.Fields("SumQuan")
  234.                                 End If
  235.                                 If Not IsNull(RecTempFz.Fields("SumMoney")) Then
  236.                                     SumMoney = RecTempFz.Fields("SumMoney")
  237.                                 End If
  238.                             End If
  239.                             
  240.                             If SumQuan <> 0 Then
  241.                                 MovePrice = Format(SumMoney / SumQuan, "###0." + String(Xtdjxsws, "0"))
  242.                             End If
  243.                             
  244.                             '移动平均单价<=0时,手工输入单价
  245.                             If MovePrice <= 0 Then
  246.                                 Tsxx = "移动平均单价<=0,不允许记帐!"
  247.                                 GoTo Mocwcl
  248.                             End If
  249.                             
  250.                             '调整移动平均单价
  251.                             If RectempMx.State = 1 Then RectempMx.Close
  252.                             RectempMx.Open "select * from chhs_list where inoutmainid=" & Rectemp.Fields("inoutmainid") & " and inoutsubid=" & Rectemp.Fields("inoutsubid") & " ", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockBatchOptimistic
  253.                             If Not Rectemp.EOF Then
  254.                                 RectempMx.Fields("outprice") = MovePrice
  255.                                 RectempMx.Fields("outmoney") = Format(RectempMx.Fields("outquan") * MovePrice, "####0." + String(Xtjexsws, "0"))
  256.                                 RectempMx.UpdateBatch
  257.                                 
  258.                                 Cw_DataEnvi.DataConnect.Execute ("update gy_inoutsub set price=" & MovePrice & ",issuemoney=" & Rectemp.Fields("outmoney") & " where inoutmainid=" & Rectemp.Fields("inoutmainid") & " and inoutsubid=" & Rectemp.Fields("inoutsubid"))
  259.                             Else
  260.                                 GoTo Swcwcl
  261.                             End If
  262.                          End If
  263.                          Rectemp.MoveNext
  264.                      Loop
  265.                      
  266.                      '调整总帐
  267.                      SqlStr = "SELECT SUM(InQuan) AS SumInQuan,SUM(InMoney) AS SumInMoney,  " & _
  268.                                  "SUM(OutQuan) AS SumOutQuan,SUM(OutMoney) AS SumOutMoney" & _
  269.                                  " FROM Chhs_List a where kjyear=" & Xtyear & _
  270.                                  " and period=" & mPeriod & " and a.StartFlag=0 " & _
  271.                                  " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  272.                                  " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  273.                      Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  274.                      If Not Rectemp.EOF Then
  275.                         If RecTempZz.State = 1 Then RecTempZz.Close
  276.                         RecTempZz.Open "select * from chhs_mate where kjyear=" & Xtyear & _
  277.                                     " and period=" & mPeriod & "  " & _
  278.                                     " and whcode='" & Trim(LrText(3).Tag) & "'" & _
  279.                                     " and mnumber='" & Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) & "'"
  280.                         If Not RecTempZz.EOF Then
  281.                             If Not IsNull(Rectemp.Fields("suminquan")) Then
  282.                                  RecTempZz.Fields("inquan") = Rectemp.Fields("suminquan")
  283.                             Else
  284.                                 RecTempZz.Fields("inquan") = 0
  285.                             End If
  286.                             If Not IsNull(Rectemp.Fields("suminmoney")) Then
  287.                                 RecTempZz.Fields("inmoney") = Rectemp.Fields("suminmoney")
  288.                             Else
  289.                                 RecTempZz.Fields("inmoney") = 0
  290.                             End If
  291.                             If RecTempZz.Fields("inquan") <> 0 And RecTempZz.Fields("inmoney") <> 0 Then
  292.                                 RecTempZz("inprice") = RecTempZz.Fields("inmoney") / RecTempZz("inquan")
  293.                             End If
  294.                             If Not IsNull(Rectemp.Fields("sumoutquan")) Then
  295.                                 RecTempZz.Fields("outquan") = Rectemp.Fields("sumoutquan")
  296.                             Else
  297.                                 RecTempZz.Fields("outquan") = 0
  298.                             End If
  299.                             If Not IsNull(Rectemp.Fields("sumoutquan")) Then
  300.                                 RecTempZz.Fields("outmoney") = Rectemp.Fields("sumoutquan")
  301.                             Else
  302.                                 RecTempZz.Fields("outmoney") = 0
  303.                             End If
  304.                             If RecTempZz.Fields("outquan") <> 0 And RecTempZz.Fields("outmoney") <> 0 Then
  305.                                 RecTempZz("outprice") = RecTempZz.Fields("outmoney") / RecTempZz("outquan")
  306.                             End If
  307.                         End If
  308.                         RecTempZz.UpdateBatch
  309.                     End If
  310.                 End If
  311.             End If
  312.         End With
  313.     Next Rowjsq
  314.     
  315.     Cw_DataEnvi.DataConnect.CommitTrans
  316.     
  317.     Sub_SaveBill = True
  318.     Tsxx = "单据存盘完毕! 单据号:" & Trim(LrText(0).Text)
  319.     Call Xtxxts(Tsxx, 0, 4)
  320.     
  321.     '标识单据发生改动
  322.     Bln_BillChange = True
  323.     
  324.     '设置单据改变后的状态
  325.     Lab_OperStatus = "1"
  326.     Call Sub_OperStatus("10")
  327.     Rec_Query.Requery
  328.     Rec_Query.Find "InOutAdjustMainId=" & Val(Lab_BillId.Caption)
  329.     
  330.     Exit Function
  331. Swcwcl:       '数据存盘时出现错误
  332.     Cw_DataEnvi.DataConnect.RollbackTrans
  333.     With WglrGrid
  334.         If Err.Number = -2147217887 Then
  335.             Tsxx = "单据中第  " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条分录录入数据超出允许范围!"
  336.             Call Xtxxts(Tsxx, 0, 1)
  337.             Changelock = True
  338.             .Select Rowjsq, Qslz
  339.             WglrGrid.SetFocus
  340.             Changelock = False
  341.             Exit Function
  342.         Else
  343.             Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  344.             Call Xtxxts(Tsxx, 0, 1)
  345.             Exit Function
  346.         End If
  347.     End With
  348. Lrcwcl:        '录入错误处理(存盘前逐行有效性判断)
  349.     With WglrGrid
  350.         Call Xtxxts("(第 " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条单据分录)-" & Tsxx, 0, 1)
  351.         Changelock = True
  352.         .Select Rowjsq, Lrywlz
  353.         WglrGrid.SetFocus
  354.         Changelock = False
  355.         Exit Function
  356.     End With
  357. Mocwcl:
  358.     Cw_DataEnvi.DataConnect.RollbackTrans
  359.     With WglrGrid
  360.         Call Xtxxts(Tsxx, 0, 1)
  361.         Changelock = True
  362.         .Select Rowjsq, Lrywlz
  363.         WglrGrid.SetFocus
  364.         Changelock = False
  365.         Exit Function
  366.     End With
  367. End Function
  368. '选择首张,上张,下张,末张(此4个过程只需用您的单据ID字段名替换"OrderBillMainId"即可)
  369. Private Sub Sub_First()             '首 张
  370.     
  371.     With Rec_Query
  372.         If .RecordCount = 0 Then
  373.             Exit Sub
  374.         End If
  375.         .MoveFirst
  376.         Lab_BillId.Caption = .Fields("InOutAdjustMainId")
  377.         Call Sub_ShowBill
  378.     End With
  379. End Sub
  380. Private Sub Sub_Prev()             '上 张
  381.     
  382.     With Rec_Query
  383.         If .RecordCount = 0 Then
  384.             Exit Sub
  385.         End If
  386.         If Not .BOF Then
  387.             .MovePrevious
  388.         End If
  389.         If Not .BOF Then
  390.             Lab_BillId.Caption = .Fields("InOutAdjustMainId")
  391.         Else
  392.             .MoveNext
  393.         End If
  394.         Call Sub_ShowBill
  395.     End With
  396. End Sub
  397. Private Sub Sub_next()             '下 张
  398.     With Rec_Query
  399.         If .RecordCount = 0 Then
  400.             Exit Sub
  401.         End If
  402.         If Not .EOF Then
  403.             .MoveNext
  404.         End If
  405.         If Not .EOF Then
  406.             Lab_BillId.Caption = .Fields("InOutAdjustMainId")
  407.         Else
  408.             .MovePrevious
  409.         End If
  410.         Call Sub_ShowBill
  411.     End With
  412. End Sub
  413. Private Sub Sub_Last()              '末 张
  414.     
  415.     With Rec_Query
  416.         If .RecordCount = 0 Then
  417.             Exit Sub
  418.         End If
  419.         .MoveLast
  420.         Lab_BillId.Caption = .Fields("InOutAdjustMainId")
  421.         Call Sub_ShowBill
  422.     End With
  423. End Sub
  424.     
  425. '[>>===================以下为根据实际业务需要自定义过程区域=============================<<]
  426. '[>>===================以上为根据实际业务需要自定义过程区域=============================<<]
  427. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
  428. Private Sub Sub_AdjustGrid()
  429.   
  430.     '调 整 网 格
  431.     With WglrGrid
  432.         '加 1 保持一行录入行
  433.         If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  434.             .Rows = Pmbcsjhs + .FixedRows + Fzxwghs + 1
  435.             For Jsqte = .FixedRows To .Rows - 1
  436.                 .RowHeight(Jsqte) = Sjhgd
  437.             Next Jsqte
  438.         End If
  439.         
  440.         '判断是否有辅助行和录入行,如没有则加行
  441.         Do While .TextMatrix(.Rows - 1 - Fzxwghs, 0) = "*"
  442.             .AddItem ""
  443.             .RowHeight(.Rows - 1) = Sjhgd
  444.         Loop
  445.     
  446.     End With
  447. End Sub
  448. Private Sub Lrzdbz()                                                      '录入字段帮助
  449.     
  450.     If Not Ydcommand.Visible Then
  451.         Exit Sub
  452.     End If
  453.    
  454.     With WglrGrid
  455.         Valilock = True
  456.     
  457.         '处理通用部分
  458.         Changelock = True        '调入另外窗体必须加锁
  459.         Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  460.         Changelock = False
  461.         
  462.         If Len(Xtfhcs) <> 0 Then
  463.             If GridInt(.Col, 7) = 0 Then
  464.                 Ydtext.Text = Xtfhcs
  465.             Else
  466.                 Ydtext.Text = Xtfhcsfz
  467.             End If
  468.         End If
  469.         
  470.         Valilock = False
  471.         If Ydtext.Visible Then
  472.             Ydtext.SetFocus
  473.         End If
  474.     End With
  475. End Sub
  476. Private Sub Cshhjwg()                                                     '初始化合计网格(*对合计网格来说,录入网格为容器)
  477.     
  478.     With HjGrid
  479.     
  480.        '是否显示合计网格
  481.        If Not Sfxshjwg Then
  482.            .Visible = False
  483.            Exit Sub
  484.        Else
  485.            .Visible = True
  486.        End If
  487.       
  488.        '设置网格相关属性
  489.        .Enabled = False
  490.        .Appearance = flexFlat
  491.        .BorderStyle = flexBorderNone
  492.        .ScrollBars = flexScrollBarNone
  493.        .Width = WglrGrid.Width
  494.        .FixedRows = 0
  495.        .Rows = 1
  496.        .Cols = WglrGrid.Cols
  497.        .LeftCol = WglrGrid.LeftCol
  498.        .TextMatrix(0, Qslz) = "合  计"
  499.        For Jsqte = 0 To WglrGrid.Cols - 1
  500.            .ColHidden(Jsqte) = WglrGrid.ColHidden(Jsqte)
  501.            .ColWidth(Jsqte) = WglrGrid.ColWidth(Jsqte)
  502.            .ColAlignment(Jsqte) = WglrGrid.ColAlignment(Jsqte)
  503.            .ColFormat(Jsqte) = WglrGrid.ColFormat(Jsqte)
  504.        Next Jsqte
  505.        .ColAlignment(Qslz) = flexAlignCenterTop
  506.        For Jsqte = .FixedRows To .Rows - 1
  507.            .RowHeight(Jsqte) = .Height / .Rows
  508.        Next Jsqte
  509.        
  510.       '程序自动调整网格高度(自动设置为网格剩余高度+辅助项网格行数(默认为1)*数据行高度)、并设置其位置信息
  511.        .Height = Fzxwghs * Sjhgd + ((WglrGrid.Height - WglrGrid.FixedRows * WglrGrid.RowHeight(0)) Mod Sjhgd)
  512.        .RowHeight(0) = .Height
  513.        .Move 0, WglrGrid.Height - .Height, WglrGrid.Width, .Height
  514.     End With
  515. End Sub
  516. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  517.    Call Cxxswbk
  518. End Sub
  519. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  520.     Fun_Drfrmyxxpd = True
  521.     With WglrGrid
  522.    
  523.         '如果文本框处于编辑状态,则先进性文本框的有效性判断
  524.         If Ydcommand1.Visible Then
  525.            If Not TextYxxpd(Ydcommand1.Tag) Then
  526.               Fun_Drfrmyxxpd = False
  527.               Exit Function
  528.            End If
  529.         End If
  530.         
  531.    
  532.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  533.         If Ydtext.Visible Or YdCombo.Visible Then
  534.             Call Lrsjhx
  535.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  536.                 Fun_Drfrmyxxpd = False
  537.                 Exit Function
  538.             End If
  539.         End If
  540.    
  541.         '进行行有效性判断
  542.         If Not Sjhzyxxpd(.Row) Then
  543.             Fun_Drfrmyxxpd = False
  544.             Exit Function
  545.         End If
  546.     End With
  547. End Function
  548. Private Sub WglrGrid_AfterUserResize(ByVal Row As Long, ByVal Col As Long)       '调整列宽
  549.     
  550.     If HjGrid.Visible Then
  551.         With HjGrid
  552.             .ColWidth(Col) = WglrGrid.ColWidth(Col)
  553.         End With
  554.     End If
  555. End Sub
  556. Private Sub WglrGrid_EnterCell()                                                 '显示当前数据行相关信息
  557.     
  558.     With WglrGrid
  559.         If .Row >= .FixedRows Then
  560.             '[>>
  561.             '此处可以填写显示与此网格行相关信息
  562.             '<<]
  563.         End If
  564.     End With
  565. End Sub
  566. Private Sub WglrGrid_GotFocus()                                     '网格得到焦点
  567.     '网格得到焦点,如果当前选择行为非数据行
  568.     '则调整当前焦点至有效数据行
  569.     With WglrGrid
  570.         If .Row < .FixedRows And .Rows > .FixedRows Then
  571.             Changelock = True
  572.             .Select .FixedRows, .Col
  573.             Changelock = False
  574.         End If
  575.         If .Col < Qslz Then
  576.             Changelock = True
  577.             .Select .Row, Qslz
  578.             Changelock = False
  579.         End If
  580.     End With
  581. End Sub
  582. Private Sub WglrGrid_LostFocus()                                    '录入网格失去焦点
  583.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  584.     If Changelock Then
  585.         Exit Sub
  586.     End If
  587.     '引发网格RowcolChange事件
  588.     With WglrGrid
  589.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  590.             .Select 0, 0
  591.         End If
  592.     End With
  593. End Sub
  594. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                       '限制用户在录入过程中滚动鼠标
  595.     If Gdtlock Then
  596.         Exit Sub
  597.     End If
  598.  
  599.     With WglrGrid
  600.         If Ydtext.Visible Or YdCombo.Visible Then
  601.             Gdtlock = True
  602.             .TopRow = Dqtoprow
  603.             .LeftCol = Dqleftcol
  604.             Gdtlock = False
  605.             Exit Sub
  606.         End If
  607.         HjGrid.LeftCol = .LeftCol
  608.     End With
  609. End Sub
  610. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  611.     
  612.     If Changelock Then
  613.         Exit Sub
  614.     End If
  615.     '记录刚刚离开网格单元的行列值
  616.     Dqlkwgh = WglrGrid.Row
  617.     Dqlkwgl = WglrGrid.Col
  618.     '判断是否需要录入数据回写
  619.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  620.         Exit Sub
  621.     End If
  622.     Call Lrsjhx
  623. End Sub
  624. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  625.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  626.     With WglrGrid
  627.         If Changelock Then
  628.             Exit Sub
  629.         End If
  630.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  631.             Exit Sub
  632.         End If
  633.         If .Row <> Dqlkwgh Then
  634.             If Not Sjhzyxxpd(Dqlkwgh) Then
  635.                 Exit Sub
  636.             End If
  637.         End If
  638.     End With
  639.    
  640.     Call fhyxh
  641.     Call Xldql
  642.    
  643. End Sub
  644. Private Sub WglrGrid_DblClick()          '鼠标双击网格显示文本框
  645.   
  646.     With WglrGrid
  647.         Call xswbk
  648.     End With
  649. End Sub
  650. Private Sub Ycwbk()                      '隐藏文本框,帮助按钮,列表组合框
  651.     
  652.     Valilock = True
  653.     Ydtext.Visible = False
  654.     YdCombo.Visible = False
  655.     Ydcommand.Visible = False
  656. End Sub
  657. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  658.     With WglrGrid
  659.         Select Case KeyCode
  660.             Case vbKeyEscape                'ESC 键放弃录入
  661.                 Valilock = True
  662.                 .SetFocus
  663.                 Call Ycwbk
  664.                 Valilock = False
  665.             Case vbKeyReturn                '回 车 键 =13
  666.                 KeyCode = 0
  667.                 .SetFocus
  668.                 Call Lrsjhx
  669.                 Rowjsq = .Row
  670.                 Coljsq = .Col + 1
  671.                 If Coljsq > .Cols - 1 Then
  672.                     If Rowjsq < .Rows - 1 Then
  673.                         Rowjsq = Rowjsq + 1
  674.                     End If
  675.                     Coljsq = Qslz
  676.                 End If
  677.                 Do While Rowjsq <= .Rows - 1
  678.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  679.                         Coljsq = Coljsq + 1
  680.                         If Coljsq > .Cols - 1 Then
  681.                             Rowjsq = Rowjsq + 1
  682.                             Coljsq = Qslz
  683.                         End If
  684.                     Else
  685.                         Exit Do
  686.                     End If
  687.                 Loop
  688.                 .Select Rowjsq, Coljsq
  689.             Case vbKeyLeft                  '左 箭 头 =37
  690.                 If .Col - 1 = Qslz Then
  691.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  692.                         GoTo jzzx
  693.                     End If
  694.                 End If
  695.                 If .Col > Qslz Then
  696.                     KeyCode = 0
  697.                     .SetFocus
  698.                     Call Lrsjhx
  699.                     Coljsq = .Col - 1
  700.                     Do While Coljsq > Qslz
  701.                         If Coljsq - 1 = Qslz Then
  702.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  703.                                 GoTo jzzx
  704.                             End If
  705.                         End If
  706.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  707.                             Coljsq = Coljsq - 1
  708.                         Else
  709.                             Exit Do
  710.                         End If
  711.                     Loop
  712.                     .Select .Row, Coljsq
  713.                 End If
  714.             Case vbKeyRight                 '右 箭 头 =39
  715.                 KeyCode = 0
  716.                 .SetFocus
  717.                 Call Lrsjhx
  718.                 Rowjsq = .Row
  719.                 Coljsq = .Col + 1
  720.                 If Coljsq > .Cols - 1 Then
  721.                     If Rowjsq < .Rows - 1 Then
  722.                         Rowjsq = Rowjsq + 1
  723.                     End If
  724.                     Coljsq = Qslz
  725.                 End If
  726.                 Do While Rowjsq <= .Rows - 1
  727.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  728.                         Coljsq = Coljsq + 1
  729.                         If Coljsq > .Cols - 1 Then
  730.                             Rowjsq = Rowjsq + 1
  731.                             Coljsq = Qslz
  732.                         End If
  733.                     Else
  734.                         Exit Do
  735.                     End If
  736.                 Loop
  737.                 .Select Rowjsq, Coljsq
  738.         Case Else
  739.    End Select
  740.    
  741. jzzx:
  742.    
  743.     End With
  744. End Sub
  745. Private Sub YdCombo_LostFocus()
  746.   
  747.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  748.         If Not Valilock Then                           '为TRUE
  749.             Call Lrsjhx
  750.             If Not Sjhzyxxpd(Dqlrwgh) Then
  751.                 Exit Sub
  752.             End If
  753.         End If
  754.     End With
  755. End Sub
  756. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  757.     Call Lrzdbz
  758. End Sub
  759. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  760.     Dim Rowjsq As Long, Coljsq As Long
  761.     With WglrGrid
  762.         Select Case KeyCode
  763.             Case vbKeyF2
  764.                 Call Lrzdbz
  765.             Case vbKeyEscape                'ESC 键放弃录入
  766.                 Valilock = True
  767.                 Call Ycwbk
  768.                 .SetFocus
  769.             Case vbKeyReturn                '回 车 键 =13
  770.                 KeyCode = 0
  771.                 .SetFocus
  772.                 Call Lrsjhx
  773.                 Rowjsq = .Row
  774.                 Coljsq = .Col + 1
  775.                 If Coljsq > .Cols - 1 Then
  776.                     If Rowjsq < .Rows - 1 Then
  777.                         Rowjsq = Rowjsq + 1
  778.                     End If
  779.                     Coljsq = Qslz
  780.                 End If
  781.                 Do While Rowjsq <= .Rows - 1
  782.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  783.                         Coljsq = Coljsq + 1
  784.                         If Coljsq > .Cols - 1 Then
  785.                             Rowjsq = Rowjsq + 1
  786.                             Coljsq = Qslz
  787.                         End If
  788.                     Else
  789.                         Exit Do
  790.                     End If
  791.                 Loop
  792.                 If Rowjsq <= .Rows - 1 Then
  793.                     .Select Rowjsq, Coljsq
  794.                 End If
  795.             Case vbKeyUp                    '上 箭 头 =38
  796.                 KeyCode = 0
  797.                 .SetFocus
  798.                 Call Lrsjhx
  799.                 If .Row > .FixedRows Then
  800.                     .Row = .Row - 1
  801.                 End If
  802.             Case vbKeyDown                  '下 箭 头 =40
  803.                 KeyCode = 0
  804.                 .SetFocus
  805.                 Call Lrsjhx
  806.                 If .Row < .Rows - 1 Then
  807.                     .Row = .Row + 1
  808.                 End If
  809.             Case vbKeyLeft                  '左 箭 头 =37
  810.                 If .Col - 1 = Qslz Then
  811.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  812.                         GoTo jzzx
  813.                     End If
  814.                 End If
  815.                 If Ydtext.SelStart = 0 And .Col > Qslz Then
  816.                     KeyCode = 0
  817.                     .SetFocus
  818.                     Call Lrsjhx
  819.                     Coljsq = .Col - 1
  820.                     Do While Coljsq > Qslz
  821.                         If Coljsq - 1 = Qslz Then
  822.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  823.                                 GoTo jzzx
  824.                             End If
  825.                         End If
  826.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  827.                             Coljsq = Coljsq - 1
  828.                         Else
  829.                             Exit Do
  830.                         End If
  831.                     Loop
  832.                     .Select .Row, Coljsq
  833.                 End If
  834. jzzx:
  835.             Case vbKeyRight                 '右 箭 头 =39
  836.                 wblong = Len(Ydtext.Text)
  837.                 If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  838.                     KeyCode = 0
  839.                     .SetFocus
  840.                     Call Lrsjhx
  841.                     Rowjsq = .Row
  842.                     Coljsq = .Col + 1
  843.                     If Coljsq > .Cols - 1 Then
  844.                         If Rowjsq < .Rows - 1 Then
  845.                             Rowjsq = Rowjsq + 1
  846.                         End If
  847.                         Coljsq = Qslz
  848.                     End If
  849.                     Do While Rowjsq <= .Rows - 1
  850.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  851.                             Coljsq = Coljsq + 1
  852.                             If Coljsq > .Cols - 1 Then
  853.                                 Rowjsq = Rowjsq + 1
  854.                                 Coljsq = Qslz
  855.                             End If
  856.                         Else
  857.                             Exit Do
  858.                         End If
  859.                     Loop
  860.                     .Select Rowjsq, Coljsq
  861.                 End If
  862.             Case Else
  863.         End Select
  864.     End With
  865. End Sub
  866. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  867.     
  868.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  869.     If KeyAscii <> 0 Then
  870.         Call Xyxhbz(Dqlrwgh)
  871.     End If
  872. End Sub
  873. Private Sub ydtext_Change()                              '录入事中变化处理
  874.     '防止程序改变但不进行处理
  875.     If Wbkbhlock Then
  876.         Exit Sub
  877.     End If
  878.     With WglrGrid
  879.         '限制字段录入长度
  880.         Wbkbhlock = True
  881.         
  882.         Call TextChangeLimit(Ydtext, GridInt(.Col, 1))  '去掉无效字符
  883.         
  884.         Select Case GridInt(.Col, 1)
  885.             Case 8, 11   '金额型
  886.                 Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  887.             Case 9, 12   '数量型
  888.                 Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  889.             Case 10      '单价型
  890.                 Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  891.             Case Else    '其他类型
  892.                 If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  893.                     Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  894.                 End If
  895.         End Select
  896.         Wbkbhlock = False
  897.     End With
  898. End Sub
  899. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  900.   
  901.     With WglrGrid
  902.         If Not Valilock Then
  903.             Call Lrsjhx
  904.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  905.                 Exit Sub
  906.             End If
  907.             If Not Sjhzyxxpd(Dqlrwgh) Then
  908.                 Exit Sub
  909.             End If
  910.         End If
  911.     End With
  912. End Sub
  913. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  914.     
  915.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  916.   
  917.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  918.     If Not Fun_AllowInput Then
  919.         Exit Sub
  920.     End If
  921.   
  922.     '显示文本框前返回有效行列(解决滚动条问题)
  923.     Call Xldqh
  924.     Call Xldql
  925.   
  926.     '隐藏文本框,帮助按钮,列表组合框
  927.     Call Ycwbk
  928.   
  929.     With WglrGrid
  930.         Dqlrwgh = .Row
  931.         Dqlrwgl = .Col
  932.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  933.             Exit Sub
  934.         End If
  935.      
  936.         Wbkpy = 30
  937.         Wbkpy1 = 15
  938.     
  939.         On Error Resume Next
  940.         
  941.         If GridBoolean(.Col, 3) Then
  942.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  943.             YdCombo.Top = .CellTop + .Top + Wbkpy
  944.             YdCombo.Width = .CellWidth - Wbkpy1
  945.             Call Wbkcl
  946.             YdCombo.Visible = True
  947.             YdCombo.SetFocus
  948.             Ydcommand.Visible = False
  949.             Ydtext.Visible = False
  950.         Else
  951.             If GridBoolean(.Col, 2) Then
  952.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  953.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  954.                 Ydcommand.Visible = True
  955.             Else
  956.                 Ydcommand.Visible = False
  957.             End If
  958.              
  959.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  960.             Ydtext.Top = .CellTop + .Top + Wbkpy
  961.             If Ydcommand.Visible Then
  962.                 If Sfblbzkd Then
  963.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  964.                 Else
  965.                     Ydtext.Width = .CellWidth - Wbkpy1
  966.                 End If
  967.             Else
  968.                 Ydtext.Width = .CellWidth - Wbkpy1
  969.             End If
  970.             Ydtext.Height = .CellHeight - Wbkpy1
  971.         
  972.             If GridInt(.Col, 2) <> 0 Then
  973.                 Ydtext.MaxLength = GridInt(.Col, 2)
  974.             Else
  975.                 Ydtext.MaxLength = 3000
  976.             End If
  977.       
  978.             Call Wbkcl
  979.       
  980.             Ydtext.Visible = True
  981.             Ydtext.SetFocus
  982.         End If
  983.         Dqtoprow = .TopRow
  984.         Dqleftcol = .LeftCol
  985.         
  986.         '重置锁值
  987.         Valilock = False
  988.         Wbkbhlock = False
  989.     End With
  990. End Sub
  991. Private Function Fun_AllowInput() As Boolean                           '当某种条件成立时禁止文本框激活使单据处于录入状态
  992.    
  993.     '如果单据操作状态为浏览状态则不能显示录入载体(通用)
  994.     If Trim(Lab_OperStatus.Caption) = "1" Then
  995.         Exit Function
  996.     End If
  997.    
  998.     '[>>
  999.     
  1000.     '此处可以填写禁止文本框激活使单据处于录入状态的理由
  1001.     If Trim(LrText(3).Text) = "" Then
  1002.         Tsxx = "请先输入仓库!"
  1003.         Call Xtxxts(Tsxx, 0, 1)
  1004.         LrText(3).SetFocus
  1005.         Exit Function
  1006.     End If
  1007.     
  1008.     '<<]
  1009.    
  1010.     Fun_AllowInput = True
  1011. End Function
  1012. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1013.                    
  1014.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1015.     Wbkpy = 30
  1016.     Wbkpy1 = 15
  1017.     With WglrGrid
  1018.         If YdCombo.Visible Then
  1019.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1020.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1021.             YdCombo.Width = .CellWidth - Wbkpy1
  1022.         End If
  1023.         If Ydcommand.Visible Then
  1024.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1025.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1026.         End If
  1027.         If Ydtext.Visible Then
  1028.             If Ydcommand.Visible Then
  1029.                 If Sfblbzkd Then
  1030.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1031.                 Else
  1032.                     Ydtext.Width = .CellWidth - Wbkpy1
  1033.                 End If
  1034.             Else
  1035.                 Ydtext.Width = .CellWidth - Wbkpy1
  1036.             End If
  1037.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1038.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1039.             Ydtext.Height = .CellHeight - Wbkpy1
  1040.         End If
  1041.     End With
  1042. End Sub
  1043. Private Sub Lrsjhx()                                                   '文本框录入数据回写
  1044.     
  1045.     With WglrGrid
  1046.         If YdCombo.Visible Then
  1047.             .Text = Trim(YdCombo.Text)
  1048.         End If
  1049.         If Ydtext.Visible Then
  1050.             .Text = Trim(Ydtext.Text)
  1051.         End If
  1052.         
  1053.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  1054.         If Zdlrqnr <> Trim(.Text) Then
  1055.             Yxxpdlock = False
  1056.             Hyxxpdlock = False
  1057.         End If
  1058.     
  1059.         '如果字段录入内容不为空则写数据行有效性标志
  1060.         If Len(Trim(.Text)) <> 0 Then
  1061.             Call Xyxhbz(.Row)
  1062.         End If
  1063.     
  1064.         '隐藏文本框,帮助按钮,列表组合框
  1065.         Call Ycwbk
  1066.     End With
  1067. End Sub
  1068. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)    '网格录入增行,删行快捷键
  1069.   
  1070.     '如果单据操作状态为浏览状态则不能显示录入载体
  1071.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1072.         Exit Sub
  1073.     End If
  1074.     Select Case KeyCode
  1075.         Case vbKeyF2                   '按F2键参照
  1076.             Call xswbk
  1077.             Call Lrzdbz
  1078.         Case vbKeyDelete               '删行
  1079.             Call Scdqfl
  1080.         Case vbKeyInsert               '增行
  1081.             Call zjlrfl
  1082.     End Select
  1083. End Sub
  1084. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                             '网格接受键盘录入
  1085.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1086.     If Not Fun_AllowInput Then
  1087.         Exit Sub
  1088.     End If
  1089.   
  1090.     With WglrGrid
  1091.         '屏 蔽 回 车 键
  1092.         If KeyAscii = vbKeyReturn Then
  1093.             KeyAscii = 0
  1094.             Rowjsq = .Row
  1095.             Coljsq = .Col + 1
  1096.             If Coljsq > .Cols - 1 Then
  1097.                 If Rowjsq < .Rows - 1 Then
  1098.                     Rowjsq = Rowjsq + 1
  1099.                 End If
  1100.                 Coljsq = Qslz
  1101.             End If
  1102.             Do While Rowjsq <= .Rows - 1
  1103.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1104.                     Coljsq = Coljsq + 1
  1105.                     If Coljsq > .Cols - 1 Then
  1106.                         Rowjsq = Rowjsq + 1
  1107.                         Coljsq = Qslz
  1108.                     End If
  1109.                 Else
  1110.                     Exit Do
  1111.                 End If
  1112.             Loop
  1113.             If Rowjsq <= .Rows - 1 Then
  1114.                 .Select Rowjsq, Coljsq
  1115.             End If
  1116.             Exit Sub
  1117.         End If
  1118.      
  1119.         '接受用户录入
  1120.         Select Case KeyAscii
  1121.             Case 0 To 32             '用户输入KeyAscii为0-32的键 如空格
  1122.                 '显示录入载体
  1123.                 Call xswbk
  1124.             Case Else
  1125.                 '防止非编辑字段SendKeys()出现死循环
  1126.                 If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1127.                     Exit Sub
  1128.                 End If
  1129.                 '如果此字段为列表框录入则调入相应列表框
  1130.                 If GridBoolean(.Col, 3) Then
  1131.                     '列表框录入
  1132.                     Call xswbk
  1133.                 Else
  1134.                     Ydtext.Text = ""
  1135.                     '录入限制
  1136.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1137.                     If KeyAscii = 0 Then
  1138.                         Exit Sub
  1139.                     End If
  1140.                     '如果录入字符有效则写有效行数据标志
  1141.                     Call Xyxhbz(.Row)
  1142.                     Call xswbk
  1143.                     Ydtext.Text = ""
  1144.                     Valilock = True
  1145.                     SendKeys Chr(KeyAscii), True
  1146.                     DoEvents
  1147.                     Valilock = False
  1148.                 End If
  1149.         End Select
  1150.     End With
  1151. End Sub
  1152. Private Sub zjlrfl()                                                    '增加录入分录
  1153.     
  1154.     With WglrGrid
  1155.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1156.             If Not Fun_Drfrmyxxpd Then
  1157.                 Exit Sub
  1158.             End If
  1159.         Else
  1160.             Exit Sub
  1161.         End If
  1162.         If .Row < .FixedRows Then
  1163.             Exit Sub
  1164.         End If
  1165.         .AddItem "", .Row
  1166.         .RowHeight(.Row) = Sjhgd
  1167.         If .Row <> .Rows - 1 Then
  1168.             If .TextMatrix(.Row + 1, 0) = "*" Then
  1169.                 .TextMatrix(.Row, 0) = "*"
  1170.             Else
  1171.                 .RemoveItem .Rows - 1
  1172.             End If
  1173.         End If
  1174.         Call Xldqh
  1175.         Call Xldql
  1176.         Hyxxpdlock = False
  1177.     End With
  1178. End Sub
  1179. Private Sub Scdqfl()                                                    '删除当前分录
  1180.     Dim Answer As Integer, Scqwghz As Long, Scqwglz As Long, Hjlzte As Long, Sflrzt As Boolean
  1181.     With WglrGrid
  1182.         Scqwghz = .Row
  1183.         Scqwglz = .Col
  1184.         If .TextMatrix(.Row, 0) = "*" Then
  1185.             '判断是否为录入状态
  1186.             If Ydtext.Visible Or YdCombo.Visible Then
  1187.                 Sflrzt = True
  1188.                 Validate = True
  1189.                 Call Lrsjhx
  1190.                 Validate = False
  1191.             End If
  1192.             Call Xldqh
  1193.             Changelock = True
  1194.             .Select .Row, 0
  1195.             Changelock = False
  1196.             If Shsfts Then
  1197.                 .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = QBColor(12)
  1198.                 Tsxx = "请确认是否删除当前记录?"
  1199.                 yhAnswer = Xtxxts(Tsxx, 2, 2)
  1200.                 If yhAnswer = 2 Then
  1201.                     .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = &H80000005
  1202.                     Changelock = True
  1203.                     .Select Scqwghz, Scqwglz
  1204.                     Changelock = False
  1205.                     
  1206.                     '如为录入状态,则恢复录入
  1207.                     If Sflrzt Then
  1208.                         Call xswbk
  1209.                     End If
  1210.                     Exit Sub
  1211.                 End If
  1212.             End If
  1213.             .RemoveItem .Row
  1214.             If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  1215.                 .AddItem ""
  1216.                 .RowHeight(.Rows - 1) = Sjhgd
  1217.             End If
  1218.             Changelock = True
  1219.             .Select .Row, Scqwglz
  1220.             Changelock = False
  1221.    
  1222.             '重新计算合计数据
  1223.             For Hjlzte = Qslz To .Cols - 1
  1224.                 Call Sjhj(Hjlzte)
  1225.             Next Hjlzte
  1226.         End If
  1227.     End With
  1228. End Sub
  1229. Private Sub Sjhj(Hjwgl As Long)                                         '网格列数据合计
  1230.     
  1231.     Dim Hjjg As Double
  1232.     If Not GridBoolean(Hjwgl, 4) Then
  1233.         Exit Sub
  1234.     End If
  1235.     With WglrGrid
  1236.         Hjjg = 0
  1237.         For Jsqte = .FixedRows To .Rows - 1
  1238.             If .TextMatrix(Jsqte, 0) = "*" Then
  1239.                 Hjjg = Hjjg + Val(.TextMatrix(Jsqte, Hjwgl))
  1240.             End If
  1241.         Next Jsqte
  1242.         If GridBoolean(Hjwgl, 5) And Hjjg = 0 Then
  1243.             HjGrid.TextMatrix(0, Hjwgl) = ""
  1244.         Else
  1245.             HjGrid.TextMatrix(0, Hjwgl) = Hjjg
  1246.         End If
  1247.     End With
  1248. End Sub
  1249. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1250.     
  1251.     If Not GridBoolean(Sjl, 5) Then
  1252.         Exit Sub
  1253.     End If
  1254.     With WglrGrid
  1255.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
  1256.             .TextMatrix(sjh, Sjl) = ""
  1257.         End If
  1258.     End With
  1259. End Sub
  1260. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1261.     
  1262.     With WglrGrid
  1263.         If .Row >= .FixedRows Then
  1264.             If .TextMatrix(.Row, 0) <> "*" Then
  1265.                 For Rowjsq = .FixedRows To .Rows - 1
  1266.                     If .TextMatrix(Rowjsq, 0) <> "*" Then
  1267.                         Exit For
  1268.                     End If
  1269.                 Next Rowjsq
  1270.                 If Rowjsq <= .Rows - 1 Then
  1271.                     Changelock = True
  1272.                     .Select Rowjsq, .Col
  1273.                     Changelock = False
  1274.                 Else
  1275.                     Changelock = True
  1276.                     .Select .Rows - 1, .Col
  1277.                     Changelock = False
  1278.                 End If
  1279.             End If
  1280.             Call Xldqh
  1281.         End If
  1282.   End With
  1283.   
  1284. End Sub
  1285. Private Sub Xldqh()                                                      '显露当前行
  1286.   
  1287.     Dim Toprowte As Long
  1288.     With WglrGrid
  1289.         Toprowte = 0
  1290.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  1291.             Toprowte = .TopRow
  1292.             .TopRow = .TopRow + 1
  1293.         Loop
  1294.         Toprowte = 0
  1295.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  1296.             Toprowte = .TopRow
  1297.             If .TopRow > 1 Then
  1298.                 .TopRow = .TopRow - 1
  1299.             End If
  1300.         Loop
  1301.     End With
  1302. End Sub
  1303. Private Sub Xldql()                                                     '显露当前列
  1304.     
  1305.     Dim Leftcolte As Long
  1306.     With WglrGrid
  1307.         If .Col >= Qslz And .Col >= .FixedCols Then
  1308.             If .LeftCol > .Col Then
  1309.                 .LeftCol = .Col
  1310.             End If
  1311.             Leftcolte = 0
  1312.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  1313.                 Leftcolte = .LeftCol
  1314.                 .LeftCol = .LeftCol + 1
  1315.             Loop
  1316.         End If
  1317.     End With
  1318. End Sub
  1319. Private Function pdhwk(sjh As Long)                                     '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
  1320.     
  1321.     With WglrGrid
  1322.         For Coljsq = Qslz To .Cols - 1
  1323.             If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
  1324.                 pdhwk = False
  1325.                 Exit Function
  1326.             End If
  1327.         Next Coljsq
  1328.         pdhwk = True
  1329.     End With
  1330. End Function
  1331. Private Sub Xyxhbz(sjh As Long)                                         '写行有效性标志,并判断是否增行
  1332.     
  1333.     With WglrGrid
  1334.         If .TextMatrix(sjh, 0) = "*" Then
  1335.             Exit Sub
  1336.         End If
  1337.         .TextMatrix(sjh, 0) = "*"
  1338.         If sjh >= .Rows - Fzxwghs - 1 Then
  1339.             .AddItem ""
  1340.             .RowHeight(.Rows - 1) = Sjhgd
  1341.         End If
  1342.     End With
  1343. End Sub
  1344. '*****************************以下为文本框录入处理程序(固定不变部分)*******************************'
  1345. Private Sub Wbklrwbcl(Index As Integer)    '文本框录入事后处理程序
  1346.     '以下为依据实际情况自定义部分[
  1347.     
  1348.     '在此填写文本框录入事后处理程序
  1349.     
  1350.     If Index = 3 Then
  1351.       
  1352.         If Trim(LrText(Index).Text) = "" Then
  1353.             LrText(0).Text = ""
  1354.             Exit Sub
  1355.         End If
  1356.         
  1357.         LrText(0).Text = CreatBillCode(BillCode, False, , , Trim(LrText(3).Tag))
  1358.         
  1359.     End If
  1360.     
  1361.     ']以上为依据实际情况自定义部分
  1362. End Sub
  1363. Private Sub LrText_Change(Index As Integer)
  1364.     '屏蔽程序改变控制
  1365.     If TextChangeLock Then
  1366.         Exit Sub
  1367.     End If
  1368.    
  1369.     TextValiJudgeLock(Index) = False    '打开有效性判断锁
  1370.         
  1371.     '限制字段录入长度
  1372.           
  1373.     TextChangeLock = True  '加锁(防止执行Lrtext_Change)
  1374.     
  1375.     Call TextChangeLimit(LrText(Index), Textint(Index, 1))  '去掉无效字符
  1376.     
  1377.     Select Case Textint(Index, 1)
  1378.         Case 8, 11       '金额型
  1379.             Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
  1380.         Case 9, 12       '数量型
  1381.             Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
  1382.         Case 10          '单价型
  1383.             Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1384.         Case Else        '其他小数类型控制
  1385.             If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
  1386.                 Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
  1387.             End If
  1388.     End Select
  1389.     
  1390.     TextChangeLock = False '解锁
  1391.      
  1392. End Sub
  1393. Private Sub LrText_GotFocus(Index As Integer)                                                 '文本框得到焦点,显示相应信息
  1394.     Call TextShow(Index)
  1395. End Sub
  1396. Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)            '字段按F2键提供帮助
  1397.     
  1398.     Select Case KeyCode
  1399.         Case vbKeyF2
  1400.             Call Text_Help(Index)
  1401.     End Select
  1402. End Sub
  1403. Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer)                            '文本框录入事中控制
  1404.     Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
  1405. End Sub
  1406. Private Sub LrText_LostFocus(Index As Integer)                                                '文本框失去焦点进行有效性判断及相应处理
  1407.     
  1408.     If Textint(Index, 9) = 0 Or Textint(Index, 9) = 1 Then '事中判断
  1409.         Call TextYxxpd(Index)
  1410.     End If
  1411. End Sub
  1412. Private Sub Ydcommand1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) '点击按钮
  1413.     Call Text_Help(Ydcommand1.Tag)
  1414. End Sub
  1415. Private Sub Text_Help(Index As Integer)                                                       '录入字段帮助
  1416.     
  1417.     If Not Ydcommand1.Visible Then
  1418.         Exit Sub
  1419.     End If
  1420.     TextValiLock = True
  1421.     Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
  1422.     If Len(Xtfhcs) <> 0 Then
  1423.         If Textint(Index, 3) = 1 Then
  1424.             LrText(Index).Text = Xtfhcsfz
  1425.             LrText(Index).Tag = Xtfhcs
  1426.         Else
  1427.             LrText(Index).Text = Xtfhcs
  1428.             LrText(Index).Tag = Xtfhcsfz
  1429.         End If
  1430.     End If
  1431.     TextValiLock = False
  1432.     LrText(Index).SetFocus
  1433. End Sub
  1434. Private Sub TextShow(Index As Integer)        '文本框得到焦点,显示相应信息
  1435.     '如果文本框有帮助,则显示帮助按钮
  1436.     If Textboolean(Index, 1) Then
  1437.         Ydcommand1.Visible = True
  1438.         Ydcommand1.Move LrText(Index).Left + LrText(Index).Width, LrText(Index).Top
  1439.         Ydcommand1.Tag = Index
  1440.     Else
  1441.         Ydcommand1.Tag = ""
  1442.         Ydcommand1.Visible = False
  1443.     End If
  1444.     
  1445.     '[>>
  1446.     '可在此处定义其他处理动作
  1447.     '<<]
  1448. End Sub
  1449. Private Sub Wbkcsh()                          '录入文本框初始化
  1450.     Dim Int_TabIndex As Integer         'Tab焦点计数器
  1451.   
  1452.     '单据录入中文本框焦点由0开始
  1453.     LrText(0).TabIndex = 0
  1454.   
  1455.     '最大录入文本框索引值
  1456.     Max_Text_Index = Textvar(1)
  1457.   
  1458.     ReDim TextValiJudgeLock(Max_Text_Index)
  1459.     For Jsqte = 0 To Max_Text_Index
  1460.         
  1461.         '判断此文本框录入索引号是否存在,如存在则对其进行初始化
  1462.         If Len(Trim(Textstr(Jsqte, 1))) <> 0 Then
  1463.         
  1464.             '自动装入录入文本框和其解释标签
  1465.             If Jsqte <> 0 Then
  1466.                 Load LrText(Jsqte)
  1467.                 Load tsLabel(Jsqte)
  1468.            
  1469.                 '判断录入文本框是否显示
  1470.                 If Textboolean(Jsqte, 4) Then
  1471.                     LrText(Jsqte).Visible = True
  1472.                     tsLabel(Jsqte).Visible = True
  1473.                 Else
  1474.                     LrText(Jsqte).Visible = False
  1475.                     tsLabel(Jsqte).Visible = False
  1476.                 End If
  1477.             
  1478.                 '判断文本框是否可编辑
  1479.                 If Textboolean(Jsqte, 5) Then
  1480.                     LrText(Jsqte).Enabled = True
  1481.                 Else
  1482.                     LrText(Jsqte).Enabled = False
  1483.                 End If
  1484.             End If
  1485.            
  1486.            '初始化其内容
  1487.             TextChangeLock = True
  1488.             LrText(Jsqte).Text = ""
  1489.             LrText(Jsqte).Tag = ""
  1490.             If Textint(Jsqte, 5) <> 0 Then
  1491.                 LrText(Jsqte).MaxLength = Textint(Jsqte, 5)
  1492.             End If
  1493.             TextChangeLock = False
  1494.         
  1495.             '设置文本框位置及大小,并设置相应标签内容及其位置
  1496.             LrText(Jsqte).Move Textint(Jsqte, 13), Textint(Jsqte, 12), Textint(Jsqte, 11), Textint(Jsqte, 10)
  1497.             tsLabel(Jsqte).Caption = Textstr(Jsqte, 7) & ":"
  1498.             tsLabel(Jsqte).Move Textint(Jsqte, 13) - tsLabel(Jsqte).Width - 20, Textint(Jsqte, 12) + (Textint(Jsqte, 10) - tsLabel(Jsqte).Height) / 2 - 30
  1499.             
  1500.         End If
  1501.      
  1502.         '将文本框有效性判断进行加锁,在文本框内容发生变化时将锁打开
  1503.         TextValiJudgeLock(Jsqte) = True
  1504.         
  1505.     Next Jsqte
  1506.     
  1507.     '设置文本框焦点转移顺序(前提文本焦点从0至Max_Text_Index)
  1508.     For Int_TabIndex = 0 To Max_Text_Index
  1509.         For Jsqte = 0 To Max_Text_Index
  1510.             If Textint(Jsqte, 14) = Int_TabIndex Then
  1511.                LrText(Jsqte).TabIndex = Int_TabIndex
  1512.             End If
  1513.         Next Jsqte
  1514.     Next Int_TabIndex
  1515.   
  1516. End Sub
  1517. Private Function TextYxxpd(Index As Integer) As Boolean           '文本框有效性判断
  1518.   
  1519.     Dim SqlStr As String
  1520.     Dim Findrec As New ADODB.Recordset
  1521.   
  1522.     '按帮助不进行有效性判断
  1523.   
  1524.     If TextValiLock Then
  1525.         TextValiLock = False
  1526.         TextYxxpd = True
  1527.         Exit Function
  1528.     End If
  1529.   
  1530.     '文本框内容未曾改变不进行有效性判断
  1531.     If Index <> 3 Then
  1532.         If TextValiJudgeLock(Index) Then
  1533.             Ydcommand1.Visible = False
  1534.             TextYxxpd = True
  1535.             Exit Function
  1536.         End If
  1537.     End If
  1538.     
  1539.     '文本框内容为空认为有效,并清空其Tag值
  1540.   
  1541.     If Trim(LrText(Index)) = "" Then
  1542.         LrText(Index).Tag = ""
  1543.         Call Wbklrwbcl(Index)
  1544.         Ydcommand1.Visible = False
  1545.         TextValiJudgeLock(Index) = True
  1546.         TextYxxpd = True
  1547.         Exit Function
  1548.     End If
  1549.    
  1550.     '[>>
  1551.       
  1552.     '可在此加入不做有效性判断的理由(参照上面程序)
  1553.       
  1554.     '<<]
  1555.   
  1556.     Select Case Textint(Index, 4)
  1557.         Case 1      '编码型
  1558.             SqlStr = Trim(Textstr(Index, 5))
  1559.             SqlStr = Replace(SqlStr, "@", "'" + Trim(LrText(Index).Text) + "'")
  1560.             SqlStr = Replace(SqlStr, "$$", "'" + Trim(Xtczybm) + "'")
  1561.             Set Findrec = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1562.             If Findrec.EOF Then
  1563.                 Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
  1564.                 LrText(Index).SetFocus
  1565.                 Exit Function
  1566.             Else
  1567.                 Select Case Textint(Index, 3)
  1568.                     Case 0
  1569.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  1570.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  1571.                         End If
  1572.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  1573.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  1574.                         End If
  1575.                     Case 1
  1576.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  1577.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  1578.                         End If
  1579.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  1580.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  1581.                         End If
  1582.                 End Select
  1583.             End If
  1584.             
  1585.         Case 2      '日期型
  1586.             If IsDate(LrText(Index).Text) Then
  1587.                 LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
  1588.                 If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
  1589.                     LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
  1590.                 End If
  1591.             Else
  1592.                 Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
  1593.                 Call Xtxxts(Tsxx, 0, 1)
  1594.                 LrText(Index).SetFocus
  1595.                 Exit Function
  1596.             End If
  1597.         Case 3      '其他类型
  1598.     End Select
  1599.     
  1600.     If Index = 3 Then
  1601.         '此仓库已期末处理,不允许增加单据
  1602.         Set Findrec = Cw_DataEnvi.DataConnect.Execute("select whcode,whname,pricemode from Gy_warehouse " & _
  1603.                 " where whcode='" & Trim(LrText(Index).Tag) & "' and enddealflagchhs=0 ")
  1604.         If Findrec.EOF Then
  1605.             Tsxx = "此仓库已期末处理,不允许增加单据!"
  1606.             TextValiJudgeLock(Index) = False
  1607.             LrText(Index).SetFocus
  1608.             TextValiLock = False
  1609.             Ydcommand1.Visible = True
  1610.             Call Xtxxts(Tsxx, 0, 1)
  1611.             Exit Function
  1612.         Else
  1613.             PriceMode = Trim(Findrec.Fields("pricemode"))
  1614.         End If
  1615.     End If
  1616.     
  1617.     '隐藏帮助按钮
  1618.     Ydcommand1.Visible = False
  1619.    
  1620.     '如果有效则加锁,用户不改变内容则不再进行有效性判断
  1621.     TextValiJudgeLock(Index) = True
  1622.     '调用文本框事后处理程序
  1623.     Call Wbklrwbcl(Index)
  1624.     
  1625.     TextYxxpd = True
  1626.     
  1627. End Function