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

企业管理

开发平台:

Visual Basic

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