【VB开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VB开源代码-frmxltype.frm的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmxltype
BorderStyle = 1 'Fixed Single
Caption = "线路类型"
ClientHeight = 5160
ClientLeft = 45
ClientTop = 330
ClientWidth = 7215
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5160
ScaleWidth = 7215
Begin VB.Frame Frame1
Height = 1575
Left = 0
TabIndex = 0
Top = 3480
Width = 7095
Begin VB.TextBox Text2
Appearance = 0 'Flat
Height = 375
Left = 3360
TabIndex = 5
Top = 240
Width = 3495
End
Begin VB.CommandButton Command3
Caption = "退出"
Height = 375
Left = 5760
TabIndex = 4
Top = 1080
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除"
Height = 375
Left = 4320
TabIndex = 3
Top = 1080
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 3120
TabIndex = 2
Top = 1080
Width = 975
End
Begin
VB.TextBox Text1
Appearance = 0 'Flat
Height = 375
Left = 840
TabIndex = 1
Top = 240
Width = 1335
End
Begin VB.Label Label2
Caption = "线路名称:"
Height = 255
Left = 2400
TabIndex = 7
Top = 360
Width = 975
End
Begin VB.Label Label1
Caption = "序号:"
Height = 255
Left = 240
TabIndex = 6
Top = 360
Width = 615
End
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid HFGrid
Height = 3315
Left = 0
TabIndex = 8
Top = 0
Width = 7095
_ExtentX = 12515
_ExtentY = 5847
_Version = 393216
FixedCols = 0
BackColorSel = 12640511
ForeColorSel = -2147483641
BackColorBkg = -2147483639
FocusRect = 0
ScrollBars = 2
SelectionMode = 1
AllowUserResizing= 1
Appearance = 0
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
Attribute VB_Name = "frmxltype"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "对不起,序号不能为空", vbInformation, App.Title
Text1.SetFocus
Exit Sub
End If
If Trim(Text2.Text) = "" Then
MsgBox "对不起,线路类型不能为空", vbInformation, App.Title
Text2.SetFocus
Exit Sub
End If
Dim rs As New ADODB.Recordset
rs.Open "select * from 编码线路类型 where index='" & Trim(Text1.Text) & "'", CN, 1, 3
If Not rs.EOF Then
MsgBox "此序号已经存在", vbInformation, App.Title
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
sql = "insert into 编码线路类型 values ('" & Trim(Text1.Text) & "','" & Trim(Text2.Text) & "')"
If exsql(sql) Then
Call datagrid
MsgBox "添加成功", vbInformation, App.Title
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End If
End Sub
Sub datagrid()
Dim sql As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Me.HFGrid.ColAlignment(0) = 0
Me.HFGrid.ColAlignment(1) = 0
HFGrid.ColWidth(0) = Me.HFGrid.Width / 2
HFGrid.ColWidth(1) = Me.HFGrid.Width / 2
rs.Open "select index as 序号,线路类型 from 编码线路类型", CN, 1, 3
Set HFGrid.DataSource = rs
End Sub
Private Sub Command2_Click()
Dim str As String
Dim str
sql As String
str = MsgBox("你真的要删除吗", vbInformation + vbYesNo, App.Title)
If str = vbYes Then
strsql = "delete from 编码线路类型 where index ='" & Me.HFGrid.TextMatrix(HFGrid.Row, 0) & "'"
If exsql(strsql) Then
MsgBox "删除成功", vbInformation, App.Title
Call datagrid
Exit Sub
End If
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Position Me
Call datagrid
End Sub