⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmrp.vb

📁 生产管理系统。vb.net sql2
💻 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 + -