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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form Note_FrmNoteDiscount 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "应收票据贴现"
  5.    ClientHeight    =   3555
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   6120
  9.    HelpContextID   =   20403
  10.    Icon            =   "应收票据_贴现.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3555
  16.    ScaleWidth      =   6120
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   1  'CenterOwner
  19.    Begin VB.Frame Frame1 
  20.       Height          =   3075
  21.       Left            =   60
  22.       TabIndex        =   15
  23.       Top             =   30
  24.       Width           =   6015
  25.       Begin VB.TextBox LrText 
  26.          Height          =   300
  27.          Index           =   11
  28.          Left            =   4140
  29.          TabIndex        =   11
  30.          Text            =   "11"
  31.          Top             =   2220
  32.          Width           =   1725
  33.       End
  34.       Begin VB.TextBox LrText 
  35.          Height          =   300
  36.          Index           =   10
  37.          Left            =   960
  38.          TabIndex        =   10
  39.          Text            =   "10"
  40.          Top             =   2220
  41.          Width           =   1725
  42.       End
  43.       Begin VB.CommandButton Ydcommand1 
  44.          Height          =   300
  45.          Index           =   3
  46.          Left            =   2670
  47.          Picture         =   "应收票据_贴现.frx":1042
  48.          Style           =   1  'Graphical
  49.          TabIndex        =   28
  50.          Top             =   600
  51.          Visible         =   0   'False
  52.          Width           =   300
  53.       End
  54.       Begin VB.TextBox LrText 
  55.          Height          =   300
  56.          Index           =   1
  57.          Left            =   4140
  58.          TabIndex        =   1
  59.          Text            =   "1"
  60.          Top             =   210
  61.          Width           =   1725
  62.       End
  63.       Begin VB.TextBox LrText 
  64.          Height          =   300
  65.          Index           =   5
  66.          Left            =   4140
  67.          TabIndex        =   5
  68.          Text            =   "5"
  69.          Top             =   1020
  70.          Width           =   1725
  71.       End
  72.       Begin VB.TextBox LrText 
  73.          Height          =   300
  74.          Index           =   9
  75.          Left            =   4140
  76.          TabIndex        =   9
  77.          Text            =   "9"
  78.          Top             =   1830
  79.          Width           =   1725
  80.       End
  81.       Begin VB.TextBox LrText 
  82.          Height          =   300
  83.          Index           =   8
  84.          Left            =   960
  85.          TabIndex        =   8
  86.          Text            =   "8"
  87.          Top             =   1830
  88.          Width           =   1725
  89.       End
  90.       Begin VB.TextBox LrText 
  91.          Height          =   300
  92.          Index           =   6
  93.          Left            =   960
  94.          TabIndex        =   6
  95.          Text            =   "6"
  96.          Top             =   1410
  97.          Width           =   1725
  98.       End
  99.       Begin VB.CommandButton Ydcommand1 
  100.          Height          =   300
  101.          Index           =   4
  102.          Left            =   2670
  103.          Picture         =   "应收票据_贴现.frx":13CC
  104.          Style           =   1  'Graphical
  105.          TabIndex        =   16
  106.          Top             =   1020
  107.          Visible         =   0   'False
  108.          Width           =   300
  109.       End
  110.       Begin VB.TextBox LrText 
  111.          Height          =   300
  112.          Index           =   12
  113.          Left            =   960
  114.          TabIndex        =   12
  115.          Text            =   "12"
  116.          Top             =   2640
  117.          Width           =   4905
  118.       End
  119.       Begin VB.TextBox LrText 
  120.          Height          =   300
  121.          Index           =   4
  122.          Left            =   960
  123.          TabIndex        =   4
  124.          Text            =   "4"
  125.          Top             =   1020
  126.          Width           =   1725
  127.       End
  128.       Begin VB.TextBox LrText 
  129.          Height          =   300
  130.          Index           =   3
  131.          Left            =   960
  132.          TabIndex        =   2
  133.          Text            =   "3"
  134.          Top             =   600
  135.          Width           =   1725
  136.       End
  137.       Begin VB.TextBox LrText 
  138.          Height          =   300
  139.          Index           =   0
  140.          Left            =   960
  141.          TabIndex        =   0
  142.          Text            =   "0"
  143.          Top             =   210
  144.          Width           =   1725
  145.       End
  146.       Begin VB.TextBox LrText 
  147.          Height          =   300
  148.          Index           =   2
  149.          Left            =   4140
  150.          TabIndex        =   3
  151.          Text            =   "2"
  152.          Top             =   600
  153.          Width           =   1725
  154.       End
  155.       Begin VB.TextBox LrText 
  156.          Height          =   300
  157.          Index           =   7
  158.          Left            =   4140
  159.          TabIndex        =   7
  160.          Text            =   "7"
  161.          Top             =   1410
  162.          Width           =   1725
  163.       End
  164.       Begin VB.Label Label1 
  165.          AutoSize        =   -1  'True
  166.          Caption         =   "本币费用:"
  167.          Height          =   195
  168.          Index           =   1
  169.          Left            =   3330
  170.          TabIndex        =   30
  171.          Top             =   2280
  172.          Width           =   765
  173.       End
  174.       Begin VB.Label Label1 
  175.          AutoSize        =   -1  'True
  176.          Caption         =   "贴现费用:"
  177.          Height          =   195
  178.          Index           =   5
  179.          Left            =   150
  180.          TabIndex        =   29
  181.          Top             =   2280
  182.          Width           =   765
  183.       End
  184.       Begin VB.Label Label1 
  185.          AutoSize        =   -1  'True
  186.          Caption         =   "票面金额:"
  187.          Height          =   195
  188.          Index           =   11
  189.          Left            =   3330
  190.          TabIndex        =   27
  191.          Top             =   270
  192.          Width           =   765
  193.       End
  194.       Begin VB.Label Label1 
  195.          AutoSize        =   -1  'True
  196.          Caption         =   "贴现率:"
  197.          Height          =   195
  198.          Index           =   9
  199.          Left            =   3330
  200.          TabIndex        =   26
  201.          Top             =   1050
  202.          Width           =   585
  203.       End
  204.       Begin VB.Label Label1 
  205.          AutoSize        =   -1  'True
  206.          Caption         =   "贴现本币:"
  207.          Height          =   195
  208.          Index           =   8
  209.          Left            =   3330
  210.          TabIndex        =   25
  211.          Top             =   1890
  212.          Width           =   765
  213.       End
  214.       Begin VB.Label Label1 
  215.          AutoSize        =   -1  'True
  216.          Caption         =   "贴现金额:"
  217.          Height          =   195
  218.          Index           =   7
  219.          Left            =   150
  220.          TabIndex        =   24
  221.          Top             =   1890
  222.          Width           =   765
  223.       End
  224.       Begin VB.Label Label1 
  225.          AutoSize        =   -1  'True
  226.          Caption         =   "贴现天数:"
  227.          Height          =   195
  228.          Index           =   6
  229.          Left            =   150
  230.          TabIndex        =   23
  231.          Top             =   1470
  232.          Width           =   765
  233.       End
  234.       Begin VB.Label Label1 
  235.          AutoSize        =   -1  'True
  236.          Caption         =   "摘要:"
  237.          Height          =   195
  238.          Index           =   4
  239.          Left            =   120
  240.          TabIndex        =   22
  241.          Top             =   2670
  242.          Width           =   405
  243.       End
  244.       Begin VB.Label Label1 
  245.          AutoSize        =   -1  'True
  246.          Caption         =   "贴现帐户:"
  247.          Height          =   195
  248.          Index           =   3
  249.          Left            =   150
  250.          TabIndex        =   21
  251.          Top             =   1050
  252.          Width           =   765
  253.       End
  254.       Begin VB.Label Label1 
  255.          AutoSize        =   -1  'True
  256.          Caption         =   "票据编号:"
  257.          Height          =   195
  258.          Index           =   2
  259.          Left            =   150
  260.          TabIndex        =   20
  261.          Top             =   270
  262.          Width           =   765
  263.       End
  264.       Begin VB.Label Label1 
  265.          AutoSize        =   -1  'True
  266.          Caption         =   "贴现日期:"
  267.          Height          =   195
  268.          Index           =   0
  269.          Left            =   150
  270.          TabIndex        =   19
  271.          Top             =   660
  272.          Width           =   765
  273.       End
  274.       Begin VB.Label Label1 
  275.          AutoSize        =   -1  'True
  276.          Caption         =   "币别:"
  277.          Height          =   195
  278.          Index           =   10
  279.          Left            =   3330
  280.          TabIndex        =   18
  281.          Top             =   660
  282.          Width           =   405
  283.       End
  284.       Begin VB.Label Label1 
  285.          AutoSize        =   -1  'True
  286.          Caption         =   "记帐汇率:"
  287.          Height          =   195
  288.          Index           =   12
  289.          Left            =   3330
  290.          TabIndex        =   17
  291.          Top             =   1470
  292.          Width           =   765
  293.       End
  294.    End
  295.    Begin VB.CommandButton QxCommand 
  296.       Caption         =   "取消(&C)"
  297.       Height          =   300
  298.       Left            =   4920
  299.       TabIndex        =   14
  300.       Top             =   3180
  301.       Width           =   1120
  302.    End
  303.    Begin VB.CommandButton QdCommand 
  304.       Caption         =   "确定(&O)"
  305.       Height          =   300
  306.       Left            =   3720
  307.       TabIndex        =   13
  308.       Top             =   3180
  309.       Width           =   1120
  310.    End
  311. End
  312. Attribute VB_Name = "Note_FrmNoteDiscount"
  313. Attribute VB_GlobalNameSpace = False
  314. Attribute VB_Creatable = False
  315. Attribute VB_PredeclaredId = True
  316. Attribute VB_Exposed = False
  317. '******************************************************************
  318. '*    模 块 名 称 :应收票据贴现
  319. '*    功 能 描 述 :
  320. '*    程序员姓名  :姜冬梅
  321. '*    最后修改人  :姜冬梅
  322. '*    最后修改时间:2001/12/06
  323. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  324. '******************************************************************
  325. Dim Tsxx As String                       '系统信息提示
  326. Dim Bln_ConVertFlag As Boolean           '币种折算方式
  327. Dim Dbl_AccRate As Double                '币种记帐汇率
  328. Dim Dbl_Bbje As Double                   '本币金额
  329. '以下为固定使用变量(文本框)
  330. Dim Textvar() As Variant                 '存储变体型文本框信息
  331. Dim Textboolean() As Boolean             '存储布尔型文本框信息
  332. Dim Textint() As Integer                 '存储整型文本框信息
  333. Dim Textstr() As String                  '存储字符型文本框信息
  334. Dim Max_Text_Index As Integer            '最大录入文本框索引值
  335. Dim TextGroupCode As String              '文本框录入分组编码
  336. Dim TextValiLock As Boolean              '文本框失去焦点是否进行有效性控制判断
  337. Dim TextValiJudgeLock() As Boolean       '文本框录入有效性判断控制锁
  338. Dim CurTextIndex As Integer              '当前文本框索引值
  339. Dim TextChangeLock As Boolean            '文本框内容变换控制锁
  340. Dim Bln_Cancel As Boolean                '取消按钮信息传递
  341. Private Sub Form_KeyPress(KeyAscii As Integer)   '控 制 焦 点 转 移(Fixed)
  342.     
  343.     Dim jdzygs As Integer                         '控件焦点转移个数
  344.     jdzygs = 20
  345.     Select Case KeyAscii
  346.         Case vbKeyReturn
  347.             If Kjjdzy(jdzygs) Then
  348.                 KeyAscii = 0
  349.             End If
  350.         Case 39           '屏蔽"'"
  351.             KeyAscii = 0
  352.     End Select
  353. End Sub
  354. Private Sub Form_Load()
  355.    
  356.     '以下为文本框处理程序(Fixed)
  357.     TextGroupCode = "Ar_NoteDiscount"
  358.     Call Drwbkxx(TextGroupCode, Textvar(), Textboolean(), Textint(), Textstr())  '读入文本框录入信息
  359.     Call Wbkcsh
  360.    
  361.     '[>>初始化查询条件默认值
  362.     Call ShowBill
  363.     '<<]
  364. End Sub
  365. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)          '查询条件窗体卸载
  366.     '查询条件窗体卸载时判断是否因为结果窗体卸载,如是则卸载,否则隐藏
  367.     Unload Me
  368. End Sub
  369. Private Sub QdCommand_Click()                                   '确 定
  370.     '录入条件有效性判断(Fixed)
  371.     If Not Lrtjyxxpd Then
  372.         Exit Sub
  373.     End If
  374.     If SaveBill = True Then
  375.     '<<]
  376.         Xtfhcs = "1"
  377.         Unload Me
  378.     End If
  379. End Sub
  380. Private Sub QxCommand_Click()                                    '取消(Fixed)
  381.     Xtfhcs = "0"
  382.     Unload Me
  383. End Sub
  384. Private Function Lrtjyxxpd() As Boolean                          '用户录入条件有效性判断
  385.  
  386.     Dim jsqte As Integer
  387.     Lrtjyxxpd = False
  388.  
  389.     '对需要进行事后判断的文本框录入内容进行有效性判断 (Fixed)
  390.     For jsqte = 0 To Max_Text_Index
  391.         If Textint(jsqte, 9) = 0 Or Textint(jsqte, 9) = 2 Then
  392.             If Not TextYxxpd(jsqte) Then
  393.                 Exit Function
  394.             End If
  395.         End If
  396.     Next jsqte
  397.    
  398.     '[>>以下为依据实际情况自定义部分
  399.  
  400.     '<<]以上为依据实际情况自定义部分
  401.  
  402.     Lrtjyxxpd = True
  403. End Function
  404. '*************以下为文本框录入处理程序(固定不变部分)*************'
  405. Private Sub Wbklrwbcl(Index As Integer)    '文本框录入事后处理程序
  406.   
  407.     '以下为依据实际情况自定义部分[
  408.   
  409.     '在此填写文本框录入事后处理程序
  410.         Select Case Index
  411.          Case 7             '记帐汇率
  412.             TextChangeLock = True
  413.             '2.如果用户选择币种为本位币则汇率必须为1,否则汇率不能为零
  414.             If Trim(LrText(3).Tag) = XtSCurrCode Then
  415.                 LrText(7).Text = 1
  416.             Else
  417.                 Call Sub_GetAccRate(LrText(3).Tag, Bln_ConVertFlag, Dbl_AccRate)    '取外币记帐汇率
  418.                 If Dbl_AccRate <> 0 Then
  419.                     LrText(7).Text = Dbl_AccRate
  420.                 Else
  421.                     LrText(7).Text = ""
  422.                 End If
  423.             End If
  424.             If Bln_ConVertFlag Then
  425.                 If Val(LrText(7).Text) <> 0 Then
  426.                     LrText(9).Text = Val(Format(Val(LrText(8).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  427.                 Else
  428.                     LrText(9).Text = 0
  429.                 End If
  430.                 If Val(LrText(7).Text) <> 0 Then
  431.                     LrText(11).Text = Val(Format(Val(LrText(10).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  432.                 Else
  433.                     LrText(11).Text = 0
  434.                 End If
  435.             Else
  436.                 LrText(9).Text = Val(Format(Val(LrText(8).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  437.                 LrText(11).Text = Val(Format(Val(LrText(10).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  438.             End If
  439.             TextChangeLock = False
  440.         Case 8      '本币金额
  441.             TextChangeLock = True
  442.             If Bln_ConVertFlag Then
  443.                 If Val(LrText(7).Text) <> 0 Then
  444.                     LrText(9).Text = Val(Format(Val(LrText(8).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  445.                 Else
  446.                     LrText(9).Text = 0
  447.                 End If
  448.             Else
  449.                 LrText(9).Text = Val(Format(Val(LrText(8).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  450.             End If
  451.         Case 10 '本币费用
  452.             TextChangeLock = True
  453.             If Bln_ConVertFlag Then
  454.                 If Val(LrText(7).Text) <> 0 Then
  455.                     LrText(11).Text = Val(Format(Val(LrText(10).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  456.                 Else
  457.                     LrText(11).Text = 0
  458.                 End If
  459.             Else
  460.                 LrText(11).Text = Val(Format(Val(LrText(10).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  461.             End If
  462.             TextChangeLock = False
  463.       End Select
  464.     ']以上为依据实际情况自定义部分
  465.   
  466. End Sub
  467. Private Sub LrText_Change(Index As Integer)
  468.     
  469.     '屏蔽程序改变控制
  470.     If TextChangeLock Then
  471.         Exit Sub
  472.     End If
  473.     
  474.     TextValiJudgeLock(Index) = False    '打开有效性判断锁
  475.     
  476.     '限制字段录入长度
  477.           
  478.     TextChangeLock = True  '加锁(防止执行Lrtext_Change)
  479.      
  480.     Select Case Textint(Index, 1)
  481.         Case 8, 11      '金额型
  482.             Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
  483.         Case 9, 12      '数量型
  484.             Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
  485.         Case 10          '单价型
  486.             Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  487.         Case Else        '其他小数类型控制
  488.             If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
  489.                 Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
  490.             End If
  491.     End Select
  492.         
  493.     TextChangeLock = False '解锁
  494. End Sub
  495. Private Sub LrText_GotFocus(Index As Integer)                                                 '文本框得到焦点,显示相应信息
  496.     
  497.     Call TextShow(Index)
  498.     CurTextIndex = Index
  499.     LrText(Index).SelStart = Len(LrText(Index))
  500. End Sub
  501. Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)            '字段按F2键提供帮助
  502.     
  503.     Select Case KeyCode
  504.         Case vbKeyF2
  505.             Call Text_Help(Index)
  506.     End Select
  507. End Sub
  508. Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer)                            '文本框录入事中控制
  509.     Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
  510. End Sub
  511. Private Sub LrText_LostFocus(Index As Integer)                                                '文本框失去焦点
  512.   '显示相应信息但不能进行有效性判断
  513.     Call Wbklrwbcl(Index)
  514. End Sub
  515. Private Sub Ydcommand1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)     '按钮提供帮助
  516.     Call Text_Help(Index)
  517. End Sub
  518. Private Sub Text_Help(Index As Integer)                                                       '录入字段帮助
  519.     If Not Textboolean(Index, 1) Then
  520.         Exit Sub
  521.     End If
  522.      
  523.     '调用帮助
  524.     Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
  525.   
  526.     '根据设置选择显示编码和名称,并进行存储
  527.     If Len(Xtfhcs) <> 0 Then
  528.         If Textint(Index, 3) = 1 Then
  529.             LrText(Index).Text = Xtfhcsfz
  530.             LrText(Index).Tag = Xtfhcs
  531.         Else
  532.             LrText(Index).Text = Xtfhcs
  533.             LrText(Index).Tag = Xtfhcsfz
  534.         End If
  535.     End If
  536.    
  537.     LrText(Index).SetFocus
  538. End Sub
  539. Private Sub TextShow(Index As Integer)        '文本框得到焦点,显示相应信息
  540.   '填写文本框得到焦点,进行相应信息处理程序
  541.    
  542. End Sub
  543. Private Sub Wbkcsh()                          '录入文本框初始化
  544.   
  545.     Dim jsqte As Integer
  546.   
  547.     '最大录入文本框索引值
  548.     Max_Text_Index = Textvar(1)
  549.   
  550.     ReDim TextValiJudgeLock(Max_Text_Index)
  551.     For jsqte = 0 To Max_Text_Index
  552.          
  553.         If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
  554.             If Textboolean(jsqte, 1) Then
  555.                 If jsqte <> 0 And Not Textboolean(jsqte, 3) Then
  556.                     Load Ydcommand1(jsqte)
  557.                 End If
  558.                 Ydcommand1(jsqte).Visible = True
  559.                 Ydcommand1(jsqte).Move LrText(jsqte).Left + LrText(jsqte).Width, LrText(jsqte).Top
  560.             End If
  561.             TextChangeLock = True
  562.             LrText(jsqte).Text = ""
  563.             LrText(jsqte).Tag = ""
  564.             If Textint(jsqte, 5) <> 0 Then
  565.                 LrText(jsqte).MaxLength = Textint(jsqte, 5)
  566.             End If
  567.             If Textboolean(jsqte, 5) = False Then
  568.                 LrText(jsqte).Enabled = False
  569.             End If
  570.             TextChangeLock = False
  571.         End If
  572.      
  573.         TextValiJudgeLock(jsqte) = True
  574.     Next jsqte
  575. End Sub
  576. Private Function TextYxxpd(Index As Integer) As Boolean           '文本框有效性判断
  577.     Dim Sqlstr As String
  578.     Dim Findrec As ADODB.Recordset
  579.   
  580.     '文本框内容未曾改变不进行有效性判断
  581.     If TextValiJudgeLock(Index) Then
  582.         TextYxxpd = True
  583.         Exit Function
  584.     End If
  585.   
  586.     '文本框内容为空认为有效,并清空其Tag值
  587.     If Trim(LrText(Index)) = "" Then
  588.         LrText(Index).Tag = ""
  589.         Call Wbklrwbcl(Index)
  590.         TextValiJudgeLock(Index) = True
  591.         TextYxxpd = True
  592.         Exit Function
  593.     End If
  594.   
  595.     '可在此加入不做有效性判断的理由
  596.   
  597.     Select Case Textint(Index, 4)
  598.         Case 1      '编码型
  599.             Sqlstr = Trim(Textstr(Index, 5))
  600.             Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
  601.             Set Findrec = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  602.             If Findrec.EOF Then
  603.                 Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
  604.                 LrText(Index).SetFocus
  605.                 Exit Function
  606.             Else
  607.                 Select Case Textint(Index, 3)
  608.                     Case 0
  609.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  610.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  611.                         End If
  612.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  613.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  614.                         End If
  615.                     Case 1
  616.                         If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
  617.                             LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
  618.                         End If
  619.                         If Len(Trim(Textstr(Index, 2))) <> 0 Then
  620.                             LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
  621.                         End If
  622.                 End Select
  623.             End If
  624.         Case 2      '日期型
  625.             If IsDate(LrText(Index).Text) Then
  626.                 LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
  627.                 If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
  628.                     LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
  629.                 End If
  630.             Else
  631.                 Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
  632.                 Call Xtxxts(Tsxx, 0, 1)
  633.                 LrText(Index).SetFocus
  634.                 Exit Function
  635.             End If
  636.         Case 3      '其他类型
  637.     End Select
  638.     
  639.     '如果有效则加锁,用户不改变内容则不再进行有效性判断
  640.     TextValiJudgeLock(Index) = True
  641.     '调用文本框事后处理程序
  642.     Call Wbklrwbcl(Index)
  643.   
  644.     '有效性判断通过则返回True
  645.     TextYxxpd = True
  646.    
  647. End Function
  648. Private Sub ShowBill()
  649.     '调入用户查询结果动态集,并定位该单据
  650.     Sqlstr = "SELECT dbo.RP_Note.*, dbo.Gy_ForeignCurrency.ForeignCurrName AS ForeignCurrName " & _
  651.             "FROM dbo.Gy_ForeignCurrency INNER JOIN  dbo.RP_Note ON " & _
  652.             "dbo.Gy_ForeignCurrency.ForeignCurrCode = dbo.RP_Note.ForeignCurrCode where NoteId='" & XT_BillID & "' and RpFlag='Ar'"
  653.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  654.     LrText(0).Text = RecTemp.Fields("NoteCode")
  655.     LrText(1).Text = RecTemp.Fields("YbSsJe") + Val(RecTemp.Fields("YbInterest") & "")  '票面金额+票面利息
  656.     LrText(3).Text = Xtrq
  657.     LrText(2).Tag = RecTemp.Fields("ForeignCurrCode")
  658.     LrText(2).Text = RecTemp.Fields("ForeignCurrName")
  659.     Call Sub_GetAccRate(LrText(2).Tag, Bln_ConVertFlag, Dbl_AccRate)    '取外币记帐汇率,和汇兑方式
  660.     LrText(7).Text = Dbl_AccRate
  661. End Sub
  662. Private Function SaveBill() As Boolean      '记录贴现数据
  663.     Dim Rec_Bill As New ADODB.Recordset
  664.     Dim RecTemp As New ADODB.Recordset
  665.     Dim Int_Kjyear As Integer               '会计年度
  666.     Dim Int_Period As Integer               '会计期间
  667.     Dim jsqte As Integer
  668.     '一.============先对单据内容进行有效性判断==============='
  669.   
  670.     '先进行字段不能为空或不能为零有效性判断(Fixed)
  671.     SaveBill = False
  672.     For jsqte = 0 To Max_Text_Index
  673.         If Textint(jsqte, 8) = 1 Then     '字段不能为空
  674.             If Len(Trim(LrText(jsqte).Text)) = 0 Then
  675.                 Tsxx = Textstr(jsqte, 7) & "不能为空!"
  676.                 Call Xtxxts(Tsxx, 0, 1)
  677.                 LrText(jsqte).SetFocus
  678.                 Exit Function
  679.             End If
  680.         Else
  681.             If Textint(jsqte, 8) = 2 Then   '字段不能为零
  682.                 If Val(Trim(LrText(jsqte).Text)) = 0 Then
  683.                     Tsxx = Textstr(jsqte, 7) & "不能为零!"
  684.                     Call Xtxxts(Tsxx, 0, 1)
  685.                     LrText(jsqte).SetFocus
  686.                     Exit Function
  687.                 End If
  688.             End If
  689.         End If
  690.     Next jsqte
  691.   
  692.     '[>>
  693.         '1.判断单据日期是否有效,如有效同时记录会计年度和会计期间
  694.     If Not Fun_GetPeriod(Trim(LrText(3).Text), Int_Kjyear, Int_Period) Then
  695.         LrText(2).SetFocus
  696.         Exit Function
  697.     End If
  698.      '2.如果用户选择币种为本位币则汇率必须为1,否则汇率不能为零
  699.     If Trim(LrText(2).Tag) <> XtSCurrCode Then
  700.        If Val(LrText(7).Text) = 0 Then
  701.           Tsxx = "汇率不能为零!"
  702.           Call Xtxxts(Tsxx, 0, 1)
  703.           LrText(7).SetFocus
  704.           Exit Function
  705.        End If
  706.     Else
  707.        LrText(7).Text = 1
  708.     End If
  709.     If Bln_ConVertFlag Then
  710.         LrText(9).Text = Val(Format(Val(LrText(8).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  711.         LrText(11).Text = Val(Format(Val(LrText(10).Text) / Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  712.     Else
  713.         LrText(9).Text = Val(Format(Val(LrText(8).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  714.         LrText(11).Text = Val(Format(Val(LrText(10).Text) * Val(LrText(7).Text), "##." + String(Xtjexsws, "0")))
  715.     End If
  716.     
  717.     '<<]
  718.    '2.开始存盘
  719.     
  720.     Sqlstr = "SELECT * From Rp_Note where NoteId='" & XT_BillID & "'"
  721.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  722.     On Error GoTo Swcwcl
  723.     Cw_DataEnvi.DataConnect.BeginTrans
  724.     
  725.     '打开单据表动态集
  726.     If Rec_Bill.State = 1 Then Rec_Bill.Close
  727.         Rec_Bill.Open "Select * From Rp_NoteClose Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  728.         With Rec_Bill
  729.             .AddNew
  730.             .Fields("NoteId") = XT_BillID                                   '单据号
  731.             .Fields("CloseDate") = CDate(LrText(3).Text)                    '贴现日期
  732.             .Fields("DiscountDays") = Val(Trim(LrText(6)))                  '贴现天数
  733.             .Fields("BankCode") = Trim(LrText(4).Tag)                       '银行帐户
  734.             .Fields("DiscountRate") = Val(LrText(5))                        '贴现率
  735.             .Fields("YbCash") = Val(LrText(8))                              '贴现原币金额
  736.             .Fields("BbCash") = Val(LrText(9))                              '贴现原币金额
  737.             .Fields("YbExpense") = Val(LrText(10))                          '原币费用
  738.             .Fields("BbExpense") = Val(LrText(11))                          '原币费用
  739.             .Fields("Digest") = Trim(LrText(12).Text)                       '备注
  740.             .Fields("ForeignCurrCode") = Trim(LrText(2).Tag)                '原币编码
  741.             .Fields("AccRate") = Val(LrText(7))                             '记帐汇率
  742.             .Fields("PsCode") = RecTemp.Fields("PsCode")                    '客户编码
  743.             .Fields("DeptCode") = Trim(RecTemp.Fields("DeptCode") & "")      '部门编码
  744.             .Fields("PersonCode") = Trim(RecTemp.Fields("PersonCode") & "")  '经办人编码
  745.             .Fields("AccCodeNote") = Trim(RecTemp.Fields("AccCode") & "")    '应收票据科目
  746.             .Fields("AccCode") = GetBankCcode(Trim(LrText(4).Tag))           '贴现的银行科目
  747.             
  748.             '系统名
  749.             .Fields("RPFlag") = "Ar"
  750.             
  751.             '单据所属的会计期间
  752.             .Fields("KjYear") = Int_Kjyear
  753.             .Fields("Period") = Int_Period
  754.             
  755.             '单据类型
  756.             .Fields("BillItemCode") = "42"
  757.             
  758.             
  759.             '票据利息科目
  760.             .Fields("AccCodeInterest") = Fun_GetInputCode("AR_NoteIntAccCode")
  761.             
  762.             '票据费用科目
  763.             .Fields("AccCodeExpense") = Fun_GetInputCode("AR_NoteFareAccCode")
  764.             
  765.             .Update
  766.             
  767.             '系统读出单据ID写入Lab_BillID
  768.         End With
  769.         Cw_DataEnvi.DataConnect.CommitTrans
  770.         Tsxx = "保存完毕!"
  771.         SaveBill = True
  772.         Call Xtxxts(Tsxx, 0, 4)
  773.         Exit Function
  774. Swcwcl:       '数据存盘时出现错误
  775.     Cw_DataEnvi.DataConnect.RollbackTrans
  776.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  777.     Call Xtxxts(Tsxx, 0, 1)
  778.     Exit Function
  779.         
  780. End Function