谁能帮我修改下这代码啊

d409142069 2009-04-23 10:42:29
主要是我想图片能对应员工信息,能浏览,修改,删除,更换图片 或者看附件的员工信息的窗口
Option Explicit
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim mysql As String
Dim a, i, msg, j, m As Integer
Private Sub cmdSelectPhoto_Click()
On Error GoTo errHandler:
dlgSelect.DialogTitle = "选择该员工的照片"
dlgSelect.Filter = "所有图形文件|*.bmp;*.dib;*.gif;*.jpg;*.ico|位图文件(*.bmp;*.dib)|*.bmp;*.dib|GIF文件(*.gif)|*.gif|JPEG文件(*.jpg)|*.jpg|图标文件(*.ico)|*.ico"
dlgSelect.ShowOpen
If dlgSelect.FileName = "" Then Exit Sub
imgPhoto.Picture = LoadPicture(dlgSelect.FileName)
mstrFileName = dlgSelect.FileName
Exit Sub
errHandler:
MsgBox Err.Description, vbCritical, "错误"
End Sub
Private Sub Command2_Click(Index As Integer)
Select Case Index
Case 0 '第一条记录
rst.MoveFirst
Command2(0).Enabled = False
Command2(1).Enabled = False
Command2(2).Enabled = True
Command2(3).Enabled = True
Case 1 '上一条记录
rst.MovePrevious '上一条
If rst.BOF Then
MsgBox "已经没有上一条记录了", 48, "警告"
rst.MoveFirst
Command2(0).Enabled = False
Command2(1).Enabled = False
Command2(2).Enabled = True
Command2(3).Enabled = True
End If
Command2(2).Enabled = True
Command2(3).Enabled = True
Case 2 '下一条记录
rst.MoveNext
If rst.EOF Then
MsgBox "已经没有最后一条记录了", 48, "警告"
Command2_Click (3)
rst.MoveLast
Command2(2).Enabled = False
Command2(3).Enabled = False
Command2(1).Enabled = True
Command2(0).Enabled = True
End If
Command2(1).Enabled = True
Command2(0).Enabled = True
Case 3 '末尾一条记录
rst.MoveLast
Command2(2).Enabled = False
Command2(3).Enabled = False
Command2(1).Enabled = True
Command2(0).Enabled = True
Case 4
For i = 0 To a - 1
Text1(i).Enabled = True
Next i
Case 5
Form9.Show 1
Case 6
Me.Hide '关闭
Case 7
msg = MsgBox("您确定删除该员工信息吗?", vbOKCancel, "警告")
If msg = 1 Then
rst.Delete
rst.MoveNext
End If
End Select
Text1(0).Text = IIf(IsNull(rst.Fields("姓名").Value), "", rst.Fields("姓名").Value) '填充记录
Text1(1).Text = IIf(IsNull(rst.Fields("政治面貌").Value), "", rst.Fields("政治面貌").Value) '填充记录
Text1(2).Text = IIf(IsNull(rst.Fields("职务").Value), "", rst.Fields("职务").Value) '填充记录
Text1(3).Text = IIf(IsNull(rst.Fields("科室").Value), "", rst.Fields("科室").Value) '填充记录
Text1(4).Text = IIf(IsNull(rst.Fields("生日").Value), "", rst.Fields("生日").Value) '填充记录
Text1(5).Text = IIf(IsNull(rst.Fields("军烈属").Value), "", rst.Fields("军烈属").Value) '填充记录
Text1(6).Text = IIf(IsNull(rst.Fields("出勤天数").Value), "", rst.Fields("出勤天数").Value) '填充记录
Text1(7).Text = IIf(IsNull(rst.Fields("缺勤天数").Value), "", rst.Fields("缺勤天数").Value) '填充记录
Text1(8).Text = IIf(IsNull(rst.Fields("基本工资").Value), "", rst.Fields("基本工资").Value) '填充记录
Text1(9).Text = IIf(IsNull(rst.Fields("奖金").Value), "", rst.Fields("奖金").Value) '填充记录
Text1(10).Text = IIf(IsNull(rst.Fields("津贴").Value), "", rst.Fields("津贴").Value) '填充记录
Text1(11).Text = IIf(IsNull(rst.Fields("洗理").Value), "", rst.Fields("洗理").Value) '填充记录
Text1(12).Text = IIf(IsNull(rst.Fields("书报").Value), "", rst.Fields("书报").Value) '填充记录
Text1(13).Text = IIf(IsNull(rst.Fields("交通").Value), "", rst.Fields("交通").Value) '填充记录
Text1(14).Text = IIf(IsNull(rst.Fields("工资扣").Value), "", rst.Fields("工资扣").Value) '填充记录
'imgPhoto.Picture = IIf(IsNull(rst.Fields("图片").Value), "", rst.Fields("图片").Value)
Text1(15).Text = Val(Text1(8).Text) + Val(Text1(9).Text) + Val(Text1(10).Text) + Val(Text1(11).Text) + Val(Text1(12).Text) + Val(Text1(13).Text)
Text1(16).Text = Text1(14).Text
Text1(17).Text = Val(Text1(15).Text) - Val(Text1(16).Text)
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
a = Text1.Count
con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=gzgl.mdb;persist security info=false"
con.CursorLocation = adUseClient
con.Open
rst.Open "select * from 员工信息,工资总 where 员工信息.ID=工资总.ID", con, adOpenKeyset, adLockOptimistic
If rst.BOF = True Or rst.EOF Then
MsgBox "数据库是空的!"
Else
Text1(0).Text = rst.Fields("姓名").Value
Text1(1).Text = rst.Fields("政治面貌").Value
Text1(2).Text = rst.Fields("职务").Value
Text1(3).Text = rst.Fields("科室").Value
Text1(4).Text = rst.Fields("生日").Value
Text1(5).Text = rst.Fields("军烈属").Value
Text1(6).Text = rst.Fields("出勤天数").Value
Text1(7).Text = rst.Fields("缺勤天数").Value
Text1(8).Text = rst.Fields("基本工资").Value
Text1(9).Text = rst.Fields("奖金").Value
Text1(10).Text = rst.Fields("津贴").Value
Text1(11).Text = rst.Fields("洗理").Value
Text1(12).Text = rst.Fields("书报").Value
Text1(13).Text = rst.Fields("交通").Value
Text1(14).Text = rst.Fields("工资扣").Value
'imgPhoto.Picture = rst.Fields("图片").Value
Text1(15).Text = Val(Text1(8).Text) + Val(Text1(9).Text) + Val(Text1(10).Text) + Val(Text1(11).Text) + Val(Text1(12).Text) + Val(Text1(13).Text)
Text1(16).Text = Text1(14).Text
Text1(17).Text = Val(Text1(15).Text) - Val(Text1(16).Text)

End If
For i = 0 To a - 1
Text1(i).Enabled = False
Next i
End Sub

Private Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
msg = MsgBox("您确定修改该员工的信息吗?", vbOKCancel, "提示")
If msg = 1 Then
If Not (rst.EOF) Then
rst.Fields("姓名").Value = CStr(Text1(0).Text)
rst.Fields("政治面貌").Value = CStr(Text1(1).Text)
rst.Fields("职务").Value = CStr(Text1(2).Text)
rst.Fields("科室").Value = CStr(Text1(3).Text)
rst.Fields("生日").Value = CStr(Text1(4).Text)
rst.Fields("军烈属").Value = CStr(Text1(5).Text)
rst.Fields("出勤天数").Value = CStr(Text1(6).Text)
rst.Fields("缺勤天数").Value = CStr(Text1(7).Text)
rst.Fields("基本工资").Value = CStr(Text1(8).Text)
rst.Fields("奖金").Value = CStr(Text1(9).Text)
rst.Fields("津贴").Value = CStr(Text1(10).Text)
rst.Fields("洗理").Value = CStr(Text1(11).Text)
rst.Fields("书报").Value = CStr(Text1(12).Text)
rst.Fields("交通").Value = CStr(Text1(13).Text)
rst.Fields("工资扣").Value = CStr(Text1(14).Text)
'rst.Fields("图片").Value = CStr(imgPhoto.Picture)
Text1(15).Text = Val(Text1(8).Text) + Val(Text1(9).Text) + Val(Text1(10).Text) + Val(Text1(11).Text) + Val(Text1(12).Text) + Val(Text1(13).Text)
Text1(16).Text = Text1(14).Text
Text1(17).Text = Val(Text1(15).Text) - Val(Text1(16).Text)
End If
End If
End If
End Sub

...全文
340 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
vansoft 2009-04-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 WallesCai 的回复:]
从不无偿写代码
[/Quote]

同意。
二两就醉 2009-04-25
  • 打赏
  • 举报
回复
楼上的去照顾天使去了,所以不无偿写代码。
熊孩子开学喽 2009-04-25
  • 打赏
  • 举报
回复
从不无偿写代码
d409142069 2009-04-25
  • 打赏
  • 举报
回复
附件里有程序 愿意帮忙的改好在这里发帖或者 改好后发我邮箱d030732@qq.com

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧