| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1994 人关注过本帖
标题:PB60取值问题
只看楼主 加入收藏
caosa1974
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-6
收藏
 问题点数:0 回复次数:1 
PB60取值问题
我这边有个用PB60编写的程序,现在发现使用数据库其中一个表中的字段的值进行自动编号时发生了问题.当数值在0-32767时编号都正确,但到了32768时就变成了-32768,以后就固定为-32768,编号也就成了负的了.谁知道其中原因么?
编号程序如下:
   Integer    li_i, li_loop, li_count, li_length, li_idx, li_serial, li_find
String     ls_flag, ls_desc, ls_module, ls_orgbracode, ls_orgmodule, ls_orgserial, ls_date, ls_codetype,ls_edit_flag
n_cst_string    lnv_string
Boolean    lb_find    // lb_autocode

CHOOSE CASE dwo.name
    CASE 'conform'    
        IF wf_checkconform(row, dwo, data) < 0 THEN
            IF data = 'Y' THEN
                SetItem(row, 'conform', 'N')
            ELSE
                SetItem(row, 'conform', 'Y')
            END IF
            SetItemStatus(row, 'conform', Primary!, NotModified! )
            RETURN 1
        END IF
        IF dw_inquery.GetItemString(dw_inquery.GetRow(), 'conform') = 'N' THEN        // 确认操作
            IF GetItemString(row, 'keepmodule') <> GetItemString(row, 'desmodule') THEN
                
                li_loop = FindGroupChange ( row + 1, 1)                
                IF li_loop = 0 THEN
                    li_loop = rowcount()
                ELSE
                    li_loop --
                END IF

                ls_module = GetItemString(row, 'keepmodule')
                li_count = 0
                FOR li_i = row - 1 TO 1 STEP -1
                    IF ls_module <> GetItemString(li_i, 'keepmodule') THEN
                        li_count = li_i
                        EXIT
                    END IF
                NEXT

                li_length = GetItemNumber(row, 'length')
                lb_find = FALSE

                FOR li_i = row - 1 TO li_count + 1 STEP -1
                    IF GetItemString(li_i, 'conform') = 'Y' THEN
                        lb_find = TRUE
                        li_count = Integer(Right(GetItemString(li_i, 'masno'), li_length) )
                        li_serial = GetItemNumber(li_i, 'serial')
                        EXIT
                    END IF
                NEXT
                
            
                IF NOT(lb_find) THEN
                    li_count = GetItemNumber(row, 'mod_masno')
                    li_serial = GetItemNumber(row, 'mod_seq')
                END IF
                
                ls_module = GetItemString(row, 'desmodule')                
                li_idx = 0
                ls_orgbracode = GetItemString(row, 'bracode')
                ls_orgmodule  = GetItemString(row, 'module')
                
//                IF GetItemString(row, 'conform') = 'Y' AND GetItemString(row, 'status') = '1' THEN    
//                    li_idx ++    
//                    IF lb_autocode THEN    SetItem(row, 'masno', ls_module + String(li_count + li_idx , Fill('0', li_length)))
//                    IF li_type > 1 THEN
//                        li_find = dw_detail.Find("bracode = '" + ls_orgbracode + "' AND module = '" + ls_orgmodule + "' AND serial = " + String(GetItemNumber(row, 'serial')) , 1, dw_detail.RowCount())
//                        IF li_find > 0 THEN
//                            dw_detail.SetItem(li_find, 'serial', li_serial + li_idx )
//                        ELSE
//                            MessageBox('错误', '主表与从表不一致!')
//                            HALT
//                        END IF
//                    END IF
//                    SetItem(row, 'serial', li_serial + li_idx )                        
//                END IF

                li_find = 0
                ls_date = String(fn_getsrvtime(), 'yyyymmdd')
                ls_codetype = GetItemString(row, 'codetype')
                
                FOR li_i = row TO li_loop        // 确认操作,自动编号(更正帐、负方帐除外)。
                    IF GetItemString(li_i, 'conform') = 'Y' AND GetItemString(li_i, 'status') = '1' THEN
                        li_idx ++    
                        IF ls_codetype = '1' THEN    
                            SetItem(li_i, 'masno', ls_module + String(li_count + li_idx , Fill('0', li_length)))
                        ELSEIF ls_codetype = '2' THEN
                            SetItem(li_i, 'masno', ls_date + String(li_count + li_idx , Fill('0', li_length)))
                        ELSEIF ls_codetype = '3' THEN
                            SetItem(li_i, 'masno', ls_module + ls_date + String(li_count + li_idx , Fill('0', li_length)))
                        ELSEIF ls_codetype = '4' THEN
                            THIS.DYNAMIC wf_genmasno(ls_module, ls_date, li_count + li_idx)
                        END IF
                        IF li_type > 1 THEN                            
                            IF li_i = row THEN
                                li_find = dw_detail.Find("bracode = '" + ls_orgbracode + "' AND module = '" + ls_orgmodule + "' AND serial = " + String(GetItemNumber(li_i, 'serial')) , li_find + 1, dw_detail.RowCount())
//                                messagebox('',ls_orgbracode + '+'+ls_orgmodule +'+'+ String(GetItemNumber(li_i, 'serial')) )
                            ELSE
                                li_find = dw_detail.Find("bracode = '" + ls_orgbracode + "' AND module = '" + ls_module + "' AND serial = " + String(GetItemNumber(li_i, 'serial')) , li_find + 1, dw_detail.RowCount())
                            END IF
                            IF li_find > 0 THEN
                                dw_detail.SetItem(li_find, 'serial', li_serial + li_idx )
                            ELSE
                                
                                MessageBox('错误', '主表与从表不一致!')
                                HALT
                            END IF
                        END IF
                        SetItem(li_i, 'serial', li_serial + li_idx )                        
                    END IF
                NEXT
            END IF
            IF data = 'Y' THEN
                SetItem(row, 'module', GetItemString(row, 'desmodule'))
                IF li_type > 1 THEN
                    li_find = dw_detail.Find("bracode = '" + ls_orgbracode + "' AND module = '" + ls_orgmodule + "' AND serial = " + String(GetItemNumber(row, 'serial')) , 1, dw_detail.RowCount())    
                    dw_detail.SetItem(li_find, 'module', GetItemString(row, 'desmodule'))
                END IF
                ////     add by shijizhi
                ls_edit_flag=GetItemString(row, 'flag')
                if ls_edit_flag='' or isnull(ls_edit_flag) then
                    SetItem(row, 'flag', '!')
                else
                    SetItem(row, 'flag', GetItemString(row, 'flag') + '!')
                end if
                ////        end add
            ELSE
                IF li_type > 1 THEN
                    li_find = dw_detail.Find("bracode = '" + ls_orgbracode + "' AND module = '" + ls_orgmodule + "' AND serial = " + String(GetItemNumber(row, 'serial')) , 1, dw_detail.RowCount())        
                    dw_detail.SetItem(li_find, 'module', GetItemString(row, 'module', Primary!, TRUE))
                    dw_detail.SetItem(li_find, 'serial', GetItemNumber(row, 'serial', Primary!, TRUE) )                            
                END IF
                SetItem(row, 'module', GetItemString(row, 'module', Primary!, TRUE))
                SetItem(row, 'flag', GetItemString(row, 'flag', Primary!, TRUE) )        
                SetItem(row, 'masno', GetItemString(row, 'masno', Primary!, TRUE) )        
                SetItem(row, 'serial', GetItemNumber(row, 'serial', Primary!, TRUE) )        
            END IF
        ELSE
            IF data = 'Y' THEN
                SetItem(row, 'flag', GetItemString(row, 'flag', Primary!, TRUE) )        
            ELSE
                SetItem(row, 'flag', lnv_string.of_globalreplace(GetItemString(row, 'flag'), '!', '') )        
            END IF
        END IF
END CHOOSE

RETURN 0
搜索更多相关主题的帖子: 数据库 
2008-05-06 11:16
freele_china
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:JiNan
等 级:版主
威 望:6
帖 子:352
专家分:0
注 册:2007-4-6
收藏
得分:0 
定义数值型变量的时候不要使用 Integer 使用DEC/Long 就可以啦
因为Integer 的长度不够!!!

雁过留声,人过留名
2008-05-08 17:40
快速回复:PB60取值问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024933 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved