+
资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:17k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "VSOCX7.OCX"
- Begin VB.Form MRP_DependentDemandBuild
- BorderStyle = 3 'Fixed Dialog
- Caption = "相关需求生成"
- ClientHeight = 4590
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6015
- Icon = "物料需求计划_相关需求生成.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4590
- ScaleWidth = 6015
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 '屏幕中心
- Begin VB.CommandButton cmd_Ok
- Caption = "确定(&O)"
- Height = 300
- Left = 3630
- MouseIcon = "物料需求计划_相关需求生成.frx":1042
- MousePointer = 99 'Custom
- Picture = "物料需求计划_相关需求生成.frx":134C
- TabIndex = 0
- Top = 4185
- Width = 1120
- End
- Begin VB.CommandButton Cmd_Cancel
- Cancel = -1 'True
- Caption = "退出(&E)"
- Height = 300
- Left = 4845
- MouseIcon = "物料需求计划_相关需求生成.frx":1656
- MousePointer = 99 'Custom
- Picture = "物料需求计划_相关需求生成.frx":1960
- TabIndex = 1
- Top = 4185
- Width = 1120
- End
- Begin VSFlex8Ctl.VSFlexGrid CxbbGrid
- Height = 3465
- Left = 90
- TabIndex = 2
- Top = 540
- Width = 5850
- _ExtentX = 10319
- _ExtentY = 6112
- Appearance = 1
- BorderStyle = 1
- Enabled = -1 'True
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- MousePointer = 0
- BackColor = 16777215
- ForeColor = -2147483640
- BackColorFixed = -2147483648
- ForeColorFixed = -2147483630
- BackColorSel = -2147483635
- ForeColorSel = -2147483634
- BackColorBkg = -2147483636
- BackColorAlternate= 16777215
- GridColor = -2147483633
- GridColorFixed = -2147483632
- TreeColor = -2147483632
- FloodColor = 192
- SheetBorder = -2147483642
- FocusRect = 1
- HighLight = 1
- AllowSelection = -1 'True
- AllowBigSelection= -1 'True
- AllowUserResizing= 0
- SelectionMode = 0
- GridLines = 1
- GridLinesFixed = 2
- GridLineWidth = 1
- Rows = 50
- Cols = 10
- FixedRows = 1
- FixedCols = 0
- RowHeightMin = 0
- RowHeightMax = 0
- ColWidthMin = 0
- ColWidthMax = 0
- ExtendLastCol = 0 'False
- FormatString = ""
- ScrollTrack = 0 'False
- ScrollBars = 3
- ScrollTips = 0 'False
- MergeCells = 0
- MergeCompare = 0
- AutoResize = -1 'True
- AutoSizeMode = 0
- AutoSearch = 0
- MultiTotals = -1 'True
- SubtotalPosition= 1
- OutlineBar = 0
- OutlineCol = 0
- Ellipsis = 0
- ExplorerBar = 0
- PicturesOver = 0 'False
- FillStyle = 0
- RightToLeft = 0 'False
- PictureType = 0
- TabBehavior = 0
- OwnerDraw = 0
- Editable = 0 'False
- ShowComboButton = -1 'True
- WordWrap = 0 'False
- TextStyle = 0
- TextStyleFixed = 0
- OleDragMode = 0
- OleDropMode = 0
- DataMode = 0
- VirtualData = -1 'True
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "计划周期"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00404040&
- Height = 240
- Left = 2490
- TabIndex = 3
- Top = 150
- Width = 1020
- End
- End
- Attribute VB_Name = "MRP_DependentDemandBuild"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '*******************************************************
- '* 模 块 名 称 :物料需求计划-相关需求生成
- '* 功 能 描 述 :分解主生产计划
- '* 程序员姓名 : 乔进
- '* 最后修改人 : 乔进
- '* 最后修改时间:2001/12/04
- '* 备 注:经过自己测试
- '*******************************************************
- Option Explicit
- Dim RecTemp As New ADODB.Recordset '需求表
- Dim jdzygs As Integer '控件焦点转移个数
- Dim Lrzt As Integer '录入状态标志(0-非录入状态 1-增加 2-修改)
- Dim ReportTitle As String '报表主标题
- Dim Sqlstr As String 'Sql语句字符串
- Dim jsqte As Integer '计数器
- '以下为固定使用变量(网格)
- Dim Cxnrrec As New ADODB.Recordset '显示查询内容动态集
- Dim Dyymctbl As New DY_Dyymsz '打印页面窗体变量
- Dim GridCode As String '显示网格网格代码
- Dim GridInf() As Variant '整个网格设置信息
- Dim Tsxx As String '系统提示信息
- Dim Qslz As Long '网格隐藏(非操作显示)列数
- Dim Sjhgd As Double '网格数据行高度
- Dim GridBoolean() As Boolean '网格列信息(布尔型)
- Dim GridStr() As String '网格列信息(字符型)
- Dim GridInt() As Integer '网格列信息(整型)
- Dim Szzls As Integer '数组总列数(网格列数-1)
- '******************************************************************************************************************************
- '*过程说明:事件
- '*过程名称:Form_KeyPress
- '*功能描述:控 制 焦 点 转 移
- '*参数说明:
- '******************************************************************************************************************************
- Private Sub Form_KeyPress(KeyAscii As Integer)
- jdzygs = 6
- Select Case KeyAscii
- Case vbKeyReturn
- If Kjjdzy(jdzygs) Then
- KeyAscii = 0
- End If
- Case 39 '屏蔽"'"
- KeyAscii = 0
- End Select
- End Sub
- '******************************************************************************************************************************
- '*过程说明:事件
- '*过程名称:Form_Load
- '*功能描述:窗体载入
- '*参数说明:
- '******************************************************************************************************************************
- Private Sub Form_Load()
- Screen.MousePointer = 11
- '定义可变部分变量
- '调入打印页面设置窗体
- '调 入 网 格
- GridCode = "MRP_BuildDepDemand"
- Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
- Qslz = GridInf(1)
- Sjhgd = GridInf(2)
- Szzls = CxbbGrid.Cols - 1
- '填 充 网 格
- Call Cxnrtcwg
- Screen.MousePointer = 0
- MRP_DependentDemandBuild.HelpContextID = 241400101
- End Sub
- '******************************************************************************************************************************
- '*过程说明:自定义子程序
- '*过程名称:Cxnrtcwg
- '*功能描述:查 询 内 容 填 充 网 格
- '*参数说明:
- '******************************************************************************************************************************
- Private Sub Cxnrtcwg()
- Dim Sqlstr As String
- Dim jsqte As Long, sMonthCyc As String, i As Integer, iYear As Integer, iMonth As Integer
- On Error GoTo Errhand
- '列出所有的月计划
- Me.CxbbGrid.Clear 1
- Sqlstr = "Select * From Gy_kjrlb Where (kjYear>'" & Year(Xtrq) & "' ) or ( kjYear='" & Year(Xtrq) & "' And Period>='" & Month(Xtrq) & "' ) Order by kjYear ,Period"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Not RecTemp.EOF Then
- RecTemp.MoveLast: RecTemp.MoveFirst: jsqte = CxbbGrid.FixedRows
- CxbbGrid.Rows = CxbbGrid.FixedRows + Val(RecTemp.RecordCount)
- Do While Not RecTemp.EOF
- CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = Trim(Str(RecTemp!kjyear)) + "." + Format(Trim(Str(RecTemp!Period)), "00")
- CxbbGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Format(RecTemp!Qsrq, "yyyy-mm-dd")
- CxbbGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Format(RecTemp!Zzrq, "yyyy-mm-dd")
- CxbbGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Fun_GetCycState(Val(RecTemp!kjyear), Val(RecTemp!Period))
- RecTemp.MoveNext
- jsqte = jsqte + 1
- Loop
- End If
- Exit Sub
- Errhand:
- If Err.Number = "-2147217871" Then
- Tsxx = "连接超时 , 请稍后重新进入!"
- Else
- Tsxx = "初始化过程发生未知错误,请稍后重新进入!"
- End If
- Me.Show
- Me.Refresh
- DoEvents
- Call Xtxxts(Tsxx, 0, 1)
- End Sub
- '返回某个周期状态,从而知道该周期是否需要汇总
- Function Fun_GetCycState(iYear As Integer, iMonth As Integer) As String
- Dim RecState As New ADODB.Recordset, Sqls As String
- Sqlstr = "Select Count(*) From MRP_PlanMain Where kjYear='" & iYear & "' And Period='" & iMonth & "' And Checker<>'' And IfBuildDemand=0 And IfComplete=0 "
- Set RecState = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Not RecState.EOF Then
- If RecState.Fields(0) = 0 Then
- Fun_GetCycState = "不需汇总"
- Else
- Fun_GetCycState = "需要汇总"
- End If
- Else
- Fun_GetCycState = "不需汇总"
- End If
- Set RecState = Nothing
- End Function
- Private Sub Form_Unload(Cancel As Integer) '窗体卸载
- Set Cxnrrec = Nothing
- Set RecTemp = Nothing
- Unload Dyymctbl
- End Sub
- Private Sub cmd_Ok_Click()
- Dim sCycStr As String, iYear As Integer, iMonth As Integer, RecBOM As New ADODB.Recordset, BillID As String
- Dim DemandNumber As Double
- If CxbbGrid.Row < CxbbGrid.FixedRows Then Exit Sub
- If Trim(CxbbGrid.TextMatrix(CxbbGrid.Row, Sydz("004", GridStr(), Szzls))) = "不需汇总" Then
- Tsxx = "该周期不需要汇总!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Sub
- End If
- sCycStr = CxbbGrid.TextMatrix(CxbbGrid.Row, Sydz("001", GridStr(), Szzls))
- Call Sub_DivMonth(sCycStr, iYear, iMonth)
- On Error GoTo Errhand
- Cw_DataEnvi.DataConnect.Errors.Clear
- Cw_DataEnvi.DataConnect.BeginTrans
- Screen.MousePointer = 11
- '取出所有可以要分解的月份计划物料
- Sqlstr = "Select * From MRP_V_MPSList Where kjYear='" & iYear & "' And Period='" & iMonth & "' And Checker<>'' And IfBuildDemand=0 And IfComplete=0 "
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.EOF Then
- Tsxx = "没有可以汇总计划!"
- Call Xtxxts(Tsxx, 0, 1): Screen.MousePointer = 0
- Exit Sub
- End If
- RecTemp.MoveLast: RecTemp.MoveFirst
- Do While Not RecTemp.EOF
- '生成主表数据
- BillID = CreatBillID("2403")
- Sqlstr = "Insert MRP_DependentDemandMain ( DepDemandMainID ,kjYear ,Period ,PlanSubID ,PlanMainID ,DeptCode ,MNumber,TotalOutput ,Maker,MakeDate ,Checker ,IfAdd ,IfTotal,IfComplete ) " & _
- " Values ( '" & BillID & "','" & Val(RecTemp!kjyear) & "','" & Val(RecTemp!Period) & "' ,'" & Val(RecTemp!PlanSubID) & "' ,'" & Val(RecTemp!MPSNumber) & "' ,'" & Trim(RecTemp!DeptCode) & "' ,'" & Trim(RecTemp!MNumber) & "' ,'" & Trim(RecTemp!TotalOutput) & "' ,'" & Xtczy & "' ,'" & Format(Xtrq, "yyyy-mm-dd") & "' ,'','" & IIf(RecTemp!IfAdd = True, 1, 0) & "' , 0 , 0 ) "
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- Sqlstr = "Select * From MRP_V_BOMList Where MNumber_Main='" & Trim(RecTemp!MNumber & "") & "' And State=1"
- Set RecBOM = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- '判断该月份计划物料是否在配方表中存在,如果存在分解,不存在则直接生成相关需求
- jsqte = 1
- If RecTemp!TotalOutput > 0 And Not RecBOM.EOF Then
- RecBOM.MoveLast: RecBOM.MoveFirst
- Do While Not RecBOM.EOF
- DemandNumber = (Val(RecTemp!TotalOutput & "") / (Val(RecBOM!ProPercent & "") / 100)) * Val(RecBOM!RationNum & "") * (1 + Val(RecBOM!WastePercent & ""))
- If Fun_NumericLen(DemandNumber) > 11 Then
- Err.Raise vbObjectError + 512
- End If
- DemandNumber = Fun_ConvDec(NumberType, DemandNumber)
- If DemandNumber <= 0 Then
- Err.Raise vbObjectError + 513
- End If
- Sqlstr = " Insert MRP_DependentDemandSub ( DepDemandSubID ,DepDemandMainID ,MNumber ,DemandNumber ,DemandDate ) " & _
- " Values ( '" & jsqte & "' ,'" & BillID & "' ,'" & Trim(RecBOM!MNumber_Sub & "") & "' ,'" & DemandNumber & "' ,'" & Format(RecTemp!BeginDate, "yyyy-mm-dd") & "' ) "
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- RecBOM.MoveNext
- jsqte = jsqte + 1
- Loop
- Else
- Sqlstr = " Insert MRP_DependentDemandSub ( DepDemandSubID ,DepDemandMainID ,MNumber ,DemandNumber ,DemandDate ) " & _
- " Values ( '" & jsqte & "' ,'" & BillID & "' ,'" & Trim(RecTemp!MNumber & "") & "' ,'" & Fun_ConvDec(NumberType, Format(Val(RecTemp!TotalOutput), "#.000000")) & "' ,'" & Format(RecTemp!BeginDate, "yyyy-mm-dd") & "' ) "
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End If
- Sqlstr = " Update MRP_PlanMain Set IfBuildDemand=1 Where PlanMainID='" & RecTemp!PlanMainID & "' "
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- RecTemp.MoveNext
- Loop
- Cw_DataEnvi.DataConnect.CommitTrans
- Tsxx = "生成完成!"
- Call Xtxxts(Tsxx, 0, 4)
- Screen.MousePointer = 0
- CxbbGrid.TextMatrix(CxbbGrid.Row, Sydz("004", GridStr(), Szzls)) = "不需汇总"
- Exit Sub
- Errhand:
- Screen.MousePointer = 0
- Cw_DataEnvi.DataConnect.RollbackTrans
- If Err.Number = vbObjectError + 512 Then
- Tsxx = "物料子项需求数量过大超出额定范围 ,请检查物料需求数量!"
- ElseIf Err.Number = vbObjectError + 513 Then
- Tsxx = "物料子项需求数量过小 ,请检查物料需求数量和配方数量!"
- Else
- Tsxx = "汇总过程出现未知错误,没有进行汇总,数据恢复!"
- End If
- Call Xtxxts(Tsxx, 0, 1)
- Exit Sub
- End Sub
- '******************************************************************************************************************************
- '*过程说明:自定义程序
- '*过程名称:Cmd_Cancel_Click
- '*功能描述:取消操作,退成汇总程序
- '*参数说明:
- '******************************************************************************************************************************
- Private Sub Cmd_Cancel_Click()
- Unload Me
- End Sub
- '*********************通用程序****************************************
- Private Sub bbyl(bbylte As Boolean) '报表打印预览
- Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
- Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
- Bbxbtgs = 1 '报 表 小 标 题 行 数
- Bbbwhgs = 0 '报 表 表 尾 行 数
- ReDim Bbxbt(1 To Bbxbtgs)
- ReDim bbxbtzzxs(1 To Bbxbtgs)
- If Bbbwhgs <> 0 Then
- ReDim Bbbwh(1 To Bbbwhgs)
- ReDim Bbbwhzzxs(1 To Bbbwhgs)
- End If
- Bbzbt = ReportTitle
- Bbxbt(1) = " "
- bbxbtzzxs(1) = 0 '报表行组织形式(0-居左 1-居中 2-居右)
- Call Scyxsjb(CxbbGrid) '生成报表数据
- Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
- If Not bbylte Then
- Unload DY_Tybbyldy
- End If
- End Sub
- Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
- Select Case Button.Key
- Case "bz"
- Call F1bz
- Case "tc"
- Unload Me
- End Select
- End Sub
- '拆分周期,从周期中提出年月
- Private Sub Sub_DivMonth(InPara As String, Out1 As Integer, Out2 As Integer)
- Dim Pos1 As Integer
- Pos1 = InStr(1, InPara, ".")
- Out1 = Val(Left(InPara, Pos1 - 1))
- Out2 = Right(InPara, Len(InPara) - Pos1)
- End Sub
- Function Fun_NumericLen(Num As Double) As Integer
- Dim sNum As String
- sNum = Str(Int(Num))
- Fun_NumericLen = Len(Trim(sNum))
- End Function