以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]下述代码,如何数据引用的年度相同,则不引用,否则引用,如何修改代码?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=116851)

--  作者:hrw68529
--  发布时间:2018/4/1 16:13:00
--  [求助]下述代码,如何数据引用的年度相同,则不引用,否则引用,如何修改代码?
Dim Cols1() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}

Dim Cols2() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}

For Each dr1 As DataRow In DataTables("人员情况表").Select("[身份证号] <> \'\'")
    Dim dr2 As DataRow = DataTables("工资总表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next


--  作者:有点甜
--  发布时间:2018/4/1 19:54:00
--  

Dim Cols1() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}


Dim Cols2() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}


For Each dr1 As DataRow In DataTables("人员情况表").Select("[身份证号] is not null")
    Dim dr2 As DataRow = DataTables("工资总表").find("身份证号 = \'" & dr1("身份证号") & "\' and 年度 = \'" & dr1("年度") & "\'")
    If dr2 Is Nothing Then
        dr2 = DataTables("工资总表").AddNew()
        For i As Integer = 0 To Cols1.Length -1
            dr2(Cols2(i)) = dr1(Cols1(i))
        Next
    End If
Next


--  作者:hrw68529
--  发布时间:2018/4/2 7:27:00
--  
有点甜,谢谢了,但是上述代码,第一次导入的是2018年的,然后,我要导入2019年时,2018年的不导入,只导入2019年的,怎么修改代码,谢谢
--  作者:hrw68529
--  发布时间:2018/4/2 7:29:00
--  
明白了,弄好了,把身份证去掉,就可以了


--  作者:hrw68529
--  发布时间:2018/4/2 7:53:00
--  

有点甜,想加一个提示框,应该放在什么位置,现在的位置不对,

Dim Cols1() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}
Dim Cols2() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}
For Each dr1 As DataRow In DataTables("人员情况表").Select("[身份证号] is not null")
    Dim dr2 As DataRow = DataTables("工资总表").find("年度 = \'" & dr1("年度") & "\'")   
If dr2 IsNot Nothing Then
    MessageBox.Show("本年度已导入,不能再导入!","温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Return
If dr2 Is Nothing Then
        dr2 = DataTables("工资总表").AddNew()
        For i As Integer = 0 To Cols1.Length -1
            dr2(Cols2(i)) = dr1(Cols1(i))
        Next
    End If
Next


--  作者:有点甜
--  发布时间:2018/4/2 8:47:00
--  
Dim Cols1() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}
Dim Cols2() As String = {"姓名","现任职务","级别","个人状态","基本工资_保留奖金","补贴_保留福补","特岗津补贴","基本养老金","享受职务","单位性质","单位名称","年度","已休假天数","级别档次","个人类别","职务区分","岗位等级","薪级","身份证号","是否省级文明单位","是否全国文明城市","离休干部月均生活补贴","性别","参加工作时间"}
For Each dr1 As DataRow In DataTables("人员情况表").Select("[身份证号] is not null")
    Dim dr2 As DataRow = DataTables("工资总表").find("年度 = \'" & dr1("年度") & "\'")
    If dr2 IsNot Nothing Then
        MessageBox.Show("本年度已导入,不能再导入!","温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        Exit For
    End If
    If dr2 Is Nothing Then
        dr2 = DataTables("工资总表").AddNew()
        For i As Integer = 0 To Cols1.Length -1
            dr2(Cols2(i)) = dr1(Cols1(i))
        Next
    End If
Next