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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  3. Begin VB.Form Dev_MalfunctionEditForm 
  4.    BackColor       =   &H00E9F4FA&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "单据处理"
  7.    ClientHeight    =   6120
  8.    ClientLeft      =   675
  9.    ClientTop       =   720
  10.    ClientWidth     =   8220
  11.    HelpContextID   =   2505007
  12.    Icon            =   "设备运行_设备故障编辑.frx":0000
  13.    KeyPreview      =   -1  'True
  14.    LinkTopic       =   "Form4"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   6120
  18.    ScaleWidth      =   8220
  19.    StartUpPosition =   1  '所有者中心
  20.    Begin VB.CommandButton Ydcommand1 
  21.       Height          =   300
  22.       Index           =   0
  23.       Left            =   7710
  24.       Picture         =   "设备运行_设备故障编辑.frx":1042
  25.       Style           =   1  'Graphical
  26.       TabIndex        =   9
  27.       Top             =   660
  28.       Visible         =   0   'False
  29.       Width           =   300
  30.    End
  31.    Begin MSComctlLib.ImageList ImageList1 
  32.       Left            =   6420
  33.       Top             =   630
  34.       _ExtentX        =   1005
  35.       _ExtentY        =   1005
  36.       BackColor       =   -2147483643
  37.       ImageWidth      =   16
  38.       ImageHeight     =   16
  39.       MaskColor       =   12632256
  40.       _Version        =   393216
  41.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  42.          NumListImages   =   37
  43.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  44.             Picture         =   "设备运行_设备故障编辑.frx":13CC
  45.             Key             =   "sz"
  46.          EndProperty
  47.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  48.             Picture         =   "设备运行_设备故障编辑.frx":1766
  49.             Key             =   "dy"
  50.          EndProperty
  51.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  52.             Picture         =   "设备运行_设备故障编辑.frx":1B00
  53.             Key             =   "yl"
  54.          EndProperty
  55.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  56.             Picture         =   "设备运行_设备故障编辑.frx":1E9A
  57.             Key             =   "xg"
  58.          EndProperty
  59.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  60.             Picture         =   "设备运行_设备故障编辑.frx":2234
  61.             Key             =   "zh"
  62.          EndProperty
  63.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  64.             Picture         =   "设备运行_设备故障编辑.frx":25CE
  65.             Key             =   "sh"
  66.          EndProperty
  67.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  68.             Picture         =   "设备运行_设备故障编辑.frx":2968
  69.             Key             =   "bc"
  70.          EndProperty
  71.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  72.             Picture         =   "设备运行_设备故障编辑.frx":2D02
  73.             Key             =   "fq"
  74.          EndProperty
  75.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  76.             Picture         =   "设备运行_设备故障编辑.frx":309C
  77.             Key             =   "bz"
  78.          EndProperty
  79.          BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  80.             Picture         =   "设备运行_设备故障编辑.frx":3436
  81.             Key             =   "tc"
  82.          EndProperty
  83.          BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  84.             Picture         =   "设备运行_设备故障编辑.frx":37D0
  85.             Key             =   "bcgs"
  86.          EndProperty
  87.          BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  88.             Picture         =   "设备运行_设备故障编辑.frx":3B6A
  89.             Key             =   "mrlk"
  90.          EndProperty
  91.          BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  92.             Picture         =   "设备运行_设备故障编辑.frx":3F04
  93.             Key             =   "xsxm"
  94.          EndProperty
  95.          BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  96.             Picture         =   "设备运行_设备故障编辑.frx":429E
  97.             Key             =   "first"
  98.          EndProperty
  99.          BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  100.             Picture         =   "设备运行_设备故障编辑.frx":4638
  101.             Key             =   "prev"
  102.          EndProperty
  103.          BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  104.             Picture         =   "设备运行_设备故障编辑.frx":49D2
  105.             Key             =   "next"
  106.          EndProperty
  107.          BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  108.             Picture         =   "设备运行_设备故障编辑.frx":4D6C
  109.             Key             =   "last"
  110.          EndProperty
  111.          BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  112.             Picture         =   "设备运行_设备故障编辑.frx":5106
  113.             Key             =   "xx"
  114.          EndProperty
  115.          BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  116.             Picture         =   "设备运行_设备故障编辑.frx":54A0
  117.             Key             =   "define"
  118.          EndProperty
  119.          BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  120.             Picture         =   "设备运行_设备故障编辑.frx":583A
  121.             Key             =   "exec"
  122.          EndProperty
  123.          BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  124.             Picture         =   "设备运行_设备故障编辑.frx":5BD4
  125.             Key             =   "xz"
  126.          EndProperty
  127.          BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  128.             Picture         =   "设备运行_设备故障编辑.frx":5F6E
  129.             Key             =   "sc"
  130.          EndProperty
  131.          BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  132.             Picture         =   "设备运行_设备故障编辑.frx":6308
  133.             Key             =   "sx"
  134.          EndProperty
  135.          BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  136.             Picture         =   "设备运行_设备故障编辑.frx":66A2
  137.             Key             =   "cx"
  138.          EndProperty
  139.          BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  140.             Picture         =   "设备运行_设备故障编辑.frx":6A3C
  141.             Key             =   "zd"
  142.          EndProperty
  143.          BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  144.             Picture         =   "设备运行_设备故障编辑.frx":6DD6
  145.             Key             =   "dz"
  146.          EndProperty
  147.          BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  148.             Picture         =   "设备运行_设备故障编辑.frx":7170
  149.             Key             =   "ph"
  150.          EndProperty
  151.          BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  152.             Picture         =   "设备运行_设备故障编辑.frx":750A
  153.             Key             =   "fz"
  154.          EndProperty
  155.          BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  156.             Picture         =   "设备运行_设备故障编辑.frx":78A4
  157.             Key             =   "dw"
  158.          EndProperty
  159.          BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  160.             Picture         =   "设备运行_设备故障编辑.frx":7C3E
  161.             Key             =   "hf"
  162.          EndProperty
  163.          BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  164.             Picture         =   "设备运行_设备故障编辑.frx":7FD8
  165.             Key             =   "pz"
  166.          EndProperty
  167.          BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  168.             Picture         =   "设备运行_设备故障编辑.frx":8372
  169.             Key             =   "check"
  170.          EndProperty
  171.          BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  172.             Picture         =   "设备运行_设备故障编辑.frx":870C
  173.             Key             =   "qs"
  174.          EndProperty
  175.          BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  176.             Picture         =   "设备运行_设备故障编辑.frx":8AA6
  177.             Key             =   "fullcheck"
  178.          EndProperty
  179.          BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  180.             Picture         =   "设备运行_设备故障编辑.frx":8E40
  181.             Key             =   "qq"
  182.          EndProperty
  183.          BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  184.             Picture         =   "设备运行_设备故障编辑.frx":91DA
  185.             Key             =   "bcw"
  186.          EndProperty
  187.          BeginProperty ListImage37 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  188.             Picture         =   "设备运行_设备故障编辑.frx":9574
  189.             Key             =   "ye"
  190.          EndProperty
  191.       EndProperty
  192.    End
  193.    Begin MSComctlLib.Toolbar Tlb_Action 
  194.       Align           =   1  'Align Top
  195.       Height          =   570
  196.       Left            =   0
  197.       TabIndex        =   1
  198.       Top             =   0
  199.       Width           =   8220
  200.       _ExtentX        =   14499
  201.       _ExtentY        =   1005
  202.       ButtonWidth     =   820
  203.       ButtonHeight    =   953
  204.       AllowCustomize  =   0   'False
  205.       Wrappable       =   0   'False
  206.       Appearance      =   1
  207.       Style           =   1
  208.       ImageList       =   "ImageList1"
  209.       _Version        =   393216
  210.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  211.          NumButtons      =   20
  212.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  213.             Caption         =   "打印"
  214.             Key             =   "dy"
  215.             Object.ToolTipText     =   "打印当前单据或Ctrl+P"
  216.             ImageKey        =   "dy"
  217.          EndProperty
  218.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  219.             Caption         =   "预览"
  220.             Key             =   "yl"
  221.             ImageKey        =   "yl"
  222.          EndProperty
  223.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  224.             Key             =   "fgh0"
  225.             Style           =   3
  226.          EndProperty
  227.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  228.             Caption         =   "新增"
  229.             Key             =   "xz"
  230.             Object.ToolTipText     =   "新增加一张单据或F5"
  231.             ImageKey        =   "xz"
  232.          EndProperty
  233.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  234.             Caption         =   "修改"
  235.             Key             =   "xg"
  236.             Object.ToolTipText     =   "修改当前单据或F3"
  237.             ImageKey        =   "xg"
  238.          EndProperty
  239.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  240.             Caption         =   "删除"
  241.             Key             =   "sc"
  242.             Object.ToolTipText     =   "删除当前单据"
  243.             ImageKey        =   "sc"
  244.          EndProperty
  245.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  246.             Key             =   "fgh2"
  247.             Style           =   3
  248.          EndProperty
  249.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  250.             Caption         =   "保存"
  251.             Key             =   "bc"
  252.             Object.ToolTipText     =   "保存单据或F6"
  253.             ImageKey        =   "bc"
  254.          EndProperty
  255.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  256.             Caption         =   "放弃"
  257.             Key             =   "fq"
  258.             Object.ToolTipText     =   "放弃此次操作"
  259.             ImageKey        =   "fq"
  260.          EndProperty
  261.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  262.             Key             =   "fgh3"
  263.             Style           =   3
  264.          EndProperty
  265.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  266.             Caption         =   "审核"
  267.             Key             =   "shsh"
  268.             ImageKey        =   "check"
  269.          EndProperty
  270.          BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  271.             Caption         =   "弃审"
  272.             Key             =   "shqs"
  273.             ImageKey        =   "qs"
  274.          EndProperty
  275.          BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  276.             Key             =   "fgh4"
  277.             Style           =   3
  278.          EndProperty
  279.          BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  280.             Caption         =   "首张"
  281.             Key             =   "first"
  282.             ImageKey        =   "first"
  283.          EndProperty
  284.          BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  285.             Caption         =   "上张"
  286.             Key             =   "prev"
  287.             ImageKey        =   "prev"
  288.          EndProperty
  289.          BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  290.             Caption         =   "下张"
  291.             Key             =   "next"
  292.             ImageKey        =   "next"
  293.          EndProperty
  294.          BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  295.             Caption         =   "末张"
  296.             Key             =   "last"
  297.             ImageKey        =   "last"
  298.          EndProperty
  299.          BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  300.             Key             =   "fgh5"
  301.             Style           =   3
  302.          EndProperty
  303.          BeginProperty Button19 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  304.             Caption         =   "帮助"
  305.             Key             =   "bz"
  306.             ImageKey        =   "bz"
  307.          EndProperty
  308.          BeginProperty Button20 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  309.             Caption         =   "退出"
  310.             Key             =   "fh"
  311.             ImageKey        =   "tc"
  312.          EndProperty
  313.       EndProperty
  314.       BorderStyle     =   1
  315.    End
  316.    Begin VB.Timer Timer1 
  317.       Interval        =   1
  318.       Left            =   9690
  319.       Top             =   150
  320.    End
  321.    Begin VB.TextBox LrText 
  322.       ForeColor       =   &H00000000&
  323.       Height          =   300
  324.       Index           =   0
  325.       Left            =   990
  326.       TabIndex        =   0
  327.       Text            =   "0"
  328.       Top             =   1470
  329.       Width           =   1650
  330.    End
  331.    Begin VB.Label Lab_BillId 
  332.       AutoSize        =   -1  'True
  333.       BackColor       =   &H0080C0FF&
  334.       Height          =   270
  335.       Left            =   6390
  336.       TabIndex        =   7
  337.       Top             =   1320
  338.       Visible         =   0   'False
  339.       Width           =   1230
  340.    End
  341.    Begin VB.Label Lab_Djclzt 
  342.       BackColor       =   &H0000FFFF&
  343.       Caption         =   "1"
  344.       ForeColor       =   &H00808080&
  345.       Height          =   255
  346.       Left            =   7170
  347.       TabIndex        =   6
  348.       Top             =   660
  349.       Visible         =   0   'False
  350.       Width           =   285
  351.    End
  352.    Begin VB.Label Lab_OperStatus 
  353.       BackColor       =   &H000080FF&
  354.       Caption         =   "1"
  355.       Height          =   345
  356.       Left            =   7710
  357.       TabIndex        =   5
  358.       Top             =   1260
  359.       Visible         =   0   'False
  360.       Width           =   345
  361.    End
  362.    Begin VB.Label Lab_Title 
  363.       AutoSize        =   -1  'True
  364.       BackColor       =   &H80000018&
  365.       BackStyle       =   0  'Transparent
  366.       Caption         =   "单据标题自动调整"
  367.       BeginProperty Font 
  368.          Name            =   "宋体"
  369.          Size            =   15
  370.          Charset         =   134
  371.          Weight          =   700
  372.          Underline       =   0   'False
  373.          Italic          =   0   'False
  374.          Strikethrough   =   0   'False
  375.       EndProperty
  376.       ForeColor       =   &H00000000&
  377.       Height          =   300
  378.       Left            =   2730
  379.       TabIndex        =   8
  380.       Top             =   750
  381.       Width           =   2520
  382.    End
  383.    Begin VB.Label Lab_Bill 
  384.       Appearance      =   0  'Flat
  385.       BackColor       =   &H80000005&
  386.       BackStyle       =   0  'Transparent
  387.       ForeColor       =   &H00000000&
  388.       Height          =   225
  389.       Left            =   9030
  390.       TabIndex        =   4
  391.       Top             =   6330
  392.       Width           =   735
  393.    End
  394.    Begin VB.Label Lab_Checker 
  395.       Appearance      =   0  'Flat
  396.       BackColor       =   &H80000005&
  397.       BackStyle       =   0  'Transparent
  398.       ForeColor       =   &H00000000&
  399.       Height          =   225
  400.       Left            =   7170
  401.       TabIndex        =   3
  402.       Top             =   6360
  403.       Width           =   735
  404.    End
  405.    Begin VB.Label TsLabel 
  406.       Alignment       =   1  'Right Justify
  407.       AutoSize        =   -1  'True
  408.       BackStyle       =   0  'Transparent
  409.       Caption         =   "单据号:"
  410.       Height          =   180
  411.       Index           =   0
  412.       Left            =   210
  413.       TabIndex        =   2
  414.       Top             =   1530
  415.       Width           =   765
  416.    End
  417. End
  418. Attribute VB_Name = "Dev_MalfunctionEditForm"
  419. Attribute VB_GlobalNameSpace = False
  420. Attribute VB_Creatable = False
  421. Attribute VB_PredeclaredId = True
  422. Attribute VB_Exposed = False
  423. '***********************************************************************************************************
  424. '*    模 块 名 称 :设备故障处理
  425. '*    程序员姓名  :王哲
  426. '*    最后修改人  :王哲
  427. '*    最后修改时间:2001/12/18
  428. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  429. '*
  430. '*    1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
  431. '*                                    TextValiLock=True             TextValiLock=false
  432. '*
  433. '*    2.Lab_OperStatus 用此标签来标识单据录入状态(默认值为1) "1"-浏览 "2"-新增 "3"-修改
  434. '*
  435. '*    3.Lab_Djclzt 用此标签来标识单据处理状态(默认值为1) "1"-填制单据  "2"-查询单据列表  "3"-明细帐联查单据
  436. '*
  437. '*    4.原则:只要单据能够存盘(无论修改或新增)则其必须接受完整性及有效性规则检查
  438. '*
  439. '*    5.支持热键操作:打印:Ctrl+P 新增:F5 修改:F3 存盘:F6
  440. '***********************************************************************************************************
  441.  
  442. '[以下为根据实际情况设置变量
  443. Dim Bln_BillChange As Boolean                   '标识单据是否发生改动
  444. Dim Rec_Query As New ADODB.Recordset            '单据组查询结果动态集(保存当前单据组ID)
  445. Public Str_QueryCondi As String                 '单据组查询条件(接收单据列表传递查询条件)
  446. ']
  447. '以下为固定使用变量(单据)
  448. Dim BillCode As String                          '单据设计编码(索引号)
  449. Dim Var_Bill() As Variant                       '用来返回单据设计信息
  450. Dim ReportTitle As String                       '报表主标题
  451. Dim Tsxx As String                              '系统提示信息
  452. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  453. '以下为固定使用变量(文本框)
  454. Dim Textvar() As Variant                        '存储变体型文本框信息
  455. Dim Textboolean() As Boolean                    '存储布尔型文本框信息
  456. Dim Textint() As Integer                        '存储整型文本框信息
  457. Dim Textstr() As String                         '存储字符型文本框信息
  458. Dim Max_Text_Index As Integer                   '最大录入文本框索引值
  459. Dim TextGroupCode As String                     '文本框录入分组编码
  460. Dim TextValiLock As Boolean                     '文本框失去焦点是否进行有效性控制判断
  461. Dim TextValiJudgeLock() As Boolean              '文本框录入有效性判断控制锁
  462. Dim TextChangeLock As Boolean                   '文本框内容变换控制锁
  463.     
  464. Private Sub Form_KeyPress(KeyAscii As Integer)      '控 制 焦 点 转 移
  465.    
  466.     Dim jdzygs As Integer
  467.     jdzygs = 50
  468.     Select Case KeyAscii
  469.         Case vbKeyReturn
  470.             If Kjjdzy(jdzygs) Then
  471.                 KeyAscii = 0
  472.             End If
  473.         Case 39           '屏蔽字符"'"
  474.             KeyAscii = 0
  475.     End Select
  476. End Sub
  477. Private Sub Form_Load()                                                        '窗 体 装 入
  478.     '初始化各种锁值(Fixed)
  479.     Changelock = False             '网格行列改变控制锁
  480.     Gdtlock = False                '滚动条滚动控制
  481.     Yxxpdlock = True               '字段有效性判断锁
  482.     Hyxxpdlock = True              '行有效性判断锁
  483.     Wbkbhlock = False              '文本框内容改变锁
  484.    
  485.     '调入单据信息(需要修改BillCode)
  486.     BillCode = "2509"
  487.     Call Sub_ReadBillInfo(BillCode, Me, Var_Bill())
  488.     Lab_Title = Var_Bill(2)
  489.     Lab_Title.Move (Me.Width - Lab_Title.Width) / 2, 800
  490.     
  491.     '报表编码
  492.     XtReportCode = Var_Bill(5)
  493.     Load Dyymctbl
  494.   
  495.     '以下为文本框处理程序(Fixed)
  496.     TextGroupCode = Var_Bill(3)
  497.  
  498.     Call Drwbkxx(TextGroupCode, Textvar(), Textboolean(), Textint(), Textstr())  '读入文本框录入信息
  499.     Call Wbkcsh
  500.       
  501.     '单据变动置为False(Fixed)
  502.     Bln_BillChange = False
  503.     
  504.     '调入数据初始化模块(Fixed)
  505.     Lab_Djclzt.Caption = Xtcdcs
  506.     Call Sjcsh(Trim(Lab_Djclzt.Caption))
  507.       
  508. End Sub
  509. Private Sub Form_Unload(Cancel As Integer)           '窗体卸载
  510.     '是否保存已修改单据
  511.     Dim YAnswer As Integer
  512.     If Lab_OperStatus.Caption = "2" Or Lab_OperStatus.Caption = "3" Then
  513.         Tsxx = "单据尚未保存,是否退出?"
  514.         YAnswer = Xtxxts(Tsxx, 2, 2)
  515.         If YAnswer <> 1 Then
  516.             Cancel = 1
  517.             Exit Sub
  518.         End If
  519.     End If
  520.     
  521.     '卸载打印页面窗体
  522.     Unload Dyymctbl
  523.     
  524.     '判断单据是否发生变化,并返回相应标识
  525.     If Bln_BillChange Then
  526.         Xtfhcs = "1"
  527.     Else
  528.         Xtfhcs = "0"
  529.     End If
  530.    
  531. End Sub
  532. Private Sub Sjcsh(Str_Pzclzt As String)              '数据初始化模块(根据实际情况)
  533.     Dim Sqlstr As String       '查询单据列表条件
  534.     '[>>根据实际情况初始化
  535.     Select Case Str_Pzclzt
  536.         Case "1"   '填制单据
  537.       
  538.             '调入用户查询结果动态集
  539.             Sqlstr = "SELECT MalfunctionID From Dev_Malfunction  Where ArisesDate='" & Xtrq & "' ORDER BY MalfunctionID"
  540.             Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  541.       
  542.             '新增单据
  543.             Call Sub_AddBill
  544.         Case "2"   '查询单据(单据列表)
  545.         
  546.             '填充查询单据标识
  547.             Lab_BillId.Caption = XT_BillID
  548.             Str_QueryCondi = Xtcdcsfz
  549.                 
  550.             Call Sub_ShowBill
  551.        
  552.             Call Sub_OperStatus("10")
  553.       
  554.             '调入用户查询结果动态集,并定位该单据
  555.             Sqlstr = "SELECT MalfunctionID From Dev_V_Malfunction  " & Str_QueryCondi & " ORDER BY MalfunctionID"
  556.             Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  557.             Rec_Query.Find "MalfunctionID=" & Val(Lab_BillId.Caption)
  558.         Case "3"   '明细帐联查单据
  559.             '设置工具条显示
  560.             With Tlb_Action
  561.                 .Buttons("xz").Enabled = False             '新增
  562.                 .Buttons("xg").Enabled = False             '修改
  563.                 .Buttons("sc").Enabled = False             '删除
  564.                 .Buttons("fgh0").Enabled = False           '分隔行
  565.                 .Buttons("zh").Enabled = False             '增行
  566.                 .Buttons("sh").Enabled = False             '删行
  567.                 .Buttons("fgh1").Enabled = False           '分隔行
  568.                 .Buttons("bc").Enabled = False             '保存
  569.                 .Buttons("fq").Enabled = False             '放弃
  570.                 .Buttons("shsh").Enabled = False           '审核
  571.                 .Buttons("shqs").Enabled = False           '弃审
  572.                 .Buttons("fgh2").Enabled = False           '分隔行
  573.                 .Buttons("first").Enabled = False          '首张
  574.                 .Buttons("prev").Enabled = False           '上张
  575.                 .Buttons("next").Enabled = False           '下张
  576.                 .Buttons("last").Enabled = False           '末张
  577.                 .Buttons("fgh5").Enabled = False           '分割行
  578.             End With
  579.             Call Sub_ShowBill
  580.       
  581.             '设置操作状态为浏览
  582.             Lab_OperStatus.Caption = "1"
  583.       
  584.             '录入文本框
  585.             For jsqte = Max_Text_Index To 0 Step -1
  586.                 LrText(jsqte).Enabled = False
  587.             Next jsqte
  588.     End Select
  589.   
  590.     '<<]
  591.   
  592. End Sub
  593. Private Sub Sub_ShowBill()                                          '根据当前单据ID显示整张单据内容
  594.    
  595.     '过程默认参数为当前窗体中单据ID:Lab_BillID
  596.     Dim Sqlstr As String                           '临时使用字符串
  597.     Dim RecTemp As New ADODB.Recordset             '临时使用动态集
  598.     Dim jsqte As Long                              '临时计数器
  599.     '本张单据查询字符串
  600.     Sqlstr = "SELECT Dev_V_Malfunction.* FROM Dev_V_Malfunction " & _
  601.             " Where MalfunctionID=" & Val(Lab_BillId.Caption)
  602.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  603.       
  604.     With RecTemp
  605.         If Not .EOF Then
  606.             '[>>显示单据
  607.             TextChangeLock = True     '文本框加锁
  608.             LrText(0).Text = Trim(.Fields("MalfunCode"))                        '故障编号
  609.             LrText(1).Text = Trim(.Fields("DEVID") & "")                        '设备编号
  610.             LrText(2).Text = Trim(.Fields("DName"))                             '设备名称
  611.             LrText(3).Text = Trim(.Fields("Model") & "")                        '规格型号
  612.             LrText(4).Text = Trim(.Fields("DeptName") & "")                     '所属部门
  613.             LrText(5).Text = Trim(.Fields("ConkPheno") & "")                    '故障现象
  614.             LrText(6).Tag = Trim(.Fields("RepairSort") & "")                    '维修类别
  615.             LrText(6).Text = Trim(.Fields("RepairName") & "")
  616.             LrText(7).Text = Trim(.Fields("RprPosition") & "")                  '维修部位
  617.             LrText(8).Text = Trim(.Fields("RepairUnit") & "")                   '维修单位
  618.             LrText(9).Text = Val(.Fields("WorkHour") & "")                      '工时
  619.             LrText(10).Text = Trim(.Fields("ConkOutCause") & "")                '故障原因
  620.             LrText(11).Text = Trim(.Fields("DealResult") & "")                  '处理结果
  621.             LrText(12).Text = Format(.Fields("ArisesDate"), "yyyy-mm-dd")       '处理日期
  622.             LrText(13).Text = Val(.Fields("StopTime") & "")                     '停机台时
  623.             LrText(14).Tag = Trim(.Fields("ConkType") & "")                     '故障类型
  624.             LrText(14).Text = Trim(.Fields("Listname") & "")
  625.             LrText(15).Tag = Trim(.Fields("Operation") & "")                    '操作员
  626.             LrText(15).Text = Trim(.Fields("PersonName") & "")
  627.             LrText(16).Text = Trim(.Fields("Remark") & "")                      '备注
  628.             LrText(17).Text = Trim(.Fields("Maker") & "")                       '制表人
  629.             LrText(18).Text = Format(.Fields("MakerDate"), "yyyy-mm-dd")        '制表日期
  630.             LrText(19).Text = Trim(.Fields("Checker") & "")                     '审核人
  631.             TextChangeLock = False    '文本框解锁
  632.             '<<]
  633.         End If
  634.     End With
  635.       
  636.     '设置审核弃审按钮状态
  637.     Call Sub_CheckStatus
  638.        
  639. End Sub
  640. Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)             '用户点击工具条
  641.      
  642.     '屏蔽文本框,下拉组合框有效性判断
  643.     Valilock = True
  644.      
  645.     '屏蔽网格失去焦点产生的有效性判断
  646.     Changelock = True
  647.        
  648.     Select Case Button.Key
  649.         Case "yl"                                            '预 览
  650.             BillTextPrint Lab_Title, LrText, TextGroupCode, XtReportCode, False
  651.         Case "dy"                                            '打 印
  652.             Dim Yhanswer As Integer      '打印提示
  653.             
  654.             '用户确认是否打印单据
  655.             Tsxx = "请确认是否打印当前单据?"
  656.             Yhanswer = Xtxxts(Tsxx, 2, 2)
  657.             If Yhanswer = 2 Then
  658.                 Exit Sub
  659.             End If
  660.             BillTextPrint Lab_Title, LrText, TextGroupCode, XtReportCode, True
  661.         Case "xz"                                            '新 增
  662.             Call Sub_AddBill
  663.         Case "xg"                                            '修 改
  664.             Call Sub_EditBill
  665.         Case "sc"                                            '删 除
  666.             Call Sub_DeleteBill
  667.         Case "bc"                                            '保 存
  668.             Call Sub_SaveBill
  669.         Case "fq"                                            '放 弃
  670.             Call Sub_AbandonBill
  671.         Case "shsh"                                          '审 核
  672.             Call Sub_CheckBill
  673.         Case "shqs"                                          '弃 审
  674.             Call Sub_AbandonCheck
  675.         Case "first"                                         '首 张
  676.             Call Sub_First
  677.         Case "prev"                                          '上 张
  678.             Call Sub_Prev
  679.         Case "next"                                          '下 张
  680.             Call Sub_Next
  681.         Case "last"                                          '末 张
  682.             Call Sub_Last
  683.         Case "bz"                                            '帮 助
  684.             Call F1bz
  685.         Case "fh"                                            '退 出
  686.             Unload Me
  687.     End Select
  688.        
  689.     '解 锁
  690.     Valilock = False
  691.     Changelock = False
  692.     TextChangeLock = False
  693.         
  694. End Sub
  695. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)     '支持热键操作
  696.    
  697.     Select Case KeyCode
  698.         Case vbKeyF5          '增加单据
  699.             If Tlb_Action.Buttons("xz").Enabled And Tlb_Action.Buttons("xz").Visible Then
  700.                 Call Sub_AddBill
  701.             End If
  702.         Case vbKeyF3          '修改单据
  703.             If Tlb_Action.Buttons("xg").Enabled And Tlb_Action.Buttons("xg").Visible Then
  704.                 Call Sub_EditBill
  705.             End If
  706.         Case vbKeyF6          '保存单据
  707.             If Tlb_Action.Buttons("bc").Enabled And Tlb_Action.Buttons("bc").Visible Then
  708.                 Call Sub_SaveBill
  709.             End If
  710.     End Select
  711. End Sub
  712. Private Sub Sub_OperStatus(Str_Status As String)                 '工具条依据不同状态所进行的变化
  713.   
  714.     With Tlb_Action
  715.         Select Case Str_Status
  716.             Case "10"   '浏览((列表)调入单据处理时的进入状态、(列表)新增状态时放弃录入)
  717.                 '工具条
  718.                 .Buttons("dy").Enabled = True       '打印
  719.                 .Buttons("yl").Enabled = True       '预览
  720.                 .Buttons("xz").Enabled = True       '新增
  721.                 .Buttons("xg").Enabled = True       '修改
  722.                 .Buttons("sc").Enabled = True       '删除
  723.                 .Buttons("bc").Enabled = False      '保存
  724.                 .Buttons("fq").Enabled = False      '放弃
  725.                 .Buttons("first").Enabled = True    '首张
  726.                 .Buttons("prev").Enabled = True     '上张
  727.                 .Buttons("next").Enabled = True     '下张
  728.                 .Buttons("last").Enabled = True     '末张
  729.                 .Buttons("bz").Enabled = True       '帮助
  730.                 .Buttons("fh").Enabled = True       '退出
  731.                 
  732.                 '设置审核弃审按钮状态
  733.                 Call Sub_CheckStatus
  734.                 
  735.                 '设置文本框录入状态
  736.                 Call Sub_LrtextStatus(False)
  737.             Case "20"   '新增单据((录入)新增一张单据 、(列表)新增一张单据)
  738.                  '工具条
  739.                  .Buttons("dy").Enabled = False      '打印
  740.                  .Buttons("yl").Enabled = False      '预览
  741.                  .Buttons("xz").Enabled = False      '新增
  742.                  .Buttons("xg").Enabled = False      '修改
  743.                  .Buttons("sc").Enabled = False      '删除
  744.                  .Buttons("bc").Enabled = True       '保存
  745.                  .Buttons("fq").Enabled = True       '放弃
  746.                  .Buttons("shsh").Enabled = False    '审核
  747.                  .Buttons("shqs").Enabled = False    '弃审
  748.                  .Buttons("first").Enabled = False   '首张
  749.                  .Buttons("prev").Enabled = False    '上张
  750.                  .Buttons("next").Enabled = False    '下张
  751.                  .Buttons("last").Enabled = False    '末张
  752.                  .Buttons("bz").Enabled = True       '帮助
  753.                  .Buttons("fh").Enabled = True       '退出
  754.                  
  755.                  '设置文本框录入状态
  756.                  Call Sub_LrtextStatus(True)
  757.             Case "30"   '修改((录入)调入修改功能、(列表)调入修改功能)
  758.                 '工具条
  759.                 .Buttons("dy").Enabled = False      '打印
  760.                 .Buttons("yl").Enabled = False      '预览
  761.                 .Buttons("xz").Enabled = False      '新增
  762.                 .Buttons("xg").Enabled = False      '修改
  763.                 .Buttons("sc").Enabled = False      '删除
  764.                 .Buttons("bc").Enabled = True       '保存
  765.                 .Buttons("fq").Enabled = True       '放弃
  766.                 .Buttons("shsh").Enabled = False    '审核
  767.                 .Buttons("shqs").Enabled = False    '弃审
  768.                 .Buttons("first").Enabled = False   '首张
  769.                 .Buttons("prev").Enabled = False    '上张
  770.                 .Buttons("next").Enabled = False    '下张
  771.                 .Buttons("last").Enabled = False    '末张
  772.                 .Buttons("bz").Enabled = True       '帮助
  773.                 .Buttons("fh").Enabled = True       '退出
  774.                 
  775.                 '设置文本框录入状态
  776.                 Call Sub_LrtextStatus(True)
  777.         End Select
  778.     End With
  779.     
  780. End Sub
  781. Private Sub Sub_LrtextStatus(TextEnabled As Boolean)                            '设置录入文本框状态
  782.     '录入文本框状态设置
  783.     If TextEnabled Then
  784.         For jsqte = Max_Text_Index To 0 Step -1
  785.             '判断文本框是否可编辑
  786.             If Textboolean(jsqte, 5) Then
  787.                 LrText(jsqte).Enabled = True
  788.             Else
  789.                 LrText(jsqte).Enabled = False
  790.             End If
  791.         Next jsqte
  792.     Else
  793.         For jsqte = Max_Text_Index To 0 Step -1
  794.             LrText(jsqte).Enabled = False
  795.         Next jsqte
  796.     End If
  797. End Sub
  798. Private Sub Sub_CheckStatus()                                       '设置审核弃审按钮状态(亦可设置其他动作按钮状态)
  799.     
  800.     '根据当前单据状态来确定审核弃审按钮状态
  801.     If Trim(LrText(19).Text) = "" Then
  802.         Tlb_Action.Buttons("shsh").Enabled = True      '审核
  803.         Tlb_Action.Buttons("shqs").Enabled = False   '弃审
  804.     Else
  805.         Tlb_Action.Buttons("shqs").Enabled = True      '弃审
  806.         Tlb_Action.Buttons("shsh").Enabled = False   '审核
  807.     End If
  808.     
  809. End Sub
  810. Private Sub Sub_AddBill()                                                '新增一张单据
  811.     
  812.     Dim RecTemp As New ADODB.Recordset            '临时使用动态集
  813.     Dim jsqte As Long                             '临时计数器
  814.      If Not Security_Log("Dev_MalfunctionEdit", Xtczybm, 1, True) Then
  815.         Exit Sub
  816.      End If
  817.     '设置操作状态为新增(Fixed)
  818.     Lab_OperStatus.Caption = "2"
  819.    
  820.     '设置工具条状态(Fixed)
  821.     Call Sub_OperStatus("20")
  822.    
  823.     '清空VouchID(Fixed)
  824.     Lab_BillId.Caption = ""
  825.    
  826.     '录入文本框清除内容
  827.     For jsqte = Max_Text_Index To 0 Step -1
  828.         LrText(jsqte).Tag = ""
  829.         LrText(jsqte).Text = ""
  830.     Next jsqte
  831.    
  832.     '[>>显示制单人,清空审核人,此处还可以设置录入默认值如自动生成单据号、默认单据录入日期注意加锁
  833.     TextChangeLock = True
  834.     LrText(17).Text = Xtczy
  835.     LrText(18).Text = Format(Xtrq, "yyyy-mm-dd")
  836.     LrText(0).Enabled = False
  837.     LrText(2).Enabled = False
  838.     LrText(3).Enabled = False
  839.     LrText(4).Enabled = False
  840.     LrText(17).Enabled = False
  841.     LrText(18).Enabled = False
  842.     LrText(19).Enabled = False
  843.     TextChangeLock = False
  844.     
  845.     '读取最新的单据编码
  846.     LrText(0).Text = CreatBillCode(BillCode, False)
  847.    
  848.     '<<]
  849.    
  850.     '让第一个录入项得到焦点(Fixed)
  851.     On Error Resume Next
  852.     LrText(1).SetFocus
  853.    
  854. End Sub
  855. Private Sub Sub_EditBill()                                                '修改一张单据
  856.     
  857.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  858.      If Not Security_Log("Dev_MalfunctionEdit", Xtczybm, 1, True) Then
  859.         Exit Sub
  860.      End If
  861.     '非有效单据不予进行修改动作
  862.     If Val(Lab_BillId.Caption) = 0 Then
  863.         Exit Sub
  864.     End If
  865.    
  866.     '判断当前单据是否允许修改
  867.     If Not Fun_AllowEdit Then
  868.         Exit Sub
  869.     End If
  870.    
  871.     '设置操作状态为修改
  872.     Lab_OperStatus.Caption = "3"
  873.    
  874.     '设置工具条状态
  875.     Call Sub_OperStatus("30")
  876.       
  877.     '显示制单人
  878.     LrText(0).Enabled = False
  879.     LrText(2).Enabled = False
  880.     LrText(3).Enabled = False
  881.     LrText(4).Enabled = False
  882.     LrText(17).Enabled = False
  883.     LrText(18).Enabled = False
  884.     LrText(19).Enabled = False
  885.     LrText(19).Text = Xtczy
  886.    
  887. End Sub
  888. Private Sub Sub_DeleteBill()                                               '删除当前单据
  889.     
  890.     Dim YAnswer As Integer               '确认是否删除当前单据
  891.     Dim jsqte As Long                    '临时使用计数器
  892.      If Not Security_Log("Dev_MalfunctionEdit", Xtczybm, 1, True) Then
  893.         Exit Sub
  894.      End If
  895.     '非有效单据不予进行删除动作
  896.     If Val(Lab_BillId.Caption) = 0 Then
  897.         Exit Sub
  898.     End If
  899.    
  900.     Tsxx = "请确认是否删除当前单据?"
  901.     YAnswer = Xtxxts(Tsxx, 2, 2)
  902.    
  903.     If YAnswer = 1 Then
  904.         
  905.         '判断当前单据是否允许删除
  906.         If Not Fun_AllowEdit Then
  907.             Exit Sub
  908.         End If
  909.         
  910.         '进行事务处理
  911.         On Error GoTo Swcwcl
  912.         Cw_DataEnvi.DataConnect.BeginTrans
  913.         
  914.         '1.删除单据所有内容
  915.         Cw_DataEnvi.DataConnect.Execute ("Delete Dev_Malfunction Where MalfunctionID=" & Val(Lab_BillId.Caption))
  916.         Cw_DataEnvi.DataConnect.CommitTrans
  917.         
  918.         '标识单据发生改动
  919.         Bln_BillChange = True
  920.         
  921.         '单据ID置0
  922.         Lab_BillId.Caption = 0
  923.     Else
  924.         Exit Sub
  925.     End If
  926.      
  927.     '删除单据后重置状态
  928.         
  929.     '1.显示下一张单据
  930.     Call Sub_Next
  931.         
  932.     '2.如果无下一张单据则搜索上一张单据
  933.     If Val(Lab_BillId.Caption) = 0 Then
  934.         Call Sub_Prev
  935.     End If
  936.         
  937.     '3.如无单据则置单据为空状态
  938.     If Val(Lab_BillId.Caption) = 0 Then
  939.         '清除录入文本框
  940.         For jsqte = Max_Text_Index To 0 Step -1
  941.             LrText(jsqte).Tag = ""
  942.             LrText(jsqte).Text = ""
  943.         Next jsqte
  944.         '设置操作状态为浏览
  945.         Lab_OperStatus = "1"
  946.         Call Sub_OperStatus("10")
  947.     End If
  948.     
  949.     Rec_Query.Requery
  950.     Rec_Query.Find "MalfunctionID=" & Val(Lab_BillId.Caption)
  951.     Exit Sub
  952. Swcwcl:          '单据删除时出现错误
  953.     Cw_DataEnvi.DataConnect.RollbackTrans
  954.     Tsxx = "单据删除过程中出现未知错误,程序自动恢复保存前状态!"
  955.     Call Xtxxts(Tsxx, 0, 1)
  956.     Exit Sub
  957. End Sub
  958. Private Sub Sub_AbandonBill()                                              '放弃对当前单据的操作
  959.  
  960.     Dim jsqte As Long                    '临时使用计数器
  961.   
  962.     '如果单据有效则重新显示当前单据,置单据为空状态
  963.     If Not Rec_Query.EOF Then
  964.         Lab_BillId.Caption = Rec_Query.Fields("MalfunctionID")
  965.         Call Sub_ShowBill
  966.     Else
  967.         '单据ID置为0
  968.         Lab_BillId.Caption = 0
  969.      
  970.         '清除录入文本框
  971.         For jsqte = Max_Text_Index To 0 Step -1
  972.             LrText(jsqte).Tag = ""
  973.             LrText(jsqte).Text = ""
  974.         Next jsqte
  975.     End If
  976.     
  977.     '设置操作状态为浏览
  978.     Lab_OperStatus = "1"
  979.     Call Sub_OperStatus("10")
  980. End Sub
  981. Private Function Sub_SaveBill() As Boolean                                   '保 存 单 据
  982.     
  983.     Dim RecTemp As New ADODB.Recordset                    '临时使用动态集
  984.     Dim Rec_Bill As New ADODB.Recordset                   '单据表动态集
  985.     Dim jsqte As Integer                                  '临时计数器
  986.       
  987.     Sub_SaveBill = False
  988.   
  989.     '一.============先对单据内容进行有效性判断==============='
  990.   
  991.     '先进行字段不能为空或不能为零有效性判断(Fixed)
  992.     For jsqte = 0 To Max_Text_Index
  993.         If Textint(jsqte, 8) = 1 Then     '字段不能为空
  994.             If Len(Trim(LrText(jsqte).Text)) = 0 Then
  995.                 Tsxx = Textstr(jsqte, 7) & "不能为空!"
  996.                 Call Xtxxts(Tsxx, 0, 1)
  997.                 LrText(jsqte).SetFocus
  998.                 Exit Function
  999.             End If
  1000.         Else
  1001.             If Textint(jsqte, 8) = 2 Then   '字段不能为零
  1002.                 If Val(Trim(LrText(jsqte).Text)) = 0 Then
  1003.                     Tsxx = Textstr(jsqte, 7) & "不能为零!"
  1004.                     Call Xtxxts(Tsxx, 0, 1)
  1005.                     LrText(jsqte).SetFocus
  1006.                     Exit Function
  1007.                 End If
  1008.             End If
  1009.         End If
  1010.     Next jsqte
  1011.     
  1012.     '对需要进行事后判断的文本框录入内容进行有效性判断 (Fixed)
  1013.     For jsqte = 0 To Max_Text_Index
  1014.         If Textint(jsqte, 9) = 0 Or Textint(jsqte, 9) = 2 Then
  1015.             If Not TextYxxpd(jsqte) Then
  1016.                 Exit Function
  1017.             End If
  1018.         End If
  1019.     Next jsqte
  1020.   
  1021.     '[>>
  1022.   
  1023.     '可在此区域写入其他对单据表头内容的有效性判断,具体格式参照如下
  1024.    
  1025.     '<<]
  1026.   
  1027.     '二.=============如果以上有效性检查均顺利通过,则执行存盘动作============'
  1028.    
  1029.     '对存盘进行事务处理(Fixed)
  1030.     On Error GoTo Swcwcl
  1031.     Cw_DataEnvi.DataConnect.BeginTrans
  1032.     
  1033.     '判断单据状态以进行不同处理
  1034.     
  1035.     '1.先对单据主表进行处理
  1036.     If Trim(Lab_OperStatus) = "2" Then
  1037.         '新增单据
  1038.         
  1039.         '1.对于某些单据号自动生成的单据则可在此处自动生成
  1040.         LrText(0).Text = CreatBillCode(BillCode, True)
  1041.         
  1042.         '2.开始存盘
  1043.          
  1044.         '打开单据表动态集
  1045.         If Rec_Bill.State = 1 Then Rec_Bill.Close
  1046.         Rec_Bill.Open "Select * From Dev_Malfunction Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1047.         With Rec_Bill
  1048.             .AddNew
  1049.             .Fields("MalfunctionID") = CreatBillID(BillCode)    '故障ID
  1050.             .Fields("MalfunCode") = Trim(LrText(0).Text)        '故障单号
  1051.             .Fields("DEVID") = Trim(LrText(1).Text)             '设备编号
  1052.             .Fields("ConkPheno") = Trim(LrText(5).Text)         '故障现象
  1053.             .Fields("RepairSort") = Trim(LrText(6).Tag)         '维修类别
  1054.             .Fields("RprPosition") = Trim(LrText(7).Text)
  1055.             .Fields("RepairUnit") = Trim(LrText(8).Text)        '维修单位
  1056.             .Fields("WorkHour") = Val(LrText(9).Text)           '工时
  1057.             .Fields("ConkOutCause") = Trim(LrText(10).Text)     '故障原因
  1058.             .Fields("DealResult") = Trim(LrText(11).Text)       '处理结果
  1059.             .Fields("ArisesDate") = CDate(LrText(12).Text)      '发生日期
  1060.             .Fields("StopTime") = Val(LrText(13).Text)          '停机台时
  1061.             .Fields("ConkType") = Trim(LrText(14).Tag)          '故障类型
  1062.             .Fields("Operation") = Trim(LrText(15).Tag)
  1063.             .Fields("Remark") = Trim(LrText(16).Text)           '备注
  1064.             .Fields("Maker") = Xtczy                            '制表人
  1065.             .Fields("MakerDate") = Xtrq                         '制表日期
  1066.             .Fields("Checker") = ""                             '审核人
  1067.             .Update
  1068.             
  1069.             '系统读出单据ID写入Lab_BillID
  1070.             Lab_BillId.Caption = .Fields("MalfunctionID")
  1071.         End With
  1072.     Else
  1073.         '修改单据
  1074.        
  1075.         '打开单据表动态集
  1076.         If Rec_Bill.State = 1 Then Rec_Bill.Close
  1077.         Rec_Bill.Open "Select * From Dev_Malfunction  Where MalfunctionID=" & Val(Lab_BillId.Caption), Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1078.         With Rec_Bill
  1079.             .Fields("MalfunCode") = Trim(LrText(0).Text)        '故障单号
  1080.             .Fields("DEVID") = Trim(LrText(1).Text)             '设备编号
  1081.             .Fields("ConkPheno") = Trim(LrText(5).Text)         '故障现象
  1082.             .Fields("RepairSort") = Trim(LrText(6).Tag)         '维修类别
  1083.             .Fields("RprPosition") = Trim(LrText(7).Text)
  1084.             .Fields("RepairUnit") = Trim(LrText(8).Text)        '维修单位
  1085.             .Fields("WorkHour") = Val(LrText(9).Text)           '工时
  1086.             .Fields("ConkOutCause") = Trim(LrText(10).Text)     '故障原因
  1087.             .Fields("DealResult") = Trim(LrText(11).Text)       '处理结果
  1088.             .Fields("ArisesDate") = CDate(LrText(12).Text)      '发生日期
  1089.             .Fields("StopTime") = Val(LrText(13).Text)          '停机台时
  1090.             .Fields("ConkType") = Trim(LrText(14).Tag)          '故障类型
  1091.             .Fields("Operation") = Trim(LrText(15).Tag)
  1092.             .Fields("Remark") = Trim(LrText(16).Text)           '备注
  1093.             .Fields("Maker") = Xtczy                            '制表人
  1094.             .Fields("MakerDate") = Xtrq                         '制表日期
  1095.             .Fields("Checker") = ""                             '审核人
  1096.             .Update
  1097.         End With
  1098.     End If
  1099.          
  1100.     Cw_DataEnvi.DataConnect.CommitTrans
  1101.     Sub_SaveBill = True
  1102.     Tsxx = "单据存盘完毕! 单据号:" & Trim(LrText(0).Text)
  1103.     Call Xtxxts(Tsxx, 0, 4)
  1104.   
  1105.     '标识单据发生改动
  1106.     Bln_BillChange = True
  1107.   
  1108.     '设置单据改变后的状态
  1109.     Lab_OperStatus = "1"
  1110.     Call Sub_OperStatus("10")
  1111.     Rec_Query.Requery
  1112.     Rec_Query.Find "MalfunctionID=" & Val(Lab_BillId.Caption)
  1113.     Exit Function
  1114. Swcwcl:       '数据存盘时出现错误
  1115.     Cw_DataEnvi.DataConnect.RollbackTrans
  1116.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  1117.     Call Xtxxts(Tsxx, 0, 1)
  1118.     Exit Function
  1119. End Function
  1120. '选择首张,上张,下张,末张(此4个过程只需用您的单据ID字段名替换"MalfunctionID"即可)
  1121. Private Sub Sub_First()             '首 张
  1122.     
  1123.     With Rec_Query
  1124.         If .RecordCount = 0 Then
  1125.             Exit Sub
  1126.         End If
  1127.         .MoveFirst
  1128.         Lab_BillId.Caption = .Fields("MalfunctionID")
  1129.         Call Sub_ShowBill
  1130.     End With
  1131. End Sub
  1132. Private Sub Sub_Prev()             '上 张
  1133.     
  1134.     With Rec_Query
  1135.         If .RecordCount = 0 Then
  1136.             Exit Sub
  1137.         End If
  1138.         If Not .BOF Then
  1139.             .MovePrevious
  1140.         End If
  1141.        
  1142.         If Not .BOF Then
  1143.             Lab_BillId.Caption = .Fields("MalfunctionID")
  1144.         Else
  1145.             .MoveNext
  1146.         End If
  1147.       
  1148.         Call Sub_ShowBill
  1149.     End With
  1150. End Sub
  1151. Private Sub Sub_Next()             '下 张
  1152.     
  1153.     With Rec_Query
  1154.         If .RecordCount = 0 Then
  1155.             Exit Sub
  1156.         End If
  1157.         If Not .EOF Then
  1158.             .MoveNext
  1159.         End If
  1160.       
  1161.         If Not .EOF Then
  1162.             Lab_BillId.Caption = .Fields("MalfunctionID")
  1163.         Else
  1164.             .MovePrevious
  1165.         End If
  1166.      
  1167.         Call Sub_ShowBill
  1168.     End With
  1169. End Sub
  1170. Private Sub Sub_Last()              '末 张
  1171.     
  1172.     With Rec_Query
  1173.         If .RecordCount = 0 Then
  1174.             Exit Sub
  1175.         End If
  1176.         .MoveLast
  1177.         Lab_BillId.Caption = .Fields("MalfunctionID")
  1178.         Call Sub_ShowBill
  1179.     End With
  1180. End Sub
  1181.     
  1182. '[>>===================以下为根据实际业务需要自定义过程区域=============================<<]
  1183. '审核,弃审
  1184. Private Sub Sub_CheckBill()             '审 核
  1185.     '[>>
  1186.     
  1187.     '此处可以写入禁止单据审核的理由
  1188.        
  1189.     '<<]
  1190.      If Not Security_Log("Dev_MalfunctionCheck", Xtczybm, 1, True) Then
  1191.         Exit Sub
  1192.      End If
  1193.     '将单据写入审核标识
  1194.     Cw_DataEnvi.DataConnect.Execute ("Update Dev_Malfunction Set Checker='" & Xtczy & "' Where MalfunctionID=" & Val(Lab_BillId.Caption))
  1195.     
  1196.     '写入系统操作员
  1197.     LrText(19).Text = Xtczy
  1198.     
  1199.     '设置审核弃审按钮状态
  1200.     Call Sub_CheckStatus
  1201.     
  1202.     '标识单据发生变化
  1203.     Bln_BillChange = True
  1204. End Sub
  1205. Private Sub Sub_AbandonCheck()          '弃 审
  1206.    '[>>
  1207.     
  1208.     '此处可以写入禁止单据弃审的理由
  1209.        
  1210.     '<<]
  1211.      If Not Security_Log("Dev_MalfunctionCheck", Xtczybm, 1, True) Then
  1212.         Exit Sub
  1213.      End If
  1214.     '将单据清除审核标识
  1215.     Cw_DataEnvi.DataConnect.Execute ("Update Dev_Malfunction Set Checker='' Where MalfunctionID=" & Val(Lab_BillId.Caption))
  1216.     
  1217.     '清空单据审核人
  1218.     LrText(19).Text = ""
  1219.     
  1220.     '设置审核弃审按钮状态
  1221.     Call Sub_CheckStatus
  1222.     
  1223.     '标识单据发生变化
  1224.     Bln_BillChange = True
  1225.   
  1226. End Sub
  1227. Private Function Fun_AllowEdit() As Boolean                      '判断当前单据是否允许编辑或删除
  1228.   
  1229.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  1230.     Fun_AllowEdit = False
  1231.     Sqlstr = "Select Checker From Dev_Malfunction Where MalfunctionID=" & Val(Lab_BillId.Caption)
  1232.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1233.     With RecTemp
  1234.         If Not .EOF Then
  1235.             If Trim(.Fields("Checker") & "") <> "" Then
  1236.                 Tsxx = "该单据已审核确认,不能修改或删除!"
  1237.                 Call Xtxxts(Tsxx, 0, 4)
  1238.                 Exit Function
  1239.             End If
  1240.             End If
  1241.     End With
  1242.     Fun_AllowEdit = True
  1243. End Function
  1244. '[>>===================以上为根据实际业务需要自定义过程区域=============================<<]
  1245. '*****************************以下为文本框录入处理程序(固定不变部分)*******************************'
  1246. '************以下为文本框录入处理程序(固定不变部分)*************'
  1247. Private Sub Wbklrwbcl(Index As Integer)    '文本框录入事后处理程序
  1248.   Dim RecTemp As New ADODB.Recordset
  1249.   
  1250.     '以下为依据实际情况自定义部分[
  1251.   
  1252.     Select Case Index
  1253.     '在此填写文本框录入事后处理程序
  1254.         Case 1
  1255.             Sqlstr = "SELECT Dev_Main.*,Gy_Department.DeptName" & _
  1256.                 " FROM Dev_Main LEFT OUTER JOIN Gy_Department ON Dev_Main.DeptCode = Gy_Department.DeptCode " & _
  1257.                 " Where DEVID='" & Trim(LrText(1).Text) & "'"
  1258.             Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1259.             If Not RecTemp.EOF Then
  1260.                 LrText(2).Text = RecTemp.Fields("Dname")
  1261.                 LrText(3).Text = RecTemp.Fields("Model")
  1262.                 LrText(4).Text = RecTemp.Fields("Deptname")
  1263.                 LrText(4).Tag = RecTemp.Fields("Deptcode")
  1264.             End If
  1265.     End Select
  1266.     ']以上为依据实际情况自定义部分
  1267.   
  1268. End Sub
  1269. Private Sub LrText_Change(Index As Integer)
  1270.     
  1271.     '屏蔽程序改变控制
  1272.     If TextChangeLock Then
  1273.         Exit Sub
  1274.     End If
  1275.     
  1276.     TextValiJudgeLock(Index) = False    '打开有效性判断锁
  1277.     
  1278.     '限制字段录入长度
  1279.           
  1280.     TextChangeLock = True  '加锁(防止执行Lrtext_Change)
  1281.      Call TextChangeLimit(LrText(Index), Textint(Index, 1))  '去掉无效字符
  1282.     Select Case Textint(Index, 1)
  1283.         Case 8, 11      '金额型
  1284.             Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
  1285.         Case 9, 12      '数量型
  1286.             Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
  1287.         Case 10          '单价型
  1288.             Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1289.         Case Else        '其他小数类型控制
  1290.             If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
  1291.                 Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
  1292.             End If
  1293.     End Select
  1294.         
  1295.     TextChangeLock = False '解锁
  1296. End Sub
  1297. Private Sub LrText_GotFocus(Index As Integer)                                                 '文本框得到焦点,显示相应信息
  1298.     
  1299.     Call TextShow(Index)
  1300.     CurTextIndex = Index
  1301.     LrText(Index).SelStart = Len(LrText(Index))
  1302. End Sub
  1303. Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)            '字段按F2键提供帮助
  1304.     
  1305.     Select Case KeyCode
  1306.         Case vbKeyF2
  1307.             Call Text_Help(Index)
  1308.     End Select
  1309. End Sub
  1310. Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer)                            '文本框录入事中控制
  1311.     Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
  1312. End Sub
  1313. Private Sub LrText_LostFocus(Index As Integer)                                                '文本框失去焦点
  1314.     '显示相应信息但不能进行有效性判断
  1315.     Select Case Index
  1316.         Case 1
  1317.             If Trim(LrText(0).Text) = "" Then
  1318.                 Exit Sub
  1319.             Else
  1320.                 Call Wbklrwbcl(Index)
  1321.             End If
  1322.             
  1323.     End Select
  1324. End Sub
  1325. Private Sub Ydcommand1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)     '按钮提供帮助
  1326.     '文本框处于非录入状态时不允许调入帮助
  1327.     If Not LrText(Index).Enabled Then
  1328.         Exit Sub
  1329.     End If
  1330.    
  1331.     Call Text_Help(Index)
  1332. End Sub
  1333. Private Sub Text_Help(Index As Integer)                                                       '录入字段帮助
  1334.     
  1335.     If Not Textboolean(Index, 1) Then
  1336.         Exit Sub
  1337.     End If
  1338.      
  1339.     '调用帮助
  1340.     Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
  1341.   
  1342.     '根据设置选择显示编码和名称,并进行存储
  1343.     If Len(Xtfhcs) <> 0 Then
  1344.         If Textint(Index, 3) = 1 Then
  1345.             LrText(Index).Text = Xtfhcsfz
  1346.             LrText(Index).Tag = Xtfhcs
  1347.         Else
  1348.             LrText(Index).Text = Xtfhcs
  1349.             LrText(Index).Tag = Xtfhcsfz
  1350.         End If
  1351.     End If
  1352.    
  1353.     LrText(Index).SetFocus
  1354.     
  1355.      If Index = 1 And Len(Xtfhcs) <> 0 Then
  1356.         Call Wbklrwbcl(Index)
  1357.      End If
  1358.     
  1359. End Sub
  1360. Private Sub TextShow(Index As Integer)        '文本框得到焦点,显示相应信息
  1361.     '填写文本框得到焦点,进行相应信息处理程序
  1362.    
  1363. End Sub
  1364. Private Sub Wbkcsh()                          '录入文本框初始化
  1365.     Dim Int_TabIndex As Integer         'Tab焦点计数器
  1366.   
  1367.     '单据录入中文本框焦点由0开始
  1368.     LrText(0).TabIndex = 0
  1369.   
  1370.     '最大录入文本框索引值
  1371.     Max_Text_Index = Textvar(1)
  1372.   
  1373.     ReDim TextValiJudgeLock(Max_Text_Index)
  1374.     For jsqte = 0 To Max_Text_Index
  1375.         
  1376.         '判断此文本框录入索引号是否存在,如存在则对其进行初始化
  1377.         If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
  1378.         
  1379.             '自动装入录入文本框和其解释标签
  1380.             If jsqte <> 0 Then
  1381.                 Load LrText(jsqte)
  1382.                 Load tsLabel(jsqte)
  1383.            
  1384.                 '判断录入文本框是否显示
  1385.                 If Textboolean(jsqte, 4) Then
  1386.                     LrText(jsqte).Visible = True
  1387.                     tsLabel(jsqte).Visible = True
  1388.                 End If
  1389.             
  1390.                 '判断文本框是否可编辑
  1391.                 If Textboolean(jsqte, 5) Then
  1392.                     LrText(jsqte).Enabled = True
  1393.                 Else
  1394.                     LrText(jsqte).Enabled = False
  1395.                 End If
  1396.                 
  1397.                  '判断文本框是否提供帮助
  1398.                 If Textboolean(jsqte, 1) Then
  1399.                     If Not Textboolean(jsqte, 3) Then
  1400.                         Load Ydcommand1(jsqte)
  1401.                     End If
  1402.                 End If
  1403.             End If
  1404.            
  1405.            '初始化其内容
  1406.             TextChangeLock = True
  1407.             LrText(jsqte).Text = ""
  1408.             LrText(jsqte).Tag = ""
  1409.             If Textint(jsqte, 5) <> 0 Then
  1410.                 LrText(jsqte).MaxLength = Textint(jsqte, 5)
  1411.             End If
  1412.             TextChangeLock = False
  1413.         
  1414.             '设置文本框位置及大小,并设置相应标签内容及其位置
  1415.             LrText(jsqte).Move Textint(jsqte, 13), Textint(jsqte, 12), Textint(jsqte, 11), Textint(jsqte, 10)
  1416.             tsLabel(jsqte).Caption = Textstr(jsqte, 7) & ":"
  1417.             tsLabel(jsqte).Move Textint(jsqte, 13) - tsLabel(jsqte).Width - 20, Textint(jsqte, 12) + (Textint(jsqte, 10) - tsLabel(jsqte).Height) / 2 - 30
  1418.             
  1419.             '判断文本框是否提供帮助
  1420.             If Textboolean(jsqte, 1) Then
  1421.                 Ydcommand1(jsqte).Visible = True
  1422.                 Ydcommand1(jsqte).Move LrText(jsqte).Left + LrText(jsqte).Width, LrText(jsqte).Top
  1423.             End If
  1424.             
  1425.             
  1426.         End If
  1427.      
  1428.         '将文本框有效性判断进行加锁,在文本框内容发生变化时将锁打开
  1429.         TextValiJudgeLock(jsqte) = True
  1430.       
  1431.     Next jsqte
  1432.     
  1433.     '设置文本框焦点转移顺序(前提文本焦点从0至Max_Text_Index)
  1434.     For Int_TabIndex = 0 To Max_Text_Index
  1435.         For jsqte = 0 To Max_Text_Index
  1436.             If Textint(jsqte, 14) = Int_TabIndex Then
  1437.                LrText(jsqte).TabIndex = Int_TabIndex
  1438.             End If
  1439.         Next jsqte
  1440.     Next Int_TabIndex
  1441.   
  1442. End Sub
  1443. Private Function TextYxxpd(Index As Integer) As Boolean           '文本框有效性判断
  1444.   
  1445.     Dim Sqlstr As String
  1446.     Dim Findrec As ADODB.Recordset
  1447.   
  1448.     '文本框内容未曾改变不进行有效性判断
  1449.     If TextValiJudgeLock(Index) Then
  1450.         TextYxxpd = True
  1451.         Exit Function
  1452.     End If
  1453.   
  1454.     '文本框内容为空认为有效,并清空其Tag值
  1455.     If Trim(LrText(Index)) = "" Then
  1456.         LrText(Index).Tag = ""
  1457.         Call Wbklrwbcl(Index)
  1458.         TextValiJudgeLock(Index) = True
  1459.         TextYxxpd = True
  1460.         Exit Function
  1461.     End If
  1462.   
  1463.     '可在此加入不做有效性判断的理由
  1464.   
  1465.     Select Case Textint(Index, 4)
  1466.         Case 1      '编码型
  1467.             Sqlstr = Trim(Textstr(Index, 5))
  1468.             Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
  1469.             Set Findrec = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1470.             If Findrec.EOF Then
  1471.                 Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
  1472.                 LrText(Index).SetFocus
  1473.                 Exit Function
  1474.             Else
  1475.                 Select Case Textint(Index, 3)
  1476.                     Case 0
  1477.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  1478.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  1479.                         End If
  1480.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  1481.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  1482.                         End If
  1483.                     Case 1
  1484.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  1485.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  1486.                         End If
  1487.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  1488.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  1489.                         End If
  1490.                 End Select
  1491.             End If
  1492.         Case 2      '日期型
  1493.             If IsDate(LrText(Index).Text) Then
  1494.                 LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
  1495.                 If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
  1496.                     LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
  1497.                 End If
  1498.             Else
  1499.                 Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
  1500.                 Call Xtxxts(Tsxx, 0, 1)
  1501.                 LrText(Index).SetFocus
  1502.                 Exit Function
  1503.             End If
  1504.         Case 3      '其他类型
  1505.     End Select
  1506.     
  1507.     '如果有效则加锁,用户不改变内容则不再进行有效性判断
  1508.     TextValiJudgeLock(Index) = True
  1509.     '调用文本框事后处理程序
  1510.     Call Wbklrwbcl(Index)
  1511.        
  1512.     '有效性判断通过则返回True
  1513.     TextYxxpd = True
  1514.    
  1515. End Function