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

企业管理

开发平台:

Visual Basic

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