Foxtable(狐表)用户栏目专家坐堂 → 数据格式化问题


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

主题:数据格式化问题

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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
数据格式化问题  发帖心情 Post By:2016/7/11 13:57:00 [显示全部帖子]

身份证读卡器读取的日期格式为:YYYYMMDD(如20160711),怎么让它直接变成2016年7月11日?没有存文本文档。

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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/11 17:15:00 [显示全部帖子]

 Dim s As String =(System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg))
    If s.Length > 0 Then
        '分段截取字符串并赋给窗口控件
        Dim r As Row = Tables("农民工实名制信息表").AddNew
        r("姓名") = s.SubString(0,14).Replace(".","-")
        r("性别") = s.SubString(15,1).Replace(".","-")
        r("民族") = s.SubString(16,2).Replace(".","-")
        r("出生日期") =  s.SubString(18,8).Replace(".","-")
        r("家庭住址") = s.SubString(26,35).Replace(".","-")
        r("身份证号") = s.SubString(61,18).Replace(".","-")
        r("发证机关") = s.SubString(79,14).Replace(".","-")
        r("签发日期") = s.SubString(94,8).Replace(".","-")
        r("有效日期") = s.SubString(102,8).Replace(".","-")
end if

yi  就是这段代码,除了日项外都正常了,日期一直是:20160711格式,不知道怎么写了。

[此贴子已经被作者于2016/7/11 17:22:54编辑过]

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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/11 18:35:00 [显示全部帖子]

这部分解决了,就差照片了

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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/13 17:44:00 [显示全部帖子]

解码也实现了(zp.bmp),但不能把照片文件加入到数据表,在表事件的DrawCell中加入如下代码:

If e.Col.Name = "照片" Then
    Dim s As String = "E:\baidudownload\农民要综合管理系统\images\zp.bmp"
    e.Graphics.DrawImage(getImage(s),e.X,e.Y,e.Width,e.Height)
End If

 

出现运行错误提示:

 

.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2016.6.26.1
错误所在事件:表,农民工实名制信息表,DrawCell
详细错误信息:
调用的目标发生了异常。
值不能为空。
参数名: image

在帮助中看了很长时间也没有找到解决办法,请指教!!


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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/13 18:23:00 [显示全部帖子]

这个做了,但表照片列中没有照片文件

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


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/13 23:52:00 [显示全部帖子]

5楼的代码是错的

 回到顶部
帅哥哟,离线,有人找我吗?
鲁吉
  7楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/14 12:37:00 [显示全部帖子]

也拷贝过去了,窗口的图片控件也能显示,就是在数据表里没有,我把窗口的timertrick事件的代码复制下来,是这样的:

For i As Integer = 1001 To 1001
    Dim portflag As Integer = 1001
    '变量声明
    Dim CardPUCIIN As Byte() = New Byte(254) {}
    Dim pucManaMsg As Byte() = New Byte(254) {}
    Dim pucCHMsg As Byte() = New Byte(254) {}
    Dim pucPHMsg As Byte() = New Byte(3023) {}
    Dim puiCHMsgLen As UInt32 = 0
    Dim puiPHMsgLen As UInt32 = 0
    Dim st As Integer = 0
    '读卡操作
    st = SDT_StartFindIDCard(portflag, CardPUCIIN, 1)
   
    If st <> &H9f Then
        Continue For
    End If
    st = SDT_SelectIDCard(portflag, pucManaMsg, 1)
   
    If st <> &H90 Then
        Continue For
    End If
    st = SDT_ReadBaseMsg(portflag, pucCHMsg, puiCHMsgLen, pucPHMsg, puiPHMsgLen, 1)
   
    If st <> &H90 Then
        Continue For
    End If
   
    Dim s As String =(System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg))
    If s.Length > 0 Then
        '分段截取字符串并赋给窗口控件
        Dim r As Row = Tables("农民工实名制信息表").AddNew
        r("姓名") = s.SubString(0,14).Replace(".","-")
        r("性别") = s.SubString(15,1).Replace(".","-")
        r("民族") = s.SubString(16,2).Replace(".","-")
        Dim tmp As String = s.Substring(18, 8).Replace(".", "-")
        r("出生日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
        r("家庭住址") = s.SubString(26,35).Replace(".","-")
        r("身份证号") = s.SubString(61,18).Replace(".","-")
        r("发证机关") = s.SubString(79,14).Replace(".","-")
        tmp = s.SubString(94,8).Replace(".","-")
        r("签发日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
        tmp = s.SubString(102,8).Replace(".","-")
        r("有效日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
         If (filesys.FileExists(ProjectPath & "zp.wlt")) Then
            '删除
            FileSys.DeleteFile(ProjectPath & "zp.wlt",2,3)
        End If
       
        system.io.File.WriteAllBytes(ProjectPath & "zp.wlt", pucPHMsg)
       
        Select Case GetBmp(ProjectPath & "zp.wlt", 2)
            Case 0
                MessageBox.Show("调用sdtapi.dll错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case 1
                '正常
                Exit Select
            Case -1
                MessageBox.Show("相片解码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -2
                MessageBox.Show("wlt文件后缀错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -3
                MessageBox.Show("wlt文件打开错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -4
                MessageBox.Show("wlt文件格式错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -5
                MessageBox.Show("软件未授权!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -6
                MessageBox.Show("设备连接错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
        End Select
       
        If (filesys.FileExists(ProjectPath & "zp.bmp")) Then
            FileSys.CopyFile(ProjectPath & "zp.bmp", ProjectPath & "\Attachments\" & r("身份证号") & ".bmp",True) '照片复制到Attachments目录
           e.Form.Controls("PictureBox1").imagefile = ProjectPath & "zp.bmp"
 
        End If

    End If
Next


 回到顶部
帅哥哟,离线,有人找我吗?
鲁吉
  8楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:710 积分:5345 威望:0 精华:0 注册:2013/5/27 9:48:00
  发帖心情 Post By:2016/7/14 12:39:00 [显示全部帖子]

窗口timertrick事件代码如下:

For i As Integer = 1001 To 1001
    Dim portflag As Integer = 1001
    '变量声明
    Dim CardPUCIIN As Byte() = New Byte(254) {}
    Dim pucManaMsg As Byte() = New Byte(254) {}
    Dim pucCHMsg As Byte() = New Byte(254) {}
    Dim pucPHMsg As Byte() = New Byte(3023) {}
    Dim puiCHMsgLen As UInt32 = 0
    Dim puiPHMsgLen As UInt32 = 0
    Dim st As Integer = 0
    '读卡操作
    st = SDT_StartFindIDCard(portflag, CardPUCIIN, 1)
   
    If st <> &H9f Then
        Continue For
    End If
    st = SDT_SelectIDCard(portflag, pucManaMsg, 1)
   
    If st <> &H90 Then
        Continue For
    End If
    st = SDT_ReadBaseMsg(portflag, pucCHMsg, puiCHMsgLen, pucPHMsg, puiPHMsgLen, 1)
   
    If st <> &H90 Then
        Continue For
    End If
   
    Dim s As String =(System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg))
    If s.Length > 0 Then
        '分段截取字符串并赋给窗口控件
        Dim r As Row = Tables("农民工实名制信息表").AddNew
        r("姓名") = s.SubString(0,14).Replace(".","-")
        r("性别") = s.SubString(15,1).Replace(".","-")
        r("民族") = s.SubString(16,2).Replace(".","-")
        Dim tmp As String = s.Substring(18, 8).Replace(".", "-")
        r("出生日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
        r("家庭住址") = s.SubString(26,35).Replace(".","-")
        r("身份证号") = s.SubString(61,18).Replace(".","-")
        r("发证机关") = s.SubString(79,14).Replace(".","-")
        tmp = s.SubString(94,8).Replace(".","-")
        r("签发日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
        tmp = s.SubString(102,8).Replace(".","-")
        r("有效日期") = (tmp.Substring(0, 4)) & "年" & (tmp.Substring(4, 2)) & "月" & (tmp.Substring(6, 2)) & "日"
         If (filesys.FileExists(ProjectPath & "zp.wlt")) Then
            '删除
            FileSys.DeleteFile(ProjectPath & "zp.wlt",2,3)
        End If
       
        system.io.File.WriteAllBytes(ProjectPath & "zp.wlt", pucPHMsg)
       
        Select Case GetBmp(ProjectPath & "zp.wlt", 2)
            Case 0
                MessageBox.Show("调用sdtapi.dll错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case 1
                '正常
                Exit Select
            Case -1
                MessageBox.Show("相片解码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -2
                MessageBox.Show("wlt文件后缀错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -3
                MessageBox.Show("wlt文件打开错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -4
                MessageBox.Show("wlt文件格式错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -5
                MessageBox.Show("软件未授权!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
            Case -6
                MessageBox.Show("设备连接错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                Exit Select
        End Select
       
        If (filesys.FileExists(ProjectPath & "zp.bmp")) Then
            FileSys.CopyFile(ProjectPath & "zp.bmp", ProjectPath & "\Attachments\" & r("身份证号") & ".bmp",True) '照片复制到Attachments目录
           e.Form.Controls("PictureBox1").imagefile = ProjectPath & "zp.bmp"
 
        End If

    End If
Next


 回到顶部