main_htgl_bminf.frm

来自「星级酒店客房管理系统一套很不错的系统」· FRM 代码 · 共 637 行 · 第 1/2 页

FRM
637
字号
   Begin MSDataGridLib.DataGrid DataGrid1 
      Bindings        =   "main_htgl_bminf.frx":2029
      Height          =   1980
      Left            =   75
      TabIndex        =   11
      Top             =   2760
      Width           =   9420
      _ExtentX        =   16616
      _ExtentY        =   3493
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   5
      BeginProperty Column00 
         DataField       =   "部门编号"
         Caption         =   "部门编号"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "部门名称"
         Caption         =   "部门名称"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "负责人"
         Caption         =   "负责人"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "部门电话"
         Caption         =   "部门电话"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column04 
         DataField       =   "部门职能"
         Caption         =   "部门职能"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   1080
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   1289.764
         EndProperty
         BeginProperty Column02 
            ColumnWidth     =   794.835
         EndProperty
         BeginProperty Column03 
            ColumnWidth     =   1470.047
         EndProperty
         BeginProperty Column04 
            ColumnWidth     =   3209.953
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "main_htgl_bminf"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义整数变量,表示字段编号和数组编号
Dim i As Integer
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Private Sub Form_Activate()
  '查询所有,并按"部门编号"排序
  Adodc1.RecordSource = "select * from 部门 order by 编码"
  Adodc1.Refresh
  If Not Adodc1.Recordset.BOF Then
   Adodc1.Recordset.MoveFirst
   For i = 0 To 4
       If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
       Text1(i).Enabled = False
   Next i
  End If
  ComSave.Enabled = False
  Me.Caption = Me.Caption & "    " & admin
End Sub

Private Sub Form_Load()
'窗口显示位置
Me.Left = MDIForm1.Picture1.Width
Me.Top = (MDIForm1.Height - Me.Height) / 2
End Sub

Private Sub Form_Unload(Cancel As Integer)
  MDIForm1.Enabled = True
End Sub

Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  Enter KeyCode    '回车获得焦点
End Sub
Private Sub ComFirst_Click()       '移到第一条记录
  If Not Adodc1.Recordset.BOF Then
     Adodc1.Recordset.MoveFirst
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
End Sub
Private Sub ComPrevious_Click()    '向上移一条记录
  If Adodc1.Recordset.RecordCount <> 0 Then
     If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
     If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
End Sub
Private Sub ComNext_Click()        '向下移一条记录
  If Adodc1.Recordset.RecordCount <> 0 Then
     If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
     If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
 End Sub
Private Sub ComLast_Click()       '移到最后一条记录
  If Not Adodc1.Recordset.EOF Then
     Adodc1.Recordset.MoveLast
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
End Sub
Private Sub ComAdd_Click()
  Dim dm As Integer
  Set rs1 = New ADODB.Recordset
   '打开"部门信息表"
  rs1.Open "select * from 部门 order by 编码", My_PROVIDER, adOpenKeyset, adLockOptimistic
   '创建部门编号
  If rs1.RecordCount > 0 Then
      If Not rs1.EOF Then rs1.MoveLast
      If rs1.Fields("编码") <> "" Then
         dm = Right(Trim(rs1.Fields("编码")), 2) + 1
         Text1(0).Text = "bm" & Format(dm, "00")
      End If
    Else
      Text1(0).Text = "bm01"
   End If
   rs1.Close
   For i = 1 To 4
       Text1(i).Enabled = True
       Text1(i).Text = ""
   Next i
   Text1(1).SetFocus
   ComAdd.Enabled = False
   ComDelete.Enabled = False
   ComModify.Enabled = False
   ComSave.Enabled = True
End Sub
Private Sub ComModify_Click()
   If Adodc1.Recordset.RecordCount <> 0 Then
     For i = 1 To 4
     Text1(i).Enabled = True
     Next i
     ComSave.Enabled = True
     ComEsc.Enabled = True
     ComFirst.Enabled = False
     ComPrevious.Enabled = False
     ComNext.Enabled = False
     ComLast.Enabled = False
     ComAdd.Enabled = False
     ComModify.Enabled = False
     ComDelete.Enabled = False
   Else
     MsgBox ("没有要修改的数据!")
  End If
End Sub
Private Sub ComDelete_Click()
'删除部门信息
  On Error Resume Next
  Adodc1.Recordset.Delete
  Adodc1.Refresh
  If Adodc1.Recordset.RecordCount <> 0 Then
     If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
     If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
End Sub
Private Sub ComSave_Click()
  Set rs1 = New ADODB.Recordset
  '打开连接
  rs1.Open "select * from 部门 where 编码='" & Trim(Text1(0).Text) & "'or 部门='" & Trim(Text1(1).Text) & "'order by 编码", My_PROVIDER, adOpenKeyset, adLockOptimistic
  If rs1.RecordCount > 0 Then
     Dim a As String
     a = MsgBox(Text1(1).Text & "  已存在,确定要修改吗?", vbYesNo)
     If a = vbYes Then
        For i = 0 To 4
            If Text1(1).Text <> "" Then rs1.Fields(i) = Trim(Text1(i).Text)
            Text1(i).Enabled = False
        Next i
        rs1.Update
        Adodc1.Refresh
     End If
   Else
     If Text1(1).Text <> "" Then
        '添加部门信息
        rs1.AddNew
        For i = 0 To 4
            rs1.Fields(i) = Trim(Text1(i).Text)
            Text1(i).Enabled = False
        Next i
         '更新数据库
         rs1.Update
         Adodc1.Refresh
      Else
         MsgBox "请填写完整的信息"
     End If
  End If
  '关闭数据集对象
  rs1.Close
  '设置控件不可用
  ComSave.Enabled = False
  ComEsc.Enabled = False
  ComFirst.Enabled = True
  ComPrevious.Enabled = True
  ComNext.Enabled = True
  ComLast.Enabled = True
  ComAdd.Enabled = True
  ComModify.Enabled = True
  ComDelete.Enabled = True
End Sub
Private Sub ComEsc_Click()
  If Not Adodc1.Recordset.BOF Then
     Adodc1.Recordset.MoveFirst
     For i = 0 To 4
         If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).Text = Adodc1.Recordset.Fields(i)
         Text1(i).Enabled = False
     Next i
  End If
  ComSave.Enabled = False
  ComEsc.Enabled = False
  ComFirst.Enabled = True
  ComPrevious.Enabled = True
  ComNext.Enabled = True
  ComLast.Enabled = True
  ComAdd.Enabled = True
  ComModify.Enabled = True
  ComDelete.Enabled = True
End Sub
Private Sub ComExit_Click()
  Unload Me
  MDIForm1.Enabled = True
End Sub

⌨️ 快捷键说明

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