【VB开源代码栏目提醒】:网学会员为需要VB开源代码的朋友们搜集整理了frmcType1.frm相关资料,希望对各位网友有所帮助!
VERSION 5.00
Begin VB.Form frmcType1
BorderStyle = 3 'Fixed Dialog
Caption = "客户类型信息"
ClientHeight = 3108
ClientLeft = 48
ClientTop = 336
ClientWidth = 6048
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3108
ScaleWidth = 6048
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.TextBox txtNo
Height = 270
Left = 480
TabIndex = 9
TabStop = 0 'False
Top = 2640
Visible = 0 'False
Width = 735
End
Begin VB.Frame Frame1
Caption = "客户类型信息:"
Height = 2292
Left = 120
TabIndex = 5
Top = 120
Width = 5772
Begin VB.TextBox txtItem
Height = 1320
Index = 2
Left = 1200
MaxLength = 80
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 720
Width = 4212
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1200
MaxLength = 20
TabIndex = 0
Top = 360
Width = 1212
End
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 4200
MaxLength = 20
TabIndex = 1
Top = 360
Width = 1212
End
Begin VB.Label Label2
Caption = "备注信息:"
Height = 252
Index = 10
Left = 360
TabIndex = 8
Top = 720
Width = 1212
End
Begin
VB.Label Label2
Caption = "客户类型:"
Height = 252
Index = 0
Left = 360
TabIndex = 7
Top = 360
Width = 852
End
Begin VB.Label Label2
Caption = "折扣比例:"
Height = 252
Index = 1
Left = 3000
TabIndex = 6
Top = 360
Width = 1212
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 3000
TabIndex = 4
Top = 2640
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 1560
TabIndex = 3
Top = 2640
Width = 1215
End
End
Attribute VB_Name = "frmcType1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改动过记录,ture为改过
Dim mblChange As Boolean
Dim mrc As ADODB.Recordset
Public txtSQL As String
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
For intCount = 0 To 1
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "客户类型"
Case 1
sMeg = "折扣比例"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Not IsNumeric(Trim(txtItem(1))) Then
sMeg = "折扣比例"
sMeg = sMeg & "请输入数字!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(1).SetFocus
Exit Sub
End If
'判断是否有相同内容的记录
txtSQL = "select * from customerType where ctypeNO<>'" & Trim(txtNo) & "' and ctypeName='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在相同客户类型的记录!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
Exit Sub
End If
'先删除已有记录
txtSQL = "delete from customerType where ctypeNO='" & Trim(txtNo) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "select * from customerType"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
mrc.Fields(0) = txtNo
For intCount = 0 To 2
mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
Next intCount
mrc.Update
mrc.Close
If gintTmode = 1 Then
MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
For intCount = 0 To 2
txtItem(intCount) = ""
Next intCount
mblChange = False
Unload frmcType
frmcType.txtSQL = "select * from customerType"
frmcType.Show
ElseIf gintTmode = 2 Then
Unload Me
Unload frmcType
frmcType.txtSQL = "select * from customerType"
frmcType.Show
End If
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim MsgText As String
Dim i As Integer
If gintTmode = 1 Then
Me.Caption = Me.Caption & "添加"
txtNo = GetRkno()
ElseIf gintTmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
txtNo = .Fields(0)
For intCount = 0 To 2
txtItem(intCount) = .Fields(intCount + 1)
Next intCount
End With
End If
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintTmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
'有变化设置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub