VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1
Caption = "主窗体"
ClientHeight = 9105
ClientLeft = 165
ClientTop = 855
ClientWidth = 11550
LinkTopic = "Form1"
ScaleHeight = 9105
ScaleWidth = 11550
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin MSAdodcLib.Adodc Adodc1
Height = 735
Left = 2880
Top = 240
Visible = 0 'False
Width = 1455
_ExtentX = 2566
_ExtentY = 1296
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = $"主窗体.frx":0000
OLEDBString = $"主窗体.frx":0090
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
Begin VB.TextBox Text6
Height = 495
Left = 9360
TabIndex = 12
Top = 8400
Width = 1935
End
Begin VB.CommandButton Command7
Caption = "更改"
Height = 495
Left = 4320
TabIndex = 11
Top = 6720
Width = 1215
End
Begin VB.TextBox Text5
Height = 495
Left = 7200
TabIndex = 10
Top = 8400
Width = 1935
End
Begin VB.TextBox Text4
Height = 495
Left = 4800
TabIndex = 9
Top = 8400
Width = 2055
End
Begin VB.TextBox Text3
Height = 495
Left = 2400
TabIndex = 8
Top = 8400
Width = 2055
End
Begin VB.TextBox Text2
Height = 495
Left = 240
TabIndex = 7
Top = 8400
Width = 1815
End
Begin VB.CommandButton Command6
Caption = "退出"
Height = 495
Left = 9840
TabIndex = 6
Top = 6720
Width = 1215
End
Begin VB.CommandButton Command5
Caption = "删除"
Height = 495
Left = 8160
TabIndex = 5
Top = 6720
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "更新工资"
Height = 495
Left = 6240
TabIndex = 4
Top = 6720
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "显示"
Height = 495
Left = 240
TabIndex = 3
Top = 6720
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "插入"
Height = 495
Left = 240
TabIndex = 2
Top = 7560
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "查询"
Height = 495
Left = 2280
TabIndex = 1
Top = 6720
Width = 1215
End
Begin VB.ListBox List1
Height = 5280
Left = 240
TabIndex = 0
Top = 1080
Width = 11175
End
Begin VB.Menu about
Caption = "关于"
Begin VB.Menu edition
Caption = "版本"
End
Begin VB.Menu exit
Caption = "退出"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Firstupdate As Integer
Public Firstadd As Integer
Private Sub Command1_Click()
Form2.Show
End Sub
'添加模块
Private Sub Command2_Click()
If Firstadd = 1 Then
Me.Text2.Text = "在此输入序号"
Me.Text3.Text = "在此输入姓名"
Me.Text4.Text = "在此输入入校时间"
Me.Text5.Text = "在此输入赡养人数"
Me.Text6.Text = "在此输入工资"
MsgBox "在根据方框内的提示正确输入"
Me.Text2.Text = ""
Me.Text3.Text = ""
Me.Text4.Text = ""
Me.Text5.Text = ""
Me.Text6.Text = ""
End If
Me.Text2.SetFocus
If Firstadd = 1 Then
Firstadd = Firstadd + 1
Exit Sub
End If
If Me.Text2.Text = "" Or Me.Text3.Text = "" Or Me.Text4 = "" Or Me.Text6.Text = "" Then
MsgBox "在方框内完整地输入要插入的信息"
Else
If Not IsNumeric(Me.Text2.Text) Or Not IsNumeric(Me.Text5.Text) Or Not IsNumeric(Me.Text6.Text) Then
MsgBox "插入值类型不匹配.增添记录失败"
GoTo error
End If
If Int(Me.Text5.Text) > 128 Then
MsgBox "赡养人数不能超过128"
GoTo error
End If
If Len(Me.Text3.Text) > 20 Then
MsgBox "姓名字长不超过20"
GoTo error
End If
If Len(Me.Text2.Text) > 9 Or Len(Me.Text6.Text) > 9 Then
MsgBox "序号或工资大小越界"
GoTo error
End If
If Not IsDate(Me.Text4.Text) Then
MsgBox "日期格式不能识别"
GoTo error
End If
'若游标打开 ,则关闭他,重新用查询语句打开游标
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 1
End If
'用查询语句打开游标
RES.ActiveConnection = Comsalary
RES.Source = "select * from 工资表"
RES.Open
ResOpen = 1
ResClose = 0
'判断是否有重复字段
For i = 0 To Me.List1.ListCount - 2
If Int(Me.Text2.Text) = RES.Fields("序号") Then
MsgBox "在关键字段插入了重复值,插入失败"
GoTo error
End If
RES.MoveNext
Next
'插入记录
If ResOpen = 1 Then
RES.Close
ResClose = 1
ResOpen = 0
RES.Source = "insert 工资表(序号,姓名,入校时间,赡养人数,原工资) values ( '" & Me.Text2.Text & "', '" & Me.Text3.Text & "','" & Me.Text4.Text & "','" & Me.Text5.Text & "', '" & Me.Text6.Text & "') "
RES.Open
ResOpen = 1
ResClose = 0
MsgBox "成功添加"
ResOpen = 0
ResClose = 1
Me.Adodc1.Refresh
Call showdata
End If
End If
error:
If ResOpen = 1 Then
RES.Close
ResClose = 1
ResOpen = 0
End If
End Sub
Private Sub Command3_Click()
Call showdata
End Sub
Private Sub Command4_Click()
CHANGE.ActiveConnection = Comsalary
CHANGE.Source = "select * from 工资表"
CHANGE.Open
CHANGE.MoveFirst
While Not CHANGE.EOF
Call refreshsalary(CHANGE.Fields("原工资"), CHANGE.Fields("入校时间"), CHANGE.Fields("赡养人数"))
CHANGE.MoveNext
Wend
Call showdata
CHANGE.Close
End Sub
Private Sub Command5_Click()
Dim Delno As String
Dim Nextres As Integer
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 0
End If
Delno = InputBox("输入要删除的教师的序号")
If IsNumeric(Delno) Then
RES.Source = "select *from 工资表"
RES.Open
ResOpen = 1
ResClose = 0
RES.MoveFirst
While Not RES.EOF
Nextres = Nextres + 1
If RES.Fields(0) = Int(Delno) Then
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 1
End If
RES.Source = "delete 工资表 where 序号= ' " & Delno & " '"
RES.Open
ResOpen = 1
ResClose = 0
MsgBox " 删除成功"
Me.Adodc1.Refresh
ResOpen = 0
ResClose = 1
Call showdata '刷新显示
ResOpen = 0
ResClose = 1
Exit Sub
Nextres = -1
End If
RES.MoveNext
Wend
If Nextres -1 Then
MsgBox "没有此记录 删除失败"
End If
End If
End Sub
Private Sub Command7_Click()
Dim UpdateIndex As String
Dim i As Integer
Dim Upname As String
Dim Upnewsalry As String
Dim Uppeople As String
Dim Uptime As String
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 1
End If
UpdateIndex = InputBox("输入要更改教师的序号")
If IsNumeric(UpdateIndex) Then
RES.Source = "select * from 工资表"
RES.Open
ResClose = 0
ResOpen = 1
Else
GoTo error
End If
While Not RES.EOF
'查找你要更新的记录
If RES.Fields(0) = Int(UpdateIndex) Then
i = 1
'查找到 输入新记录信息
'该姓名--------------------------------------------------------
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 1
End If
Upname = InputBox("输入新姓名,如果保持原来姓名,单击取消")
If Len(Upname) > 20 Then
MsgBox "姓名长度小于20"
Upname = ""
End If
If Upname "" Then
RES.ActiveConnection = Comsalary
RES.Source = "update 工资表 set 姓名 ='" & Upname & "' where 序号= '" & UpdateIndex & "'"
RES.Open
End If
'改日期 ------------------------------------------------------------
Uptime = (InputBox("输入新的入校日期,如果保持原来的值,单击取消"))
If Not IsDate(Uptime) And Uptime "" Then
MsgBox "输入的日期格式不能识别"
Uptime = ""
End If
If Uptime "" Then
RES.Source = "update 工资表 set 入校时间 ='" & Uptime & "' where 序号= '" & UpdateIndex & "'"
RES.Open
End If
'改工资-------------------------------------------------------------
Upnewsalry = InputBox("输入新的工资,如果保持原来的值,单击取消")
If Not IsNumeric(Upnewsalry) And Upnewsalry "" Then
MsgBox "输入错误"
Upnewsalry = ""
End If
If Upnewsalry "" Then
RES.Source = "update 工资表 set 原工资 ='" & Upnewsalry & "' where 序号= '" & UpdateIndex & "'"
RES.Open
End If
'改赡养人数-----------------------------------------------------
Uppeople = InputBox("输入新的赡养人数,如果保持原来的值,单击取消")
If Not IsNumeric(Uppeople) And Uppeople "" Then
MsgBox "输入错误"
Uppeople = ""
End If
If Uppeople "" Then
RES.Source = "update 工资表 set 赡养人数 ='" & Uppeople & "' where 序号= '" & UpdateIndex & "'"
RES.Open
'更改后退出 自动关闭游标
End If
Call showdata
ResOpen = 0
ResClose = 1
Exit Sub
End If
RES.MoveNext
Wend
If i 1 Then
MsgBox "不存在序号为 " & UpdateIndex & " 的教师 更新无法完成"
GoTo error
End If
Firstupdate = 9
'未更改退出,关闭游标
RES.Close
ResClose = 1
ResOpen = 0
error:
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub edition_Click()
Form4.Show
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub Command8_Click()
End Sub
Private Sub Form_load()
ResClose = 1
If ResClose = 1 Then
RES.ActiveConnection = Comsalary
Firstadd = 1
Firstupdate = 1
End If
Call showdata
End Sub
'显示列表
Public Sub showdata()
'游标的SQL语句
'RES.Close
If ResOpen = 1 Then '若游标打开,则关闭他重新打开
RES.Close
ResClose = 0
ResOpen = 1
End If
'重新用查询语句将游标打开
RES.ActiveConnection = Comsalary
RES.Source = "select * from 工资表"
RES.Open
ResOpen = 1
ResClose = 0
Me.List1.Clear '清空列表
'当游标指向的记录存在时操作
Me.List1.List(0) = RES.Fields(0).Name & " " & RES.Fields(1).Name & " " & RES.Fields(2).Name & " " & RES.Fields(3).Name & " " & RES.Fields(4).Name & " " & RES.Fields(5).Name
Index = 1
RES.MoveFirst
While Not RES.EOF
For num = 0 To RES.Fields.Count - 1
Me.List1.List(Index) = Me.List1.List(Index) & RES.Fields(num) & " "
Next
RES.MoveNext
Index = Index + 1
Wend
RES.Close
ResClose = 1
ResOpen = 0
End Sub
Public Sub refreshsalary(sa As Long, year As Date, people As Long)
Dim op As Long
Dim OY As Integer
If ResOpen = 1 Then
RES.Close
ResOpen = 0
ResClose = 1
End If
OY = Now - year
OY = OY / 365
If Int(year) < 0 Then
MsgBox "工龄为负数,计算终止"
End
End If
If Int(people) < 0 Then
MsgBox "赡养人数为负数,计算终止"
End
End If
If sa > 26000 Then
op = sa
Else
op = sa + 100 * people + Int(OY) * 50
If op > 26000 Then
op = 26000
End If
End If
RES.Source = "update 工资表 set 更改工资 = '" & op & "' where 原工资 = '" & sa & "'"
RES.Open
ResClose = 1
ResOpen = 0
End Sub