Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共12 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:上传单号新增

11楼
nuoyan89 发表于:2024/6/19 14:20:00
问题描述:击新增一行或者新增多行后,上传单号自动递增,前提是第一个需要先查询表中的最大码,然后点击新增按照后自动按1递增。各项代码如下:
上传单号新增号的代码写在表DataColChanged 中
1、If e.DataCol.Name = "上传日期" Then
    If e.DataRow.IsNull("上传日期") Then
        e.DataRow("上传单号") = Nothing
    Else
        e.DataRow.save
        Dim bh As String = Format(e.DataRow("上传日期"), "yyMM") ' 取得编号的8位前缀
        If e.DataRow("上传单号").StartsWith(bh) = False Then'如果编号的前8位不符
            Dim dt2 As DataTable = DataTables("发动机记录表")
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.SQLCompute("Max(上传单号)", "上传单号 like '" & "ZK" & bh & "%' And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(6, 3)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            e.DataRow("上传单号") = "ZK" & bh & Format(idx, "000")
            e.DataRow.save
        End If
    End If
End If
2、上传日期赋值代码:DataRowAdding事件
e.DataRow("上传日期") = Date.Today
e.DataRow("上传人员") = _UserName

3、新增多行代码:ItemClick 事件
        Syscmd.Row.AddNews()
12楼
有点蓝 发表于:2024/6/19 14:31:00
DataRowAdding事件代码改为放到DataRowAdded事件
共12 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01563 s, 2 queries.