FixPay.frm
上传用户:cntx88
上传日期:2022-08-07
资源大小:169k
文件大小:6k
- VERSION 5.00
- Begin VB.Form FixPay
- Caption = "修改"
- ClientHeight = 3165
- ClientLeft = 60
- ClientTop = 450
- ClientWidth = 3675
- LinkTopic = "Form1"
- ScaleHeight = 3165
- ScaleWidth = 3675
- StartUpPosition = 3 'Windows Default
- Begin VB.Frame Frame1
- Caption = "修改工资记录"
- Height = 2895
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 3375
- Begin VB.CommandButton Command2
- Caption = "取消"
- Height = 495
- Left = 1800
- TabIndex = 9
- Top = 2040
- Width = 1215
- End
- Begin VB.CommandButton Command1
- Caption = "定位"
- Height = 495
- Left = 360
- TabIndex = 8
- Top = 2040
- Width = 1215
- End
- Begin VB.ComboBox Combo2
- Height = 300
- Left = 1920
- TabIndex = 5
- Text = "Combo2"
- Top = 1440
- Width = 855
- End
- Begin VB.ComboBox Combo1
- Height = 300
- ItemData = "FixPay.frx":0000
- Left = 360
- List = "FixPay.frx":0002
- TabIndex = 4
- Text = "Combo1"
- Top = 1425
- Width = 1215
- End
- Begin VB.TextBox Text1
- Height = 270
- Left = 360
- TabIndex = 1
- Text = "Text1"
- Top = 720
- Width = 2655
- End
- Begin VB.Label Label5
- Caption = "月"
- Height = 255
- Left = 2880
- TabIndex = 7
- Top = 1470
- Width = 255
- End
- Begin VB.Label Label4
- Caption = "年"
- Height = 255
- Left = 1680
- TabIndex = 6
- Top = 1470
- Width = 255
- End
- Begin VB.Label Label3
- Caption = "工资月份"
- Height = 255
- Left = 360
- TabIndex = 3
- Top = 1200
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "职工ID"
- Height = 255
- Left = 360
- TabIndex = 2
- Top = 480
- Width = 2175
- End
- End
- End
- Attribute VB_Name = "FixPay"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub Command1_Click()
- Dim sql As String
- Dim rs As New ADODB.Recordset
- Dim paydate As String
-
- If Text1.Text = "" Then '输入有效性和完整性判断
- MsgBox "职工ID不能为空!", vbCritical
- Text1.SetFocus
- Exit Sub
- End If
- If Combo1.ListIndex = -1 Then
- MsgBox "年份必须选择!", vbCritical
- Combo1.SetFocus
- Exit Sub
- End If
- If Combo2.ListIndex = -1 Then
- MsgBox "月份必须选择!", vbCritical
- Combo2.SetFocus
- Exit Sub
- End If
- paydate = Combo1.List(Combo1.ListIndex) & "-" & Combo2.List(Combo2.ListIndex)
- '组合年月下拉列表值
- If DbHandle.DbConnection Then
- sql = "TBL_USER" '打开职工表,查看输入的职工ID是否有效(存在)
- rs.CursorType = adOpenDynamic
- rs.LockType = adLockOptimistic
- rs.Filter = "USER_ID='" & Text1.Text & "'"
- rs.Open sql, DbFinance
- If DbHandle.resultcount(rs) <> 1 Then '表中无此职工ID,提示错误,要求用户继续输入正确地职工ID
- MsgBox "错误,不存在的职工ID号!", vbExclamation
- Text1.SetFocus
- rs.Close
- Set rs = Nothing
- DbHandle.DbClose
- Exit Sub
- End If
- rs.Close '职工ID存在,继续打开月工资表,查看职工当月工资是否已经录入数据库
- sql = "TBL_PAY"
- rs.CursorType = adOpenDynamic
- rs.LockType = adLockOptimistic
- rs.Filter = "PAY_USER='" & Text1.Text & "' AND PAY_DATE='" & paydate & "'"
- rs.Open sql, DbFinance
- If DbHandle.resultcount(rs) <> 1 Then '没有当月该职工工资记录,无法修改,退出
- MsgBox "工资记录不存在!", vbExclamation
- rs.Close
- DbHandle.DbClose
- Exit Sub
- End If
- FixPay2.Cancel = False '如果工资记录存在,显示修改工资对话框,并且设置窗体元素默认为原记录属性
- FixPay2.Text1.Text = Trim(Str(rs("PAY_MONEY")))
- FixPay2.Left = (Screen.Width - FixPay2.ScaleWidth) / 2
- FixPay2.Top = (Screen.Height - FixPay2.ScaleHeight) / 2
- FixPay2.Show 1
- If FixPay2.Cancel Then '如果工资记录修改确认(没取消),更新数据库,修改工资记录
- rs("PAY_MONEY") = Val(FixPay2.Text1.Text)
- rs.Update
- MsgBox "工资记录已经成功修改!"
- End If
- rs.Close
- DbHandle.DbClose
- Unload Me '修改完成,返回主窗体
- Else '数据库连接出错,退出
- MsgBox "数据库错误!", vbExclamation
- DbHandle.DbClose
- End
- End If
- End Sub
- Private Sub Command2_Click()
- Unload Me '返回主窗体
- End Sub
- Private Sub Form_Load()
- Dim i As Long
-
- Me.Left = (Screen.Width - Me.ScaleWidth) / 2 '窗体居中显示
- Me.Top = (Screen.Height - Me.ScaleHeight) / 2
- For i = 2003 To 2030 '窗体界面元素属性初始化
- Combo1.AddItem Trim(Str(i))
- Next i
- For i = 1 To 12
- Combo2.AddItem Trim(Str(i))
- Next i
- Text1.Text = ""
- Combo1.Text = ""
- Combo2.Text = ""
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- On Error Resume Next
- DbHandle.DbClose '窗体关闭时关闭数据库连接
- End Sub