📄 j_canpinlb.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form J_canpinlb
BackColor = &H80000013&
Caption = "产品类别设置"
ClientHeight = 5835
ClientLeft = 60
ClientTop = 465
ClientWidth = 7515
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 5835
ScaleWidth = 7515
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame3
BackColor = &H80000013&
Height = 3375
Left = 240
TabIndex = 12
Top = 2280
Width = 6975
Begin MSFlexGridLib.MSFlexGrid ssList
Height = 3015
Left = 120
TabIndex = 13
Top = 240
Width = 6735
_ExtentX = 11880
_ExtentY = 5318
_Version = 393216
End
End
Begin VB.Frame Frame2
BackColor = &H80000013&
Height = 735
Left = 240
TabIndex = 7
Top = 1440
Width = 6975
Begin VB.CommandButton Command6
Caption = "删除"
Height = 375
Left = 4560
TabIndex = 15
Top = 240
Width = 975
End
Begin VB.CommandButton Command5
Caption = "确定修改"
Height = 375
Left = 3480
TabIndex = 14
Top = 240
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "取消"
Height = 375
Left = 5520
TabIndex = 11
Top = 240
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "更新"
Height = 375
Left = 1320
TabIndex = 10
Top = 240
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "修改"
Height = 375
Left = 2400
TabIndex = 9
Top = 240
Width = 1095
End
Begin VB.CommandButton Command1
BackColor = &H80000013&
Caption = "添加"
Height = 375
Left = 240
TabIndex = 8
Top = 240
Width = 1095
End
End
Begin VB.Frame Frame1
BackColor = &H80000013&
Height = 1215
Left = 240
TabIndex = 0
Top = 120
Width = 6975
Begin VB.TextBox Text3
BackColor = &H80000013&
Height = 375
Left = 1680
TabIndex = 6
Top = 600
Width = 5055
End
Begin VB.TextBox Text2
BackColor = &H80000013&
Height = 375
Left = 4680
TabIndex = 4
Top = 120
Width = 2055
End
Begin VB.TextBox Text1
BackColor = &H80000013&
Height = 375
Left = 1680
TabIndex = 2
Top = 120
Width = 1575
End
Begin VB.Label Label3
BackColor = &H80000013&
Caption = "备注信息:"
Height = 375
Left = 600
TabIndex = 5
Top = 720
Width = 1095
End
Begin VB.Label Label2
BackColor = &H80000013&
Caption = "产品类别名称:"
Height = 375
Left = 3480
TabIndex = 3
Top = 240
Width = 1335
End
Begin VB.Label Label1
BackColor = &H80000013&
Caption = "产品类别编号:"
Height = 255
Left = 360
TabIndex = 1
Top = 240
Width = 1335
End
End
End
Attribute VB_Name = "J_canpinlb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public maa As ADODB.Recordset
Public txtSQL As String
Public intCount As Integer
Dim MsgText As String
Private Sub Command1_Click()
Frame1.Enabled = True
End Sub
Public Sub Command2_Click()
Dim str As String
str = MsgBox("真的要修改编号为" & Trim(ssList.TextMatrix(ssList.Row, 1)) & "的记录吗?", vbOKCancel + vbExclamation, "提示")
If str = vbOK Then
intCount = ssList.Row
txtSQL = "select * from g_cpleibie where lbcode='" & Trim(ssList.TextMatrix(intCount, 1)) & "' "
Set maa = ExecuteSQL(txtSQL, MsgText)
Text1.Text = ssList.TextMatrix(intCount, 1)
Text2.Text = ssList.TextMatrix(intCount, 2)
Text3.Text = ssList.TextMatrix(intCount, 3)
Frame1.Enabled = True
Text1.Enabled = False
Command5.Enabled = True
End If
End Sub
Private Sub Command3_Click()
Dim mrc As ADODB.Recordset
Dim txtSQL As String
Dim MsgText As String
If Frame1.Enabled = False Then
MsgBox "请单击添加按钮", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
If Trim(Text1.Text) = "" Then
MsgBox "产品类别编号不能为空", vbOKOnly + vbExclamation, "提示"
Text1.SetFocus
Exit Sub
Else
txtSQL = "select * from g_cpleibie"
Set mrc = ExecuteSQL(txtSQL, MsgText)
While (mrc.EOF = False)
If Trim(mrc.Fields(0)) = Trim(Text1.Text) Then
MsgBox "类别编号已经存在", vbOKOnly + vbExclamation, "提示"
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
mrc.MoveNext
End If
Wend
If Text2.Text = "" Then
MsgBox "产品类别名称不能为空", vbOKOnly + vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "产品备注信息不能为空", vbOKOnly + vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
mrc.AddNew
mrc.Fields(0) = Trim(Text1.Text)
mrc.Fields(1) = Trim(Text2.Text)
mrc.Fields(2) = Trim(Text3.Text)
mrc.Update
mrc.Close
MsgBox "更新用户成功", vbOKOnly + vbExclamation, ""
ssList.Refresh
ShowData
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Frame1.Enabled = False
End If
End Sub
Private Sub Command4_Click()
Frame1.Enabled = False
End Sub
Private Sub Command5_Click()
maa.Fields(1) = Text2.Text
maa.Fields(2) = Text3.Text
maa.Update
ssList.Refresh
maa.Close
MsgBox "修改成功", vbOKOnly
Command5.Enabled = False
Unload Me
End Sub
Private Sub Command6_Click()
Dim strr As String
If ssList.Row < 1 Then
MsgBox "数据库已经为空,不能删除", vbOKOnly + vbExclamation, "提示"
Exit Sub
End If
strr = MsgBox("真的要删除产品类别编号为" & Trim(ssList.TextMatrix(ssList.Row, 1)) & "记录吗?", vbOKCancel + vbExclamation, "警告")
If strr = vbOK Then
intCount = ssList.Row
txtSQL = "delete from g_cpleibie where lbcode='" & Trim(ssList.TextMatrix(intCount, 1)) & "'"
Set maa = ExecuteSQL(txtSQL, MsgText)
End If
ShowData
End Sub
Private Sub Form_Load()
ShowTile
ShowData
Frame1.Enabled = False
Command5.Enabled = False
End Sub
Private Sub ShowTile()
Dim i As Integer
With ssList
.Cols = 4
.TextMatrix(0, 1) = "产品类别编号"
.TextMatrix(0, 2) = "产品类别名称"
.TextMatrix(0, 3) = "备注信息"
.FixedRows = 1
For i = 0 To 3
.ColAlignment(i) = 0
Next i
'表头项居中
.FillStyle = flexFillRepeat
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.ColWidth(0) = 1000
.ColWidth(1) = 2000
.ColWidth(2) = 2000
.ColWidth(3) = 1000
.Row = 1
End With
End Sub
Public Sub ShowData()
Dim j As Integer
Dim i As Integer
Dim MsgText As String
txtSQL = "select * from g_cpleibie"
Set maa = ExecuteSQL(txtSQL, MsgText)
With ssList
.Rows = 1
Do While Not maa.EOF
.Rows = .Rows + 1
For i = 1 To maa.Fields.Count
Select Case maa.Fields(i - 1).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(maa.Fields(i - 1) & "", "yyyy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = maa.Fields(i - 1) & ""
End Select
Next i
maa.MoveNext
Loop
End With
maa.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -