📄 照片.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form zhaopian
BackColor = &H00C0C0C0&
BorderStyle = 0 'None
Caption = "照片"
ClientHeight = 3255
ClientLeft = 0
ClientTop = 0
ClientWidth = 2070
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3255
ScaleWidth = 2070
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox imgPhoto
BackColor = &H00FFFFFF&
BorderStyle = 0 'None
Height = 2175
Left = 120
ScaleHeight = 2175
ScaleWidth = 1815
TabIndex = 3
Top = 480
Width = 1815
End
Begin MSComDlg.CommonDialog DLG
Left = 960
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdPhoto
Caption = "保存修改"
Height = 375
Left = 480
TabIndex = 0
Top = 2760
Width = 1095
End
Begin VB.Label lblClose
BackColor = &H8000000B&
Caption = "×"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Left = 1820
TabIndex = 2
Top = 15
Width = 225
End
Begin VB.Label lblTitle
Alignment = 2 'Center
BackStyle = 0 'Transparent
Height = 255
Left = 240
TabIndex = 1
Top = 240
Width = 1695
End
End
Attribute VB_Name = "zhaopian"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdPhoto_Click()
Dim Bit() As Byte
If cmdPhoto.Caption = "保存" Then
Open Dlg.FileName For Binary As #1
ReDim Bit(LOF(1)) As Byte
Get 1, 1, Bit
Close 1
sql = "Select * from [员工档案] where [id]=" & ID
rs.Open sql, conn, 1, 3
'rs.AddNew
rs.Fields("照片").AppendChunk Bit
rs.Update
rs.Close
Set rs = Nothing
MsgBox "保存成功!"
Unload Me
Else
Dlg.DialogTitle = "选择员工照片"
Dlg.Filter = "BMP位图(*.bmp)|*.bmp|JPG图像(*.jpg)|*.jpg|GIF图像(*.gif)|*.gif|所有文件(*.*)|*.*"
Dlg.ShowOpen
If Trim(Dlg.FileName) <> "" Then
imgPhoto.Picture = LoadPicture(Dlg.FileName)
cmdPhoto.Caption = "保存"
End If
End If
End Sub
Private Sub Form_Load()
Dim FileNum As Integer
Dim FileName As String
temporaryFileName
FileNum = FreeFile
Open FileName For Binary As #FileNum
lblTitle = "员工:" & yuangong.txtInfo(1).Text
Me.Left = Screen.Width / 2 + 3500
Me.Top = Screen.Height / 2 - Me.Height / 2
sql = "Select * from [员工档案] where [id]=" & ID
rs.Open sql, conn, 1, 1
If Len(rs.Fields("照片")) > 0 Then
cmdPhoto.Caption = "修改照片"
imgPhoto.DataField = rs.Fields("照片").GetChunk()
Else
cmdPhoto.Caption = "添加照片"
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub lblClose_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -