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

📄 form1.frm

📁 汽车维修管理软件。其中包含三个编辑控件。
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form InputView 
   ClientHeight    =   4980
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6975
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   10.5
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   MDIChild        =   -1  'True
   ScaleHeight     =   4980
   ScaleWidth      =   6975
   WindowState     =   2  'Maximized
   Begin MSFlexGridLib.MSFlexGrid Grid 
      Height          =   3975
      Left            =   120
      TabIndex        =   1
      Top             =   840
      Width           =   6615
      _ExtentX        =   11668
      _ExtentY        =   7011
      _Version        =   393216
      FixedCols       =   0
      BackColorFixed  =   -2147483639
      BackColorBkg    =   16777215
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComctlLib.ImageList ImageList 
      Left            =   0
      Top             =   3120
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   15
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   6
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0542
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0A84
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0FC6
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1418
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":152A
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.Toolbar Toolbar 
      Align           =   1  'Align Top
      Height          =   615
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6975
      _ExtentX        =   12303
      _ExtentY        =   1085
      ButtonWidth     =   820
      ButtonHeight    =   926
      AllowCustomize  =   0   'False
      Appearance      =   1
      ImageList       =   "ImageList"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   10
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "打印"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "预览"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   4
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "增加"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "修改"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "删除"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   4
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "过滤"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   4
         EndProperty
         BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "退出"
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
End
Attribute VB_Name = "InputView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private m_EditWin As Form
Private m_CommandText As String

Private m_TableData As ADODB.Recordset
Event EndWindow()
Private Sub Form_Load()
RefreshReCode
DrawTable
ShowData
End Sub

Private Sub Form_Resize()
Grid.Top = Toolbar.Height + 10
Grid.Height = Me.Height - Toolbar.Top - 1050
Grid.Width = Me.Width - 120
Grid.Left = 5
End Sub
Public Sub ShowViwe(ByRef pEditWin As Form, ByRef pCommand As String)
Set m_EditWin = pEditWin
m_CommandText = pCommand

Me.Show
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not m_EditWin Is Nothing Then
   Set m_EditWin = Nothing
End If
RaiseEvent EndWindow
End Sub

Private Sub Toolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
       Case 1
            
       Case 2
       ' PrintViwe
       Case 4 'Add
            m_EditWin.DoModal PM_ADD
            RefreshReCode
            ShowData
       Case 5 'Edit
            If Grid.RowSel > 0 Then
              If m_EditWin.DoModal(PM_EDIT, Grid.TextMatrix(Grid.RowSel, 0)) = RC_OK Then
                 RefreshReCode
                 ShowData
              End If
            End If
       Case 6 'Delete
            Delete
      ' Case 8 'Find
       Case 10 'Exit
            Unload Me
End Select
End Sub
Private Sub DrawTable()
Dim i As Integer
Grid.Cols = m_TableData.Fields.COUNT
Grid.Rows = 1
Grid.Row = 0
Grid.RowHeight(0) = 400
For i = 0 To m_TableData.Fields.COUNT - 1
    Grid.ColAlignment(i) = 5
    Grid.Col = i
    Grid.Text = m_TableData.Fields(i).Name
Next i
End Sub
Private Sub ShowData()
Dim X As Long, Y As Long
Dim DataText As String

If Not (m_TableData.BOF And m_TableData.EOF) Then
   m_TableData.MoveFirst
End If
Y = 1
While Not m_TableData.EOF
     Grid.Rows = Y + 1
'    Grid.Row = y
     For X = 0 To m_TableData.Fields.COUNT - 1
         If IsNumeric(m_TableData.Fields(X).Value) Then
            DataText = CStr(m_TableData.Fields(X).Value)
         Else
         DataText = m_TableData.Fields(X).Value
         End If
'         Grid.Col = x
'         Grid.CellAlignment = vbAlignLeft Or vbAlignBottom
         Grid.TextMatrix(Y, X) = DataText
         If Grid.ColWidth(X) < TextWidth(DataText) Then Grid.ColWidth(X) = TextWidth(DataText) + 1000
  '   MsgBox TextWidth(DataText)
     Next X
     m_TableData.MoveNext
     Y = Y + 1
Wend
End Sub
Private Sub RefreshReCode()
If g_Conn Is Nothing Then
Set g_Conn = New ADODB.Connection
With g_Conn
    .Provider = g_Provider
    .CommandTimeout = 7
    .ConnectionTimeout = 10
    .Open g_DataSource
End With
End If
If g_Conn.State = adStateClosed Then
   g_Conn.Open g_DataSource
End If
Set m_TableData = g_Conn.Execute(m_CommandText)
End Sub
Private Function Delete() As Boolean
Dim comm As ADODB.Command
Set comm = New ADODB.Command
If g_Conn Is Nothing Then
Set g_Conn = New ADODB.Connection
With g_Conn
    .Provider = g_Provider
    .CommandTimeout = 7
    .ConnectionTimeout = 10
    .Open g_DataSource
End With
End If
If g_Conn.State = adStateClosed Then
   g_Conn.Open g_DataSource
End If
Set comm.ActiveConnection = g_Conn
comm.CommandType = adCmdText
comm.CommandText = "DELETE " & m_EditWin.TableName & " WHERE AutoId="
Select Case m_EditWin.TableName
       Case "Inventory"
           Dim t_inv As New TInventor
           If Not t_inv.Find(Trim$(Grid.TextMatrix(Grid.RowSel, 0)), Find_From_Code) Then
              Delete = False
              Exit Function
           End If
           If Not SQLFindIsNull(CStr(t_inv.Id), "WorkSub_2", "InvId", FT_NUMBER) Then
              MsgBox "该存货以使用,故不能删除", vbCritical Or vbOKOnly, "错误"
              Exit Function
           End If
           comm.CommandText = comm.CommandText & CStr(t_inv.Id)
           comm.Execute , , adExecuteNoRecords
           Set t_inv = Nothing
       Case "RepairItem"
           Dim t_rep As New TRepair
           If Not t_rep.Find(Trim$(Grid.TextMatrix(Grid.RowSel, 0))) Then
              Delete = False
              Exit Function
           End If
           If Not SQLFindIsNull(CStr(t_rep.Id), "WorkSub_1", "RepairId", FT_NUMBER) Then
              MsgBox "该维修项目以使用,故不能删除", vbCritical Or vbOKOnly, "错误"
              Exit Function
           End If
           comm.CommandText = comm.CommandText & CStr(t_rep.Id)
           comm.Execute , , adExecuteNoRecords
           Set t_rep = Nothing
End Select
Set comm = Nothing
End Function

⌨️ 快捷键说明

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