?? frmmrp.vb
字號:
Public Class frmMRP
Inherits System.Windows.Forms.Form
Dim dvProduct, dvResult As DataView
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調用是 Windows 窗體設計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調用之后添加任何初始化
End Sub
'窗體重寫 dispose 以清理組件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下過程是 Windows 窗體設計器所必需的
'可以使用 Windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents ckbDepot As System.Windows.Forms.CheckBox
Friend WithEvents ckbAhead As System.Windows.Forms.CheckBox
Friend WithEvents ckbWaste As System.Windows.Forms.CheckBox
Friend WithEvents btnCalculate As System.Windows.Forms.Button
Friend WithEvents btnRelease As System.Windows.Forms.Button
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
Friend WithEvents dgdProductList As System.Windows.Forms.DataGrid
Friend WithEvents dgdResultList As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmMRP))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.btnRelease = New System.Windows.Forms.Button
Me.btnCalculate = New System.Windows.Forms.Button
Me.ckbWaste = New System.Windows.Forms.CheckBox
Me.ckbAhead = New System.Windows.Forms.CheckBox
Me.ckbDepot = New System.Windows.Forms.CheckBox
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.dgdProductList = New System.Windows.Forms.DataGrid
Me.GroupBox3 = New System.Windows.Forms.GroupBox
Me.dgdResultList = New System.Windows.Forms.DataGrid
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.dgdProductList, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox3.SuspendLayout()
CType(Me.dgdResultList, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox1.Controls.Add(Me.btnRelease)
Me.GroupBox1.Controls.Add(Me.btnCalculate)
Me.GroupBox1.Controls.Add(Me.ckbWaste)
Me.GroupBox1.Controls.Add(Me.ckbAhead)
Me.GroupBox1.Controls.Add(Me.ckbDepot)
Me.GroupBox1.Location = New System.Drawing.Point(0, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(608, 72)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "計算參數"
'
'btnRelease
'
Me.btnRelease.Enabled = False
Me.btnRelease.Location = New System.Drawing.Point(520, 32)
Me.btnRelease.Name = "btnRelease"
Me.btnRelease.TabIndex = 4
Me.btnRelease.Text = "結果發布"
'
'btnCalculate
'
Me.btnCalculate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btnCalculate.Location = New System.Drawing.Point(424, 32)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(80, 23)
Me.btnCalculate.TabIndex = 3
Me.btnCalculate.Text = "計算"
'
'ckbWaste
'
Me.ckbWaste.Location = New System.Drawing.Point(336, 32)
Me.ckbWaste.Name = "ckbWaste"
Me.ckbWaste.Size = New System.Drawing.Size(88, 24)
Me.ckbWaste.TabIndex = 2
Me.ckbWaste.Text = "考慮損耗"
'
'ckbAhead
'
Me.ckbAhead.Location = New System.Drawing.Point(216, 32)
Me.ckbAhead.Name = "ckbAhead"
Me.ckbAhead.Size = New System.Drawing.Size(88, 24)
Me.ckbAhead.TabIndex = 1
Me.ckbAhead.Text = "考慮提前期"
'
'ckbDepot
'
Me.ckbDepot.Location = New System.Drawing.Point(24, 32)
Me.ckbDepot.Name = "ckbDepot"
Me.ckbDepot.Size = New System.Drawing.Size(168, 24)
Me.ckbDepot.TabIndex = 0
Me.ckbDepot.Text = "考慮庫存,生產和采購訂單"
'
'GroupBox2
'
Me.GroupBox2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox2.Controls.Add(Me.dgdProductList)
Me.GroupBox2.Location = New System.Drawing.Point(0, 80)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(608, 168)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "主生產計劃"
'
'dgdProductList
'
Me.dgdProductList.CaptionVisible = False
Me.dgdProductList.DataMember = ""
Me.dgdProductList.Dock = System.Windows.Forms.DockStyle.Fill
Me.dgdProductList.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dgdProductList.Location = New System.Drawing.Point(3, 17)
Me.dgdProductList.Name = "dgdProductList"
Me.dgdProductList.Size = New System.Drawing.Size(602, 148)
Me.dgdProductList.TabIndex = 0
'
'GroupBox3
'
Me.GroupBox3.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox3.Controls.Add(Me.dgdResultList)
Me.GroupBox3.Location = New System.Drawing.Point(0, 256)
Me.GroupBox3.Name = "GroupBox3"
Me.GroupBox3.Size = New System.Drawing.Size(608, 112)
Me.GroupBox3.TabIndex = 2
Me.GroupBox3.TabStop = False
Me.GroupBox3.Text = "MRP計算結果(物料需求)"
'
'dgdResultList
'
Me.dgdResultList.CaptionVisible = False
Me.dgdResultList.DataMember = ""
Me.dgdResultList.Dock = System.Windows.Forms.DockStyle.Fill
Me.dgdResultList.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dgdResultList.Location = New System.Drawing.Point(3, 17)
Me.dgdResultList.Name = "dgdResultList"
Me.dgdResultList.Size = New System.Drawing.Size(602, 92)
Me.dgdResultList.TabIndex = 1
'
'frmMRP
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(608, 373)
Me.Controls.Add(Me.GroupBox3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmMRP"
Me.Text = "MRP計算"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
CType(Me.dgdProductList, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox3.ResumeLayout(False)
CType(Me.dgdResultList, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub SetForProductList()
'執行SQL語句
Dim db As DataBase = New DataBase
Dim strSQL As String = "select a.物料編號,b.物料名稱,編號,年份,"
strSQL += "計劃期,開始日期,結束日期,MPS數量 from 主生產計劃 as a ,"
strSQL += "物料主文件 as b where a.物料編號 = b.物料編號"
dvProduct = db.RunSelectSQL(strSQL)
'設置DataGrid
Dim ts As New DataGridTableStyle
Dim aColumnTextColumn As DataGridTextBoxColumn
Dim numCols As Integer = dvProduct.Table.Columns.Count
Dim i As Integer
For i = 0 To numCols - 1
aColumnTextColumn = New DataGridTextBoxColumn
aColumnTextColumn.MappingName = _
dvProduct.Table.Columns(i).ColumnName
aColumnTextColumn.HeaderText = _
dvProduct.Table.Columns(i).ColumnName
aColumnTextColumn.NullText = ""
ts.GridColumnStyles.Add(aColumnTextColumn)
Next
ts.AlternatingBackColor = Color.LightGray
ts.AllowSorting = False
ts.MappingName = dvProduct.Table.TableName
dgdProductList.TableStyles.Clear()
dgdProductList.TableStyles.Add(ts)
dvProduct.AllowNew = False
dvProduct.AllowDelete = False
dvProduct.AllowEdit = False
'設置數據源
dgdProductList.DataSource = dvProduct
db.Dispose()
End Sub
Private Sub SetForResultList()
'獲得3個CheckBox的狀態
Dim iCheckOne, iCheckTwo, iCheckThree As Integer
iCheckOne = CInt(ckbDepot.CheckState)
iCheckTwo = CInt(ckbAhead.CheckState)
iCheckThree = CInt(ckbWaste.CheckState)
'執行存儲過程進行計算
Dim db As DataBase = New DataBase
db.RunDelOrInsSQL("exec sf_mrp計算 " + iCheckOne.ToString + "," _
+ iCheckTwo.ToString + "," + iCheckThree.ToString)
'查詢計算結果
Dim strSQL As String = "select a.物料編號,物料名稱,年份,計劃期,"
strSQL += "期初庫存,毛需求,預計庫存,凈需求,預計出庫,計劃產出,"
strSQL += "計劃投入 from mrp物料需求計算 as a,物料主文件 as "
strSQL += "b where a.物料編號 = b.物料編號"
dvResult = db.RunSelectSQL(strSQL)
db.Dispose()
'設置DataGrid樣式
Dim ts As New DataGridTableStyle
Dim aColumnTextColumn As DataGridTextBoxColumn
Dim numCols As Integer = dvResult.Table.Columns.Count
Dim i As Integer
For i = 0 To numCols - 1
aColumnTextColumn = New DataGridTextBoxColumn
aColumnTextColumn.MappingName = _
dvResult.Table.Columns(i).ColumnName
aColumnTextColumn.HeaderText = _
dvResult.Table.Columns(i).ColumnName
aColumnTextColumn.Format = "F"
aColumnTextColumn.NullText = ""
aColumnTextColumn.Width = 60
ts.GridColumnStyles.Add(aColumnTextColumn)
Next
ts.AlternatingBackColor = Color.LightGray
ts.MappingName = dvResult.Table.TableName
ts.AllowSorting = False
dgdResultList.TableStyles.Clear()
dgdResultList.TableStyles.Add(ts)
dvResult.AllowNew = False
dvResult.AllowDelete = False
dvResult.AllowEdit = False
'設置數據源
dgdResultList.DataSource = dvResult
End Sub
Private Sub frmMRP_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
SetForProductList()
End Sub
Private Sub btnCalculate_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnCalculate.Click
Try
SetForResultList()
btnRelease.Enabled = True
Catch ex As Exception
' MessageBox.Show("計算出錯!", "生產管理系統")
MessageBox.Show(ex.ToString, "生產管理系統")
End Try
End Sub
Private Sub btnRelease_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnRelease.Click
Dim dlgResult As DialogResult = _
MessageBox.Show("是否發布本次計算結果", _
"生產管理系統", MessageBoxButtons.YesNo)
If dlgResult = DialogResult.No Then
Exit Sub
End If
Try
Dim db As DataBase = New DataBase
db.RunDelOrInsSQL("exec sf_mrp結果發布 ")
db.Dispose()
Catch ex As Exception
MessageBox.Show("結果發布出錯!", "生產管理系統")
End Try
SetForProductList()
SetForResultList()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -