📄 frmygbj.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmYGBJ
Caption = "员工编辑"
ClientHeight = 7248
ClientLeft = 48
ClientTop = 336
ClientWidth = 9228
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 7248
ScaleWidth = 9228
WindowState = 2 'Maximized
Begin VB.Frame Frame1
Height = 2325
Left = 1560
TabIndex = 1
Top = 120
Width = 6135
Begin VB.ComboBox Combo1
Height = 300
Left = 3960
TabIndex = 19
Top = 180
Width = 1935
End
Begin VB.TextBox Text1
Height = 300
Left = 960
TabIndex = 11
Top = 180
Width = 2205
End
Begin VB.TextBox Text5
Height = 300
Left = 960
TabIndex = 10
Top = 1260
Width = 4980
End
Begin VB.TextBox Text3
Height = 300
Left = 960
TabIndex = 9
Top = 900
Width = 2205
End
Begin VB.TextBox Text4
Height = 300
Left = 3960
TabIndex = 8
Top = 900
Width = 1965
End
Begin VB.TextBox Text2
Height = 300
Left = 3960
TabIndex = 7
Top = 540
Width = 1965
End
Begin VB.Frame Frame3
Height = 570
Left = 240
TabIndex = 2
Top = 1680
Width = 5715
Begin VB.CommandButton Command2
Caption = "修改"
Height = 330
Left = 3000
TabIndex = 20
Top = 180
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 330
Left = 120
TabIndex = 5
Top = 180
Width = 1335
End
Begin VB.CommandButton Command3
Caption = "删除"
Height = 330
Left = 4320
TabIndex = 4
Top = 180
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "保存"
Height = 330
Left = 1560
TabIndex = 3
Top = 180
Width = 1335
End
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 300
Left = 960
TabIndex = 6
Top = 540
Width = 2205
_ExtentX = 3895
_ExtentY = 529
_Version = 393216
Format = 203489281
CurrentDate = 37394
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "姓名"
Height = 180
Left = 480
TabIndex = 18
Top = 240
Width = 360
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "现住址"
Height = 180
Left = 300
TabIndex = 17
Top = 1320
Width = 540
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "出生日期"
Height = 180
Left = 120
TabIndex = 16
Top = 600
Width = 720
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "电话"
Height = 180
Left = 480
TabIndex = 15
Top = 960
Width = 360
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "传呼"
Height = 180
Left = 3480
TabIndex = 14
Top = 960
Width = 360
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "手机"
Height = 180
Left = 3480
TabIndex = 13
Top = 600
Width = 360
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "性别"
Height = 180
Left = 3480
TabIndex = 12
Top = 240
Width = 360
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Align = 2 'Align Bottom
Height = 4368
Left = 0
TabIndex = 0
Top = 2544
Width = 9228
_ExtentX = 16277
_ExtentY = 7705
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 2
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Caption = "员工信息一览表"
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
MarqueeStyle = 3
AllowFocus = 0 'False
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSAdodcLib.Adodc Adodc1
Align = 2 'Align Bottom
Height = 336
Left = 0
Top = 6912
Visible = 0 'False
Width = 9228
_ExtentX = 16277
_ExtentY = 593
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "frmYGBJ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim editing As Boolean
Private Sub Command1_Click()
If editing = False Then
editing = True
Text1.Text = ""
Text2.Text = ""
Combo1.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
DTPicker1.Value = Date
Command1.Caption = "放弃"
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
Else
If MsgBox("确定取消添加新记录?", vbQuestion + vbYesNo, "取消?") = vbYes Then
editing = False
Call DataGrid1_Click
End If
End If
End Sub
Private Sub Command2_Click()
If editing = False Then
editing = True
Command2.Caption = "放弃"
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
Command4.Enabled = True
Else
If MsgBox("确定取消修改当前记录?", vbQuestion + vbYesNo, "取消?") = vbYes Then
editing = False
Adodc1.Recordset.CancelBatch adAffectAllChapters
Call DataGrid1_Click
End If
End If
End Sub
Private Sub Command3_Click()
If MsgBox("确定删除当前记录?", vbQuestion + vbYesNo, "删除?") = vbYes Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.MoveLast
End If
End If
Call DataGrid1_Click
End If
End Sub
Private Sub Command4_Click()
If Text1.Text = "" Then
MsgBox "请输入员工姓名!"
Text1.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "请选择员工性别!"
Combo1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "请输入员工手机!"
Text2.SetFocus
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请输入员工电话!"
Text3.SetFocus
Exit Sub
End If
If Text4.Text = "" Then
MsgBox "请输入员工传呼!"
Text4.SetFocus
Exit Sub
End If
If Text5.Text = "" Then
MsgBox "请输入员工住址!"
Text5.SetFocus
Exit Sub
End If
If Command1.Enabled = True Then
If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "姓名 = '" & Text1.Text & "'"
If Not Adodc1.Recordset.EOF Then
MsgBox "该员工的记录已经存在!将取消添加。"
editing = False
Call DataGrid1_Click
Exit Sub
End If
End If
Adodc1.Recordset.AddNew
Adodc1.Recordset(1) = Text1.Text
Adodc1.Recordset(2) = Combo1.Text
Adodc1.Recordset(3) = DTPicker1.Value
Adodc1.Recordset(4) = Text2.Text
Adodc1.Recordset(5) = Text3.Text
Adodc1.Recordset(6) = Text4.Text
Adodc1.Recordset(7) = Text5.Text
Adodc1.Recordset.UpdateBatch adAffectAllChapters
Else
Adodc1.Recordset(1) = Text1.Text
Adodc1.Recordset(2) = Combo1.Text
Adodc1.Recordset(3) = DTPicker1.Value
Adodc1.Recordset(4) = Text2.Text
Adodc1.Recordset(5) = Text3.Text
Adodc1.Recordset(6) = Text4.Text
Adodc1.Recordset(7) = Text5.Text
Adodc1.Recordset.UpdateBatch adAffectAllChapters
End If
editing = False
Call DataGrid1_Click
End Sub
Private Sub DataGrid1_Click()
If editing = False Then
Command1.Caption = "添加"
Command1.Enabled = True
If Adodc1.Recordset.RecordCount <> 0 Then
Command2.Caption = "修改"
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Text1.Text = Adodc1.Recordset(1)
Combo1.Text = Adodc1.Recordset(2)
DTPicker1.Value = Adodc1.Recordset(3)
Text2.Text = Adodc1.Recordset(4)
Text3.Text = Adodc1.Recordset(5)
Text4.Text = Adodc1.Recordset(6)
Text5.Text = Adodc1.Recordset(7)
Else
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
End If
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = constr
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = "业务员表"
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
DataGrid1.ReBind
Combo1.AddItem "男"
Combo1.AddItem "女"
editing = False
Call DataGrid1_Click
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
Exit Sub
End If
With Frame1
.Left = (Me.Width - Frame1.Width) / 2
.Top = 120
End With
DataGrid1.Height = Me.Height - Frame1.Height - Adodc1.Height - 200
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -