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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "VSOCX7.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  4. Begin VB.Form Ed_EmpCorArFrm 
  5.    BackColor       =   &H00C0C0C0&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "相关档案维护"
  8.    ClientHeight    =   6990
  9.    ClientLeft      =   675
  10.    ClientTop       =   720
  11.    ClientWidth     =   11400
  12.    HelpContextID   =   2113002
  13.    Icon            =   "处理_相关档案维护.frx":0000
  14.    KeyPreview      =   -1  'True
  15.    LinkTopic       =   "Form4"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   6990
  19.    ScaleWidth      =   11400
  20.    StartUpPosition =   1  '所有者中心
  21.    Begin VB.CommandButton Ydcommand 
  22.       Height          =   300
  23.       Left            =   10980
  24.       Picture         =   "处理_相关档案维护.frx":1042
  25.       Style           =   1  'Graphical
  26.       TabIndex        =   1
  27.       Top             =   2730
  28.       Visible         =   0   'False
  29.       Width           =   300
  30.    End
  31.    Begin VB.PictureBox Pic_Title 
  32.       BackColor       =   &H00FFFFFF&
  33.       Height          =   765
  34.       Left            =   0
  35.       Picture         =   "处理_相关档案维护.frx":13CC
  36.       ScaleHeight     =   705
  37.       ScaleWidth      =   11745
  38.       TabIndex        =   7
  39.       Top             =   600
  40.       Width           =   11805
  41.       Begin MSComctlLib.ImageList ImageList1 
  42.          Left            =   10320
  43.          Top             =   420
  44.          _ExtentX        =   1005
  45.          _ExtentY        =   1005
  46.          BackColor       =   -2147483643
  47.          ImageWidth      =   16
  48.          ImageHeight     =   16
  49.          MaskColor       =   12632256
  50.          _Version        =   393216
  51.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  52.             NumListImages   =   26
  53.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  54.                Picture         =   "处理_相关档案维护.frx":1E30C
  55.                Key             =   "sz"
  56.             EndProperty
  57.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  58.                Picture         =   "处理_相关档案维护.frx":1E6A6
  59.                Key             =   "dy"
  60.             EndProperty
  61.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  62.                Picture         =   "处理_相关档案维护.frx":1EA40
  63.                Key             =   "yl"
  64.             EndProperty
  65.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  66.                Picture         =   "处理_相关档案维护.frx":1EDDA
  67.                Key             =   "xg"
  68.             EndProperty
  69.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  70.                Picture         =   "处理_相关档案维护.frx":1F174
  71.                Key             =   "zh"
  72.             EndProperty
  73.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  74.                Picture         =   "处理_相关档案维护.frx":1F50E
  75.                Key             =   "sh"
  76.             EndProperty
  77.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  78.                Picture         =   "处理_相关档案维护.frx":1F8A8
  79.                Key             =   "bc"
  80.             EndProperty
  81.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  82.                Picture         =   "处理_相关档案维护.frx":1FC42
  83.                Key             =   "fq"
  84.             EndProperty
  85.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  86.                Picture         =   "处理_相关档案维护.frx":1FFDC
  87.                Key             =   "bz"
  88.             EndProperty
  89.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  90.                Picture         =   "处理_相关档案维护.frx":20376
  91.                Key             =   "tc"
  92.             EndProperty
  93.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  94.                Picture         =   "处理_相关档案维护.frx":20710
  95.                Key             =   "bcgs"
  96.             EndProperty
  97.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  98.                Picture         =   "处理_相关档案维护.frx":20AAA
  99.                Key             =   "mrlk"
  100.             EndProperty
  101.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  102.                Picture         =   "处理_相关档案维护.frx":20E44
  103.                Key             =   "xsxm"
  104.             EndProperty
  105.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  106.                Picture         =   "处理_相关档案维护.frx":211DE
  107.                Key             =   "first"
  108.             EndProperty
  109.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  110.                Picture         =   "处理_相关档案维护.frx":21578
  111.                Key             =   "prev"
  112.             EndProperty
  113.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  114.                Picture         =   "处理_相关档案维护.frx":21912
  115.                Key             =   "next"
  116.             EndProperty
  117.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  118.                Picture         =   "处理_相关档案维护.frx":21CAC
  119.                Key             =   "last"
  120.             EndProperty
  121.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  122.                Picture         =   "处理_相关档案维护.frx":22046
  123.                Key             =   "xx"
  124.             EndProperty
  125.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  126.                Picture         =   "处理_相关档案维护.frx":223E0
  127.                Key             =   "define"
  128.             EndProperty
  129.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  130.                Picture         =   "处理_相关档案维护.frx":2277A
  131.                Key             =   "exec"
  132.             EndProperty
  133.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  134.                Picture         =   "处理_相关档案维护.frx":22B14
  135.                Key             =   "xz"
  136.             EndProperty
  137.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  138.                Picture         =   "处理_相关档案维护.frx":22EAE
  139.                Key             =   "sc"
  140.             EndProperty
  141.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  142.                Picture         =   "处理_相关档案维护.frx":23248
  143.                Key             =   "sx"
  144.             EndProperty
  145.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  146.                Picture         =   "处理_相关档案维护.frx":235E2
  147.                Key             =   "cx"
  148.             EndProperty
  149.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  150.                Picture         =   "处理_相关档案维护.frx":2397C
  151.                Key             =   "zd"
  152.             EndProperty
  153.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  154.                Picture         =   "处理_相关档案维护.frx":23D16
  155.                Key             =   "arsort"
  156.             EndProperty
  157.          EndProperty
  158.       End
  159.       Begin VB.Label Label2 
  160.          AutoSize        =   -1  'True
  161.          BackStyle       =   0  'Transparent
  162.          Caption         =   "相关档案维护"
  163.          BeginProperty Font 
  164.             Name            =   "宋体"
  165.             Size            =   12
  166.             Charset         =   134
  167.             Weight          =   700
  168.             Underline       =   0   'False
  169.             Italic          =   0   'False
  170.             Strikethrough   =   0   'False
  171.          EndProperty
  172.          Height          =   240
  173.          Left            =   660
  174.          TabIndex        =   11
  175.          Top             =   240
  176.          Width           =   1530
  177.       End
  178.       Begin VB.Label Lbl_ArName 
  179.          AutoSize        =   -1  'True
  180.          BackStyle       =   0  'Transparent
  181.          Caption         =   "档案类别:"
  182.          Height          =   180
  183.          Left            =   2430
  184.          TabIndex        =   10
  185.          Top             =   255
  186.          Width           =   810
  187.       End
  188.       Begin VB.Label Lbl_EmpNo 
  189.          AutoSize        =   -1  'True
  190.          BackStyle       =   0  'Transparent
  191.          Caption         =   "职工号:"
  192.          Height          =   180
  193.          Left            =   5700
  194.          TabIndex        =   9
  195.          Top             =   270
  196.          Visible         =   0   'False
  197.          Width           =   1920
  198.       End
  199.       Begin VB.Label Lbl_EmpName 
  200.          AutoSize        =   -1  'True
  201.          BackStyle       =   0  'Transparent
  202.          Caption         =   "姓名:"
  203.          Height          =   180
  204.          Left            =   7710
  205.          TabIndex        =   8
  206.          Top             =   270
  207.          Visible         =   0   'False
  208.          Width           =   450
  209.       End
  210.    End
  211.    Begin VB.TextBox Ydtext 
  212.       BackColor       =   &H00C0FFFF&
  213.       BorderStyle     =   0  'None
  214.       Height          =   330
  215.       Left            =   9300
  216.       MultiLine       =   -1  'True
  217.       TabIndex        =   0
  218.       Top             =   2340
  219.       Visible         =   0   'False
  220.       Width           =   1185
  221.    End
  222.    Begin VB.ComboBox YdCombo 
  223.       Height          =   300
  224.       Left            =   9300
  225.       Style           =   2  'Dropdown List
  226.       TabIndex        =   3
  227.       Top             =   2730
  228.       Visible         =   0   'False
  229.       Width           =   1665
  230.    End
  231.    Begin VB.Timer Timer1 
  232.       Interval        =   1
  233.       Left            =   10530
  234.       Top             =   2280
  235.    End
  236.    Begin VSFlex8Ctl.VSFlexGrid WglrGrid 
  237.       Height          =   5490
  238.       Left            =   45
  239.       TabIndex        =   4
  240.       Top             =   1500
  241.       Width           =   8205
  242.       _ExtentX        =   14473
  243.       _ExtentY        =   9684
  244.       Appearance      =   1
  245.       BorderStyle     =   1
  246.       Enabled         =   -1  'True
  247.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  248.          Name            =   "宋体"
  249.          Size            =   9
  250.          Charset         =   134
  251.          Weight          =   400
  252.          Underline       =   0   'False
  253.          Italic          =   0   'False
  254.          Strikethrough   =   0   'False
  255.       EndProperty
  256.       MousePointer    =   0
  257.       BackColor       =   16777215
  258.       ForeColor       =   -2147483640
  259.       BackColorFixed  =   12632256
  260.       ForeColorFixed  =   -2147483630
  261.       BackColorSel    =   -2147483635
  262.       ForeColorSel    =   -2147483634
  263.       BackColorBkg    =   -2147483636
  264.       BackColorAlternate=   16777215
  265.       GridColor       =   -2147483633
  266.       GridColorFixed  =   -2147483632
  267.       TreeColor       =   -2147483632
  268.       FloodColor      =   192
  269.       SheetBorder     =   -2147483642
  270.       FocusRect       =   1
  271.       HighLight       =   1
  272.       AllowSelection  =   -1  'True
  273.       AllowBigSelection=   -1  'True
  274.       AllowUserResizing=   0
  275.       SelectionMode   =   0
  276.       GridLines       =   1
  277.       GridLinesFixed  =   2
  278.       GridLineWidth   =   1
  279.       Rows            =   50
  280.       Cols            =   10
  281.       FixedRows       =   1
  282.       FixedCols       =   1
  283.       RowHeightMin    =   0
  284.       RowHeightMax    =   0
  285.       ColWidthMin     =   0
  286.       ColWidthMax     =   0
  287.       ExtendLastCol   =   0   'False
  288.       FormatString    =   ""
  289.       ScrollTrack     =   0   'False
  290.       ScrollBars      =   3
  291.       ScrollTips      =   0   'False
  292.       MergeCells      =   0
  293.       MergeCompare    =   0
  294.       AutoResize      =   -1  'True
  295.       AutoSizeMode    =   0
  296.       AutoSearch      =   0
  297.       MultiTotals     =   -1  'True
  298.       SubtotalPosition=   1
  299.       OutlineBar      =   0
  300.       OutlineCol      =   0
  301.       Ellipsis        =   0
  302.       ExplorerBar     =   0
  303.       PicturesOver    =   0   'False
  304.       FillStyle       =   0
  305.       RightToLeft     =   0   'False
  306.       PictureType     =   0
  307.       TabBehavior     =   0
  308.       OwnerDraw       =   0
  309.       Editable        =   0   'False
  310.       ShowComboButton =   -1  'True
  311.       WordWrap        =   0   'False
  312.       TextStyle       =   0
  313.       TextStyleFixed  =   0
  314.       OleDragMode     =   0
  315.       OleDropMode     =   0
  316.       DataMode        =   0
  317.       VirtualData     =   -1  'True
  318.    End
  319.    Begin MSComctlLib.Toolbar Tlb_Action 
  320.       Align           =   1  'Align Top
  321.       Height          =   570
  322.       Left            =   0
  323.       TabIndex        =   2
  324.       Top             =   0
  325.       Width           =   11400
  326.       _ExtentX        =   20108
  327.       _ExtentY        =   1005
  328.       ButtonWidth     =   820
  329.       ButtonHeight    =   953
  330.       AllowCustomize  =   0   'False
  331.       Wrappable       =   0   'False
  332.       Appearance      =   1
  333.       Style           =   1
  334.       ImageList       =   "ImageList1"
  335.       _Version        =   393216
  336.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  337.          NumButtons      =   11
  338.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  339.             Caption         =   "设置"
  340.             Key             =   "ymsz"
  341.             Object.ToolTipText     =   "打印页面设置"
  342.             ImageKey        =   "sz"
  343.          EndProperty
  344.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  345.             Caption         =   "打印"
  346.             Key             =   "dy"
  347.             Object.ToolTipText     =   "打印当前单据或Ctrl+P"
  348.             ImageKey        =   "dy"
  349.          EndProperty
  350.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  351.             Caption         =   "预览"
  352.             Key             =   "yl"
  353.             ImageKey        =   "yl"
  354.          EndProperty
  355.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  356.             Style           =   3
  357.          EndProperty
  358.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  359.             Caption         =   "增行"
  360.             Key             =   "zh"
  361.             ImageKey        =   "zh"
  362.          EndProperty
  363.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  364.             Caption         =   "删行"
  365.             Key             =   "sh"
  366.             Object.ToolTipText     =   "删除当前记录行或Delete"
  367.             ImageKey        =   "sh"
  368.          EndProperty
  369.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  370.             Style           =   3
  371.          EndProperty
  372.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  373.             Caption         =   "类别"
  374.             Key             =   "arsort"
  375.             ImageKey        =   "arsort"
  376.          EndProperty
  377.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  378.             Style           =   3
  379.          EndProperty
  380.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  381.             Caption         =   "帮助"
  382.             Key             =   "bz"
  383.             ImageKey        =   "bz"
  384.          EndProperty
  385.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  386.             Caption         =   "退出"
  387.             Key             =   "fh"
  388.             ImageKey        =   "tc"
  389.          EndProperty
  390.       EndProperty
  391.       BorderStyle     =   1
  392.       Begin MSComctlLib.Toolbar GsToolbar 
  393.          Height          =   540
  394.          Left            =   9720
  395.          TabIndex        =   6
  396.          Top             =   0
  397.          Width           =   1695
  398.          _ExtentX        =   2990
  399.          _ExtentY        =   953
  400.          ButtonWidth     =   1455
  401.          ButtonHeight    =   953
  402.          AllowCustomize  =   0   'False
  403.          Appearance      =   1
  404.          Style           =   1
  405.          ImageList       =   "ImageList1"
  406.          _Version        =   393216
  407.          BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  408.             NumButtons      =   2
  409.             BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  410.                Caption         =   "保存格式"
  411.                Key             =   "bcgs"
  412.                ImageKey        =   "bcgs"
  413.             EndProperty
  414.             BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  415.                Caption         =   "默认列宽"
  416.                Key             =   "hfmrgs"
  417.                ImageKey        =   "mrlk"
  418.             EndProperty
  419.          EndProperty
  420.       End
  421.    End
  422.    Begin VB.Label Lab_OperStatus 
  423.       BackColor       =   &H000080FF&
  424.       Caption         =   "1"
  425.       Height          =   345
  426.       Left            =   10980
  427.       TabIndex        =   5
  428.       Top             =   2310
  429.       Visible         =   0   'False
  430.       Width           =   345
  431.    End
  432. End
  433. Attribute VB_Name = "Ed_EmpCorArFrm"
  434. Attribute VB_GlobalNameSpace = False
  435. Attribute VB_Creatable = False
  436. Attribute VB_PredeclaredId = True
  437. Attribute VB_Exposed = False
  438. '**************************************************************************************************
  439. '*    模 块 名 称 :相关档案维护(增行式)
  440. '*    功 能 描 述 :直接录入人员的相关档案
  441. '*    程序员姓名  :刘  刚
  442. '*    最后修改人  :刘  刚
  443. '*    最后修改时间:2002/01/03
  444. '*    备        注:程序中所有依实际情况自定义部分均用[>> <<]括起,注意此种录入需要修改"Sub Scdqfl"
  445. '*
  446. '*    1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
  447. '*
  448. '*    3.Lab_OperStatus 用此标签来标识单据录入状态(默认值为1) 1-浏览 2-修改
  449. '**************************************************************************************************
  450.  
  451.  '以下为自定义变量
  452.  
  453. Public int_if As Integer                        '1直接录入,0查询列表调用
  454. Public EmpId As String                          '职工ID
  455. '其它固定使用变量
  456. Dim Tsxx As String                              '系统信息提示(Fixed)
  457. Dim ReportTitle As String                       '报表主标题(Fixed)
  458. Dim Str_RightEdit As String             '编辑(新增、修改、删除)权限索引
  459.     
  460. '以下为固定使用变量(网格)
  461. Dim Cxnrrec As New ADODB.Recordset              '显示查询内容动态集
  462. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  463. Dim GridCode As String                          '显示网格网格代码
  464. Dim GridInf() As Variant                        '整个网格设置信息
  465. Dim Pmbcsjhs As Long                            '屏幕网格保持数据行数(大于等于1)
  466. Dim Fzxwghs As Integer                          '辅助项网格行数(包括合计行)
  467. Dim Sfxshjwg As Boolean                         '是否显示合计网格
  468. Dim Qslz As Long                                '网格隐藏(非操作显示)列数
  469. Dim Sjhgd As Double                             '网格数据行高度
  470. Dim GridBoolean() As Boolean                    '网格列信息(布尔型)
  471. Dim GridStr()  As String                        '网格列信息(字符型)
  472. Dim GridInt() As Integer                        '网格列信息(整型)
  473. Dim Sfblbzkd As Boolean                         '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  474. Dim Dqlrwgh As Long                             '当前录入数据网格行
  475. Dim Dqlrwgl As Long                             '当前录入数据网格列
  476. Dim Dqlkwgh As Long                             '刚刚离开网格行(不一定为录入行)
  477. Dim Dqlkwgl As Long                             '刚刚离开网格列
  478. Dim Dqtoprow As Long                            '当前录入状态时最上端可视行
  479. Dim Dqleftcol As Long                           '当前录入状态时最左端可视列
  480. Dim Zdlrqnr As String                           '字段录入修改前内容(用来判断内容是否修改)
  481. Dim Wbkbhlock As Boolean                        '文本框改变值锁
  482. Dim Changelock As Boolean                       '网格行列改变控制锁(用来区别用户改变.程序改变)
  483. Dim Gdtlock As Boolean                          '滚动条滚动控制(用来区别用户改变.程序改变)
  484. Dim Yxxpdlock As Boolean                        '字段有效性判断锁(内容不修改不需进行字段有效性判断)
  485. Dim Hyxxpdlock As Boolean                       '行有效性判断锁(字段内容不修改不需进行行有效性判断)
  486. Dim Valilock As Boolean                         '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
  487. Dim Shsfts As Boolean                           '删除记录行是否提示
  488. Dim Szzls As Integer                            '网格信息数组最大下标值(网格列数-1)
  489. Private Sub Form_KeyPress(KeyAscii As Integer)      '控制焦点转移和限制录入字符"'"
  490.     
  491.     Select Case KeyAscii
  492.     Case 39           '屏蔽字符"'"
  493.         KeyAscii = 0
  494.     End Select
  495.     
  496. End Sub
  497. Private Sub Form_Load()                              '窗 体 装 入
  498.     
  499.     '初始化各种锁值(Fixed)
  500.     Changelock = False             '网格行列改变控制锁
  501.     Gdtlock = False                '滚动条滚动控制
  502.     Yxxpdlock = True               '字段有效性判断锁
  503.     Hyxxpdlock = True              '行有效性判断锁
  504.     Wbkbhlock = False              '文本框内容改变锁
  505.     
  506.     '报表主标题及报表编码(Fixed)
  507.     ReportTitle = "相 关 档 案"
  508.     XtReportCode = "Rs_CorAr"
  509.     Load Dyymctbl
  510.     
  511.     
  512.     '调 入 网 格(Fixed)
  513.     
  514.     WglrGrid.Rows = 0
  515.     WglrGrid.Cols = 0
  516.     '设置标题栏宽度、网格宽度高度(Fixed)
  517.     Pic_Title.Move 50, Pic_Title.Top, Me.Width - 150, Pic_Title.Height
  518.     WglrGrid.Move 50, Pic_Title.Top + Pic_Title.Height, Me.Width - 150
  519.     WglrGrid.Height = Me.Height - WglrGrid.Top - 380
  520.     WglrGrid.Enabled = False
  521.     
  522.     '生成查询结果
  523.     'Call Sub_Query
  524.     
  525.     
  526.     '设置状态为修改状态
  527.     Lab_OperStatus = "2"
  528.     If int_if = 0 Then
  529.         Lbl_EmpNo.Visible = True
  530.         Lbl_EmpName.Visible = True
  531.     End If
  532.     
  533.     '编辑(增行、删行)权限索引
  534.     Str_RightEdit = "Rs_Ed_EmpCorAr_Edit"
  535.           
  536. End Sub
  537. Private Sub Form_Unload(Cancel As Integer)           '窗体卸载
  538.     
  539.     '调入其它窗体或功能产生的有效性判断(包括数据回写)
  540.     If Not Fun_Drfrmyxxpd Then
  541.         Cancel = True
  542.         Exit Sub
  543.     End If
  544.     
  545.     '卸载打印页面窗体
  546.     Unload Dyymctbl
  547.     
  548. End Sub
  549. Private Sub Sub_Query()                            '生成查询结果
  550.     
  551.     Dim Sqlstr As String                           '临时使用字符串
  552.     Dim tmpRs As New ADODB.Recordset               '临时使用动态集
  553.     Dim jsqte As Long                              '临时计数器
  554.     '禁止网格刷新动作,为加快网格显示速度(Fixed)
  555.     WglrGrid.Redraw = False
  556.     '查询字符串
  557.     If int_if = 1 Then
  558.         Sqlstr = "SELECT * FROM Rs_ArMain WHERE 1=2"
  559.     Else
  560.         Sqlstr = "SELECT * FROM Rs_ArMain WHERE ArSort ='" & Lbl_ArName.Tag & "' AND EmpId = '" & EmpId & "' ORDER BY SNo"
  561.     End If
  562.     Set tmpRs = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  563.     With tmpRs
  564.         WglrGrid.Rows = WglrGrid.FixedRows
  565.         jsqte = WglrGrid.FixedRows
  566.         Do While Not .EOF
  567.             WglrGrid.AddItem ""
  568.             WglrGrid.TextMatrix(jsqte, 0) = "*"                                                                             '有效记录标识
  569.             WglrGrid.TextMatrix(jsqte, 1) = .Fields("EmpId")                                                                '记录唯一标识
  570.             WglrGrid.TextMatrix(jsqte, 2) = .Fields("EmpId")                                                                '职工ID
  571.             WglrGrid.TextMatrix(jsqte, 3) = Trim(.Fields("SNo") & "")                                                       '档案序号
  572.             i = 1: j = 1
  573.             While i <= WglrGrid.Cols - 4 - 2
  574.                 If Searched(j + 2) Then
  575.                     WglrGrid.TextMatrix(jsqte, Sydz(Format(j + 2, "000"), GridStr(), Szzls)) = Trim(.Fields(Lbl_ArName.Tag & Format(j, "000")) & "")
  576.                     i = i + 1
  577.                 End If
  578.                 j = j + 1
  579.             Wend
  580.             '<<]
  581.             WglrGrid.RowHeight(jsqte) = 300 'Sjhgd
  582.             .MoveNext
  583.             jsqte = jsqte + 1
  584.         Loop
  585.     End With
  586.     '将网格刷新解禁(Fixed)
  587.     WglrGrid.Redraw = True
  588.     '调整网格(Fixed)
  589.     Call Sub_AdjustGrid
  590. End Sub
  591. Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)             '用户点击工具条
  592.     
  593.     '屏蔽文本框,下拉组合框有效性判断
  594.     
  595.     Valilock = True
  596.     
  597.     '屏蔽网格失去焦点产生的有效性判断
  598.     
  599.     Changelock = True
  600.     
  601.     Select Case Button.Key
  602.     Case "ymsz"                                          '页面设置
  603.         Dyymctbl.Show 1
  604.     Case "yl"                                            '预 览
  605.         If WglrGrid.Rows - WglrGrid.FixedRows = 0 Then Exit Sub
  606.         If Fun_Drfrmyxxpd Then
  607.             Call bbyl(True)
  608.         End If
  609.     Case "dy"                                            '打 印
  610.         If WglrGrid.Rows - WglrGrid.FixedRows = 0 Then Exit Sub
  611.         If Fun_Drfrmyxxpd Then
  612.             Call bbyl(False)
  613.         End If
  614.     Case "zh"                                            '增 行
  615.         '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  616.         If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
  617.             Exit Sub
  618.         End If
  619.         If WglrGrid.Rows - WglrGrid.FixedRows = 0 Then Exit Sub
  620.         Call zjlrfl
  621.     Case "sh"                                            '删 行
  622.         '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  623.         If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
  624.             Exit Sub
  625.         End If
  626.         If WglrGrid.Rows - WglrGrid.FixedRows = 0 Then Exit Sub
  627.         Call Scdqfl
  628.     Case "arsort"                                       '选择档案类别
  629.         Call SelectArSort
  630.     Case "bz"                                            '帮 助
  631.         Call F1bz
  632.     Case "fh"                                            '退 出
  633.         Unload Me
  634.     End Select
  635.     
  636.     '解 锁
  637.     Valilock = False
  638.     Changelock = False
  639.     
  640. End Sub
  641. Private Function SelectArSort() As Boolean
  642. Dim tmpRs As New ADODB.Recordset
  643.     
  644.     Set tmpRs = Cw_DataEnvi.DataConnect.Execute("SELECT * FROM Rs_ArSort ")
  645.     If tmpRs.EOF Then
  646.         Call Xtxxts("请先设置档案类别!", 0, 1)
  647.         Exit Function
  648.     End If
  649.     Ed_EmpCorArSortFrm.Show 1
  650.     If Trim(Ed_EmpCorArSortFrm.Cbo_ArSort.Tag) <> "" Then
  651.         Lbl_ArName.Tag = Ed_EmpCorArSortFrm.Cbo_ArSort.Tag
  652.         Lbl_ArName.Caption = "档案类别:  " & Ed_EmpCorArSortFrm.Cbo_ArSort.Text
  653.         
  654.         Call Ini_Grid
  655.         WglrGrid.SetFocus
  656.     End If
  657. End Function
  658. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)        '支持热键操作
  659.     
  660.     If Shift = 2 Then
  661.         Select Case UCase(Chr(KeyCode))
  662.         Case "P"                   'Ctrl+P 打印
  663.             If Tlb_Action.Buttons("dy").Enabled Then
  664.                 Call bbyl(False)
  665.             End If
  666.         End Select
  667.     End If
  668.     
  669. End Sub
  670. Private Sub Wbkcl()                                                 '文本框录入之前处理(根据实际情况)
  671.     
  672.     Dim xswbrr As String
  673.     
  674.     With WglrGrid
  675.         Zdlrqnr = Trim(.Text)
  676.         xswbrr = Trim(.Text)
  677.         
  678.         If GridBoolean(.Col, 3) Then   '列表框录入
  679.             
  680.             '填充列表框程序
  681.             Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
  682.         Else
  683.             Wbkbhlock = True
  684.             
  685.             '====以下为用户自定义
  686.             Ydtext.Text = xswbrr
  687.             '====以上为用户自定义
  688.             
  689.             Wbkbhlock = False
  690.             Ydtext.SelStart = Len(Ydtext.Text)
  691.         End If
  692.     End With
  693.     
  694. End Sub
  695. Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long) As Boolean       '录入数据字段有效性判断,同时进行字段录入事后处理
  696.     '函数参数:Dqpdwgh, Dqpdwgl 当前要判断网格单元所处行列值
  697.     Dim Str_JudgeText As String                 '临时有效性判断字段内容(Fixed)
  698.     Dim Coljsq As Long                          '临时列计数器(Fixed)
  699.     Dim RecTemp   As New ADODB.Recordset          '临时使用动态集(Fixed)
  700.     Dim tmpRs As New ADODB.Recordset
  701.     
  702.     Dim Sqlstr As String                        '临时使用查询字符串(Fixed)
  703.     Dim tmpNo As Integer
  704.     
  705.     With WglrGrid
  706.         
  707.         '非录入状态或非数据行则其有效性为合法(Fixed)
  708.         If Yxxpdlock Or .Row < .FixedRows Then
  709.             sjzdyxxpd = True
  710.             Exit Function
  711.         End If
  712.         
  713.         '取得当前要判断字段内容(Fixed)
  714.         Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
  715.         
  716.         '根据不同字段进行相应的处理(依据其逻辑编号)
  717.         Select Case GridInt(Dqpdwgl, 1)
  718.             Case "7"                                                            '日期型
  719.                 If Not Trim(Str_JudgeText) = "" Then
  720.                     If Not IsDate(Trim(Str_JudgeText)) Then
  721.                         Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
  722.                         GoTo Lrcwcl
  723.                     End If
  724.                 End If
  725.             
  726.         End Select
  727.         Select Case GridStr(Dqpdwgl, 1)
  728.             '[>>以下为自定义部分
  729.         Case "001"                   '职工号(字段不为空则做有效性判断及事后处理)
  730.             If Not Trim(Str_JudgeText) = "" Then
  731. '                **********************下面的代码,在根据工号选姓名时,可以参考
  732.                 '1.放置字段有效性判断
  733.                 Sqlstr = "SELECT EmpId,EmpName From Rs_BasicInfo WHERE EmpNo ='" & Str_JudgeText & "' AND YNStop <> 1"
  734.                 Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  735.                 If Not RecTemp.EOF Then
  736.                     .TextMatrix(Dqpdwgh, 2) = Trim(RecTemp.Fields("EmpId") & "")
  737.                 Else
  738.                     Tsxx = "此职工不存在!"
  739.                     GoTo Lrcwcl
  740.                 End If
  741.                 
  742.                 Sqlstr = "IF EXISTS(SELECT Sno FROM  Rs_ArMain WHERE ArSort ='" & Lbl_ArName.Tag & "' AND EmpId = " & .TextMatrix(Dqpdwgh, 2) & ")"
  743.                 Sqlstr = Sqlstr & " SELECT no= MAX(Sno)+1 FROM Rs_ArMain WHERE ArSort ='" & Lbl_ArName.Tag & "' AND EmpId ='" & WglrGrid.TextMatrix(Dqpdwgh, 2) & "'"
  744.                 Sqlstr = Sqlstr & " ELSE SELECT no =1 "
  745.                 Set tmpRs = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  746.                 If Not tmpRs.EOF Then
  747.                     tmpNo = tmpRs.Fields("no")
  748.                 End If
  749.                 
  750.                 '2.放置字段事后处理程序
  751.                 .TextMatrix(Dqpdwgh, 2) = Trim(RecTemp.Fields("EmpId") & "")                                        '隐藏EmpId
  752.                 .TextMatrix(Dqpdwgh, 3) = tmpNo                                                                     '档案序号
  753.                 .TextMatrix(Dqpdwgh, Sydz("002", GridStr(), Szzls)) = Trim(RecTemp.Fields("EmpName") & "")          '职工姓名
  754.             Else
  755.                 '3.清空相关字段
  756.                 .TextMatrix(Dqpdwgh, Sydz("002", GridStr(), Szzls)) = ""                                            '职工姓名
  757.             End If
  758.             '<<以上为自定义部分]
  759.         End Select
  760.         
  761.         '字段录入正确后为零字段清空(Fixed)
  762.         Call Qkwlzd(Dqpdwgh, Dqpdwgl)
  763.                 
  764.         
  765.         '字段有效性判断通过,将字段有效性判断加锁直至再次改变(Fixed)
  766.         sjzdyxxpd = True
  767.         Yxxpdlock = True
  768.         Exit Function
  769.     End With
  770.     
  771. Lrcwcl:    '录入错误处理(Fixed)
  772.     
  773.     With WglrGrid
  774.         '给出错误提示信息
  775.         Call Xtxxts(Tsxx, 0, 1)
  776.         
  777.         '返回网格错误位置(ChangeLock避免再次引发RowColChange有效性判断),装入录入载体
  778.         Changelock = True
  779.         .Select Dqpdwgh, Dqpdwgl
  780.         Changelock = False
  781.         Call xswbk
  782.         
  783.         '函数返回False
  784.         sjzdyxxpd = False
  785.         Exit Function
  786.     End With
  787.     
  788. End Function
  789. Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean                  '录入数据行有效性判断,同时进行行处理
  790.     
  791.     Dim Lrywlz As Long                     '录入错误列值(Fixed)
  792.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  793.     Dim Sqlstr As String                   '临时查询字符串
  794.     Dim ItmEmpty As Boolean
  795.     Dim tmpNo As Integer
  796.     Dim i As Integer
  797.     With WglrGrid
  798.         
  799.         '判断行为空和无效数据行则清除当前行
  800.         If .Rows <= .FixedRows Then Exit Function   ' 如果没有记录,则退出
  801.         If .TextMatrix(Yxxpdh, 0) <> "*" Then
  802.             Sjhzyxxpd = True
  803.             Exit Function
  804.         Else
  805.             If pdhwk(Yxxpdh) And Yxxpdh + 1 <= .Rows - 1 Then
  806.                 If .TextMatrix(Yxxpdh + 1, 0) <> "*" Then
  807.                     Changelock = True
  808.                     .RemoveItem Yxxpdh                                  '取消的情况删行
  809.                     
  810.                     If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  811.                         .AddItem ""
  812.                         .RowHeight(.Rows - 1) = Sjhgd
  813.                     End If
  814.                     
  815.                     Changelock = False
  816.                     Sjhzyxxpd = True
  817.                     Exit Function
  818.                 End If
  819.             End If
  820.         End If
  821.         
  822.         '行没有发生变化则不进行有效性判断
  823.         If Hyxxpdlock Then
  824.             Sjhzyxxpd = True
  825.             Exit Function
  826.         End If
  827.         
  828.         '以下为自定义部分[
  829.         
  830.         '1.1首先进行单个不能为空或不能为零判断(Fixed)
  831.         For jsqte = Qslz To .Cols - 1
  832.             
  833.             '字段不能为空
  834.             If GridInt(jsqte, 5) = 1 Then
  835.                 If Len(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  836.                     Tsxx = GridStr(jsqte, 2)
  837.                     Lrywlz = jsqte
  838.                     GoTo Lrcwcl
  839.                     Exit For
  840.                 End If
  841.             End If
  842.             
  843.             '字段不能为零
  844.             If GridInt(jsqte, 5) = 2 Then
  845.                 If Val(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  846.                     Tsxx = GridStr(jsqte, 2)
  847.                     Lrywlz = jsqte
  848.                     GoTo Lrcwcl
  849.                     Exit For
  850.                 End If
  851.             End If
  852.             
  853.         Next jsqte
  854.         
  855.         
  856.         '1.2进行其他有效性判断,编写格式同1.1
  857.         
  858.         '2.放置行处理程序(当数据行通过有效性判断)
  859. '        -------------------
  860.         '如果职工号为空则提示错误
  861.         If (int_if = 1) And (Trim(.TextMatrix(Yxxpdh, Sydz("001", GridStr(), Szzls))) = "") Then
  862.             Tsxx = "职工号不能为空!"
  863.             Lrywlz = Sydz("001", GridStr(), Szzls)
  864.             GoTo Lrcwcl
  865.         End If
  866. '        如果每一个项目都是空的,则提示错误
  867.         ItmEmpty = True
  868.         For jsqte = Qslz + 2 To .Cols - 1
  869.             If Trim(.TextMatrix(Yxxpdh, jsqte)) <> "" Then
  870.                 ItmEmpty = False
  871.                 Exit For
  872.             End If
  873.         Next
  874.         
  875.         
  876.         If ItmEmpty Then
  877.             Tsxx = "档案内容不能为空!"
  878.             GoTo Lrcwcl
  879.         End If
  880.         
  881. '        ----------------------
  882.         '直接录入,职员ID号取当前行第二列的值,档案序号取取当前行第三列的值
  883.         '查询列表调用,职员ID号不变,档案序号取行号
  884.         If int_if = 1 Then
  885.             EmpId = Val(WglrGrid.TextMatrix(Yxxpdh, 2))
  886.             tmpNo = Val(WglrGrid.TextMatrix(Yxxpdh, 3))
  887.         Else
  888.             tmpNo = Yxxpdh
  889.         End If
  890.         
  891.         On Error GoTo Swcwcl
  892.         
  893.         Cw_DataEnvi.DataConnect.BeginTrans
  894.         
  895.         With RecTemp
  896.             
  897.             '判断此行记录ID是否为零,如不为零则修改记录;否则为新增记录,然后将新增后记录ID回写网格
  898.             If Val(Trim(WglrGrid.TextMatrix(Yxxpdh, 1))) <> 0 Then
  899.                 If .State = 1 Then .Close
  900.                 .Open "SELECT * From Rs_ArMain WHERE ArSort = '" & Lbl_ArName.Tag & "' AND EmpId = " & EmpId & "AND SNo = " & tmpNo, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  901.                 
  902.                 If Not .EOF Then
  903.                 i = 1 '
  904.                 j = 1
  905.                 While i <= WglrGrid.Cols - 4 - 2
  906.                     If Searched(j + 2) Then
  907.                         .Fields(Lbl_ArName.Tag & Format(j, "000")) = WglrGrid.TextMatrix(Yxxpdh, Sydz(Format(j + 2, "000"), GridStr(), Szzls))
  908.                         i = i + 1
  909.                     End If
  910.                     j = j + 1
  911.                 Wend
  912.                     .Update
  913.                 End If
  914.                 
  915.             Else
  916.                 '重新排序
  917.                 
  918.                 Sqlstr = "EXECUTE Rs_Sp_ArMainOrder  '" & Lbl_ArName.Tag & "'," & EmpId & " ," & tmpNo & ",1"
  919.                 Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  920.                 
  921.                 If .State = 1 Then .Close
  922.                 .Open "SELECT * From Rs_ArMain WHERE 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  923.                 .AddNew
  924.                 .Fields("ArSort") = Lbl_ArName.Tag
  925.                 .Fields("EmpId") = EmpId
  926.                 .Fields("SNo") = tmpNo
  927.                 
  928.                 i = 1 '
  929.                 j = 1
  930.                 While i <= WglrGrid.Cols - 4 - 2
  931.                     If Searched(j + 2) Then
  932.                         .Fields(Lbl_ArName.Tag & Format(j, "000")) = WglrGrid.TextMatrix(Yxxpdh, Sydz(Format(j + 2, "000"), GridStr(), Szzls))
  933.                         i = i + 1
  934.                     End If
  935.                     j = j + 1
  936.                 Wend
  937.                 
  938.                 .Update
  939.                                
  940.                 WglrGrid.TextMatrix(Yxxpdh, 1) = .Fields("EmpID")                                                '记录唯一标识
  941.                 
  942.             End If
  943.             
  944.         End With
  945.         
  946.         Cw_DataEnvi.DataConnect.CommitTrans
  947.         
  948.     End With
  949.     
  950.     '以上为自定义部分]
  951.     
  952.     Sjhzyxxpd = True
  953.     Hyxxpdlock = True
  954.     Exit Function
  955.     
  956. Swcwcl:
  957.     
  958.     Cw_DataEnvi.DataConnect.RollbackTrans
  959.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  960.     Call Xtxxts(Tsxx, 0, 1)
  961.     Exit Function
  962.     
  963. Lrcwcl:      '录入错误处理
  964.     
  965.     With WglrGrid
  966.         Call Xtxxts(Tsxx, 0, 1)
  967.         Changelock = True
  968.         .Select Yxxpdh, Lrywlz
  969.         Changelock = False
  970.         Call xswbk
  971.         
  972.         Sjhzyxxpd = False
  973.         Exit Function
  974.     End With
  975.     
  976. End Function
  977. Private Function Searched(i As Integer) As Boolean
  978. Dim tmpRs As New ADODB.Recordset
  979. Dim j As Integer
  980. Dim tmpStr As String
  981. Searched = False
  982. tmpStr = "SELECT * FROM Xt_Grid WHERE Grid_code = '" & Lbl_ArName.Tag & "' AND ColIndex ='" & Format(i, "000") & "'"
  983.     Set tmpRs = Cw_DataEnvi.DataConnect.Execute(tmpStr)
  984.     If tmpRs.RecordCount > 0 Then Searched = True
  985. End Function
  986. Public Sub Ini_Grid()
  987.     
  988.     If (Lbl_ArName.Tag <> "") Then
  989.         GridCode = Lbl_ArName.Tag     '网格属性编码
  990.         
  991.         WglrGrid.Enabled = True
  992.         
  993.         Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  994.         Qslz = GridInf(1)
  995.         Sjhgd = GridInf(2)
  996.         Pmbcsjhs = GridInf(3)
  997.         Fzxwghs = GridInf(4)
  998.         Sfblbzkd = GridInf(5)
  999.         Shsfts = GridInf(6)
  1000.         Sfxshjwg = GridInf(7)
  1001.         Szzls = WglrGrid.Cols - 1
  1002.         If int_if = 1 Then
  1003.             WglrGrid.ColHidden(Sydz("001", GridStr(), Szzls)) = False
  1004.             WglrGrid.ColHidden(Sydz("002", GridStr(), Szzls)) = False
  1005.         Else
  1006.             WglrGrid.ColHidden(Sydz("001", GridStr(), Szzls)) = True
  1007.             WglrGrid.ColHidden(Sydz("002", GridStr(), Szzls)) = True
  1008.         End If
  1009.     End If
  1010.     Sub_Query
  1011.     
  1012. End Sub
  1013. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
  1014. Private Sub Sub_AdjustGrid()
  1015.     
  1016.     '调 整 网 格
  1017.     With WglrGrid
  1018.         '加 1 保持一行录入行
  1019.         If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  1020.             .Rows = Pmbcsjhs + .FixedRows + Fzxwghs + 1
  1021.             For jsqte = .FixedRows To .Rows - 1
  1022.                 .RowHeight(jsqte) = Sjhgd
  1023.             Next jsqte
  1024.         End If
  1025.         
  1026.         '判断是否有辅助行和录入行,如没有则加行
  1027.         Do While .TextMatrix(.Rows - 1 - Fzxwghs, 0) = "*"
  1028.             .AddItem ""
  1029.             .RowHeight(.Rows - 1) = Sjhgd
  1030.         Loop
  1031.     
  1032.     End With
  1033.     
  1034. End Sub
  1035. Private Sub Lrzdbz()                                                      '录入字段帮助
  1036. Dim sSql As String
  1037. Dim tmpRs As New ADODB.Recordset
  1038.     
  1039.     If Not Ydcommand.Visible Then
  1040.         Exit Sub
  1041.     End If
  1042.     
  1043.     With WglrGrid
  1044.         
  1045.         Valilock = True
  1046.         
  1047.         '处理通用部分
  1048.         Changelock = True        '调入另外窗体必须加锁
  1049.         Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  1050.         Changelock = False
  1051.         
  1052.         If Len(Xtfhcs) <> 0 Then
  1053.             If GridInt(.Col, 7) = 0 Then
  1054.                 Ydtext.Text = Xtfhcs
  1055.             Else
  1056.                 Ydtext.Text = Xtfhcsfz
  1057.             End If
  1058. '           [>>
  1059.             sSql = "SELECT EmpId ,EmpName From Rs_BasicInfo WHERE EmpNo ='" & Xtfhcs & "' AND YNStop <> 1"
  1060.                 Set tmpRs = Cw_DataEnvi.DataConnect.Execute(sSql)
  1061.                 If tmpRs.EOF Then
  1062.                     Tsxx = "此职工不存在!"
  1063.                     GoTo Lrcwcl
  1064.                 Else
  1065.                     WglrGrid.TextMatrix(WglrGrid.Row, 2) = tmpRs.Fields("EmpId")
  1066.                     
  1067.                 End If
  1068. '            <<]
  1069.         End If
  1070.         
  1071.         Valilock = False
  1072.         
  1073.         If Ydtext.Visible Then
  1074.             Ydtext.SetFocus
  1075.         End If
  1076.             
  1077.     End With
  1078.     Exit Sub
  1079.     
  1080. Lrcwcl:        '录入错误处理(Fixed)
  1081.     
  1082.     With WglrGrid
  1083.         '给出错误提示信息
  1084.         Call Xtxxts(Tsxx, 0, 1)
  1085.         
  1086.         '返回网格错误位置(ChangeLock避免再次引发RowColChange有效性判断),装入录入载体
  1087.         Changelock = True
  1088.         .Select Dqpdwgh, Dqpdwgl
  1089.         Changelock = False
  1090.         Call xswbk
  1091.         
  1092. '        '函数返回False
  1093. '        sjzdyxxpd = False
  1094. '        Exit Function
  1095.     End With
  1096.     
  1097.     
  1098. End Sub
  1099. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  1100.     
  1101.     Call Cxxswbk
  1102.     
  1103. End Sub
  1104. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  1105.   
  1106.     Fun_Drfrmyxxpd = True
  1107.     
  1108.     With WglrGrid
  1109.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  1110.         If .Row < 0 Then Exit Function
  1111.         
  1112.         If Ydtext.Visible Or YdCombo.Visible Then
  1113.             Call Lrsjhx
  1114.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1115.                 Fun_Drfrmyxxpd = False
  1116.                 Exit Function
  1117.             End If
  1118.         End If
  1119.         
  1120.         
  1121.         '进行行有效性判断
  1122.         If Not Sjhzyxxpd(.Row) Then
  1123.             Fun_Drfrmyxxpd = False
  1124.             Exit Function
  1125.         End If
  1126.     End With
  1127.   
  1128. End Function
  1129. Private Sub WglrGrid_EnterCell()                                                 '显示当前数据行相关信息
  1130.     
  1131.     With WglrGrid
  1132.         If .Row >= .FixedRows Then
  1133.             '[>>
  1134.             '此处可以填写显示与此网格行相关信息
  1135.             '<<]
  1136.         End If
  1137.     End With
  1138.     
  1139. End Sub
  1140. Private Sub WglrGrid_GotFocus()                                     '网格得到焦点
  1141.     
  1142.     '网格得到焦点,如果当前选择行为非数据行
  1143.     '则调整当前焦点至有效数据行
  1144.     
  1145.     With WglrGrid
  1146.         If .Row < .FixedRows And .Rows > .FixedRows Then
  1147.             Changelock = True
  1148.             .Select .FixedRows, .Col
  1149.             Changelock = False
  1150.         End If
  1151.         If .Col < Qslz Then
  1152.             Changelock = True
  1153.             .Select .Row, Qslz
  1154.             Changelock = False
  1155.         End If
  1156.     End With
  1157.     
  1158. End Sub
  1159. Private Sub WglrGrid_LostFocus()                                    '录入网格失去焦点
  1160.     
  1161.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  1162.     If Changelock Then
  1163.         Exit Sub
  1164.     End If
  1165.     
  1166.     '引发网格RowcolChange事件
  1167.     With WglrGrid
  1168.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1169.             .Select 0, 0
  1170.         End If
  1171.     End With
  1172.     
  1173. End Sub
  1174. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                       '限制用户在录入过程中滚动鼠标
  1175.     If Gdtlock Then
  1176.         Exit Sub
  1177.     End If
  1178.  
  1179.     With WglrGrid
  1180.         If Ydtext.Visible Or YdCombo.Visible Then
  1181.             Gdtlock = True
  1182.             .TopRow = Dqtoprow
  1183.             .LeftCol = Dqleftcol
  1184.             Gdtlock = False
  1185.             Exit Sub
  1186.         End If
  1187.     End With
  1188.     
  1189. End Sub
  1190. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  1191.   
  1192.     If Changelock Then
  1193.         Exit Sub
  1194.     End If
  1195.     '记录刚刚离开网格单元的行列值
  1196.     Dqlkwgh = WglrGrid.Row
  1197.     Dqlkwgl = WglrGrid.Col
  1198.     '判断是否需要录入数据回写
  1199.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1200.         Exit Sub
  1201.     End If
  1202.     
  1203.     Call Lrsjhx
  1204.     
  1205. End Sub
  1206. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  1207.    
  1208.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  1209.     
  1210.     With WglrGrid
  1211.         If Changelock Then
  1212.             Exit Sub
  1213.         End If
  1214.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1215.             Exit Sub
  1216.         End If
  1217.         If .Row <> Dqlkwgh Then
  1218.             If Not Sjhzyxxpd(Dqlkwgh) Then
  1219.                 Exit Sub
  1220.             End If
  1221.         End If
  1222.     End With
  1223.     
  1224.     Call fhyxh
  1225.     Call Xldql
  1226.    
  1227. End Sub
  1228. Private Sub WglrGrid_DblClick()          '鼠标双击网格显示文本框
  1229.     With WglrGrid
  1230.         If .CellWidth = 0 Then Exit Sub
  1231.         Call xswbk
  1232.     End With
  1233.   
  1234. End Sub
  1235. Private Sub Ycwbk()                      '隐藏文本框,帮助按钮,列表组合框
  1236.  
  1237.     Valilock = True
  1238.     Ydtext.Visible = False
  1239.     YdCombo.Visible = False
  1240.     Ydcommand.Visible = False
  1241.     
  1242. End Sub
  1243. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  1244.     With WglrGrid
  1245.         Select Case KeyCode
  1246.         Case vbKeyEscape                'ESC 键放弃录入
  1247.             Valilock = True
  1248.             .SetFocus
  1249.             Call Ycwbk
  1250.             Valilock = False
  1251.         Case vbKeyReturn                '回 车 键 =13
  1252.             KeyCode = 0
  1253.             .SetFocus
  1254.             Call Lrsjhx
  1255.             Rowjsq = .Row
  1256.             Coljsq = .Col + 1
  1257.             If Coljsq > .Cols - 1 Then
  1258.                 If Rowjsq < .Rows - 1 Then
  1259.                     Rowjsq = Rowjsq + 1
  1260.                 End If
  1261.                 Coljsq = Qslz
  1262.             End If
  1263.             Do While Rowjsq <= .Rows - 1
  1264.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1265.                     Coljsq = Coljsq + 1
  1266.                     If Coljsq > .Cols - 1 Then
  1267.                         Rowjsq = Rowjsq + 1
  1268.                         Coljsq = Qslz
  1269.                     End If
  1270.                 Else
  1271.                     Exit Do
  1272.                 End If
  1273.             Loop
  1274.             .Select Rowjsq, Coljsq
  1275.             
  1276.         Case vbKeyLeft                  '左 箭 头 =37
  1277.             If .Col - 1 = Qslz Then
  1278.                 If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1279.                     GoTo jzzx
  1280.                 End If
  1281.             End If
  1282.             If .Col > Qslz Then
  1283.                 KeyCode = 0
  1284.                 .SetFocus
  1285.                 Call Lrsjhx
  1286.                 Coljsq = .Col - 1
  1287.                 Do While Coljsq > Qslz
  1288.                     If Coljsq - 1 = Qslz Then
  1289.                         If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1290.                             GoTo jzzx
  1291.                         End If
  1292.                     End If
  1293.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1294.                         Coljsq = Coljsq - 1
  1295.                     Else
  1296.                         Exit Do
  1297.                     End If
  1298.                 Loop
  1299.                 .Select .Row, Coljsq
  1300.             End If
  1301.             
  1302.         Case vbKeyRight                 '右 箭 头 =39
  1303.             KeyCode = 0
  1304.             .SetFocus
  1305.             Call Lrsjhx
  1306.             Rowjsq = .Row
  1307.             Coljsq = .Col + 1
  1308.             If Coljsq > .Cols - 1 Then
  1309.                 If Rowjsq < .Rows - 1 Then
  1310.                     Rowjsq = Rowjsq + 1
  1311.                 End If
  1312.                 Coljsq = Qslz
  1313.             End If
  1314.             Do While Rowjsq <= .Rows - 1
  1315.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1316.                     Coljsq = Coljsq + 1
  1317.                     If Coljsq > .Cols - 1 Then
  1318.                         Rowjsq = Rowjsq + 1
  1319.                         Coljsq = Qslz
  1320.                     End If
  1321.                 Else
  1322.                     Exit Do
  1323.                 End If
  1324.             Loop
  1325.             .Select Rowjsq, Coljsq
  1326.         Case Else
  1327.             
  1328.         End Select
  1329.         
  1330. jzzx:
  1331.         
  1332.     End With
  1333.     
  1334. End Sub
  1335. Private Sub YdCombo_LostFocus()
  1336.     
  1337.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  1338.         If Not Valilock Then                           '为TRUE
  1339.             Call Lrsjhx
  1340.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1341.                 Exit Sub
  1342.             End If
  1343.         End If
  1344.     End With
  1345. End Sub
  1346. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1347.     
  1348.     Call Lrzdbz
  1349.     
  1350. End Sub
  1351. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  1352.     
  1353.     Dim Rowjsq As Long, Coljsq As Long
  1354.     
  1355.     With WglrGrid
  1356.         Select Case KeyCode
  1357.         Case vbKeyF2
  1358.             Call Lrzdbz
  1359.         Case vbKeyEscape                'ESC 键放弃录入
  1360.             Valilock = True
  1361.             Call Ycwbk
  1362.             .SetFocus
  1363.         Case vbKeyReturn                '回 车 键 =13
  1364.             KeyCode = 0
  1365.             .SetFocus
  1366.             Call Lrsjhx
  1367.             Rowjsq = .Row
  1368.             Coljsq = .Col + 1
  1369.             If Coljsq > .Cols - 1 Then
  1370.                 If Rowjsq < .Rows - 1 Then
  1371.                     Rowjsq = Rowjsq + 1
  1372.                 End If
  1373.                 Coljsq = Qslz
  1374.             End If
  1375.             Do While Rowjsq <= .Rows - 1
  1376.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1377.                     Coljsq = Coljsq + 1
  1378.                     If Coljsq > .Cols - 1 Then
  1379.                         Rowjsq = Rowjsq + 1
  1380.                         Coljsq = Qslz
  1381.                     End If
  1382.                 Else
  1383.                     Exit Do
  1384.                 End If
  1385.             Loop
  1386.             If Rowjsq <= .Rows - 1 Then
  1387.                 .Select Rowjsq, Coljsq
  1388.             End If
  1389.             
  1390.         Case vbKeyUp                    '上 箭 头 =38
  1391.             KeyCode = 0
  1392.             .SetFocus
  1393.             Call Lrsjhx
  1394.             If .Row > .FixedRows Then
  1395.                 .Row = .Row - 1
  1396.             End If
  1397.             
  1398.         Case vbKeyDown                  '下 箭 头 =40
  1399.             KeyCode = 0
  1400.             .SetFocus
  1401.             Call Lrsjhx
  1402.             If .Row < .Rows - 1 Then
  1403.                 .Row = .Row + 1
  1404.             End If
  1405.             
  1406.         Case vbKeyLeft                  '左 箭 头 =37
  1407.             If .Col - 1 = Qslz Then
  1408.                 If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1409.                     GoTo jzzx
  1410.                 End If
  1411.             End If
  1412.             If Ydtext.SelStart = 0 And .Col > Qslz Then
  1413.                 KeyCode = 0
  1414.                 .SetFocus
  1415.                 Call Lrsjhx
  1416.                 Coljsq = .Col - 1
  1417.                 Do While Coljsq > Qslz
  1418.                     If Coljsq - 1 = Qslz Then
  1419.                         If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1420.                             GoTo jzzx
  1421.                         End If
  1422.                     End If
  1423.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1424.                         Coljsq = Coljsq - 1
  1425.                     Else
  1426.                         Exit Do
  1427.                     End If
  1428.                 Loop
  1429.                 .Select .Row, Coljsq
  1430.             End If
  1431. jzzx:
  1432.             
  1433.         Case vbKeyRight                 '右 箭 头 =39
  1434.             wblong = Len(Ydtext.Text)
  1435.             If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  1436.                 KeyCode = 0
  1437.                 .SetFocus
  1438.                 Call Lrsjhx
  1439.                 Rowjsq = .Row
  1440.                 Coljsq = .Col + 1
  1441.                 If Coljsq > .Cols - 1 Then
  1442.                     If Rowjsq < .Rows - 1 Then
  1443.                         Rowjsq = Rowjsq + 1
  1444.                     End If
  1445.                     Coljsq = Qslz
  1446.                 End If
  1447.                 Do While Rowjsq <= .Rows - 1
  1448.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1449.                         Coljsq = Coljsq + 1
  1450.                         If Coljsq > .Cols - 1 Then
  1451.                             Rowjsq = Rowjsq + 1
  1452.                             Coljsq = Qslz
  1453.                         End If
  1454.                     Else
  1455.                         Exit Do
  1456.                     End If
  1457.                 Loop
  1458.                 .Select Rowjsq, Coljsq
  1459.             End If
  1460.         Case Else
  1461.             
  1462.         End Select
  1463.     End With
  1464.     
  1465. End Sub
  1466. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  1467.     
  1468.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1469.     
  1470.     If KeyAscii <> 0 Then
  1471.         Call Xyxhbz(Dqlrwgh)
  1472.     End If
  1473.     
  1474. End Sub
  1475. Private Sub ydtext_Change()                              '录入事中变化处理
  1476.     
  1477.     '防止程序改变但不进行处理
  1478.     
  1479.     If Wbkbhlock Then
  1480.         Exit Sub
  1481.     End If
  1482.     
  1483.     With WglrGrid
  1484.         
  1485.         '限制字段录入长度
  1486.         Wbkbhlock = True
  1487.         Select Case GridInt(.Col, 1)
  1488.         Case 8, 11   '金额型
  1489.             Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  1490.         Case 9, 12   '数量型
  1491.             Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  1492.         Case 10      '单价型
  1493.             Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1494.         Case Else    '其他类型
  1495.             If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  1496.                 Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  1497.             End If
  1498.         End Select
  1499.         Wbkbhlock = False
  1500.     End With
  1501.     
  1502. End Sub
  1503. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  1504.     
  1505.     With WglrGrid
  1506.         If Not Valilock Then
  1507.             Call Lrsjhx
  1508.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1509.                 Exit Sub
  1510.             End If
  1511.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1512.                 Exit Sub
  1513.             End If
  1514.         End If
  1515.     End With
  1516.     
  1517. End Sub
  1518. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  1519.     
  1520.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  1521.    
  1522.     '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  1523.     If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
  1524.         Exit Sub
  1525.     End If
  1526.     
  1527.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1528.     If Not Fun_AllowInput Then
  1529.         Exit Sub
  1530.     End If
  1531.   
  1532.     '显示文本框前返回有效行列(解决滚动条问题)
  1533.     Call Xldqh
  1534.     Call Xldql
  1535.   
  1536.     '隐藏文本框,帮助按钮,列表组合框
  1537.     Call Ycwbk
  1538.   
  1539.     With WglrGrid
  1540.         Dqlrwgh = .Row
  1541.         Dqlrwgl = .Col
  1542.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1543.             Exit Sub
  1544.         End If
  1545.      
  1546.         Wbkpy = 30
  1547.         Wbkpy1 = 15
  1548.     
  1549.         If GridBoolean(.Col, 3) Then
  1550.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1551.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1552.             YdCombo.Width = .CellWidth - Wbkpy1
  1553.             Call Wbkcl
  1554.             YdCombo.Visible = True
  1555.             YdCombo.SetFocus
  1556.             Ydcommand.Visible = False
  1557.             Ydtext.Visible = False
  1558.         Else
  1559.             If GridBoolean(.Col, 2) Then
  1560.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1561.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1562.                 Ydcommand.Visible = True
  1563.             Else
  1564.                 Ydcommand.Visible = False
  1565.             End If
  1566.      
  1567.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1568.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1569.             
  1570.             If Ydcommand.Visible Then
  1571.                 If Sfblbzkd Then
  1572.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1573.                 Else
  1574.                     Ydtext.Width = .CellWidth - Wbkpy1
  1575.                 End If
  1576.             Else
  1577.                 Ydtext.Width = .CellWidth - Wbkpy1
  1578.             End If
  1579.             
  1580.             Ydtext.Height = .CellHeight - Wbkpy1
  1581.       
  1582.             If GridInt(.Col, 2) <> 0 Then
  1583.                 Ydtext.MaxLength = GridInt(.Col, 2)
  1584.             Else
  1585.                 Ydtext.MaxLength = 3000
  1586.             End If
  1587.       
  1588.             Call Wbkcl
  1589.       
  1590.             Ydtext.Visible = True
  1591.             Ydtext.SetFocus
  1592.         End If
  1593.         
  1594.         Dqtoprow = .TopRow
  1595.         Dqleftcol = .LeftCol
  1596.     
  1597.         '重置锁值
  1598.         Valilock = False
  1599.         Wbkbhlock = False
  1600.         
  1601.     End With
  1602.  
  1603. End Sub
  1604. Private Function Fun_AllowInput() As Boolean                           '当某种条件成立时禁止文本框激活使单据处于录入状态
  1605.     
  1606.     '如果单据操作状态为浏览状态则不能显示录入载体(通用)
  1607.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1608.         Exit Function
  1609.     End If
  1610.     
  1611.     '[>>
  1612.     
  1613.     '此处可以填写禁止文本框激活使单据处于录入状态的理由
  1614.     
  1615.     '<<]
  1616.     
  1617.     Fun_AllowInput = True
  1618.     
  1619. End Function
  1620. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1621.                    
  1622.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1623.   
  1624.     Wbkpy = 30
  1625.     Wbkpy1 = 15
  1626.     
  1627.     With WglrGrid
  1628.         If YdCombo.Visible Then
  1629.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1630.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1631.             YdCombo.Width = .CellWidth - Wbkpy1
  1632.         End If
  1633.         If Ydcommand.Visible Then
  1634.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1635.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1636.         End If
  1637.         If Ydtext.Visible Then
  1638.             If Ydcommand.Visible Then
  1639.                 If Sfblbzkd Then
  1640.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1641.                 Else
  1642.                     Ydtext.Width = .CellWidth - Wbkpy1
  1643.                 End If
  1644.             Else
  1645.                 Ydtext.Width = .CellWidth - Wbkpy1
  1646.             End If
  1647.       
  1648.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1649.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1650.             Ydtext.Height = .CellHeight - Wbkpy1
  1651.         End If
  1652.    End With
  1653. End Sub
  1654. Private Sub Lrsjhx()                                                   '文本框录入数据回写
  1655.     
  1656.     With WglrGrid
  1657.         If YdCombo.Visible Then
  1658.             .Text = Trim(YdCombo.Text)
  1659.         End If
  1660.         If Ydtext.Visible Then
  1661.             .Text = Trim(Ydtext.Text)
  1662.         End If
  1663.         
  1664.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  1665.         If Zdlrqnr <> Trim(.Text) Then
  1666.             Yxxpdlock = False
  1667.             Hyxxpdlock = False
  1668.         End If
  1669.         
  1670.         '如果字段录入内容不为空则写数据行有效性标志
  1671.         
  1672.         If Len(Trim(.Text)) <> 0 Then
  1673.             Call Xyxhbz(.Row)
  1674.         End If
  1675.         
  1676.         '隐藏文本框,帮助按钮,列表组合框
  1677.         Call Ycwbk
  1678.     End With
  1679.     
  1680. End Sub
  1681. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)    '网格录入增行,删行快捷键
  1682.     
  1683.     '如果单据操作状态为浏览状态则不能显示录入载体
  1684.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1685.         Exit Sub
  1686.     End If
  1687.     
  1688.     Select Case KeyCode
  1689.     Case vbKeyF2                   '按F2键参照
  1690.         Call xswbk
  1691.         Call Lrzdbz
  1692.     Case vbKeyDelete               '删行
  1693.         Call Scdqfl
  1694.     Case vbKeyInsert               '增行
  1695.         Call zjlrfl
  1696.     End Select
  1697.     
  1698. End Sub
  1699. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                             '网格接受键盘录入
  1700.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1701.     If Not Fun_AllowInput Then
  1702.         Exit Sub
  1703.     End If
  1704.   
  1705.     With WglrGrid
  1706.   
  1707.         '屏 蔽 回 车 键
  1708.         If KeyAscii = vbKeyReturn Then
  1709.             KeyAscii = 0
  1710.             Rowjsq = .Row
  1711.             Coljsq = .Col + 1
  1712.             If Coljsq > .Cols - 1 Then
  1713.                 If Rowjsq < .Rows - 1 Then
  1714.                     Rowjsq = Rowjsq + 1
  1715.                 End If
  1716.                 Coljsq = Qslz
  1717.             End If
  1718.             Do While Rowjsq <= .Rows - 1
  1719.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1720.                     Coljsq = Coljsq + 1
  1721.                     If Coljsq > .Cols - 1 Then
  1722.                         Rowjsq = Rowjsq + 1
  1723.                         Coljsq = Qslz
  1724.                     End If
  1725.                 Else
  1726.                     Exit Do
  1727.                 End If
  1728.             Loop
  1729.           
  1730.             If Rowjsq <= .Rows - 1 Then
  1731.                .Select Rowjsq, Coljsq
  1732.             End If
  1733.        
  1734.              Exit Sub
  1735.         End If
  1736.      
  1737.         '接受用户录入
  1738.         Select Case KeyAscii
  1739.             Case 0 To 32             '用户输入KeyAscii为0-32的键 如空格
  1740.           
  1741.                 '显示录入载体
  1742.                 Call xswbk
  1743.             Case Else
  1744.                 '防止非编辑字段SendKeys()出现死循环
  1745.                 If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1746.                    Exit Sub
  1747.                 End If
  1748.                 '如果此字段为列表框录入则调入相应列表框
  1749.                 If GridBoolean(.Col, 3) Then
  1750.                     '列表框录入
  1751.                     Call xswbk
  1752.                 Else
  1753.                     Ydtext.Text = ""
  1754.             
  1755.                     '录入限制
  1756.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1757.             
  1758.                     If KeyAscii = 0 Then
  1759.                         Exit Sub
  1760.                     End If
  1761.                     '如果录入字符有效则写有效行数据标志
  1762.                     Call Xyxhbz(.Row)
  1763.                     Call xswbk
  1764.                     Ydtext.Text = ""
  1765.                     Valilock = True
  1766.                     SendKeys Chr(KeyAscii), True
  1767.                     DoEvents
  1768.                     Valilock = False
  1769.                 End If
  1770.         End Select
  1771.     End With
  1772.         
  1773. End Sub
  1774. Private Sub zjlrfl()                                                    '增加录入分录
  1775.     
  1776.     '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  1777.     If Not Security_Log(Str_RightEdit, Xtczybm, 1, True, False) Then
  1778.         Exit Sub
  1779.     End If
  1780.     
  1781.     With WglrGrid
  1782.   
  1783.         '处于录入状态不能增行
  1784.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1785.             If Not Fun_Drfrmyxxpd Then
  1786.                 Exit Sub
  1787.             End If
  1788.         Else
  1789.             Exit Sub
  1790.         End If
  1791.     
  1792.         '处于非数据行和最后一行时不能增行
  1793.         If .Row < .FixedRows Or .Row = .Rows - 1 Then
  1794.             Exit Sub
  1795.         End If
  1796.     
  1797.         .AddItem "", .Row
  1798.         .RowHeight(.Row) = Sjhgd
  1799.     
  1800.         If .Row <> .Rows - 1 Then
  1801.             If .TextMatrix(.Row + 1, 0) = "*" Then
  1802.                 .TextMatrix(.Row, 0) = "*"
  1803.             Else
  1804.                 .RemoveItem .Rows - 1
  1805.             End If
  1806.         End If
  1807.         Call Xldqh
  1808.         Call Xldql
  1809.         Hyxxpdlock = False
  1810.     End With
  1811.     
  1812. End Sub
  1813. Private Sub Scdqfl()                                                    '删除当前分录
  1814.     
  1815.     '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  1816.     If Not Security_Log(Str_RightEdit, Xtczybm, 1, True, False) Then
  1817.         Exit Sub
  1818.     End If
  1819.     
  1820.     
  1821.     Dim Answer As Integer, Scqwghz As Long, Scqwglz As Long, Hjlzte As Long, Sflrzt As Boolean '(Fixed)
  1822.     Dim Sqlstr As String   '临时使用连接字符串
  1823.     
  1824.     With WglrGrid
  1825.         Scqwghz = .Row
  1826.         Scqwglz = .Col
  1827.         
  1828.         If .TextMatrix(.Row, 0) = "*" Then
  1829.             '判断是否为录入状态
  1830.             If Ydtext.Visible Or YdCombo.Visible Then
  1831.                 Sflrzt = True
  1832.                 Validate = True
  1833.                 Call Lrsjhx
  1834.                 Validate = False
  1835.             End If
  1836.             
  1837.             Call Xldqh
  1838.             Changelock = True
  1839.             .Select .Row, 0
  1840.             Changelock = False
  1841.             If Shsfts Then
  1842.                 .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = QBColor(12)
  1843.                 Tsxx = "请确认是否删除当前记录?"
  1844.                 Yhanswer = Xtxxts(Tsxx, 2, 2)
  1845.                 If Yhanswer = 2 Then
  1846.                     .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = &H80000005
  1847.                     Changelock = True
  1848.                     .Select Scqwghz, Scqwglz
  1849.                     Changelock = False
  1850.                     
  1851.                     '如为录入状态,则恢复录入
  1852.                     If Sflrzt Then
  1853.                         Call xswbk
  1854.                     End If
  1855.                     
  1856.                     Exit Sub
  1857.                 End If
  1858.             End If
  1859.             
  1860.             '[>>以下为自定义部分
  1861.             '直接录入,职员ID号取当前行第二列的值,档案序号取取当前行第三列的值
  1862.             '查询列表调用,职员ID号不变,档案序号取行号
  1863.             If int_if = 1 Then
  1864.                 EmpId = Val(WglrGrid.TextMatrix(.Row, 2))
  1865.                 tmpNo = Val(WglrGrid.TextMatrix(.Row, 3))
  1866.             Else
  1867.                 tmpNo = .Row
  1868.             End If
  1869.             
  1870.             On Error GoTo Swcwcl
  1871.             
  1872.             Cw_DataEnvi.DataConnect.BeginTrans
  1873.                    
  1874.             
  1875.             If Val(WglrGrid.TextMatrix(.Row, 1)) <> 0 Then
  1876.                 Sqlstr = "DELETE Rs_ArMain WHERE ArSort ='" & Lbl_ArName.Tag & "' AND EmpId = " & EmpId & " AND SNo = " & tmpNo
  1877.                 Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1878.                 '重新排序
  1879.                 Sqlstr = "EXECUTE Rs_Sp_ArMainOrder  '" & Lbl_ArName.Tag & "'," & EmpId & " ," & tmpNo & ",0"
  1880.                 Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1881.             End If
  1882.             
  1883.             Cw_DataEnvi.DataConnect.CommitTrans
  1884.             
  1885.             '<<以上为自定义部分]
  1886.             
  1887.             .RemoveItem .Row                                                    '正常的删除行
  1888.             
  1889.         '[>>
  1890.             For i = .Row To .Rows - 2                                           'SNo
  1891.                 .TextMatrix(i, 2) = .Row
  1892.             Next i
  1893.             
  1894.         '<<]
  1895.             If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  1896.                 .AddItem ""
  1897.                 .RowHeight(.Rows - 1) = Sjhgd
  1898.             End If
  1899.             
  1900.             Changelock = True
  1901.             .Select .Row, Scqwglz
  1902.             Changelock = False
  1903.         End If
  1904.         
  1905.     End With
  1906.     
  1907.     Exit Sub
  1908.     
  1909.     '[>>事务错误处理
  1910.     
  1911. Swcwcl:
  1912.     
  1913.     Cw_DataEnvi.DataConnect.RollbackTrans
  1914.     
  1915.     Tsxx = "删除过程中出现错误!"
  1916.     Call Xtxxts(Tsxx, 0, 1)
  1917.     Exit Sub
  1918.     '<<]
  1919. End Sub
  1920. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1921.     
  1922.     If Not GridBoolean(Sjl, 5) Then
  1923.         Exit Sub
  1924.     End If
  1925.     
  1926.     With WglrGrid
  1927.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
  1928.             .TextMatrix(sjh, Sjl) = ""
  1929.         End If
  1930.     End With
  1931.     
  1932. End Sub
  1933. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1934.     
  1935.     With WglrGrid
  1936.         If .Row >= .FixedRows Then
  1937.             If .TextMatrix(.Row, 0) <> "*" Then
  1938.                 For Rowjsq = .FixedRows To .Rows - 1
  1939.                     If .TextMatrix(Rowjsq, 0) <> "*" Then
  1940.                         Exit For
  1941.                     End If
  1942.                 Next Rowjsq
  1943.                 If Rowjsq <= .Rows - 1 Then
  1944.                     Changelock = True
  1945.                     .Select Rowjsq, .Col
  1946.                     Changelock = False
  1947.                 Else
  1948.                     Changelock = True
  1949.                     .Select .Rows - 1, .Col
  1950.                     Changelock = False
  1951.                 End If
  1952.             End If
  1953.             Call Xldqh
  1954.         End If
  1955.     End With
  1956.     
  1957. End Sub
  1958. Private Sub Xldqh()                                                      '显露当前行
  1959.     
  1960.     Dim Toprowte As Long
  1961.     
  1962.     With WglrGrid
  1963.         Toprowte = 0
  1964.         
  1965.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  1966.             Toprowte = .TopRow
  1967.             .TopRow = .TopRow + 1
  1968.         Loop
  1969.         
  1970.         Toprowte = 0
  1971.         
  1972.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  1973.             Toprowte = .TopRow
  1974.             .TopRow = .TopRow - 1
  1975.         Loop
  1976.     End With
  1977.     
  1978. End Sub
  1979. Private Sub Xldql()                                                     '显露当前列
  1980.     
  1981.     Dim Leftcolte As Long
  1982.     
  1983.     With WglrGrid
  1984.         If .Col >= Qslz And .Col >= .FixedCols Then
  1985.             If .LeftCol > .Col Then
  1986.                 .LeftCol = .Col
  1987.             End If
  1988.             Leftcolte = 0
  1989.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  1990.                 Leftcolte = .LeftCol
  1991.                 .LeftCol = .LeftCol + 1
  1992.             Loop
  1993.         End If
  1994.     End With
  1995.     
  1996. End Sub
  1997. Private Function pdhwk(sjh As Long)                                     '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
  1998.  
  1999.     With WglrGrid
  2000.         For Coljsq = Qslz To .Cols - 1
  2001.             If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
  2002.                 pdhwk = False
  2003.                 Exit Function
  2004.             End If
  2005.         Next Coljsq
  2006.         pdhwk = True
  2007.     End With
  2008.     
  2009. End Function
  2010. Private Sub Xyxhbz(sjh As Long)                                         '写行有效性标志,并判断是否增行
  2011.    
  2012.    With WglrGrid
  2013.         If .TextMatrix(sjh, 0) = "*" Then
  2014.             Exit Sub
  2015.         End If
  2016.         .TextMatrix(sjh, 0) = "*"
  2017.         If sjh >= .Rows - Fzxwghs - 1 Then
  2018.             .AddItem ""
  2019.             .RowHeight(.Rows - 1) = Sjhgd
  2020.         End If
  2021.    End With
  2022.    
  2023. End Sub
  2024. Private Sub WglrGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
  2025.     
  2026.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  2027. End Sub
  2028. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   '表格格式设置(通用)
  2029.     
  2030.     Select Case Button.Key
  2031.         Case "bcgs"                                       '保存表格格式
  2032.             Call Bcwggs(WglrGrid, GridCode, GridStr())
  2033.         Case "hfmrgs"                                     '恢复默认格式
  2034.             Call Hfmrgs(WglrGrid, GridCode, GridStr())
  2035.     End Select
  2036.     
  2037. End Sub
  2038. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  2039.     
  2040.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  2041.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  2042.     Bbxbtgs = 1                                         '报 表 小 标 题 行 数
  2043.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  2044.     ReDim Bbxbt(1 To Bbxbtgs)
  2045.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  2046.     
  2047.     ReportTitle = Lbl_ArName.Caption
  2048.     '职工号和姓名在小标题栏显示
  2049.     If Lbl_EmpNo.Visible = True Then
  2050.         Bbxbt(1) = Lbl_EmpNo.Caption & "  " & Lbl_EmpName.Caption
  2051.     Else
  2052.         Bbxbtgs = 1
  2053.         ReDim Bbxbt(1 To Bbxbtgs)
  2054.         ReDim bbxbtzzxs(1 To Bbxbtgs)
  2055.     End If
  2056.     If Bbbwhgs <> 0 Then
  2057.         ReDim Bbbwh(1 To Bbbwhgs)
  2058.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  2059.     End If
  2060.     
  2061.     Bbzbt = ReportTitle
  2062.     
  2063.     Call Scyxsjb(WglrGrid)                               '生成报表数据
  2064.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  2065.     
  2066.     If Not bbylte Then
  2067.         Unload DY_Tybbyldy
  2068.     End If
  2069.     
  2070. End Sub