一、人民币大写转换
string ls_hz1[] , ls_hz2[] , ls_return , ls_temp , ls_argument
int li_1 , li_len
boolean lb_first_zero
ls_hz1[1] = "分"
ls_hz1[2] = "角"
ls_hz1[3] = ""
ls_hz1[4] = "元"
ls_hz1[5] = "拾"
ls_hz1[6] = "佰"
ls_hz1[7] = "仟"
ls_hz1[8] = "万"
ls_hz1[9] = "拾"
ls_hz1[10] = "佰"
ls_hz1[11] = "仟"
ls_hz1[12] = "亿"
ls_hz1[13] = "拾"
ls_hz1[14] = "佰"
ls_hz1[15] = "仟"
ls_hz2[1] = "壹"
ls_hz2[2] = "贰"
ls_hz2[3] = "叁"
ls_hz2[4] = "肆"
ls_hz2[5] = "伍"
ls_hz2[6] = "陆"
ls_hz2[7] = "柒"
ls_hz2[8] = "捌"
ls_hz2[9] = "玖"
ls_hz2[10] = "零"
If ad_amout = 0 Then
Return ''
End If
ls_argument = string( ad_amout ,"############0.00")
If len( ls_argument ) > 15 Then
Return ''
End If
If right(ls_argument,1) = '0' Then ls_return = '整'
Do While True
li_1 += 1
li_len = len( ls_argument )
ls_temp = right( ls_argument , 1 )
ls_argument = left( ls_argument , li_len - 1 )
If ls_temp = '' Or isnull( ls_temp ) Then
Exit
End If
If ls_temp = '.' Then
Continue
End If
If ls_temp = '-' Then
ls_return = '负' + ls_return
Continue
End If
If ls_temp <> '0' Then
ls_return = ls_hz2[integer(ls_temp)] + ls_hz1[ li_1 ] + ls_return
lb_first_zero = True
Else
If lb_first_zero Then
if (li_1 <> 4 And li_1 <> 2) Or dec(ls_argument) <> 0 Then
ls_return = '零' + ls_return
End If
lb_first_zero = False
End If
If li_1 = 12 Or li_1 = 8 Then
If right(ls_argument, 3) <> '000' Then ls_return = ls_hz1[ li_1] + ls_return
End If
If li_1 = 4 Then
If dec(ls_argument) <> 0 Then ls_return = ls_hz1[ li_1 ] + ls_return
End If
End If
Loop
Return ls_return
二、PB身份证号码正确性校验
string ls_identity_no
string ls_year,ls_month,ls_day,ls_date
string ls_today
long ll_year
long ll_identity_no_len
ls_identity_no = as_identity
ls_today = string(today(),'yyyy/mm/dd')
ll_identity_no_len=LEN(ls_identity_no)
if ls_identity_no = '' then
MessageBox("系统提示","身份证号码不能为空!!",StopSign!,ok!)
return False
elseif ll_identity_no_len <> 15 AND ll_identity_no_len <> 18 then
MessageBox("系统提示","身份证号码位数不足,请检查输入情况!!",StopSign!,ok!)
return False
end if
if ll_identity_no_len = 15 then
ls_year = mid(ls_identity_no, 7, 2)
ls_month = mid(ls_identity_no, 9, 2)
ls_day = mid(ls_identity_no, 11, 2)
ls_year = '19' + ls_year
ls_date = ls_year +'/' + ls_month +'/' + ls_day
else
ls_year = mid(ls_identity_no, 7, 4)
if Left(ls_year,2) <> '19' and left(ls_year,2) <> '20' then
MessageBox("系统提示","身份证号码中的出生年份不正确, 请您重新输入! ",StopSign!,ok!)
return False
end if
ls_month = mid(ls_identity_no, 11, 2)
ls_day = mid(ls_identity_no, 13, 2)
ls_date = ls_year +'/' + ls_month +'/' + ls_day
end if
if ls_month > '12' then
MessageBox("系统提示","身份证号码中的出生月份大于12, 请您重新输入 ",StopSign!,ok!)
return False
elseif ls_month < '1' then
MessageBox("系统提示","身份证号码中的出生月份小于01, 请您重新输入 ",StopSign!,ok!)
return False
end if
if ls_day < '01' then
MessageBox("系统提示","身份证号码的出生日小于01, 请您重新输入 !",StopSign!,ok!)
return False
end if
CHOOSE CASE ls_month
CASE '01','03','05','07','08','10','12'
if ls_day > '31' then
MessageBox("系统提示","身份证号码的出生日大于31, 请您重新输入 !",StopSign!,ok!)
return False
end if
CASE '04','06','05','09','11'
if ls_day > '30' then
MessageBox("系统提示","身份证号码的出生日大于30, 请您重新输入 !",StopSign!,ok!)
return False
end if
CASE '02'
ll_year = long(ls_year)
if (mod(ll_year,4) = 0 and Mod(ll_year,100)<>0) or (Mod(ll_year,400) = 0) then
if ls_day > '29' then
MessageBox("系统提示","闰年的二月份没有" + ls_day + "日,请重新输入出生日期!",StopSign!,ok!)
return False
end if
else
if ls_day > '28' then
MessageBox("系统提示","平年的二月份没有" + ls_day + "日,请重新输入出生日期!",StopSign!,ok!)
return 提lse
end if
end if
END CHOOSE
if ls_date > ls_today then
MessageBox("系统提示","身份证号码的出生日期小于登记日期,不合理请您重新输入 !",StopSign!,ok!)
return False
end if
return True
三、从数据库中取数据添加到DDLB控件中的通用函数
// 从数据库中取数据添加到DDLB控件中的通用函数
// 同时适用于listbox控件
// 变量设置:return type:integer
// Pass By Argument Type Function Name
// value string table_name
// value string column_name
// value dropdownlistbox ddlb_parm
// value string where_clause
// value any where_variable
//
// 调用格式:
// uf_ddlb_from_db(table_name,column_name,ddlb_parm,where_clause,where_variable)
// 例如:uf_ddlb_from_db("专业表,院系表","专业名称",ddlb_1,"(专业表.院系名称 = 院系表.院系代码) AND 院系表.院系名称 = ?",yx_name)
// uf_ddlb_from_db("t_city_dictionary","cd_city",tab_1.tabpage_1.ddlb_76,"cd_province = ?","辽宁")
string ls_add_string,ls_select_string
string where_var_string
real where_var_num
int li_pos
//根据传递的参数设置select语句
if len(trim(where_clause)) = 0 then
ls_select_string = "SELECT DISTINCT " + column_name + " FROM " + table_name
else
ls_select_string = "SELECT DISTINCT " + column_name + " FROM " + table_name + " WHERE " + where_clause
end if
DECLARE dyn_cursor DYNAMIC CURSOR FOR sqlsa;
PREPARE sqlsa FROM :ls_select_string;
if len(trim(where_clause)) > 0 then
if classname(where_variable) = 'string' then
if len(trim(where_variable)) = 0 then
OPEN DYNAMIC dyn_cursor;
else
where_var_string = where_variable
OPEN DYNAMIC dyn_cursor using :where_var_string;
end if
end if
if classname(where_variable) = 'real' then
where_var_string = where_variable
OPEN DYNAMIC dyn_cursor using :where_var_num;
end if
else
OPEN DYNAMIC dyn_cursor;
end if
if sqlca.sqlcode < 0 then
MessageBox("数据库错误!",sqlca.sqlerrtext)
return sqlca.sqlcode
end if
ddlb_parm.SetRedraw(false)
ddlb_parm.reset()
Do While sqlca.sqlcode = 0
Fetch dyn_cursor into :ls_add_string;
if sqlca.sqlcode = 0 then
ddlb_parm.AddItem(ls_add_string)
elseif sqlca.sqlcode < 0 then
MessageBox("数据库错误!",sqlca.sqlerrtext)
return sqlca.sqlcode
else
exit
end
if
Loop
ddlb_parm.SetRedraw(true)
Close dyn_cursor;
return 0
四、数据窗口列名轮询代码
//*********************************************************
//轮询数据窗口列名
//*********************************************************
String ls_display
String ls_column_name[] //存放列名
String ls_column_text[] //存放列标题名称
Integer i,li_column_count
//得到数据窗口的总列数
li_column_count = long(ds_1.Describe("DataWindow.Column.Count"))
//循环依次读取
for i = 1 to li_column_count
ls_column_name[i] = ds_1.Describe("#"+string(i)+".name")
ls_column_text[i] = ds_1.Describe(ls_column_name[i] + "_t.text")
ls_display += '列名:' + ls_column_name[i] + '; 存放列标题名称:' + ls_column_text[i] + '~r~n'
next
messagebox('显示',ls_display)
//*********************************************************