📄 frmclientupdate.frm
字号:
VERSION 5.00
Begin VB.Form frmClientUpdate
BorderStyle = 1 'Fixed Single
Caption = "新增客户"
ClientHeight = 4515
ClientLeft = 45
ClientTop = 435
ClientWidth = 7860
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 4515
ScaleWidth = 7860
Begin VB.CommandButton Command2
Caption = "取 消"
Height = 400
Left = 4320
TabIndex = 19
Top = 3840
Width = 1000
End
Begin VB.CommandButton Command1
Caption = "修 改"
Height = 400
Left = 2400
TabIndex = 18
Top = 3840
Width = 1000
End
Begin VB.ComboBox cmbSex
Height = 300
Left = 5160
TabIndex = 17
Top = 810
Width = 2100
End
Begin VB.TextBox txtName
Height = 270
Left = 1440
TabIndex = 16
Top = 825
Width = 2100
End
Begin VB.TextBox txtID
Height = 270
Left = 840
TabIndex = 13
Top = 240
Visible = 0 'False
Width = 1665
End
Begin VB.TextBox txtRemark
Height = 270
Left = 1440
TabIndex = 12
Top = 3240
Width = 5870
End
Begin VB.TextBox txtAddress
Height = 270
Left = 1440
TabIndex = 11
Top = 2640
Width = 5870
End
Begin VB.TextBox txtFax
Height = 270
Left = 5160
TabIndex = 10
Top = 2040
Width = 2100
End
Begin VB.TextBox txtMobile
Height = 270
Left = 1440
TabIndex = 9
Top = 2040
Width = 2100
End
Begin VB.TextBox txtTelePhone
Height = 270
Left = 5160
TabIndex = 8
Top = 1440
Width = 2100
End
Begin VB.TextBox txtCompany
Height = 270
Left = 1440
TabIndex = 7
Top = 1440
Width = 2100
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓 名:"
Height = 180
Left = 360
TabIndex = 15
Top = 870
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "性 别:"
Height = 180
Left = 3960
TabIndex = 14
Top = 870
Width = 900
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "备 注:"
Height = 180
Left = 360
TabIndex = 6
Top = 3285
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "联系地址:"
Height = 180
Left = 360
TabIndex = 5
Top = 2685
Width = 900
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "传 真:"
Height = 180
Left = 3960
TabIndex = 4
Top = 2085
Width = 900
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "手 机:"
Height = 180
Left = 360
TabIndex = 3
Top = 2085
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "联系电话:"
Height = 180
Left = 3960
TabIndex = 2
Top = 1485
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "工作单位:"
Height = 180
Left = 360
TabIndex = 1
Top = 1485
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "修 改 客 户"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 2760
TabIndex = 0
Top = 240
Width = 2400
End
End
Attribute VB_Name = "frmClientUpdate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public myupdateid As Integer
Private Sub Command1_Click()
If CheckForm() = True Then
'删除原有数据
strsql = "DELETE FROM CLIENT WHERE ID=" & myupdateid
sys.DB.ExecuteSQL (strsql)
'插入数据
Dim DB As New clsDataBase
strsql = "INSERT INTO CLIENT (ID,NAME,SEX,COMPANY,TELEPHONE,MOBILE,FAX,ADDRESS,REMARK)" & _
" VALUES (" & sys.NumToInsert(txtID.Text) & "," & sys.StrToInsert(txtName.Text) & "," & _
"" & sys.NumToInsert(cmbSex.ItemData(cmbSex.ListIndex)) & "," & sys.StrToInsert(txtCompany.Text) & "," & sys.StrToInsert(txtTelePhone.Text) & "," & _
"" & sys.StrToInsert(txtMobile.Text) & "," & sys.StrToInsert(txtFax.Text) & "," & sys.StrToInsert(txtAddress.Text) & "," & sys.StrToInsert(txtRemark.Text) & ")"
sys.DB.ExecuteSQL (strsql)
MsgBox "操作成功!"
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = 0
Me.Left = 0
Me.Width = MainForm.Width * 0.54
Me.Height = MainForm.Height * 0.54
Dim inum As Integer
Dim strsql As String
Dim DB As New clsDataBase
Dim rs As New ADODB.Recordset
'初始化性别
cmbSex.AddItem (" 男")
cmbSex.ItemData(0) = 0
cmbSex.AddItem (" 女")
cmbSex.ItemData(1) = 1
cmbSex.ListIndex = 0
strsql = "SELECT * FROM CLIENT WHERE ID=" & myupdateid
Set rs = sys.DB.OpenRecordSet(strsql)
If Not rs.EOF Then
txtName.Text = sys.StrToText(rs("NAME"))
If Not IsNull(rs("SEX")) Then
cmbSex.ListIndex = rs("SEX")
End If
txtCompany.Text = sys.StrToText(rs("Company"))
txtTelePhone.Text = sys.StrToText(rs("TelePhone"))
txtMobile.Text = sys.StrToText(rs("Mobile"))
txtFax.Text = sys.StrToText(rs("Fax"))
txtAddress.Text = sys.StrToText(rs("Address"))
txtRemark.Text = sys.StrToText(rs("Remark"))
Else
MsgBox "数据错误!"
Unload Me
End If
txtID.Text = myupdateid
End Sub
'检查表单数据
Private Function CheckForm() As Boolean
CheckForm = False
If txtName.Text = "" Then
MsgBox "姓名不能为空!"
txtCarNum.SetFocus
Else
CheckForm = True
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -