frmgzfp.frm

来自「企业工资管理系统的具体实现」· FRM 代码 · 共 552 行 · 第 1/2 页

FRM
552
字号
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   2415
            TabIndex        =   3
            Top             =   855
            Width           =   1290
         End
      End
   End
End
Attribute VB_Name = "frmgzfp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdexit_Click()
Call frmgzyesno
Unload Me
End Sub

Private Sub cmdok_Click()
Dim cnn As New ADODB.Connection
Dim cnn1 As New ADODB.Connection
Dim cjm As String
Dim grdh, i As Integer
If Combo1.Text <> "" Then
    If List2.ListCount = 0 Then
        If MsgBox("没有可以选择的工人!请先进行车间设置。", vbInformation + vbOKOnly, "提示") Then
            frmcjsz.Show
            Unload Me
            Exit Sub
        End If
    ElseIf MsgBox("你确定你的选择吗?确定请按“是”,否则按“否”", vbYesNo + vbInformation, "提示") = vbYes Then
        With Adodc1
            .ConnectionString = constr
            .RecordSource = "select * from cjb where cjdh= '" & Combo1.Text & "'"
            .Refresh
            cjm = .Recordset.Fields("cjm").Value
        End With
        With Adodc1
            .ConnectionString = constr
            .RecordSource = "select max(grdh) as maxgrdh from grfpb where cjdh= '" & Trim(Combo1.Text) & "'"
            .Refresh
            If Not .Recordset.EOF And Not .Recordset.BOF And Not IsNull(.Recordset.Fields("maxgrdh").Value) Then
                .Recordset.MoveFirst
                grdh = Val(Right(Trim(.Recordset.Fields("maxgrdh").Value), 5))
            Else
                grdh = 9999   '第次分配时工人代号设为9999
            End If
            .RecordSource = "select * from grfpb"
            .Refresh
            If Not (.Recordset.EOF And .Recordset.BOF) Then
                .Recordset.MoveFirst
            End If
            For i = 0 To List2.ListCount - 1
                grdh = grdh + 1
                v = Split(List2.List(i))
                .Recordset.AddNew
                .Recordset.Fields("cjdh").Value = Trim(Combo1.Text)
                .Recordset.Fields("cjm").Value = Trim(cjm)
                .Recordset.Fields("xm").Value = v(0)
                .Recordset.Fields("grdh").Value = Trim(Combo1.Text) & Trim(Str$(grdh))
                .Recordset.Update
                sfzh = StrReverse(Trim(List2.List(i)))
                sfzh1 = Split(Trim(sfzh))
                sfzh2 = StrReverse(Trim(sfzh1(0)))
                With Adowork          '根据身份证号删除报名符表中已被分配的工人
                    .ConnectionString = constr
                    .RecordSource = "select * from bmb1 where sfzh= '" & Trim(sfzh2) & "'"
                    .Refresh
                    If Not (.Recordset.EOF And .Recordset.BOF) Then
                        .Recordset.Delete
                        .Recordset.Update
                    End If
                End With
            Next i
        End With
        List2.Clear
        MsgBox "初始化第一步!"
        For i = 1 To 12
        With cnn
            .Open constr
            If Len(Trim(Str$(i))) = 1 Then
                .Execute "delete * from sbqkb" & Trim("0" & Trim(Str$(i))) & " where cjdh='" & Trim(Combo1.Text) & "'"
                .Execute "insert into sbqkb" & Trim("0" & Trim(Str$(i))) & "(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb where cjdh='" & Trim(Combo1.Text) & "'"

            Else
                .Execute "delete * from sbqkb" & Trim(Str$(i)) & " where cjdh='" & Trim(Combo1.Text) & "'"
                .Execute "insert into sbqkb" & Trim(Str$(i)) & "(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb where cjdh='" & Trim(Combo1.Text) & "'"

            End If
            .Close
        End With
        Set cnn = Nothing
        Next i
        With cnn1
            .Open constr
            .Execute "delete * from gzzjb where cjdh='" & Trim(Combo1.Text) & "'"
            .Execute "insert into gzzjb(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb where cjdh='" & Trim(Combo1.Text) & "'"
            .Close
        End With
        Set cnn1 = Nothing
        cmdok.Enabled = False
        MsgBox "分配成功!", vbInformation, "提示"
    Else
        Exit Sub
    End If
Else
    MsgBox "你没有选择车间或者你没有进行车间设置!", vbInformation, "提示"
    Exit Sub
End If
End Sub



Private Sub Command1_Click()
Dim i, j As Integer
If List1.SelCount = 0 Then
    MsgBox "请选择要分配工人", vbInformation, "提示"
    Exit Sub
End If
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) = True Then
        List2.AddItem List1.List(i)
        select1 = 1
    End If
Next i
For i = 1 To List1.SelCount
    For j = 0 To List1.ListCount - 1
        If List1.Selected(j) = True Then
            List1.RemoveItem (j)
            Exit For
        End If
    Next j
Next i
cmdok.Enabled = True
End Sub

Private Sub Command2_Click()
Dim i As Integer
If List1.ListCount = 0 Then
    MsgBox "没有可以分配的工人!", vbInformation, "提示"
    Exit Sub
End If
For i = 0 To List1.ListCount - 1
'    v = Split(List1.List(0))
'    If v(0) = "" Then
'        MsgBox "只少有一个工人没姓名,请重新报名后再分配工作。", vbExclamation, "警告"
'        With Adowork
'            .ConnectionString = constr
'            .RecordSource = "select * from bmb1"
'            .Refresh
'            If Not (.Recordset.EOF And .Recordset.BOF) Then
'                .Recordset.MoveFirst
'            End If
'            List1.Clear
'            Do While Not .Recordset.EOF
'                xm = Trim(.Recordset.Fields("xm").Value)
'                xb = Trim(.Recordset.Fields("xb").Value)
'                mz = Trim(.Recordset.Fields("mz").Value)
'                csrq = Trim(.Recordset.Fields("csrq").Value)
'                zz = Trim(.Recordset.Fields("zz").Value)
'                sfzh = Trim(.Recordset.Fields("sfzh").Value)
'                List1.AddItem xm & " " & xb & " " & mz & " " & csrq & " " & zz & " " & sfzh
'                .Recordset.MoveNext
'            Loop
'        End With
'        List2.Clear
'        Exit Sub
'    End If
    List2.AddItem List1.List(0)
    List1.RemoveItem (0)
Next i
cmdok.Enabled = True
End Sub

Private Sub Command3_Click()
Dim i, j As Integer
If List2.SelCount = 0 Then
    MsgBox "请选择工人", vbInformation, "提示"
    Exit Sub
End If
For i = 0 To List2.ListCount - 1
    If List2.Selected(i) = True Then
        List1.AddItem List2.List(i)
    End If
Next i
For i = 1 To List2.SelCount
    For j = 0 To List2.ListCount - 1
        If List2.Selected(j) = True Then
            List2.RemoveItem (j)
            Exit For
        End If
    Next j
Next i
cmdok.Enabled = True
End Sub

Private Sub Command4_Click()
Dim i As Integer
If List2.ListCount = 0 Then
    MsgBox "没有可以选取的工人!", vbInformation, "提示"
    Exit Sub
End If
For i = 0 To List2.ListCount - 1
        
'        Do While Not .Recordset.EOF
'            If List2.List(i) = .Recordset.Fields("sfzh").Value Then
'                .Recordset.MoveFirst
'                Exit Do
'            End If
'        .Recordset.MoveNext
'        Loop
'        xm = Trim(.Recordset.Fields("xm").Value)
'        xb = Trim(.Recordset.Fields("xb").Value)
'        mz = Trim(.Recordset.Fields("mz").Value)
'        csrq = Trim(.Recordset.Fields("csrq").Value)
'        zz = Trim(.Recordset.Fields("zz").Value)
'        sfzh = Trim(.Recordset.Fields("sfzh").Value)
'        List1.AddItem xm & " " & xb & " " & mz & " " & csrq & " " & zz & " " & sfzh

    List1.AddItem List2.List(0)
    List2.RemoveItem (0)
    Next i
    cmdok.Enabled = True
'End With
End Sub

'Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
'aa = DataGrid1.Col
'bb = DataGrid1.Row
'End Sub

Private Sub Form_Load()
'Dim xm, xb, mz, dsrq, zz, sfzh As String
With Adowork                               '在屏幕左框中显示要分配工作的人的情况
    .ConnectionString = constr
    .RecordSource = "select * from bmb1"
    .Refresh
    If Not (.Recordset.EOF And .Recordset.BOF) Then
        .Recordset.MoveFirst
    End If
    Do While Not .Recordset.EOF
        xm = Trim(.Recordset.Fields("xm").Value)
        xb = Trim(.Recordset.Fields("xb").Value)
        mz = Trim(.Recordset.Fields("mz").Value)
        csrq = Trim(.Recordset.Fields("csrq").Value)
        zz = Trim(.Recordset.Fields("zz").Value)
        sfzh = Trim(.Recordset.Fields("sfzh").Value)
        List1.AddItem xm & " " & xb & " " & mz & " " & csrq & " " & zz & " " & sfzh
        .Recordset.MoveNext
    Loop
End With
With Adodc1
    .ConnectionString = constr
    .RecordSource = "select * from cjb order by cjdh"
    .Refresh
    If Not (.Recordset.EOF And .Recordset.BOF) Then
        .Recordset.MoveFirst
    Else
        MsgBox "请先进行车间设置后,再进行工作分配!", vbInformation, "提示"
'        frmcjsz.Show
        Exit Sub
    End If
    Do While Not .Recordset.EOF
        Combo1.AddItem .Recordset.Fields("cjdh").Value            '在列表框中显示所有设置好的车间代号
        .Recordset.MoveNext
    Loop
End With
Combo1.Text = Combo1.List(0)
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?