资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:35k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form Balance_KF_Autobalance
- BorderStyle = 1 'Fixed Single
- Caption = "自动结算"
- ClientHeight = 2280
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4560
- HelpContextID = 1215001
- Icon = "结算_库房自动结算.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2280
- ScaleWidth = 4560
- StartUpPosition = 2 '屏幕中心
- Begin VB.Frame Frame2
- Height = 1005
- Left = 60
- TabIndex = 19
- Top = 90
- Visible = 0 'False
- Width = 4425
- Begin MSComctlLib.ProgressBar ProgressBar
- Height = 285
- Left = 150
- TabIndex = 21
- Top = 570
- Width = 4035
- _ExtentX = 7117
- _ExtentY = 503
- _Version = 393216
- BorderStyle = 1
- Appearance = 0
- Scrolling = 1
- End
- Begin VB.Label Label2
- Caption = "正在进行数据处理..."
- Height = 255
- Left = 210
- TabIndex = 20
- Top = 240
- Width = 4005
- End
- End
- Begin VB.CommandButton Cmd_Clear
- Caption = "全清"
- Height = 300
- Left = 60
- TabIndex = 18
- Top = 1920
- Width = 1120
- End
- Begin VB.Timer Timer1
- Enabled = 0 'False
- Interval = 1
- Left = 150
- Top = 2910
- End
- Begin VB.CommandButton QxCommand
- Caption = "取消(&C)"
- Height = 300
- Left = 3360
- TabIndex = 5
- Top = 1920
- Width = 1120
- End
- Begin VB.CommandButton QdCommand
- Caption = "确定(&O)"
- Height = 300
- Left = 2160
- TabIndex = 6
- Top = 1920
- Width = 1120
- End
- Begin VB.Frame Frame1
- Height = 1785
- Left = 60
- TabIndex = 8
- Top = 60
- Width = 4425
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Index = 0
- Left = 2190
- Picture = "结算_库房自动结算.frx":1042
- Style = 1 'Graphical
- TabIndex = 17
- Top = 210
- Visible = 0 'False
- Width = 300
- End
- Begin VB.TextBox LrText
- Height = 300
- Index = 0
- Left = 1020
- TabIndex = 0
- Text = "0"
- Top = 210
- Width = 1185
- End
- Begin VB.TextBox LrText
- Height = 300
- Index = 1
- Left = 2850
- TabIndex = 1
- Text = "1"
- Top = 210
- Width = 1185
- End
- Begin VB.TextBox LrText
- Height = 300
- Index = 2
- Left = 1020
- TabIndex = 2
- Text = "2"
- Top = 600
- Width = 3015
- End
- Begin VB.TextBox LrText
- Height = 300
- Index = 3
- Left = 1020
- TabIndex = 3
- Text = "3"
- Top = 990
- Width = 3015
- End
- Begin VB.TextBox LrText
- Height = 300
- Index = 4
- Left = 1020
- TabIndex = 4
- Text = "4"
- Top = 1380
- Width = 3015
- End
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Index = 4
- Left = 4020
- Picture = "结算_库房自动结算.frx":13CC
- Style = 1 'Graphical
- TabIndex = 12
- Top = 1380
- Visible = 0 'False
- Width = 300
- End
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Index = 2
- Left = 4020
- Picture = "结算_库房自动结算.frx":1756
- Style = 1 'Graphical
- TabIndex = 11
- Top = 600
- Visible = 0 'False
- Width = 300
- End
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Index = 1
- Left = 4020
- Picture = "结算_库房自动结算.frx":1AE0
- Style = 1 'Graphical
- TabIndex = 10
- Top = 210
- Visible = 0 'False
- Width = 300
- End
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Index = 3
- Left = 4020
- Picture = "结算_库房自动结算.frx":1E6A
- Style = 1 'Graphical
- TabIndex = 9
- Top = 990
- Visible = 0 'False
- Width = 300
- End
- Begin VB.Line Line2
- Index = 1
- X1 = 2580
- X2 = 2760
- Y1 = 360
- Y2 = 360
- End
- Begin VB.Label Label1
- Caption = "日期:"
- Height = 255
- Index = 0
- Left = 150
- TabIndex = 16
- Top = 240
- Width = 465
- End
- Begin VB.Label Label1
- Caption = "物料编码:"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 15
- Top = 1410
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "物料分类:"
- Height = 255
- Index = 3
- Left = 150
- TabIndex = 14
- Top = 1020
- Width = 975
- End
- Begin VB.Label Label1
- Caption = "供应商:"
- Height = 255
- Index = 2
- Left = 150
- TabIndex = 13
- Top = 660
- Width = 735
- End
- End
- Begin VB.CheckBox UnloadCheck
- Caption = "卸载窗体"
- Height = 615
- Left = 4680
- TabIndex = 7
- Top = 1560
- Width = 825
- End
- End
- Attribute VB_Name = "Balance_KF_Autobalance"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '******************************************************************
- '* 模 块 名 称 :自动结算
- '* 功 能 描 述 :
- '* 程序员姓名 :周化江
- '* 最后修改人 :周化江
- '* 最后修改时间:2001/10/25
- '* 备 注:程序中所有依实际情况自定义部分均用[>> <<]括起
- '******************************************************************
- Dim Tsxx As String '系统信息提示
- '以下为固定使用变量(文本框)
- Dim Textvar() As Variant '存储变体型文本框信息
- Dim Textboolean() As Boolean '存储布尔型文本框信息
- Dim Textint() As Integer '存储整型文本框信息
- Dim Textstr() As String '存储字符型文本框信息
- Dim Max_Text_Index As Integer '最大录入文本框索引值
- Dim TextGroupCode As String '文本框录入分组编码
- Dim TextValiLock As Boolean '文本框失去焦点是否进行有效性控制判断
- Dim TextValiJudgeLock() As Boolean '文本框录入有效性判断控制锁
- Dim CurTextIndex As Integer '当前文本框索引值
- Dim TextChangeLock As Boolean '文本框内容变换控制锁
- Dim Bln_Cancel As Boolean '取消按钮信息传递
- ' 以下为自定义
- Dim Bln_ClrkdKfsc As Boolean
- Dim FilterInvoice As String '发票条件
- Dim FilterRKD As String 'RKD条件
- Dim FilterInOut As String '入库单中是否存在符合的记录
- Dim Collect_BalanceRelation() As New Collection
- Dim Bln_HaveErr As Boolean
- Private Sub Form_KeyPress(KeyAscii As Integer) '控 制 焦 点 转 移(Fixed)
- Dim jdzygs As Integer '控件焦点转移个数
- jdzygs = 8
- Select Case KeyAscii
- Case vbKeyReturn
- If Kjjdzy(jdzygs) Then
- KeyAscii = 0
- End If
- Case 39 '屏蔽"'"
- KeyAscii = 0
- End Select
- End Sub
- Private Sub Form_Load()
- '以下为文本框处理程序(Fixed)
- TextGroupCode = "Kf_Autobalance"
- Call Drwbkxx(TextGroupCode, Textvar(), Textboolean(), Textint(), Textstr()) '读入文本框录入信息
- Call Wbkcsh
- '[>>初始化查询条件默认值
- LrText(0).Text = Format(CDate(Xtrq), "yyyy-mm-dd")
- LrText(1).Text = Format(CDate(Xtrq), "yyyy-mm-dd")
- '<<]
- End Sub
- Private Sub QdCommand_Click() '确 定
- '录入条件有效性判断(Fixed)
- If Not Lrtjyxxpd Then
- Exit Sub
- End If
- '<<]
- Bln_ClrkdKfsc = Fun_ClrkdKfsc ''材料入库单是不是由库房生成
- Call FilterCondition
- If Check_InoutMain Then
- Call Autobalance
- End If
- End Sub
- Private Sub Autobalance()
- Dim int_temp As Long
- Dim rst_temp As New ADODB.Recordset
- Dim str_sqlTemp As String
- Dim str_SqlInOut As String
- Dim Rst_Invoice As New ADODB.Recordset
- Dim Rst_InOut As New ADODB.Recordset
- Dim int_InvoiceMainID As Integer
- Dim int_FrmHeight As Integer
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- Set Rst_Invoice = Cw_DataEnvi.DataConnect.Execute("select InvoiceMainID, CgBalanceCode, InvoiceDate, SupplierCode, MNumber, InvSortcode from kf_V_BalanceCG " & FilterInvoice)
- If Rst_Invoice.RecordCount = 0 Then
- Tsxx = "没有可以结算的发票数据!"
- Call Xtxxts(Tsxx, 0, 4)
- Rst_Invoice.Close
- Set Rst_Invoice = Nothing
- Cw_DataEnvi.DataConnect.RollbackTrans
- Exit Sub
- End If
- int_FrmHeight = Me.Height
- Me.Height = 1785
- Me.Frame1.Visible = False
- Me.Refresh
- Me.ProgressBar.Max = Rst_Invoice.RecordCount + 1
- Me.ProgressBar.Value = 0
- Me.Frame2.Visible = True
- Me.Refresh
- Rst_Invoice.MoveFirst
- int_InvoiceMainID = Rst_Invoice.Fields("InvoiceMainID").Value
- int_temp = 0
- Int_InvoiceSubNumber = 0
- ReDim Collect_BalanceRelation(0) As New Collection
- With Rst_Invoice
- Do While Not .EOF '结算过程
- Me.ProgressBar.Value = Me.ProgressBar.Value + 1
- Me.Label2.Caption = Label2.Caption & ".."
- str_SqlInOut = "SELECT Gy_InOutMain.InOutMainId,Gy_InOutSub.InOutSubId ,Gy_InOutMain.WhCode " & _
- " FROM Gy_InOutMain INNER JOIN " & _
- " Gy_InOutSub ON Gy_InOutMain.InOutMainId = Gy_InOutSub.InOutMainId INNER JOIN" & _
- " Gy_Material ON Gy_InOutSub.MNumber = Gy_Material.MNumber" & _
- " WHERE (Gy_InOutSub.BalanceDate IS NULL) AND (LTRIM(RTRIM(Gy_InOutMain.BillCode)) " & _
- " = '1201' or LTRIM(RTRIM(Gy_InOutMain.BillCode))='1211' ) AND (LTRIM(RTRIM(ISNULL(Gy_InOutMain.SupplierCode, ''))) " & _
- " + '#' + LTRIM(RTRIM(ISNULL(Gy_InOutSub.MNumber, ''))) " & _
- " + '$' + LTRIM(RTRIM(CONVERT(char(40), CONVERT(decimal(18, 6), " & _
- " Gy_InOutSub.FactReceiptQuan)))) = '" & Trim("" & Rst_Invoice.Fields("CgBalanceCode")) & "') " & FilterRKD
- Set Rst_InOut = Cw_DataEnvi.DataConnect.Execute(str_SqlInOut)
- If Rst_InOut.RecordCount <> 0 Then
- If int_InvoiceMainID <> Rst_Invoice.Fields("InvoiceMainID").Value Then
- Bln_HaveErr = False
- Call Creat_BalanceBill ''生成结算单
- If Bln_HaveErr = True Then GoTo Errexec
- Me.Label2.Caption = "正在进行数据处理..."
- ReDim Collect_BalanceRelation(0) As New Collection
- int_InvoiceMainID = Rst_Invoice.Fields("InvoiceMainID").Value
- int_temp = 1
- ReDim Preserve Collect_BalanceRelation(int_temp) As New Collection
- Collect_BalanceRelation(int_temp).Add str(int_InvoiceMainID)
- Collect_BalanceRelation(int_temp).Add str(Rst_InOut.Fields("InOutMainId"))
- Collect_BalanceRelation(int_temp).Add str(Rst_InOut.Fields("InOutSubId"))
- Else
- int_temp = int_temp + 1
- ReDim Preserve Collect_BalanceRelation(int_temp) As New Collection
- Collect_BalanceRelation(int_temp).Add str(int_InvoiceMainID)
- Collect_BalanceRelation(int_temp).Add str(Rst_InOut.Fields("InOutMainId"))
- Collect_BalanceRelation(int_temp).Add str(Rst_InOut.Fields("InOutSubId"))
- End If
- End If
- int_InvoiceMainID = Rst_Invoice.Fields("InvoiceMainID").Value
- Rst_Invoice.MoveNext
- Loop
- Bln_HaveErr = False
- Call Creat_BalanceBill ''生成结算单
- If Bln_HaveErr = True Then GoTo Errexec
- ReDim Collect_BalanceRelation(0) As New Collection
- int_temp = 1
- Me.ProgressBar.Value = Me.ProgressBar.Value + 1
- End With
- Cw_DataEnvi.DataConnect.CommitTrans
- Me.Label2.Caption = "数据处理完成!"
- Tsxx = "自动结算完成!"
- Call Xtxxts(Tsxx, 0, 4)
- Errexec:
- Me.Frame2.Visible = False
- Me.Height = int_FrmHeight
- Me.Frame1.Visible = True
- Me.Refresh
- Exit Sub
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- End Sub
- Private Sub Creat_BalanceBill()
- Dim int_temp As Long
- Dim str_sqlTemp As String
- Dim rst_temp As New ADODB.Recordset
- Dim Bln_BalanceOK As Boolean
- Dim str_WhCode As String
- Dim banl_MainRecordset As New ADODB.Recordset
- Dim banl_SubRecordset As New ADODB.Recordset
- Dim rst_BalanceRelation As New ADODB.Recordset
- Dim Rkd_MainRecordset As New ADODB.Recordset
- Dim Rkd_subRecordset As New ADODB.Recordset
- On Error GoTo Swcwcl
- Dim banl_Mainid As Integer
- Dim RKd_MainId As Integer
- Bln_BalanceOK = False
- If UBound(Collect_BalanceRelation) <> 0 Then
- str_sqlTemp = "SELECT B.InvoiceMainID, A.SupplierCode, B.MNumber, " & _
- " B.Quantity * (C.PurInvCon1 / C.PurInvCon2) AS Quantity, A.DeptCode, A.PersonCode, " & _
- " B.IsCharge, B.InvoiceSubID, " & _
- " B.MoneyBb / (B.Quantity * (C.PurInvCon1 / C.PurInvCon2)) AS PriceBb ,B.TotalMoneyBb,B.TaxMoneyBb " & _
- " FROM Cg_InvoiceMain A INNER JOIN " & _
- " Cg_InvoiceSub B ON A.InvoiceMainID = B.InvoiceMainID INNER JOIN " & _
- " Gy_Material C ON B.MNumber = C.MNumber" & _
- " WHERE (A.InvoiceMainID =" & Val(Collect_BalanceRelation(1).Item(1)) & ")"
- Set rst_temp = Cw_DataEnvi.DataConnect.Execute(str_sqlTemp)
- If rst_temp.RecordCount = UBound(Collect_BalanceRelation) Then
- rst_temp.MoveFirst
- With banl_MainRecordset
- If .State = 1 Then .Close
- .Open "select * from Kf_BalanceMain where 2=1 ", Cw_DataEnvi.DataConnect, adOpenForwardOnly, adLockOptimistic
- .AddNew
- .Fields("BalanceMainId") = CreatBillID("1210")
- .Fields("BillNum") = CreatBillCode("1210", True)
- .Fields("BillCode") = "1210"
- If Trim("" & rst_temp.Fields("SupplierCode")) <> "" Then
- .Fields("SupplierCode") = Trim("" & rst_temp.Fields("SupplierCode"))
- End If
- .Fields("opertype") = "库房结算"
- If Trim("" & rst_temp.Fields("DeptCode")) <> "" Then
- .Fields("DeptCode") = Trim("" & rst_temp.Fields("DeptCode"))
- End If
- If Trim("" & rst_temp.Fields("PersonCode")) <> "" Then
- .Fields("PersonCode") = Trim("" & rst_temp.Fields("PersonCode"))
- End If
- .Fields("Maker") = Xtczy
- .Fields("BillDate") = CDate(Xtrq)
- .Fields("KjYear") = Xtyear
- .Fields("Period") = Xtmm
- .Fields("BanlType") = "1"
- .Update
- banl_Mainid = .Fields("BalanceMainId")
- End With
- For int_temp = 1 To rst_temp.RecordCount
- With banl_SubRecordset
- If .State = 1 Then .Close
- .Open "select * from Kf_BalanceSub where 2=1 ", Cw_DataEnvi.DataConnect, adOpenForwardOnly, adLockOptimistic
- .AddNew
- .Fields("BalanceMainId") = banl_Mainid
- .Fields("BalanceSubId") = rst_temp.Fields("InvoiceSubID")
- .Fields("MNumber") = rst_temp.Fields("MNumber")
- .Fields("Quan") = rst_temp.Fields("Quantity")
- .Fields("Price") = rst_temp.Fields("PriceBb")
- .Fields("EMoney") = rst_temp.Fields("TotalMoneyBb")
- .Fields("TaxMoney") = rst_temp.Fields("TaxMoneyBb")
- .Fields("TotalMoney") = rst_temp.Fields("TaxMoneyBb") + rst_temp.Fields("TotalMoneyBb")
- .Update
- End With
- rst_temp.MoveNext
- Next int_temp
- For int_temp = 1 To UBound(Collect_BalanceRelation)
- With rst_BalanceRelation
- If .State = 1 Then .Close
- .Open "select * from Kf_BalanceRelation where 2=1 ", Cw_DataEnvi.DataConnect, adOpenForwardOnly, adLockOptimistic
- .AddNew
- .Fields("BalanceMainId") = banl_Mainid
- .Fields("InvoiceMainID") = Val(Collect_BalanceRelation(int_temp).Item(1))
- .Fields("InOutMainId") = Val(Collect_BalanceRelation(int_temp).Item(2))
- .Fields("InOutSubId") = Val(Collect_BalanceRelation(int_temp).Item(3))
- .Update
- End With
- Next int_temp
- Cw_DataEnvi.DataConnect.Execute (" Kf_Sp_BalanceRelation " & banl_Mainid)
- Bln_BalanceOK = True
- End If
- End If
- If Bln_BalanceOK = False Then Exit Sub
- If Bln_ClrkdKfsc = True Then
- Dim str_InsertSql As String
- Set rst_BalanceRelation = Cw_DataEnvi.DataConnect.Execute("SELECT InOutMainId From Kf_BalanceRelation Where (BalanceMainId = " & banl_Mainid & " ) GROUP BY InOutMainId")
- If rst_BalanceRelation.RecordCount <> 0 Then
- Do While Not rst_BalanceRelation.EOF
- Set rst_temp = Cw_DataEnvi.DataConnect.Execute("SELECT WhCode FROM Gy_InOutMain where InOutMainId= " & rst_BalanceRelation.Fields("InOutMainId"))
- If rst_temp.RecordCount <> 0 Then
- rst_temp.MoveFirst
- str_WhCode = Trim("" & rst_temp.Fields(0))
- Else
- Tsxx = "结算过程中某单据发生变化,结算失败!"
- Call Xtxxts(Tsxx, 0, 1)
- GoTo Swcwcl
- End If
- RKd_MainId = CreatBillID("1212")
- str_InsertSql = " INSERT INTO Gy_InOutMain " & _
- " (InOutMainId, BillCode, BillNum, WhCode, InoutFlag, PurTypeCode, OperType, " & _
- " OperbillNum, BillDate, InoutClassCode, TranCompanyCode, TransferWayCode, " & _
- " BusNum, DeptCode, PersonCode, CusCode, SupplierCode, " & _
- " ConsignbillNum, Consignbillid, KfChecker , Maker, KjYear, Period,BanlanceId) " & _
- " SELECT " & RKd_MainId & " ,'1212', '" & CreatBillCode("1212", True, Xtyear, Xtmm, str_WhCode) & "', WhCode, InoutFlag, PurTypeCode, OperType, " & _
- " OperbillNum, convert(datetime,'" & Xtrq & "'), InoutClassCode, TranCompanyCode, TransferWayCode, " & _
- " BusNum, DeptCode, PersonCode, CusCode, SupplierCode, " & _
- " ConsignbillNum , Consignbillid, '" & Xtczy & "','" & Xtczy & "', " & Xtyear & ", " & Xtmm & "," & banl_Mainid & _
- " From Gy_InOutMain " & _
- " Where (InOutMainId =" & rst_BalanceRelation.Fields("InOutMainId") & ")"
- Cw_DataEnvi.DataConnect.Execute (str_InsertSql)
- str_InsertSql = "INSERT INTO Gy_InOutSub " & _
- " (InOutSubId, InOutMainId, MNumber, FactReceiptQuan, Price, EMoney, EvaluationMoney, " & _
- " PlanPrice, PlanMoney) " & _
- " SELECT InOutSubId, " & RKd_MainId & ", MNumber, FactReceiptQuan, Price, EMoney, EvaluationMoney, " & _
- " PlanPrice, PlanMoney" & _
- " From Gy_InOutSub " & _
- " WHERE (InOutMainId = " & rst_BalanceRelation.Fields("InOutMainId") & ") AND (InOutSubId IN " & _
- " (SELECT InOutSubId " & _
- " From Kf_BalanceRelation " & _
- " WHERE BalanceMainId = " & banl_Mainid & " AND InOutMainId = " & rst_BalanceRelation.Fields("InOutMainId") & "))"
- Cw_DataEnvi.DataConnect.Execute (str_InsertSql)
- rst_BalanceRelation.MoveNext
- Loop
- Else
- Tsxx = "结算过程中某单据发生变化,结算失败!"
- Call Xtxxts(Tsxx, 0, 1)
- GoTo Swcwcl
- End If
- End If
- Exit Sub
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Bln_HaveErr = True
- End Sub
- Private Function Check_InoutMain() As Boolean '是否有可以结算的入库单
- Dim int_temp As Long
- Dim rst_temp As New ADODB.Recordset
- Dim str_sqlTemp As String
- str_sqlTemp = "SELECT Gy_InOutMain.InOutMainId " & _
- " FROM Gy_InOutMain INNER JOIN " & _
- " Gy_InOutSub ON Gy_InOutMain.InOutMainId = Gy_InOutSub.InOutMainId INNER JOIN" & _
- " Gy_Material ON Gy_InOutSub.MNumber = Gy_Material.MNumber" & _
- " WHERE (Gy_InOutSub.BalanceDate IS NULL and (ltrim(rtrim(isnull(Gy_InOutMain.kfChecker,''))) <>'') AND (ltrim(rtrim(Gy_InOutMain.BillCode))='1211' or ltrim(rtrim(Gy_InOutMain.BillCode))='1201')) " & FilterInOut
- Set rst_temp = Cw_DataEnvi.DataConnect.Execute(str_sqlTemp)
- If rst_temp.RecordCount <> 0 Then
- Check_InoutMain = True
- Else
- Tsxx = "没有可以结算的入库单数据!"
- Call Xtxxts(Tsxx, 0, 4)
- Check_InoutMain = False
- End If
- rst_temp.Close
- Set rst_temp = Nothing
- End Function
- Private Sub FilterCondition()
- Dim Jsqte As Integer
- FilterInvoice = " where 1=1 "
- FilterRKD = " "
- FilterInOut = " "
- For Jsqte = 1 To 5
- Select Case Jsqte
- Case 1 '查询日期范围(起始)
- If Trim(LrText(0).Text) <> "" Then
- FilterInvoice = FilterInvoice & " And InvoiceDate>=convert(datetime,'" & Trim(LrText(0).Text) & "')"
- FilterRKD = FilterRKD & " And BillDate>=convert(datetime,'" & Trim(LrText(0).Text) & "')"
- FilterInOut = FilterInOut & " And BillDate>=convert(datetime,'" & Trim(LrText(0).Text) & "')"
- End If
- Case 2 '查询日期范围(终止)
- If Trim(LrText(1).Text) <> "" Then
- FilterInvoice = FilterInvoice & " And InvoiceDate<= convert(datetime,'" & Trim(LrText(1).Text) & "')"
- FilterRKD = FilterRKD & " And BillDate<= convert(datetime,'" & Trim(LrText(1).Text) & "')"
- FilterInOut = FilterInOut & " And BillDate<= convert(datetime,'" & Trim(LrText(1).Text) & "')"
- End If
- Case 3 '供应商(Like)
- If Trim(LrText(2).Text) <> "" Then
- FilterInvoice = FilterInvoice & " And SupplierCode ='" & Trim(LrText(2).Tag) & "'"
- FilterInOut = FilterInOut & " And SupplierCode ='" & Trim(LrText(2).Tag) & "'"
- End If
- Case 4 '物料分类
- If Trim(LrText(3).Text) <> "" Then
- FilterInvoice = FilterInvoice & " and InvSortcode like '" & Trim(LrText(3).Tag) & "%'"
- FilterInOut = FilterInOut & " and InvSortcode like '" & Trim(LrText(3).Tag) & "%'"
- End If
- Case 5 '物料
- If Trim(LrText(4).Text) <> "" Then
- FilterInvoice = FilterInvoice & " and Gy_InOutSub.MNumber= '" & Trim(LrText(4).Text) & "'"
- FilterInOut = FilterInOut & " and Gy_InOutSub.MNumber= '" & Trim(LrText(4).Text) & "'"
- End If
- End Select
- Next
- FilterRKD = FilterRKD & " And Gy_InOutMain.WhCode in (select whcode from KF_V_WhLimit where ltrim(rtrim(Czybm))='" & Xtczybm & "')"
- FilterInOut = FilterInOut & " And Gy_InOutMain.WhCode in (select whcode from KF_V_WhLimit where ltrim(rtrim(Czybm))='" & Xtczybm & "')"
- End Sub
- Private Sub QxCommand_Click() '取消(Fixed)
- Unload Me
- End Sub
- Private Function Lrtjyxxpd() As Boolean '用户录入条件有效性判断
- Dim Jsqte As Integer
- Lrtjyxxpd = False
- '对需要进行事后判断的文本框录入内容进行有效性判断 (Fixed)
- For Jsqte = 0 To Max_Text_Index
- If Textint(Jsqte, 9) = 0 Or Textint(Jsqte, 9) = 2 Then
- If Not TextYxxpd(Jsqte) Then
- Exit Function
- End If
- End If
- Next Jsqte
- '[>>以下为依据实际情况自定义部分
- '查询日期范围应由小到大
- If LrText(0).Text > LrText(1).Text And Trim(LrText(1).Text) <> "" Then
- Tsxx = "查询日期范围应由小到大!"
- Call Xtxxts(Tsxx, 0, 4)
- LrText(0).SetFocus
- Exit Function
- End If
- '<<]以上为依据实际情况自定义部分
- Lrtjyxxpd = True
- End Function
- Private Sub Cmd_Clear_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '将用户输入条件全部清除(可选)
- '清除文本框(Fixed)
- For Jsqte = 0 To Max_Text_Index
- LrText(Jsqte).Tag = ""
- LrText(Jsqte).Text = ""
- Next Jsqte
- '[>>
- '此处可以写入其他清除条件程序
- '<<]
- End Sub
- '*************以下为文本框录入处理程序(固定不变部分)*************'
- Private Sub Wbklrwbcl(Index As Integer) '文本框录入事后处理程序
- '以下为依据实际情况自定义部分[
- '在此填写文本框录入事后处理程序
- ']以上为依据实际情况自定义部分
- End Sub
- Private Sub LrText_Change(Index As Integer)
- '屏蔽程序改变控制
- If TextChangeLock Then
- Exit Sub
- End If
- TextValiJudgeLock(Index) = False '打开有效性判断锁
- '限制字段录入长度
- TextChangeLock = True '加锁(防止执行Lrtext_Change)
- Select Case Textint(Index, 1)
- Case 8, 11 '金额型
- Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12 '数量型
- Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10 '单价型
- Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else '其他小数类型控制
- If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
- Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
- End If
- End Select
- TextChangeLock = False '解锁
- '如果仓库改变,清空对应的货区
- End Sub
- Private Sub LrText_GotFocus(Index As Integer) '文本框得到焦点,显示相应信息
- Call TextShow(Index)
- CurTextIndex = Index
- LrText(Index).SelStart = Len(LrText(Index))
- End Sub
- Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) '字段按F2键提供帮助
- Select Case KeyCode
- Case vbKeyF2
- Call Text_Help(Index)
- End Select
- End Sub
- Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer) '文本框录入事中控制
- Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
- End Sub
- Private Sub LrText_LostFocus(Index As Integer) '文本框失去焦点
- '显示相应信息但不能进行有效性判断
- End Sub
- Private Sub Ydcommand1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) '按钮提供帮助
- Call Text_Help(Index)
- End Sub
- Private Sub Text_Help(Index As Integer) '录入字段帮助
- If Not Textboolean(Index, 1) Then
- Exit Sub
- End If
- If Textint(Index, 2) <> 1 Then
- If Index = 0 Then
- strHlpR = FunHlpR(Trim(Textstr(Index, 4)), "billcode", S1)
- Else
- strHlpR = FunHlpR(Trim(Textstr(Index, 4)), "czybm", Xtczybm)
- End If
- End If
- Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
- '根据设置选择显示编码和名称,并进行存储
- If Len(Xtfhcs) <> 0 Then
- If Textint(Index, 3) = 1 Then
- LrText(Index).Text = Xtfhcsfz
- LrText(Index).Tag = Xtfhcs
- Else
- LrText(Index).Text = Xtfhcs
- LrText(Index).Tag = Xtfhcsfz
- End If
- End If
- LrText(Index).SetFocus
- End Sub
- Private Sub TextShow(Index As Integer) '文本框得到焦点,显示相应信息
- '填写文本框得到焦点,进行相应信息处理程序
- End Sub
- Private Sub Wbkcsh() '录入文本框初始化
- Dim Jsqte As Integer
- '最大录入文本框索引值
- Max_Text_Index = Textvar(1)
- ReDim TextValiJudgeLock(Max_Text_Index)
- For Jsqte = 0 To Max_Text_Index
- If Len(Trim(Textstr(Jsqte, 1))) <> 0 Then
- If Textboolean(Jsqte, 1) Then
- If Jsqte <> 0 And Not Textboolean(Jsqte, 3) Then
- Load Ydcommand1(Jsqte)
- End If
- Ydcommand1(Jsqte).Visible = True
- Ydcommand1(Jsqte).Move LrText(Jsqte).Left + LrText(Jsqte).Width, LrText(Jsqte).Top
- End If
- TextChangeLock = True
- LrText(Jsqte).Text = ""
- LrText(Jsqte).Tag = ""
- If Textint(Jsqte, 5) <> 0 Then
- LrText(Jsqte).MaxLength = Textint(Jsqte, 5)
- End If
- TextChangeLock = False
- End If
- TextValiJudgeLock(Jsqte) = True
- Next Jsqte
- End Sub
- Private Function TextYxxpd(Index As Integer) As Boolean '文本框有效性判断
- Dim Sqlstr As String
- Dim Findrec As ADODB.Recordset
- '文本框内容未曾改变不进行有效性判断
- If TextValiJudgeLock(Index) Then
- TextYxxpd = True
- Exit Function
- End If
- '文本框内容为空认为有效,并清空其Tag值
- If Trim(LrText(Index)) = "" Then
- LrText(Index).Tag = ""
- Call Wbklrwbcl(Index)
- TextValiJudgeLock(Index) = True
- TextYxxpd = True
- Exit Function
- End If
- '可在此加入不做有效性判断的理由
- Select Case Textint(Index, 4)
- Case 1 '编码型
- Sqlstr = Trim(Textstr(Index, 5))
- Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
- Set Findrec = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Findrec.EOF Then
- Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
- LrText(Index).SetFocus
- Exit Function
- Else
- Select Case Textint(Index, 3)
- Case 0
- If Len(Trim(Textstr(Index, 2))) <> 0 Then
- LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
- End If
- If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
- LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
- End If
- Case 1
- If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
- LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
- End If
- If Len(Trim(Textstr(Index, 2))) <> 0 Then
- LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
- End If
- End Select
- End If
- Case 2 '日期型
- If IsDate(LrText(Index).Text) Then
- LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
- If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
- LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
- End If
- Else
- Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(Index).SetFocus
- Exit Function
- End If
- Case 3 '其他类型
- End Select
- '如果有效则加锁,用户不改变内容则不再进行有效性判断
- TextValiJudgeLock(Index) = True
- '调用文本框事后处理程序
- Call Wbklrwbcl(Index)
- '有效性判断通过则返回True
- TextYxxpd = True
- End Function