+
资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:16k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "VSOCX7.OCX"
- Begin VB.Form MRP_TotalDemandBuild
- BorderStyle = 3 'Fixed Dialog
- Caption = "汇总物料需求"
- ClientHeight = 4560
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 6030
- Icon = "物料需求计划_汇总需求生成.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4560
- ScaleWidth = 6030
- ShowInTaskbar = 0 'False
- StartUpPosition = 2 '屏幕中心
- Begin VB.Frame Frame1
- Caption = "考虑因素"
- Height = 630
- Left = 60
- TabIndex = 4
- Top = 5760
- Width = 5850
- Begin VB.CheckBox Check
- Caption = "安 全 库 存"
- Height = 357
- Index = 2
- Left = 4020
- TabIndex = 7
- Top = 195
- Value = 1 'Checked
- Width = 1320
- End
- Begin VB.CheckBox Check
- Caption = "已 分 配 量"
- Height = 357
- Index = 1
- Left = 2220
- TabIndex = 6
- Top = 195
- Value = 1 'Checked
- Width = 1365
- End
- Begin VB.CheckBox Check
- Caption = "现 有 库 存"
- Height = 357
- Index = 0
- Left = 382
- TabIndex = 5
- Top = 195
- Value = 1 'Checked
- Width = 1365
- End
- End
- Begin VB.CommandButton Cmd_Cancel
- Cancel = -1 'True
- Caption = "退出(&E)"
- Height = 300
- Left = 4785
- MouseIcon = "物料需求计划_汇总需求生成.frx":1042
- MousePointer = 99 'Custom
- Picture = "物料需求计划_汇总需求生成.frx":134C
- TabIndex = 1
- Top = 4185
- Width = 1120
- End
- Begin VB.CommandButton cmd_Ok
- Caption = "确定(&O)"
- Height = 300
- Left = 3540
- MouseIcon = "物料需求计划_汇总需求生成.frx":1656
- MousePointer = 99 'Custom
- Picture = "物料需求计划_汇总需求生成.frx":1960
- TabIndex = 0
- 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 = 2430
- TabIndex = 3
- Top = 150
- Width = 1020
- End
- End
- Attribute VB_Name = "MRP_TotalDemandBuild"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '*******************************************************
- '* 模 块 名 称 :物料需求计划-汇总物料需求生成
- '* 功 能 描 述 :汇总物料需求
- '* 程序员姓名 : 乔进
- '* 最后修改人 : 乔进
- '* 最后修改时间:2001/12/10
- '* 备 注:经过自己测试
- '*******************************************************
- 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
- 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_DependentDemandMain Where kjYear='" & iYear & "' And Period='" & iMonth & "' And Checker<>'' And IfTotal=0 And IfComplete=0 "
- Set RecState = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecState.Fields(0) <> 0 Then
- Fun_GetCycState = "需要汇总"
- Exit Function
- End If
- Sqlstr = "Select Count(*) From MRP_IndependentDemandMain Where kjYear='" & iYear & "' And Period='" & iMonth & "' And Checker<>'' And IfTotal=0 And IfComplete=0 "
- Set RecState = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecState.Fields(0) <> 0 Then
- Fun_GetCycState = "需要汇总"
- Exit Function
- End If
- Fun_GetCycState = "不需汇总"
- Set RecState = Nothing
- End Function
- Private Sub Form_Unload(Cancel As Integer) '窗体卸载
- Set Cxnrrec = Nothing
- Set RecTemp = Nothing
- Unload Dyymctbl
- End Sub
- '******************************************************************************************************************************
- '*过程说明:自定义程序
- '*过程名称:cmd_Ok_Click
- '*功能描述:根据所选计划周期对该计划周期内的相关与独立需求进行汇总
- '*参数说明:
- '******************************************************************************************************************************
- Private Sub cmd_Ok_Click()
- Dim sCycStr As String, iYear As Integer, iMonth As Integer, RecBOM As New ADODB.Recordset
- 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
- Dim c As New ADODB.Command: Dim p As ADODB.Parameter
- c.ActiveConnection = Cw_DataEnvi.DataConnect
- c.CommandType = adCmdStoredProc
- c.CommandText = "MRP_Sp_TotalSum"
- Set p = c.CreateParameter("kjYear", adChar, adParamInput, 20)
- c.Parameters.Append p: p.Value = iYear
- Set p = c.CreateParameter("Period", adChar, adParamInput, 20)
- c.Parameters.Append p: p.Value = iMonth
- Set p = c.CreateParameter("Czymc", adChar, adParamInput, 20)
- c.Parameters.Append p: p.Value = Xtczy
- Set p = c.CreateParameter("Czrq", adChar, adParamInput, 20)
- c.Parameters.Append p: p.Value = Format(Xtrq, "yyyy-mm-dd")
- Set p = c.CreateParameter("BillCode", adChar, adParamInput, 20)
- c.Parameters.Append p: p.Value = "2405"
- Set p = c.CreateParameter("Status", adInteger, adParamOutput)
- c.Parameters.Append p
- c.Execute
- If c.Parameters(5) = 0 Then
- Tsxx = "该周期内没有可以汇总物料!"
- Call Xtxxts(Tsxx, 0, 1)
- Cw_DataEnvi.DataConnect.RollbackTrans
- Screen.MousePointer = 0
- Exit Sub
- ElseIf c.Parameters(4) = 2 Then
- GoTo Errhand
- End If
- 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
- Tsxx = "汇总过程出现未知错误,没有进行汇总,数据恢复!"
- Call Xtxxts(Tsxx, 0, 4)
- 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