Foxtable(狐表)用户栏目专家坐堂 → 导入


  共有1569人关注过本帖树形打印复制链接

主题:导入

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
导入  发帖心情 Post By:2017/3/31 14:17:00 [只看该作者]

Dim com4 As String =  trim(e.Form.Controls("combobox7").text)
If com4 > ""
    If User.IsRole("业务主管") Then
        Dim dt As Table = Tables("中考报名_table5")
        If dt.Rows.count>0
            Dim dr As DataRow
            dr = DataTables("学校信息").sqlFind("单位全称 = '" & user.group & "'and 学段 = '初中'" )
            If dr IsNot Nothing
                Dim bydm As String = left(dr("毕业学校代码"),8)
                Dim jm As String = dr("学校班级用简称")
                Dim p As WinForm.ProgressBar
                p = e.Form.Controls("ProgressBar1")
                p.Maximum = dt.Rows.Count '设置最大值
                p.Minimum = 0 '设置最小值
                p.Value = 0 '设置当前值
                Dim dwmc As String = user.group
                If  com4 > ""
                    Dim Cols1() As String = {"学校名称","学生姓名","班级","年级","身份证件号","学籍号","性别","班级"}
                    Dim Cols2() As String = {"学校名称","姓名","班级","年级","身份证号","学籍号","性别","级"}
                    Dim su As Integer = 0
                    Dim dr2 As DataRow
                    Dim p1 As Integer = 0
                    For Each dr1 As Row In dt.Rows
                        If DataTables("生地报名库").sqlFind("身份证号 = '" & dr1("身份证件号") & "' and  姓名 = '" & dr1("学生姓名") & "'") Is Nothing Then
                            dr2 = DataTables("生地报名库").AddNew()
                            For i As Integer = 0 To Cols1.Length -1
                                Select Case i
                                    Case 0,1,5,4,6,7
                                        dr2(Cols2(i)) = dr1(Cols1(i))
                                    Case 2
                                        Dim c() As Char = {"级", "班"}
                                        Dim str As String = dr1(Cols1(i))
                                        Dim s1() As String = str.Split(c)
                                        dr2(Cols2(i)) = s1(1)
                                    Case 3
                                        Dim year As String = com4.Substring(0,2)
                                        Dim v As Integer = cint(year)
                                        Dim ji As String = com4.Substring(2,1)
                                        Dim j As Integer
                                        If ji = "春"
                                            j = 0
                                        End If
                                        If ji = "秋"
                                            j = 1
                                        End If
                                        dr2(Cols2(i)) = trim(str(v - val(dr1(Cols1(i)).Substring(4,2)) + j +6))
                                        If dr2(Cols2(i)) = "9"
                                            dr2("备注") ="补考"
                                        End If
                                End Select
                                dr2("考试名称") = com4
                           
                        Next

                        P1 =P1+1
                        P.VALUE = P1
                        dr2("毕业中学代码") = bydm 'left(dr("毕业学校代码"),8)
                        dr2("学校班级") = jm & dr2("年级") & "." & dr2("班级")
                        'End If
                        Dim dr3 As DataRow
                        dr3 = DataTables("师表").Find("学校名称 = '" & dr2("学校名称") & "'and 班级 = '" & dr2("级") & "'" )
                        If dr3 IsNot Nothing
                            dr2("生物教师")= dr3("生物教师")
                            dr2("地理教师")= dr3("地理教师")
                        End If
                        dr2.save()
                       End If
                    Next
                    p.value=0
                End If
            Else
                messagebox.show("请选择勾选8年级和9年级在校学生","提示",MessageBoxButtons.OK)
            End If
        End If
    End If
Else
    messagebox.show("请选择好报考名称","提示",MessageBoxButtons.OK)
End If
Tables("中考报名_table4").sort = "学校班级,备注"

 

 

老师,上面代码是想查找有不有身份证号和姓名相同的记录有则跳过,无则增加并填充,但做出来结果是都要增加记录,没找到是什么地方错了,请指点,谢谢


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/31 14:53:00 [只看该作者]

If DataTables("生地报名库").sqlFind("身份证号 = '" & dr1("身份证件号") & "' and  姓名 = '" & dr1("学生姓名") & "'") Is Nothing Then

 

改成

 

If DataTables("生地报名库").Find("身份证号 = '" & dr1("身份证件号") & "' and  姓名 = '" & dr1("学生姓名") & "'") Is Nothing AndAlso DataTables("生地报名库").sqlFind("身份证号 = '" & dr1("身份证件号") & "' and  姓名 = '" & dr1("学生姓名") & "'") Is Nothing Then


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/3/31 14:59:00 [只看该作者]

效果一样呢

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/31 15:03:00 [只看该作者]

msgbox("身份证号 = '" & dr1("身份证件号") & "' and  姓名 = '" & dr1("学生姓名") & "'")

 

弹出条件看看,看看是否正常。看是否有特殊字符,比如空格之类的。


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/3/31 15:58:00 [只看该作者]

问题如找到了,谢谢,但现在还有一个问题是如果生地库中学生的身份证为空,导入一次又会重复增加记录呢,请问如何解决这种没身份证的问题呢?


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/31 16:06:00 [只看该作者]

条件这样生成

 

Dim Filter As String = ""
If dr1.IsNull("身份证件号") Then
    filter &= "身份证号 is Null"
Else
    filter &= "身份证号 = '" & dr1("身份证件号") & "'"
End If

If dr1.IsNull("姓名") Then
    filter &= "姓名 is Null"
Else
    filter &= "姓名 = '" & dr1("学生姓名") & "'"
End If

msgbox(filter)


 回到顶部