📄 pgdanweimingcheng.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form pgdanweimingcheng
Caption = "建单位名称窗口"
ClientHeight = 4950
ClientLeft = 60
ClientTop = 345
ClientWidth = 6945
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4950
ScaleWidth = 6945
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox Combo1
Height = 300
Left = 5130
TabIndex = 5
Top = 690
Width = 1365
End
Begin VB.Frame Frame2
Height = 4815
Left = 4050
TabIndex = 1
Top = 30
Width = 2775
Begin VB.TextBox Text1
Appearance = 0 'Flat
Height = 375
Left = 1140
TabIndex = 8
Top = 2190
Width = 1335
End
Begin VB.Frame Frame3
Height = 1575
Left = 0
TabIndex = 3
Top = 3240
Width = 2775
Begin VB.CommandButton Command5
Caption = "删 除"
Height = 375
Left = 1470
TabIndex = 14
Top = 600
Width = 1035
End
Begin VB.CommandButton Command4
Caption = "退 出"
Height = 375
Left = 840
TabIndex = 13
Top = 1050
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "修 改"
Height = 375
Left = 270
TabIndex = 12
Top = 600
Width = 975
End
Begin VB.CommandButton Command2
Caption = "存 盘"
Height = 375
Left = 1470
TabIndex = 11
Top = 210
Width = 1035
End
Begin VB.CommandButton Command1
Caption = "增 加"
Height = 375
Left = 270
TabIndex = 10
Top = 210
Width = 975
End
End
Begin VB.Label Label4
Height = 255
Left = 810
TabIndex = 9
Top = 1380
Width = 735
End
Begin VB.Label Label3
Caption = "单位名称:"
Height = 255
Left = 240
TabIndex = 7
Top = 2280
Width = 975
End
Begin VB.Label Label2
Caption = "序号:"
Height = 255
Left = 240
TabIndex = 6
Top = 1440
Width = 855
End
Begin VB.Label Label1
Caption = "地区:"
Height = 375
Left = 240
TabIndex = 4
Top = 720
Width = 855
End
End
Begin VB.Frame Frame1
Height = 4815
Left = 120
TabIndex = 0
Top = 30
Width = 3855
Begin MSFlexGridLib.MSFlexGrid MSF
Height = 4455
Left = 120
TabIndex = 2
Top = 240
Width = 3375
_ExtentX = 5953
_ExtentY = 7858
_Version = 393216
AllowUserResizing= 3
End
End
End
Attribute VB_Name = "pgdanweimingcheng"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim en As rdoEnvironment
Dim cn As rdoConnection
Dim result As rdoResultset
Dim SQL As String
Dim i As Integer
Private Sub Combo1_Click()
SQL = "select max(序号) from pgdanweimingcheng where 地区='" & Trim(Combo1.Text) & "' "
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
If IsNull(result.RowCount) = True Then
Label4.Caption = 1
Else
Label4.Caption = Val(Trim(result(0))) + 1
End If
result.Close
End Sub
Private Sub Combo1_GotFocus()
Combo1.Clear
SQL = "select distinct 地区 from pgdanweimingcheng "
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
If result.RowCount <> 0 Then
result.MoveFirst
Do While Not result.EOF
Combo1.AddItem Trim(result("地区"))
result.MoveNext
Loop
End If
result.Close
End Sub
Private Sub Command1_Click()
Combo1.Text = ""
Text1.Text = ""
End Sub
Private Sub Command2_Click()
If Combo1.Text = "" Or Text1.Text = "" Then
Exit Sub
End If
If MsgBox("确认是否存盘", vbYesNo, "提示") = vbYes Then
SQL = "select * from pgdanweimingcheng where 地区='" & Trim(Combo1) & "' and 序号= '" & Trim(Label4.Caption) & "'"
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
If result.RowCount <> 0 Then
MsgBox "存盘失败"
result.Close
Exit Sub
End If
SQL = "insert into pgdanweimingcheng values('" & Trim(Combo1.Text) & "','" & Trim(Label4.Caption) & "','" & Trim(Text1.Text) & "')"
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
result.Close
SQL = "select * from pgdanweimingcheng "
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
MSF.Rows = 2
If result.RowCount <> 0 Then
result.MoveFirst
i = 1
Do While Not result.EOF
MSF.TextArray(i * MSF.Cols) = Trim(result("地区"))
MSF.TextArray(i * MSF.Cols + 1) = Trim(result("序号"))
MSF.TextArray(i * MSF.Cols + 2) = Trim(result("单位名称"))
MSF.RowHeight(i) = 300
MSF.Rows = MSF.Rows + 1
i = i + 1
result.MoveNext
Loop
Label4.Caption = i
MSF.Rows = MSF.Rows - 1
Else
Label4.Caption = 1
End If
result.Close
MsgBox "存盘结束"
End If
End Sub
Private Sub Command3_Click()
If Combo1.Text = "" Or Text1.Text = "" Then
Exit Sub
End If
If MsgBox("确认是否修改", vbYesNo, "提示") = vbYes Then
SQL = "update pgdanweimingcheng set 单位名称='" & Trim(Text1.Text) & "' where 地区='" & Trim(Combo1) & "' and 序号= '" & Trim(Label4.Caption) & "'"
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
result.Close
SQL = "select * from pgdanweimingcheng "
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
MSF.Rows = 2
If result.RowCount <> 0 Then
result.MoveFirst
i = 1
Do While Not result.EOF
MSF.TextArray(i * MSF.Cols) = Trim(result("地区"))
MSF.TextArray(i * MSF.Cols + 1) = Trim(result("序号"))
MSF.TextArray(i * MSF.Cols + 2) = Trim(result("单位名称"))
MSF.RowHeight(i) = 300
MSF.Rows = MSF.Rows + 1
i = i + 1
result.MoveNext
Loop
Label4.Caption = i
MSF.Rows = MSF.Rows - 1
Else
Label4.Caption = 1
End If
result.Close
MsgBox "修改结束"
End If
End Sub
Private Sub Command4_Click()
cn.Close
en.Close
Unload Me
End Sub
Private Sub Command5_Click()
If MsgBox("确认是否删除", vbYesNo, "提示") = vbYes Then
SQL = "delete from pgdanweimingcheng where 序号='" & Trim(Label4.Caption) & "'"
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
SQL = "select * from pgdanweimingcheng "
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
MSF.Rows = 2
If result.RowCount <> 0 Then
result.MoveFirst
i = 1
Do While Not result.EOF
MSF.TextArray(i * MSF.Cols) = Trim(result("地区"))
MSF.TextArray(i * MSF.Cols + 1) = Trim(result("序号"))
MSF.TextArray(i * MSF.Cols + 2) = Trim(result("单位名称"))
MSF.RowHeight(i) = 300
MSF.Rows = MSF.Rows + 1
i = i + 1
result.MoveNext
Loop
Label4.Caption = i
MSF.Rows = MSF.Rows - 1
Else
Label4.Caption = 1
End If
result.Close
End If
End Sub
Private Sub Form_Load()
Move Screen.Width / 2 - pgdanweimingcheng.Width / 2, Screen.Height / 2 - pgdanweimingcheng.Height / 2 - 500
Set en = rdoEnvironments(0)
Set cn = en.OpenConnection(dsname:="odbc_api_demo", Prompt:="rdodriverprompt", ReadOnly:=False, Connect:="uid=sa;pwd=;driver={SQL SERVER};SERVER=ntserver;database=rongpin2004;")
MSF.FormatString = "地区|^ 序号 |^ 单位名称 "
For i = 0 To MSF.Rows - 1
MSF.RowHeight(i) = 300
Next i
SQL = "select * from pgdanweimingcheng order by 序号"
Set result = cn.OpenResultset(SQL, rdOpenDynamic, rdConcurRowVer)
If result.RowCount <> 0 Then
result.MoveFirst
i = 1
Do While Not result.EOF
MSF.TextArray(i * MSF.Cols) = Trim(result("地区"))
MSF.TextArray(i * MSF.Cols + 1) = Trim(result("序号"))
MSF.TextArray(i * MSF.Cols + 2) = Trim(result("单位名称"))
MSF.RowHeight(i) = 300
MSF.Rows = MSF.Rows + 1
i = i + 1
result.MoveNext
Loop
Label4.Caption = i
MSF.Rows = MSF.Rows - 1
Else
Label4.Caption = 1
End If
result.Close
End Sub
Private Sub MSF_DblClick()
Combo1.Text = Trim(MSF.TextArray(MSF.Row * MSF.Cols))
Label4.Caption = Trim(MSF.TextArray(MSF.Row * MSF.Cols + 1))
Text1.Text = Trim(MSF.TextArray(MSF.Row * MSF.Cols + 2))
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -