软件界面多国语言应用(英文/简体/繁体)-PB版本
author:chinayaosir=chinanetboy
blog:http://blog.csdn.net/chinayaosir
function:pb connect database sql server2000
系统新功能:
1.用户可以设置默认的语言
2.程序运行后,用户可以在英文/简体/繁体3都之间进行切换
3.数据库的连接可以由超级用户manager的密码动态设置
目录:
0.数据库表erp_baisc_users
1.数据库连接文件db.ini
2.语言配置文件language.ini
3.应用程序全局变量
4.应用程序对象清单
5.应用程序open事件代码
6.登录窗口w_login全部代码
6.0 语言选择ddlb_languaged事件代码
6.1 登录窗口控件清单
6.2 登录窗口的open事件代码
6.3 用户ID的ddlb_user控件selectionchanged事件代码
6.4 登录按钮cb_login控件的clicked事件代码
6.5 连接数据库参数按钮事件代码
7.密码验证窗口w_db_option_check
7.1控件清单
7.2密码验证窗口w_db_option_check的open事件代码
7.3按钮检查密码cb_checkpwd控件单击事件代码
8.数据库连接参数管理窗口w_db_option
8.1 控件清单:
8.2数据库连接参数管理窗口w_db_option的open事件
8.3窗口w_db_option的cb_default按钮的clicked事件
8.4窗口w_db_option的cb_read按钮的clicked事件
8.5窗口w_db_option的cb_Write按钮的clicked事件
/*———————————————————————————-*/
0.数据库表erp_baisc_users
table sql
create table erp_baisc_users
(
userid char(20) NOT NULL,
username char(30) NOT NULL,
password char(12) NULL default ‘654321’,
userofsite char(4) NULL default ”,
department varchar(20) NULL default ”,
statusflag char(1) NULL default ‘0’,
)
alter table erp_baisc_users
add constraint erp_baisc_users_pk PRIMARY KEY (userid)
create index erp_baisc_users_ik on erp_baisc_users(userid)
插入试验记录
userid username password userofsite department statusflag
DDG01 JORLIN 654321 HK IT 0
DDG03 DOREN 654321 HK QA 0
GZ-01 HAWEEN 654321 GZ QA 0
GZ-02 JESSE J GZ IT 0
/*———————————————————————————-*/
1.数据库连接文件db.ini
db.ini file
[DataBase]
ServerName =db
DBMS =MSS Microsoft SQL Server 6.x
Database =erp
LogId =sa
LogPassword =db11
/*———————————————————————————-*/
2.语言配置文件language.ini
[default]
language=Simplified
[english]
appname=PB demo program
language=language
Connect=&Connect DataBase
db_connect_manage=Database Connect Manage
servername=ServerName
database=Database
default=&Default
read =&Read
write =&Write
userid =UserID
username=UserName
PassWord=PassWord
login =&Login
exit =&Exit
checkpwd=Check Password
warning =Warning
password_error=password error
insert =&Insert
delete =&Delete
modify =&Modify
save =&Save
[Simplified]
appname=PB演示程序
language=语言选择
Connect=&C连接数据库
db_connect_manage=数据库连接参数管理
servername=服务器名称
database=数据库
default =&D缺省
read =&R读取
write =&W写入
userid =用户ID
username=用户名称
PassWord=用户密码
login =&L登录
exit =&E退出
checkpwd=&C检查密码
warning =警告
password_error=密码错误
insert =&I插入
delete =&D删除
modify =&M修改
save =&S保存
[Traditional]
appname=PB演示程式
language=語言選擇
Connect=&C連接資料庫
db_connect_manage=資料庫連接參數管理
servername=伺服器名稱
database=資料庫
default =&D缺省
read =&R讀取
write =&W寫入
userid =用戶ID
username=用戶名稱
PassWord=用戶密碼
login =&L登錄
exit =&E退出
checkpwd=&C檢查密碼
warning =警告
password_error=密碼錯誤
insert =&I插入
delete =&D刪除
modify =&M修改
save =&S保存
/*———————————————————————————-*/
3.应用程序全局变量
string ls_inifile =”E:/MTYJOB/PB-DEMO/db.ini”
string g_language_inifile =”E:/MTYJOB/PB-DEMO/language.ini”
string g_language=””
string as_server,as_dbms,as_database,as_logid,as_logpass
/*———————————————————————————-*/
4.应用程序对象清单
应用程序名称:demo
登陆窗口名称:w_login
密码验证窗口:w_db_option_check
数据库连接参数管理:w_db_option
主窗口:w_main
数据窗口:dw_userlist
/*———————————————————————————-*/
5.应用程序open事件代码
/*
1.连接数据库的方法定义
string connect_method= “INIFILE”
string connect_method= “SCRIPT”
*/
string connect_method= “INIFILE”
/************************************/
/*2.连接方式选择(ini文件/脚本)*/
Choose Case connect_method
/*以ini配置文件连接数据库*/
Case “INIFILE”
if FileExists (ls_inifile) then
as_server = ProfileString ( ls_inifile, “Database”, “Servername”, “”)
as_dbms = ProfileString ( ls_inifile, “Database”, “DBMS”, “”)
as_database = ProfileString ( ls_inifile, “Database”, “Database”, “”)
as_logid = ProfileString ( ls_inifile, “Database”, “LogID”, “”)
as_logpass = ProfileString ( ls_inifile, “Database”, “LogPassword”,””)
end if
/*以脚本直接连接数据库*/
Case “SCRIPT”
as_server = “db”
as_dbms = “MSS Microsoft SQL Server 6.x”
as_database = “erp”
as_logid = “sa”
as_logpass = “db1”
End Choose
SQLCA.DBMS = as_dbms
SQLCA.Database = as_database
SQLCA.LogPass = as_logpass
SQLCA.ServerName = as_server
SQLCA.LogId = as_logid
SQLCA.AutoCommit = false
SQLCA.DBParm = “”
/************************************/
/*3.打开连接*/
connect using SQLCA;
if SQLCA.SQLCode <> 0 Then
MessageBox (“Cannot Connect to Database”, SQLCA.SQLErrText )
end if
/************************************/
/*4.打开窗口*/
open(w_login)
/************************************/
/*———————————————————————————-*/
6.登录窗口w_login全部代码
6.0 语言选择ddlb_languaged事件代码
/*0.全局变量定义
string g_language
string g_language_inifile=”E:/MTYJOB/PB-DEMO/language.ini”
*/
/*1.读取用户选择的语言*/
g_language=trim(ddlb_language.text)
/*2.判断配置文件是否存在?*/
if not FileExists (g_language_inifile) then
return
end if
/*3.设置用户语言选择结果*/
choose case g_language
case “english” /*读取英文字母 */
g_language=”english”
case “Simplified” /*读取简体文字*/
g_language=”Simplified”
case “Traditional” /*读取繁体文字 */
g_language=”Traditional”
end choose
/*4.改变当前窗口控件的语言*/
w_login.title = ProfileString ( g_language_inifile, g_language, “appname”, “”)
st_language.text = ProfileString ( g_language_inifile, g_language, “language”, “”)
cb_db.text = ProfileString ( g_language_inifile, g_language, “Connect”, “”)
st_userid.text = ProfileString ( g_language_inifile, g_language, “userid”, “”)
st_username.text = ProfileString ( g_language_inifile, g_language, “username”, “”)
st_pwd.text = ProfileString ( g_language_inifile, g_language, “PassWord”,””)
cb_login.text = ProfileString ( g_language_inifile, g_language, “login”, “”)
cb_exit.text = ProfileString ( g_language_inifile, g_language, “exit”, “”)
/************************************/
6.1登录窗口控件清单
window:共1个
w_login title=User Login
statictext:共4个
st_language text=language
st_userid text=UserID
st_username text=UserName
st_pwd text=PassWord
dropdownlistbox:共2个
ddlb_language items={english,Simplified,Traditional} 功能:让用户选择语言
ddlb_user 功能:用户ID清单
singlelineedit:共2个
sle_username 功能:得到用户ID的得到用户名称
sle_pwd 功能:用户输入密码
commandbutton:共3个
cb_db text=&onnect Database
cb_login text=&Login default=true
cb_exit text=&Exit cancle=true
datawindows:共1个
dw_user dataojbect=dw_userlist
/************************************/
6.2 w_login窗口的open事件代码
/*1.得到用户清单*/
dw_user.visible=false
dw_user.settransobject(sqlca)
dw_user.retrieve()
/*2.添加用户ID到下拉列表中*/
int ii,ti
ti=dw_user.rowcount()
for ii=1 to ti
ddlb_user.additem(dw_user.object.userid[ii])
next
/*3装载默认的语言配置*/
g_language= ProfileString ( g_language_inifile, “default”, “language”, “”)
if FileExists (g_language_inifile) then
choose case g_language
case “english” /*读取英文字母 */
g_language=”english”
case “Simplified” /*读取简体文字*/
g_language=”Simplified”
case “Traditional” /*读取繁体文字 */
g_language=”Traditional”
end choose
w_login.title = ProfileString ( g_language_inifile, g_language, “appname”, “”)
st_language.text = ProfileString ( g_language_inifile, g_language, “language”, “”)
cb_db.text = ProfileString ( g_language_inifile, g_language, “Connect”, “”)
st_userid.text = ProfileString ( g_language_inifile, g_language, “userid”, “”)
st_username.text = ProfileString ( g_language_inifile, g_language, “username”, “”)
st_pwd.text = ProfileString ( g_language_inifile, g_language, “PassWord”,””)
cb_login.text = ProfileString ( g_language_inifile, g_language, “login”, “”)
cb_exit.text = ProfileString ( g_language_inifile, g_language, “exit”, “”)
end if
/************************************/
6.3 用户ID的ddlb_user控件selectionchanged事件代码
string c_userid,c_username
c_userid=trim(ddlb_user.text)
select username into:c_username
from erp_baisc_users
where userid=:c_userid using sqlca;
sle_username.text=c_username
/************************************/
6.4登录按钮cb_login控件的clicked事件代码
/*1.读取用户与密码*/
string c_user,c_pwd,right_pwd
c_user=””
c_pwd=””
right_pwd=””
c_user=trim(ddlb_user.text)
c_pwd=trim(sle_pwd.text)
/*2.判断用户与密码*/
select password into:right_pwd
from erp_baisc_users
where userid=:c_user using sqlca;
if right_pwd<>c_pwd then
/*3.密码错误翻译*/
string s_warning,s_password_error
s_warning=ProfileString ( g_language_inifile, g_language, “warning”, “”)
s_password_error=ProfileString ( g_language_inifile, g_language, “password_error”, “”)
messagebox(s_warning,s_password_error)
sle_pwd.text=””
sle_pwd.setfocus()
right_pwd=””
else
/*4.密码正确*/
/*打开主窗口*/
open(w_main)
//检查用户的菜单权限
/*关闭登录窗口*/
close(parent)
end if
/************************************/
6.5 连接数据库参数按钮clicked事件代码
open(w_db_option_check)
/*———————————————————————————-*/
7.密码验证窗口w_db_option_check
7.1控件清单
statictext:共2个
st_username text:username 功能:用户名称
st_pwd text:password 功能:密码
singlelineedit:共2个
sle_user text:admin enable:false功能:用户名为admin
sle_pwd text:manage password:true
/************************************/
7.2密码验证窗口w_db_option_check的open事件代码
/*1.判断配置文件是否存在?*/
if not FileExists (g_language_inifile) then
return
end if
/*2.改变当前窗口控件的语言*/
this.title = ProfileString ( g_language_inifile, g_language, “warning”, “”)
st_username.text = ProfileString ( g_language_inifile, g_language, “username”, “”)
st_pwd.text = ProfileString ( g_language_inifile, g_language, “PassWord”, “”)
cb_checkpwd.text = ProfileString ( g_language_inifile, g_language, “checkpwd”, “”)
/************************************/
7.3按钮检查密码cb_checkpwd控件单击事件代码
/*1.警告框信息文字翻译*/
string s_warning,s_password_error
s_warning=ProfileString ( g_language_inifile, g_language, “warning”, “”)
s_password_error=ProfileString ( g_language_inifile, g_language, “password_error”, “”)
/*2.密码输入检查*/
if sle_pwd.text=”admin” then
open(w_db_option)
else
messagebox(s_warning,s_password_error)
end if
close(parent)
/*———————————————————————————-*/
8.数据库连接参数管理窗口w_db_option
8.1 控件清单:
statictext:共5个
st_servername text=servername
st_dbms text=DBMS
st_database text=DataBase
st_userid text=UserID
st_password text=PassWord
singlelineedit:共5个
sle_servername 对应st_servername
sle_dbms 对应st_dbms
sle_database 对应st_database
sle_logid 对应st_userid
sle_logpassword 对应st_password,password=true
commandbotton:共3个
cb_default text=&Default
cb_read text=&Read
cb_Write text=&Write
/************************************/
8.2数据库连接参数管理窗口w_db_option的open事件
/*1.判断配置文件是否存在?*/
if not FileExists (g_language_inifile) then
return
end if
/*2.改变当前窗口控件的语言*/
this.title = ProfileString ( g_language_inifile, g_language, “db_connect_manage”, “”)
st_servername.text = ProfileString ( g_language_inifile, g_language, “servername”, “”)
st_Database.text = ProfileString ( g_language_inifile, g_language, “Database”, “”)
st_userid.text = ProfileString ( g_language_inifile, g_language, “userid”, “”)
st_PassWord.text = ProfileString ( g_language_inifile, g_language, “PassWord”, “”)
cb_default.text = ProfileString ( g_language_inifile, g_language, “default”, “”)
cb_read.text = ProfileString ( g_language_inifile, g_language, “read”, “”)
cb_write.text = ProfileString ( g_language_inifile, g_language, “write”, “”)
/************************************/
8.3数据库连接参数管理窗口w_db_option的open事件
/*1.判断配置文件是否存在?*/
if not FileExists (g_language_inifile) then
return
end if
/*2.改变当前窗口控件的语言*/
this.title = ProfileString ( g_language_inifile, g_language, “db_connect_manage”, “”)
st_servername.text = ProfileString ( g_language_inifile, g_language, “servername”, “”)
st_Database.text = ProfileString ( g_language_inifile, g_language, “Database”, “”)
st_userid.text = ProfileString ( g_language_inifile, g_language, “userid”, “”)
st_PassWord.text = ProfileString ( g_language_inifile, g_language, “PassWord”, “”)
cb_default.text = ProfileString ( g_language_inifile, g_language, “default”, “”)
cb_read.text = ProfileString ( g_language_inifile, g_language, “read”, “”)
cb_write.text = ProfileString ( g_language_inifile, g_language, “write”, “”)
/************************************/
8.4窗口w_db_option的cb_default按钮的clicked事件
/*0.设置默认连接参数到5个全局变量*/
as_server = “MTY-DATABASE”
as_dbms = “MSS Microsoft SQL Server 6.x”
as_database = “erp”
as_logid = “sa”
as_logpass = “mtysql2000”
/*1.五个全局变量到五个文本框*/
sle_servername.text = as_server
sle_dbms.text = as_dbms
sle_database.text = as_database
sle_logpassword.text = as_logpass
sle_logid.text = as_logid
/*2.设置默认连接参数更新到db.ini文件中*/
if FileExists (ls_inifile) then
SetProfileString ( ls_inifile, “Database”, “Servername”, as_server)
SetProfileString ( ls_inifile, “Database”, “DBMS”, as_dbms)
SetProfileString ( ls_inifile, “Database”, “Database”, as_database)
SetProfileString ( ls_inifile, “Database”, “LogID”, as_logid)
SetProfileString ( ls_inifile, “Database”, “LogPassword”,as_logpass)
end if
/************************************/
8.4窗口w_db_option的cb_read按钮的clicked事件
/*读取db.ini文件设置值到文本框*/
if FileExists (ls_inifile) then
sle_servername.text = ProfileString ( ls_inifile, “Database”, “Servername”, “”)
sle_dbms.text = ProfileString ( ls_inifile, “Database”, “DBMS”, “”)
sle_database.text = ProfileString ( ls_inifile, “Database”, “Database”, “”)
sle_logid.text = ProfileString ( ls_inifile, “Database”, “LogID”, “”)
sle_logpassword.text = ProfileString ( ls_inifile, “Database”, “LogPassword”,””)
end if
/************************************/
8.5窗口w_db_option的cb_Write按钮的clicked事件
/*1.设置参数值存入5个全局变量*/
as_server =trim(sle_servername.text)
as_dbms =trim(sle_dbms.text)
as_database =trim(sle_database.text)
as_logid =trim(sle_logid.text)
as_logpass =trim(sle_logpassword.text)
/*2.检查参数是否都输入完毕?*/
if len(as_server)=0 or len(as_dbms)=0 or len(as_database)=0 or len(as_logid)=0 or len(as_logpass)=0 then
messagebox(“Warning!”,”can’t be null,pls check server,dbms,database,logid,logpass!”)
return
end if
/*3.设置参数写入db.ini文件中*/
if FileExists (ls_inifile) then
SetProfileString ( ls_inifile, “Database”, “Servername”, as_server)
SetProfileString ( ls_inifile, “Database”, “DBMS”, as_dbms)
SetProfileString ( ls_inifile, “Database”, “Database”, as_database)
SetProfileString ( ls_inifile, “Database”, “LogID”, as_logid)
SetProfileString ( ls_inifile, “Database”, “LogPassword”,as_logpass)
end if
/*4.重新连接数据库,并关闭此窗口*/
disconnect using SQLCA;
connect using SQLCA;
if SQLCA.SQLCode <> 0 Then
MessageBox (“Cannot Connect to Database”, SQLCA.SQLErrText )
end if
close(parent)
st_pwd.textnbsp; quot;,
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/35992.html