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

企业管理

开发平台:

Visual Basic

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