以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 关于根据订单日期列给订单添加订单编号的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147322) |
-- 作者:温馨的大树 -- 发布时间:2020/3/14 2:29:00 -- 关于根据订单日期列给订单添加订单编号的问题 订单明细表已经有相关订单,以前没有对订单进行编号,现在希望根据订单日期列的值,对每一行进行添加编号,格式为4位年2位月-00001五位整数编号,如201908-00005,编码如下,一直有报错,请问需要怎么修改啊,求助!谢谢! DataTables("订单明细表").StopRedraw Dim dt As DataTable = DataTables("订单明细表") Dim dat As List(of String) =dt.GetValues("订单日期") For Each mn As String In dat Dim y As String = cdate(mn).year Dim m1 As Integer = cdate(mn).month Dim m As String = Format(m1,"00") Dim z As String = y & m Dim drs As List(of DataRow) drs = DataTables("订单明细表").Select("[订单日期] = mn") For Each r As DataRow In drs Dim sum As Integer sum = sum+1 Dim sum1 As String = format(sum,"00000") r("订单编号1") = z & "-" & sum1 Next Next DataTables("订单明细表").ResumeRedraw
|
-- 作者:程兴刚 -- 发布时间:2020/3/14 5:18:00 -- drs = DataTables("订单明细表").Select("[订单日期] = #" & mn & "#") |
-- 作者:温馨的大树 -- 发布时间:2020/3/14 11:06:00 -- 回复:(程兴刚) drs = DataTables("订... 你好老师,修改了代码如下并执行,结果出现一个问题,如附件,想要的是编号规则是按照四位年两位月份作为前缀,再加“-”和“00000”格式的月订单流水号,但是目前代码不能实现月度流水号编号,请问怎么解快啊,谢谢! DataTables("订单明细表").StopRedraw Dim dt As DataTable = DataTables("订单明细表") Dim dat As List(of String) =dt.GetValues("订单日期") For Each mn As String In dat Dim y As String = cdate(mn).year Dim m1 As Integer = cdate(mn).month Dim m As String = Format(m1,"00") Dim z As String = y & m Dim drs As List(of DataRow) drs = DataTables("订单明细表").Select("[订单日期] = #" & mn &"#") For Each r As DataRow In drs Dim sum As Integer sum = sum+1 Dim sum1 As String = format(sum,"00000") r("订单编号") = z & "-" & sum1 Next DataTables("订单明细表").ResumeRedraw |
-- 作者:有点蓝 -- 发布时间:2020/3/14 11:29:00 -- 参考这种:http://www.foxtable.com/webhelp/topics/2403.htm |
-- 作者:程兴刚 -- 发布时间:2020/3/14 16:05:00 -- DataTables("订单明细表").StopRedraw Dim dt As DataTable = DataTables("订单明细表") Dim dat As List(of String) =dt.GetValues("订单日期") Dim d1,d2 As Date Dim Days As Integer For Each mn As String In dat Dim y As String = cdate(mn).year Dim m1 As Integer = cdate(mn).month d1= cdate(mn).AddMonths(-1) days = Date.DaysInMonth(d1.year,d1.Month) d1 = d1.Adddays(days - d1.day) d2 = d1.AddMonths(1) days = Date.DaysInMonth(d2.year,d2.Month) d2 = d2.Adddays(days - d2.day).adddays(1) Dim m As String = Format(m1,"00") Dim z As String = y & m Dim drs As List(of DataRow) drs = DataTables("订单明细表").Select("[订单日期] > #" & d1 & "# And [订单日期] < #" & d2 & "#") For Each r As DataRow In drs Dim sum As Integer sum = sum+1 Dim sum1 As String = format(sum,"00000") r("订单编号") = z & "-" & sum1 Next Next DataTables("订单明细表").ResumeRedraw [此贴子已经被作者于2020/3/14 16:06:51编辑过]
|