📄 frmemployee.frm
字号:
' con.Execute "delete from Employee where EmployeeID=" & recGrid.Fields("EmployeeID")
' RefreshBill
Exit Sub
DelErr:
ErrMsg
End Sub
Private Sub cmbEmployee_BtnsClick(ByVal nIndex As Integer)
If nIndex = 0 Then
rstEmployee.Requery
bufEmployee.DataSource = rstEmployee
cmbEmployee.DataSource = bufEmployee
End If
If nIndex = 1 Then
cmbEmployee.SearchID 0
End If
End Sub
Private Sub cmdEdit_Click()
Me.PopupMenu MNU.mnuEmployee, , cmdEdit.Left, cmdEdit.Top + cmdEdit.Height
End Sub
Private Sub cmdExpor_Click()
On Error GoTo IsErr:
Dim tmpRst As New ADODB.Recordset
' tmpRst.CursorLocation = adUseClient
' tmpRst.Fields.Append "序号", adInteger
' tmpRst.Fields.Append "员工编号", adVarChar, 50
' tmpRst.Fields.Append "员工名称", adVarChar, 50
' tmpRst.Fields.Append "员工卡号", adVarChar, 50
' tmpRst.Fields.Append "默认排班", adVarChar, 50
' tmpRst.Fields.Append "默认休假", adVarChar, 50
' tmpRst.Open "", , adOpenStatic, adLockBatchOptimistic
Grid.Col("Serial").bOutput = True
Grid.Col("DelFlag").bOutput = False
Grid.FillOutRstEx tmpRst, byHeadCaption
' Dim lRow As Long
' Dim lCount As Long
' lCount = Grid.RecordCount
'
' For lRow = 0 To lCount - 1
' tmpRst.AddNew
' tmpRst.Fields("序号") = Grid.FieldByKey(lRow, "Serial")
' tmpRst.Fields("员工编号") = Grid.FieldByKey(lRow, "Code")
' tmpRst.Fields("员工名称") = Grid.FieldByKey(lRow, "Name")
' tmpRst.Fields("员工卡号") = Grid.FieldByKey(lRow, "Card")
' tmpRst.Fields("默认排班") = Grid.FieldByKey(lRow, "OnClassName")
' tmpRst.Fields("默认休假") = Grid.FieldByKey(lRow, "VacName")
' tmpRst.Update
' Next
'
ComDlg.CancelError = True
ComDlg.Filter = "ExcelFile(*.xls)|*.xls"
ComDlg.Flags = cdlOFNHideReadOnly
ComDlg.InitDir = App.Path
ComDlg.DialogTitle = "导出"
ComDlg.ShowSave
If Trim(ComDlg.FileName) = "" Then Exit Sub
ExporToExcel tmpRst, "报表", ComDlg.FileName
If tmpRst.State = 1 Then tmpRst.Close
Set tmpRst = Nothing
Exit Sub
IsErr:
If InStr(Err.Description, "选定") <> 0 Then
Exit Sub
End If
ErrMsg
End Sub
Private Sub cmdFind_Click()
If cmbEmployee.Text <> "" Then
Grid.FilterCol(0) = "Name"
Grid.Filter(0).SetCondition "in(" + cmbEmployee.Text + ")"
Grid.ReFetch
Else
Grid.FilterCol(0) = "Name"
Grid.Filter(0).SetCondition ""
Grid.ReFetch
End If
End Sub
Private Sub cmdPrint_Click()
Set iFrom = Me
Me.PopupMenu MNU.mnuPrint, , cmdPrint.Left - 15, cmdPrint.Top + cmdPrint.Height
End Sub
Private Sub Form_Load()
Me.Icon = MDI.Icon
If recGrid.State = 1 Then recGrid.Close
Set recGrid = Nothing
recGrid.CursorLocation = adUseClient
' recGrid.Open "select a.EmployeeID,a.Code,a.Name,a.card,a.OnClassID,a.VacID,a.ClassFlag,b.OnClassName,c.VacName from Employee a , ClassInfo b , " _
' & " VacInfo c where a.OnClassID=b.OnClassID and a.VacID=c.VacID", con, adOpenStatic, adLockBatchOptimistic
recGrid.Open "select a.*,b.OnClassName,c.VacName from (Employee a " _
& " Left outer join ClassInfo b on a.OnClassID=b.OnClassID) " _
& " Left outer join VacInfo c on a.VacID=c.VacID ", con, adOpenStatic, adLockBatchOptimistic
Grid.ClearHeadData
Grid.AddBuf bufOnClass, -1, "OnClassID"
Grid.AddBuf bufVac, -1, "VacID"
Grid.AddHeader "序号", "Serial", 40, -1, -1, False, sSerial
Grid.AddHeader "员工编号", "Code", 80, -1, "Code", False, sDefault
Grid.AddHeader "员工名称", "Name", 80, -1, "Name", False, sDefault
Grid.AddHeader "员工卡号", "Card", 80, -1, "Card", False, sDefault
Grid.AddHeader "默认排班", "OnClassName", 80, 0, "OnClassName", False, sDefault
Grid.AddHeader "默认休假", "VacName", 80, 1, "VacName", False, sDefault
Dim imgCol As Long
Grid.ImageList = MDI.Image
imgCol = Grid.AddHeader("选中", "DelFlag", 50, -1, "DelFlag", True, sImage)
Grid.SetColImage imgCol, "0[],1[arrow],2[Hand]"
Set Grid.DataSource = recGrid
Grid.AllowAddNew = False
Grid.AllowEdit = True
Grid.ColAutoResize = False
'======员工
cmbEmployee.ShowHeadScale = "0,20,20,20"
cmbEmployee.ShowHeadValue = "EmployeeID,编号,名称,卡号"
cmbEmployee.ShowIndex = 2
cmbEmployee.Type = tDynamic
cmbEmployee.SetBtns "刷新,清空"
cmbEmployee.ButtonHeight = 20
' cmbEmployee.DropWidth = cmbEmployee.Width
cmbEmployee.DataSource = bufEmployee
Grid.ShowTail = True
' cmbEmployee.ShowHeadValue = "employeeid,Code,name,Card"
' cmbEmployee.ShowHeadScale = "0,20,20,20"
' cmbEmployee.ShowIndex = 2
' cmbEmployee.SetBtns "清空"
' Set cmbEmployee.DataSource = bufEmployee
Me.Width = 7695
Me.Height = 5820
End Sub
Private Sub Form_Resize()
On Error Resume Next
Grid.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight - 375 - 120
cmdEdit.Move 60, Grid.Top + Grid.Height + 60
cmdPrint.Move cmdEdit.Left + cmdPrint.Width + 60, cmdEdit.Top
cmdExpor.Move cmdPrint.Left + cmdExpor.Width + 60, cmdPrint.Top
cmdFind.Move Me.ScaleWidth - cmdFind.Width - 120, Grid.Top + Grid.Height + 60
cmbEmployee.Move cmdFind.Left - cmbEmployee.Width - 120, cmdFind.Top
End Sub
Public Sub DelSelect()
On Error GoTo IsErr:
If Val(Grid.Col("DelFlag").SumText) = 0 Then
Message "请先选中数据!"
Exit Sub
End If
If QueryDly("确定删除?") = False Then Exit Sub
con.Execute "delete from Employee where DelFlag=1"
RefreshBill
' Grid.DelRow "DelFlag", "=1"
' Grid.DataSource.Properties.Item("Unique Table") = "Employee"
' Grid.DataSource.UpdateBatch
Exit Sub
IsErr:
ErrMsg
End Sub
Private Sub Grid_AfterExColUpdate(ByVal ColIndex As Long, ByVal vOldValue As Variant)
Grid.DataSource.Properties.Item("Unique Table") = "Employee"
Grid.DataSource.UpdateBatch
End Sub
Private Sub Grid_DblClick()
EditBill
End Sub
Private Sub Grid_RButtonUp(ByVal Area As SSUPERGRIDLib.sArea, ByVal X As Long, ByVal Y As Long)
Me.PopupMenu MNU.mnuEmployee
End Sub
Public Sub PrintBill()
If recGrid.State <> adStateOpen Then Exit Sub
ACRptEngine1.Init
ACRptEngine1.AddDataSet "ac", recGrid
ACRptEngine1.SetReportFile App.Path & "\RPT\EMPRPT.apt"
ACRptEngine1.PrintReport
End Sub
Public Sub PreviewBill()
If recGrid.State <> adStateOpen Then Exit Sub
ACRptEngine1.Init
ACRptEngine1.AddDataSet "ac", recGrid
ACRptEngine1.SetReportFile App.Path & "\RPT\EMPRPT.apt"
ACRptEngine1.Preview
End Sub
Public Sub ShowDesignerBill()
If recGrid.State <> adStateOpen Then Exit Sub
ACRptEngine1.Init
ACRptEngine1.AddDataSet "ac", recGrid
ACRptEngine1.SetReportFile App.Path & "\RPT\EMPRPT.apt"
ACRptEngine1.ShowDesigner
End Sub
'〓〓〓〓〓 GridMnu 全选 〓〓〓〓〓
Public Sub GridMnuAll()
If recGrid.RecordCount = 0 Then Exit Sub
Grid.ModifyField "DelFlag", "", "DelFlag", "1", "", ""
Grid.DataSource.UpdateBatch
End Sub
'〓〓〓〓〓 GridMnu 全清 〓〓〓〓〓
Public Sub GridMnuClear()
If recGrid.RecordCount = 0 Then Exit Sub
Grid.ModifyField "DelFlag", "", "DelFlag", "0", "", ""
Grid.DataSource.UpdateBatch
End Sub
'〓〓〓〓〓 GridMnu 反选 〓〓〓〓〓
Public Sub GridMnuReverse()
If recGrid.RecordCount = 0 Then Exit Sub
Grid.SetColFieldBatch "DelFlag", "1-DelFlag", "between (0,1)"
Grid.DataSource.UpdateBatch
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -