📄 frmareacard.frm
字号:
VERSION 5.00
Object = "{F42BDC2B-FC9B-11D1-9ABD-444553540000}#3.4#0"; "ATLEDIT1.OCX"
Begin VB.Form frmAreaCard
BorderStyle = 1 'Fixed Single
Caption = "新增地区"
ClientHeight = 2100
ClientLeft = 45
ClientTop = 330
ClientWidth = 5400
HelpContextID = 10243
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2100
ScaleWidth = 5400
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin AtlEdit.TEdit txtInput
Height = 300
Index = 1
Left = 1380
TabIndex = 3
Top = 1320
Width = 2325
_ExtentX = 4101
_ExtentY = 529
maxchar = 30
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Text = ""
End
Begin AtlEdit.TEdit txtInput
Height = 300
Index = 0
Left = 1380
TabIndex = 1
Top = 435
Width = 2325
_ExtentX = 4101
_ExtentY = 529
maxchar = 16
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Text = ""
End
Begin VB.CommandButton cmdOK
Height = 350
Index = 3
Left = 4080
Style = 1 'Graphical
TabIndex = 7
Tag = "1013"
Top = 1320
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOK
Height = 350
Index = 2
Left = 4080
Style = 1 'Graphical
TabIndex = 6
Tag = "1009"
Top = 920
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOK
Height = 350
Index = 0
Left = 4080
Style = 1 'Graphical
TabIndex = 4
Tag = "1001"
Top = 120
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOK
Cancel = -1 'True
Height = 350
Index = 1
Left = 4080
Style = 1 'Graphical
TabIndex = 5
Tag = "1002"
Top = 520
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.Label lblTitle
Caption = "地区编码(&C)"
Height = 195
Index = 0
Left = 345
TabIndex = 0
Top = 510
Width = 1035
End
Begin VB.Label lblTitle
Caption = "地区名称(&N)"
Height = 195
Index = 1
Left = 345
TabIndex = 2
Top = 1380
Width = 1035
End
End
Attribute VB_Name = "frmAreaCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'功能: 完成地区的增、删、改。
'卡片接口: EditCard 参数: lngID 记录的ID号
'作用: LNGID为零是增加记录、其它为编辑记录
' DelCard 参数: lngID 记录的ID号
'作用: 删除ID号为LNGID的记录
'作者: 苏涛
Option Explicit
Option Compare Text
Private mblnIsInit As Boolean
Private mblnIsList As Boolean
Private mblnIsChanged As Boolean
Private mblnIsDetail As Boolean
Private mblnIsNew As Boolean
Private mblnPIsDetail As Boolean 'NEW--上级明细,EDIT--目的明细
Private mintLevel As Integer
Private mintOldLevel As Integer
Private mlngPCodeID As Long 'NEW--上级ID,EDIT--目的ID
Private mlngAreaID As Long '当前地区ID
Private mstrNotes As String
Private mstrLastCode As String
Private mstrCode As String
Private mstrName As String
Private mstrLastName As String
Private mstrFullName As String
Private mstrOldFullName As String
Private mstrStartDate As String
Public Function AddArea(ByVal strArea As String) As Integer
Dim strCode As String, strName As String
Dim strTemp As String
AddArea = 0
If Not GetString(strArea, strCode, 1) Then Exit Function
If Not GetString(strArea, strName, 2) Then Exit Function
If Not GetString(strArea, mstrNotes, 2) Then Exit Function
If strCode = "" Or strName = "" Then Exit Function
txtInput(0).Text = strCode
txtInput(1).Text = strName
mblnIsNew = True
If Not SaveCard(True) Then Exit Function
AddArea = 1
End Function
Public Property Get getID() As Variant
getID = mlngAreaID
End Property
Public Function AddCard(Optional strName As String = "", Optional intModal As Integer = 0, _
Optional ByVal IsList As Boolean = False) As Long
mlngAreaID = 0
mblnIsNew = True
InitCard strName
Caption = "新增地区"
mblnIsList = IsList
Show intModal
AddCard = mlngAreaID
End Function
Public Sub EditCard(ByVal lngID As Long, Optional intModal As Integer = 0, _
Optional strArea As String)
Dim strMess As String
If Not CheckIDUsed("Area", "lngAreaID", lngID) Then
If Trim(strArea) <> "" Then
strMess = "“" & strArea & "”"
Else
strMess = "该"
End If
ShowMsg 0, strMess & "地区不存在,不能进行修改!", _
vbExclamation + MB_TASKMODAL, "修改地区"
Unload Me
Else
mlngAreaID = lngID
mblnIsNew = False
InitCard
Caption = "修改地区"
cmdOK(2).Visible = False
cmdOK(3).Move cmdOK(2).Left, cmdOK(2).top
Show intModal
End If
End Sub
Private Function CodeIsUsed(ByVal lngID As Long) As Boolean
CodeIsUsed = True
If lngID <> 0 Then
If CheckIDUsed("Customer", "lngAreaID", lngID) Then Exit Function
If CheckIDUsed("Item", "lngAreaID", lngID) Then Exit Function
End If
CodeIsUsed = False
End Function
Private Sub cmdOK_Click(Index As Integer)
Dim strNextCode As String
If Index = 0 Then
If Not SaveCard Then Exit Sub
ElseIf Index = 2 Then
If SaveCard Then
strNextCode = GetNextCode(txtInput(0).Text)
' mlngAreaID = 0
InitCard
txtInput(0).Text = strNextCode
txtInput(0).SetFocus
txtInput(0).SelStart = 0
txtInput(0).SelLength = Len(txtInput(0).Text)
End If
Exit Sub
ElseIf Index = 3 Then
mstrNotes = frmNotePad.EditCard(Me.Caption, txtInput(0).Text, _
txtInput(1).Text, mstrNotes) '调记事
Exit Sub
End If
Unload Me
End Sub
Public Function DelCard(ByVal lngID As Long, Optional lnghWnd As Long = 0) As Boolean
Dim recDep As rdoResultset, strSQL As String
Dim strDep As String, strCode As String
On Error GoTo ErrHandle
gclsBase.BaseWorkSpace.BeginTrans
DelCard = False
If lngID = 0 Then Exit Function
strSQL = "SELECT * FROM Area WHERE lngAreaID=" & lngID
Set recDep = gclsBase.BaseDB.OpenResultset(strSQL, rdOpenStatic)
If Not recDep.EOF = True Then
strCode = recDep!strAreaCode
strDep = "“" & Trim(recDep!strAreaCode) & " " _
& Trim(recDep!strAreaName) & "”"
If recDep!blnIsDetail = 0 Then
ShowMsg lnghWnd, strDep & "有下级地区,不能删除!", vbExclamation + MB_TASKMODAL, "删除地区"
GoTo ErrHandle
End If
Else
DelCard = True
GoTo ErrHandle
End If
If CodeIsUsed(lngID) Then
ShowMsg lnghWnd, strDep & "地区已有业务发生,不能删除!", vbExclamation + MB_TASKMODAL, "删除地区"
GoTo ErrHandle
End If
If ShowMsg(lnghWnd, "你确实要删除" & strDep & "地区吗?", vbQuestion + vbYesNo + MB_TASKMODAL + vbDefaultButton2, _
"删除地区") = vbNo Then GoTo ErrHandle
strSQL = "DELETE FROM Area WHERE lngAreaID=" & lngID
If Not gclsBase.ExecSQL(strSQL) Then GoTo ErrHandle
If Not ChangeHigherCardDetail("Area", "strAreaCode", strCode) Then GoTo ErrHandle
gclsBase.BaseWorkSpace.CommitTrans
gclsSys.SendMessage CStr(Me.hwnd), Message.msgArea
Exit Function
ErrHandle:
gclsBase.BaseWorkSpace.RollBacktrans
End Function
Private Sub Form_Activate()
SetHelpID 10243
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If mblnIsList Then
mblnIsList = False
Exit Sub
End If
If KeyAscii = vbKeyReturn Then
BKKEY Me.ActiveControl.hwnd, vbKeyTab
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn And Shift = 2 Then
cmdOK(0).Value = True
End If
End Sub
Private Sub Form_Load()
Dim edtErrReturn As ErrDealType
On Error GoTo ErrHandle
' SetHelpID hwnd, 10243
Utility.LoadFormResPicture Me
' SendKeys "%{C}"
Exit Sub
ErrHandle:
edtErrReturn = Errors.ErrorsDeal
If edtErrReturn = edtResume Then
Resume
Else
On Error Resume Next
Unload Me
End If
End Sub
Private Sub Form_Paint()
FrameBox Me.hwnd, 150, 120, 3900, 1900
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim intMsgReturn As Integer, strMess As String
If UnloadMode <> vbFormControlMenu Then Exit Sub
If Trim(txtInput(0).Text & txtInput(1).Text) = "" Then Exit Sub
If mblnIsChanged Then
If mblnIsNew Then
strMess = "您要保存新增的地区"
If txtInput(0).Text <> "" Then
strMess = strMess & "“" & txtInput(0).Text & "”"
End If
If txtInput(1).Text <> "" Then
strMess = strMess & "“" & txtInput(1).Text & "”"
End If
strMess = strMess & "吗?"
Else
strMess = "“" & txtInput(0).Text & "”" & " " _
& "“" & txtInput(1).Text & "”地区已被修改,是否保存?"
End If
intMsgReturn = ShowMsg(hwnd, strMess, vbQuestion + vbYesNoCancel, Caption)
If intMsgReturn = vbYes Then
Cancel = Not SaveCard
ElseIf intMsgReturn = vbCancel Then
Cancel = True
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Utility.UnLoadFormResPicture Me
mblnIsChanged = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -