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