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

📄 ware_compos2.frm

📁 一个企业生产管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmware_compos2 
   Caption         =   "temp0"
   ClientHeight    =   8595
   ClientLeft      =   1110
   ClientTop       =   345
   ClientWidth     =   9000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   8595
   ScaleWidth      =   9000
   Begin VB.CommandButton cmdRefresh 
      Caption         =   "刷新(&R)"
      Height          =   300
      Left            =   0
      TabIndex        =   12
      Top             =   0
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H80000001&
      Height          =   375
      Left            =   3480
      Picture         =   "ware_compos2.frx":0000
      ScaleHeight     =   315
      ScaleWidth      =   195
      TabIndex        =   8
      Top             =   1800
      Width           =   255
   End
   Begin VB.TextBox Text1 
      DataField       =   "ware_layer_id"
      DataSource      =   "Adodc1"
      Height          =   375
      Index           =   0
      Left            =   2040
      TabIndex        =   7
      Top             =   1800
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      DataField       =   "warename"
      DataSource      =   "Adodc1"
      Height          =   375
      Index           =   1
      Left            =   2040
      TabIndex        =   6
      Top             =   2640
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      DataField       =   "quantity"
      DataSource      =   "Adodc1"
      Height          =   375
      Index           =   2
      Left            =   2040
      TabIndex        =   5
      Top             =   3480
      Width           =   1215
   End
   Begin VB.CommandButton cmadd 
      Caption         =   "增加"
      Height          =   375
      Left            =   600
      TabIndex        =   4
      Top             =   4680
      Width           =   1095
   End
   Begin VB.CommandButton amdel 
      Caption         =   "删除"
      Height          =   375
      Left            =   2040
      TabIndex        =   3
      Top             =   4680
      Width           =   1095
   End
   Begin VB.CommandButton cmupdate 
      Caption         =   "保存"
      Height          =   375
      Left            =   3480
      TabIndex        =   2
      Top             =   4680
      Width           =   1095
   End
   Begin VB.CommandButton cmdClose 
      Cancel          =   -1  'True
      Caption         =   "关闭(&C)"
      Height          =   300
      Left            =   7560
      TabIndex        =   0
      Top             =   5640
      Width           =   1080
   End
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1 
      DragIcon        =   "ware_compos2.frx":0152
      Height          =   3840
      Left            =   5280
      TabIndex        =   1
      Top             =   1200
      Width           =   4440
      _ExtentX        =   7832
      _ExtentY        =   6773
      _Version        =   393216
      BackColor       =   16777215
      ForeColor       =   0
      Rows            =   20
      Cols            =   4
      GridColor       =   12632256
      GridColorFixed  =   -2147483632
      WordWrap        =   -1  'True
      AllowBigSelection=   0   'False
      FocusRect       =   0
      HighLight       =   0
      AllowUserResizing=   1
      FormatString    =   "|ware_layer_id|warename|quantity"
      _NumberOfBands  =   1
      _Band(0).Cols   =   4
      _Band(0).GridLineWidthBand=   1
      _Band(0).TextStyleBand=   0
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   600
      Top             =   7680
      Width           =   3735
      _ExtentX        =   6588
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   3
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "DSN=warehouse"
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   "warehouse"
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "temp0"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label Label1 
      Caption         =   "零件编号"
      Height          =   255
      Left            =   960
      TabIndex        =   11
      Top             =   1920
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "零件名称"
      Height          =   255
      Left            =   960
      TabIndex        =   10
      Top             =   2760
      Width           =   855
   End
   Begin VB.Label Label3 
      Caption         =   "数    量"
      Height          =   255
      Left            =   960
      TabIndex        =   9
      Top             =   3600
      Width           =   855
   End
End
Attribute VB_Name = "frmware_compos2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Const MARGIN_SIZE = 60      ' 单位为缇
' 数据绑定变量
Private datPrimaryRS As ADODB.Recordset

' 能列排序变量
Private m_iSortCol As Integer
Private m_iSortType As Integer

' 列拖拽变量
Private m_bDragOK As Boolean
Private m_iDragCol As Integer
Private xdn As Integer, ydn As Integer

Dim strcon As String
'Dim i As Integer
Dim db As Connection

Private Sub amdel_Click()
  On Error GoTo DeleteErr
  With Adodc1.Recordset
    .Delete
    .MoveNext
    If .EOF Then .MoveLast
  End With
  Exit Sub
DeleteErr:
  MsgBox Err.Description
End Sub

Private Sub cmadd_Click()
  On Error GoTo AddErr
  Adodc1.Recordset.AddNew
  Exit Sub
AddErr:
  MsgBox Err.Description
End Sub


Private Sub cmdRefresh_Click()
  '只有多用户应用程序需要
  On Error GoTo RefreshErr
  Set MSHFlexGrid1.DataSource = Nothing
  datPrimaryRS.Requery
  Set MSHFlexGrid1.DataSource = datPrimaryRS

  Exit Sub
RefreshErr:
  MsgBox Err.Description
End Sub

Private Sub cmupdate_Click()
On Error GoTo Err
Adodc1.Recordset.Update
cmdRefresh_Click
cmdClose.Visible = True

Exit Sub

Err:
MsgBox Error.Description
End Sub

Private Sub Form_Load()

    Dim sConnect As String
    Dim sSQL As String
    Dim db As ADODB.Connection

    ' 设置字符串
'    sConnect = "Provider=MSDASQL.1;Connect Timeout=15;Extended Properties='DRIVER=SQL Server;SERVER=ht;UID=sa;PWD=;APP=Visual Basic;WSID=HT;DATABASE=warehouse';Locale Identifier=2052"
'    sSQL = "select ware_layer_id,warename,quantity from temp0"
    sSQL = "PROVIDER=MSDASQL;driver={SQL Server};server=ht;uid=sa;pwd=;database=warehouse;"
    ' 打开连接
'    Set db = New Connection
''    db.Open sConnect
i = 0
  Set db = New Connection
  db.CursorLocation = adUseClient
  db.Open "PROVIDER=MSDASQL;driver={SQL Server};server=ht;uid=sa;pwd=;database=warehouse;"

  Set datPrimaryRS = New Recordset
  'datprimaryRS.Open "select war_ware_id,ware_id,ware_layer_id,quantity,blong_to from ware_compos", db, adOpenStatic, adLockOptimistic
  db.Execute "if exists (select * from sysobjects where id = object_id(N'[dbo].[temp0]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[temp0]"
  db.Execute "CREATE TABLE [dbo].[temp0] (   [ware_layer_id] [VARchar] (50) NOT NULL ,[warename] [VARchar](25) NULL , [quantity] [numeric] (7,2) NULL)"
'  db.Execute "ALTER TABLE [dbo].[TEMP0] WITH NOCHECK ADD CONSTRAINT [dUUUUdf] PRIMARY KEYCLUSTERED ([ware_id]) ON [PRIMARY] "
'  db.Execute "SELECT *  INTO temp0 FROM co "
  datPrimaryRS.Open "select ware_layer_id AS  '产品编号',warename as '产品名称' ,quantity as  '数量'  from TEMP0", db, adOpenStatic, adLockOptimistic

    ' 使用提供的集合创建 recordset
    Set datPrimaryRS = New Recordset
    datPrimaryRS.CursorLocation = adUseClient
    datPrimaryRS.Open sSQL, db, adOpenForwardOnly, adLockReadOnly

    Set MSHFlexGrid1.DataSource = datPrimaryRS

    With MSHFlexGrid1

        .Redraw = False
        ' 设置网格列宽度
        .ColWidth(0) = 300
        .ColWidth(1) = -1
        .ColWidth(2) = -1
        .ColWidth(3) = -1

        ' 设置网格样式
        .AllowBigSelection = True
        .FillStyle = flexFillRepeat

        ' 将标头作成粗体
        .row = 0
        .col = 0
        .RowSel = .FixedRows - 1
        .ColSel = .Cols - 1
        .CellFontBold = True

        .AllowBigSelection = False
        .FillStyle = flexFillSingle
        .Redraw = True

    End With

End Sub

Private Sub MSHFlexGrid1_DragDrop(Source As Control, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------

    If m_iDragCol = -1 Then Exit Sub    ' 现在不能拖拽
    If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub
    If MSHFlexGrid1.FixedCols = 1 And MSHFlexGrid1.MouseCol = 0 Then Exit Sub

    With MSHFlexGrid1
        .Redraw = False
        .ColPosition(m_iDragCol) = .MouseCol
        .Redraw = True
    End With

End Sub

Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------

    If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub
    If MSHFlexGrid1.MouseCol = 0 And MSHFlexGrid1.FixedCols = 1 Then Exit Sub

    xdn = X
    ydn = Y
    m_iDragCol = -1     ' 清除拖拽标志
    m_bDragOK = True

End Sub

Private Sub MSHFlexGrid1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------

    ' 测试是否能够开始拖拽
    If Not m_bDragOK Then Exit Sub
    If Button <> 1 Then Exit Sub                        ' 错误按钮
    If m_iDragCol <> -1 Then Exit Sub                   ' 已经开始拖拽
    If Abs(xdn - X) + Abs(ydn - Y) < 50 Then Exit Sub   ' 移得不够
    If MSHFlexGrid1.MouseRow <> 0 Then Exit Sub         ' 必须拖拽标头

    ' 如果到达这则开始拖拽
    m_iDragCol = MSHFlexGrid1.MouseCol
    MSHFlexGrid1.Drag vbBeginDrag

End Sub

Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'-------------------------------------------------------------------------------------------
' 网格中 DragDrop, MouseDown, MouseMove, 和 MouseUp 事件代码能进行列拖拽
'-------------------------------------------------------------------------------------------

    m_bDragOK = False

End Sub

Private Sub MSHFlexGrid1_DblClick()
'-------------------------------------------------------------------------------------------
' 网格的 DblClick 事件代码能进行列排序
'-------------------------------------------------------------------------------------------

    Dim i As Integer

    ' 仅在单击固定行时进行排序
    If MSHFlexGrid1.MouseRow >= MSHFlexGrid1.FixedRows Then Exit Sub

    i = m_iSortCol                  ' 保存旧列
    m_iSortCol = MSHFlexGrid1.col   ' 设置新列

    ' 递增排序类型
    If i <> m_iSortCol Then
        ' 如果在新的列上单击鼠标,开始升序排序
        m_iSortType = 1
    Else
        ' 如果在相同列单击鼠标,则进行升序和降序排序的转换。
        m_iSortType = m_iSortType + 1
    If m_iSortType = 3 Then m_iSortType = 1
    End If

    DoColumnSort

End Sub

Sub DoColumnSort()
'-------------------------------------------------------------------------------------------
' 作 Exchange-type 排序在列 m_iSortCol
'-------------------------------------------------------------------------------------------

    With MSHFlexGrid1
        .Redraw = False
        .row = 1
        .RowSel = .Rows - 1
        .col = m_iSortCol
        .Sort = m_iSortType
        .Redraw = True
    End With

End Sub

Private Sub Form_Resize()

    Dim sngButtonTop As Single
    Dim sngScaleWidth As Single
    Dim sngScaleHeight As Single

    On Error GoTo Form_Resize_Error
    With Me
        sngScaleWidth = .ScaleWidth
        sngScaleHeight = .ScaleHeight

        ' 移动“关闭”按钮到右下角
        With .cmdClose
                sngButtonTop = sngScaleHeight - (.Height + MARGIN_SIZE)
                .Move sngScaleWidth - (.Width + MARGIN_SIZE), sngButtonTop
        End With

        .MSHFlexGrid1.Move MARGIN_SIZE, _
            MARGIN_SIZE, _
            sngScaleWidth - (2 * MARGIN_SIZE), _
            sngButtonTop - (2 * MARGIN_SIZE)

    End With
    Exit Sub

Form_Resize_Error:
    ' 避免负值错误
    Resume Next

End Sub
Private Sub cmdClose_Click()
'cmdUpdate_Click
Dim rs As New ADODB.Recordset
rs.Open "temp0", db, adOpenStatic, adLockBatchOptimistic
strcon = "ware_layer_id not like '%' "
With rs
If rs.RecordCount = 0 Then
    If MsgBox("您未输入计划,请重新输入", vbOKCancel, "错误提示") = vbOK Then
    Exit Sub
    Else
    Unload Me
    Exit Sub
    
    End If
End If
    
.MoveFirst

 Do While Not .EOF
 strcon = strcon & " or war_ware_id ='" & .Fields("ware_layer_id") & "'"
 .MoveNext
 Loop

 End With
Unload Me
  find_item strcon, 0, 15
    Unload Me

End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -