$PBExportHeader$w_set_book.srw forward global type w_set_book from w_publ_base end type type cb_ok from uo_imflatbutton within w_set_book end type type cb_connect from uo_imflatbutton within w_set_book end type type st_1 from statictext within w_set_book end type type sle_bookname from singlelineedit within w_set_book end type type st_2 from statictext within w_set_book end type type sle_database from singlelineedit within w_set_book end type type st_10 from statictext within w_set_book end type type rb_1 from radiobutton within w_set_book end type type rb_2 from radiobutton within w_set_book end type type cb_1 from commandbutton within w_set_book end type type st_11 from statictext within w_set_book end type type sle_fjname from singlelineedit within w_set_book end type type cb_ch3 from commandbutton within w_set_book end type type sle_filename from singlelineedit within w_set_book end type type cb_ch2 from commandbutton within w_set_book end type type st_13 from statictext within w_set_book end type type sle_folder from singlelineedit within w_set_book end type type cb_2 from commandbutton within w_set_book end type type st_8 from statictext within w_set_book end type type cbx_fj from checkbox within w_set_book end type type cbx_yj from checkbox within w_set_book end type type sle_yjname from singlelineedit within w_set_book end type type cb_ch4 from commandbutton within w_set_book end type type st_12 from statictext within w_set_book end type type ddlb_1 from dropdownlistbox within w_set_book end type type cbx_modify from checkbox within w_set_book end type type sle_sqldb_mdf_sor from singlelineedit within w_set_book end type type sle_sqldb_ldf_sor from singlelineedit within w_set_book end type type sle_bookcode from singlelineedit within w_set_book end type type gb_3 from groupbox within w_set_book end type type gb_1 from groupbox within w_set_book end type type gb_2 from groupbox within w_set_book end type end forward global type w_set_book from w_publ_base integer width = 2263 integer height = 1296 string title = "帐套设置" boolean minbox = false windowtype windowtype = response! long backcolor = 16777215 boolean center = true cb_ok cb_ok cb_connect cb_connect st_1 st_1 sle_bookname sle_bookname st_2 st_2 sle_database sle_database st_10 st_10 rb_1 rb_1 rb_2 rb_2 cb_1 cb_1 st_11 st_11 sle_fjname sle_fjname cb_ch3 cb_ch3 sle_filename sle_filename cb_ch2 cb_ch2 st_13 st_13 sle_folder sle_folder cb_2 cb_2 st_8 st_8 cbx_fj cbx_fj cbx_yj cbx_yj sle_yjname sle_yjname cb_ch4 cb_ch4 st_12 st_12 ddlb_1 ddlb_1 cbx_modify cbx_modify sle_sqldb_mdf_sor sle_sqldb_mdf_sor sle_sqldb_ldf_sor sle_sqldb_ldf_sor sle_bookcode sle_bookcode gb_3 gb_3 gb_1 gb_1 gb_2 gb_2 end type global w_set_book w_set_book type prototypes Subroutine Sleep(ulong dwMilliseconds) LIBRARY "kernel32.dll" Function long ShellExecuteA (long hwnd, string lpOperation ,String lpFile, String lpParameters, String lpDirectory, Long nShowCmd) Library "shell32.dll" alias for "ShellExecuteA;Ansi" Function long GetFullPathName (String lpFileName ,Long nBufferLength,ref string lpBuffer,ref long lpFilePart) library "kernel32" ALIAS FOR "GetFullPathNameA;Ansi" end prototypes type variables long ins_bookid = 0 string ins_servername string ins_logid string ins_logpass string masterpath //string mssqlpath long ins_rslt = 0 long ins_ifguid = 0 end variables forward prototypes public subroutine wf_facechange () public function integer wf_buildsqldb (ref string arg_msg) public function integer wf_chk_database (string arg_databasename, transaction arg_transaction) public function integer wf_create_database (string arg_folder, string arg_databasename, string arg_filename, string arg_sqldb_mdf_sor, string arg_sqldb_ldf_sor, transaction arg_transaction, boolean arg_ifcommit, ref string arg_msg) public function integer wf_drop_database (string arg_databasename, transaction arg_transaction, boolean arg_ifcommit, ref string arg_msg) end prototypes public subroutine wf_facechange ();IF rb_2.Checked THEN cb_1.Text = '︾' cb_1.Visible = false st_11.Visible = false ELSE cb_1.Visible = true st_11.Visible = true END IF long ph ph = 150 IF cb_1.Text = '︽' THEN This.Height = 1216 + ph gb_2.Visible = True st_12.Visible = True ddlb_1.Visible = True cbx_modify.Visible = True st_8.Visible = True sle_filename.Visible = true cb_ch2.Visible = true cbx_fj.Visible = true sle_fjname.visible = true cb_ch3.visible = true cbx_yj.visible = true sle_yjname.visible = true cb_ch4.visible = true st_13.visible = true sle_folder.visible = true cb_2.visible = true cb_ok.Y = 1084 cb_exit.Y = 1084 cb_connect.Y = 1084 ELSE This.Height = 596 + ph gb_2.Visible = false st_12.Visible = false ddlb_1.Visible = false cbx_modify.Visible = false st_8.Visible = false sle_filename.Visible = false cb_ch2.Visible = false cbx_fj.Visible = false sle_fjname.visible = false cb_ch3.visible = false cbx_yj.visible = false sle_yjname.visible = false cb_ch4.visible = false st_13.visible = false sle_folder.visible = false cb_2.visible = false cb_ok.Y = 472 cb_exit.Y = 472 cb_connect.Y = 472 END IF end subroutine public function integer wf_buildsqldb (ref string arg_msg);//wf_buildsqldb Integer li_FileNum,rslt = 1 String comm,msg Long i,j,lu_return String ls_test String ls_dat String ls_databasename String ls_filename Transaction db_Transaction db_Transaction = Create Transaction Open(w_sys_wait) IF Trim(sle_folder.Text) = '' THEN arg_msg = '请输入目标文件路径!' rslt = 0 GOTO ext END IF Int ll_result ll_result = createdirectory(sle_folder.Text) //IF ll_result = -1 THEN // arg_msg = '目标文件路径创建失败!' // rslt = 0 // GOTO ext //END IF ls_dat = sle_filename.Text IF Not FileExists ( ls_dat ) THEN arg_msg = "主数据库文件不存在!" rslt = 0 GOTO ext END IF IF rb_1.Checked THEN ls_dat = Trim(sle_fjname.Text) IF Not FileExists ( ls_dat ) THEN arg_msg = "附件数据库文件不存在!" rslt = 0 GOTO ext END IF END IF IF cbx_yj.Checked THEN ls_dat = Trim(sle_yjname.Text) IF Not FileExists ( ls_dat ) THEN arg_msg = "邮件数据库文件不存在!" rslt = 0 GOTO ext END IF END IF w_sys_wait.wf_set_msg("正在尝试新建数据库,此过程预计需要用时1分钟...") db_Transaction.DBMS = "SNC SQL Native Client(OLE DB)" db_Transaction.Database = 'master' db_Transaction.UserID = ins_logid db_Transaction.DBPass = ins_logpass db_Transaction.LogID = ins_logid db_Transaction.LogPass = ins_logpass db_Transaction.ServerName = ins_servername db_Transaction.Lock = "RU" db_Transaction.AutoCommit = False db_Transaction.DBParm = "Database= 'master' ,PBTrimCharColumns='YES'" IF db_Transaction.Database = '' Or db_Transaction.ServerName = '' THEN arg_msg = "连接数据库失败!" rslt = 0 GOTO ext END IF CONNECT Using db_Transaction; db_Transaction.AutoCommit = True IF db_Transaction.SQLCode <> 0 THEN DISCONNECT Using db_Transaction; arg_msg = '服务器连接失败!!' rslt = 0 GOTO ext END IF //检查主数据库 ls_databasename = Trim(sle_database.Text) IF wf_chk_database(ls_databasename, db_Transaction) = 1 THEN IF MessageBox ("询问","主数据库已存在,是否确定要覆盖?",Question!,YesNo! ) = 2 THEN rslt = 2 GOTO ext ELSE IF wf_drop_database(ls_databasename, db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF //检查附件数据库 ls_databasename = Trim(sle_database.Text)+ '_fj' IF wf_chk_database(ls_databasename, db_Transaction) = 1 THEN IF MessageBox ("询问","附件数据库已存在,是否确定要覆盖?",Question!,YesNo! ) = 2 THEN rslt = 2 GOTO ext ELSE IF wf_drop_database(ls_databasename, db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF //检查邮件数据库 ls_databasename = Trim(sle_database.Text) + '_yj' IF wf_chk_database(ls_databasename, db_Transaction) = 1 THEN IF MessageBox ("询问","邮件数据库已存在,是否确定要覆盖?",Question!,YesNo! ) = 2 THEN rslt = 2 GOTO ext ELSE IF wf_drop_database(ls_databasename, db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF END IF END IF //新建主数据库 ls_databasename = Trim(sle_database.Text) ls_filename = Trim(sle_filename.Text) //st_jd.Text = '正在新建主数据库' IF wf_create_database(sle_folder.Text, ls_databasename, ls_filename, sle_sqldb_mdf_sor.Text, sle_sqldb_ldf_sor.Text, db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF comm = "DELETE FROM " + Trim(sle_database.Text) + ".dbo.U_OuterConnection" EXECUTE Immediate :comm Using db_Transaction; //新建附件数据库 IF cbx_fj.Checked THEN ls_databasename = Trim(sle_database.Text)+ '_fj' ls_filename = Trim(sle_fjname.Text) // st_jd.Text = '正在新建附件数据库' IF wf_create_database(sle_folder.Text, ls_databasename, ls_filename, 'filemanage_Data', 'filemanage_Log', db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF String ls_MDF,ls_ldf ls_MDF = ls_databasename + ".MDF" ls_ldf = ls_databasename + ".ldf" comm = "INSERT INTO " + Trim(sle_database.Text) + ".dbo.U_OuterConnection ("+& "ConnectionID ,"+& "DBMS ,"+& "ConnectionName ,"+& "ConnectionType ,"+& "DataBaseName ,"+& "ServerName ,"+& "LogId ,"+& "LogPass ,"+& "mdf_name ,"+& "ldf_name ,"+& "opdate"+& ")"+& "VALUES"+& "("+& "11,"+& "'MSS Microsoft SQL Server 6.x',"+& "'附件数据库',"+& "0,"+& "'" + ls_databasename + "',"+& "'" + db_Transaction.ServerName+"',"+& "'" + db_Transaction.LogID + "',"+& "'" + db_Transaction.LogPass + "',"+& "'" + ls_MDF + "',"+& "'" + ls_ldf + "',"+& "getdate()"+& ");" EXECUTE Immediate :comm Using db_Transaction; IF db_Transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '设置附件数据库连接失败,请手动设置,' + db_Transaction.SQLErrText GOTO ext END IF END IF //新建邮件数据库 IF cbx_yj.Checked THEN ls_databasename = Trim(sle_database.Text) + '_yj' ls_filename = Trim(sle_yjname.Text) // st_jd.Text = '正在新建邮件数据库' IF wf_create_database(sle_folder.Text, ls_databasename, ls_filename, 'filemanage_Data', 'filemanage_Log', db_Transaction, False, arg_msg) = 0 THEN rslt = 0 GOTO ext END IF ls_MDF = ls_databasename + ".MDF" ls_ldf = ls_databasename + ".ldf" comm = "INSERT INTO " + Trim(sle_database.Text) + ".dbo.U_OuterConnection ("+& "ConnectionID ,"+& "DBMS ,"+& "ConnectionName ,"+& "ConnectionType ,"+& "DataBaseName ,"+& "ServerName ,"+& "LogId ,"+& "LogPass ,"+& "mdf_name ,"+& "ldf_name ,"+& "opdate"+& ")"+& "VALUES"+& "("+& "12,"+& "'MSS Microsoft SQL Server 6.x',"+& "'邮件数据库',"+& "2,"+& "'" + ls_databasename + "',"+& "'" + db_Transaction.ServerName+"',"+& "'" + db_Transaction.LogID + "',"+& "'" + db_Transaction.LogPass + "',"+& "'" + ls_MDF + "',"+& "'" + ls_ldf + "',"+& "getdate()"+& ");" EXECUTE Immediate :comm Using db_Transaction; IF db_Transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '设置邮件数据库连接失败,请手动设置,' + db_Transaction.SQLErrText GOTO ext END IF END IF ext: w_sys_wait.Hide() Close(w_sys_wait) IF rslt = 1 THEN COMMIT Using db_Transaction; ELSE ROLLBACK Using db_Transaction; END IF DISCONNECT Using db_Transaction; Destroy db_Transaction RETURN rslt end function public function integer wf_chk_database (string arg_databasename, transaction arg_transaction);String ls_test ls_test = "if exists(select 1 from master..sysdatabases where name='" + arg_databasename + "') raiserror('Database existed',18,1) else raiserror('Database not existed',18,1) " EXECUTE Immediate :ls_test Using arg_transaction; IF pos(arg_transaction.SQLErrText , 'Database existed' ) > 0 THEN RETURN 1 ELSE RETURN 0 END IF end function public function integer wf_create_database (string arg_folder, string arg_databasename, string arg_filename, string arg_sqldb_mdf_sor, string arg_sqldb_ldf_sor, transaction arg_transaction, boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1 String comm comm = ' create DATABASE '+arg_databasename+& " on(name='"+arg_sqldb_mdf_sor+"',FILENAME= '"+arg_folder + '\' + arg_databasename+'_data.ldf'+"') log on (name='"+arg_sqldb_ldf_sor+"',FILENAME= '"+arg_folder + '\' + arg_databasename+'_log.ldf'+"')" EXECUTE Immediate :comm Using arg_transaction; IF arg_transaction.SQLCode <> 0 THEN arg_msg = '建立数据库['+arg_databasename+']失败,请手动建立及恢复>'+arg_transaction.SQLErrText rslt = 0 GOTO ext END IF // st_jd.Text = '正在恢复主数据库...' comm = 'RESTORE DATABASE '+arg_databasename+" from DISK= '"+arg_filename+"'"+& " WITH MOVE '"+arg_sqldb_mdf_sor+"' TO '"+arg_folder + '\' + arg_databasename+'_data.ldf'+"',"+& " MOVE '"+arg_sqldb_ldf_sor+"' TO '"+arg_folder + '\' + arg_databasename+'_log.ldf'+"',"+'REPLACE' EXECUTE Immediate :comm Using arg_transaction; IF arg_transaction.SQLCode <> 0 THEN arg_msg = '恢复数据库['+arg_databasename+']失败,请手动恢复>'+arg_transaction.SQLErrText rslt = 0 END IF ext: IF rslt = 0 THEN ROLLBACK Using arg_transaction; ELSEIF arg_ifcommit THEN COMMIT Using arg_transaction; END IF RETURN rslt end function public function integer wf_drop_database (string arg_databasename, transaction arg_transaction, boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1 String comm comm = " IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'" + arg_databasename + "') DROP DATABASE [" + arg_databasename + "]" EXECUTE Immediate :comm Using arg_Transaction; IF arg_Transaction.SQLCode <> 0 THEN arg_msg = '删除数据库失败,请手动删除['+arg_databasename+']>'+arg_Transaction.SQLErrText rslt = 0 ELSE rslt = 1 END IF IF rslt = 0 THEN ROLLBACK Using arg_Transaction; ELSEIF arg_ifcommit THEN COMMIT Using arg_Transaction; END IF RETURN rslt end function on w_set_book.create int iCurrent call super::create this.cb_ok=create cb_ok this.cb_connect=create cb_connect this.st_1=create st_1 this.sle_bookname=create sle_bookname this.st_2=create st_2 this.sle_database=create sle_database this.st_10=create st_10 this.rb_1=create rb_1 this.rb_2=create rb_2 this.cb_1=create cb_1 this.st_11=create st_11 this.sle_fjname=create sle_fjname this.cb_ch3=create cb_ch3 this.sle_filename=create sle_filename this.cb_ch2=create cb_ch2 this.st_13=create st_13 this.sle_folder=create sle_folder this.cb_2=create cb_2 this.st_8=create st_8 this.cbx_fj=create cbx_fj this.cbx_yj=create cbx_yj this.sle_yjname=create sle_yjname this.cb_ch4=create cb_ch4 this.st_12=create st_12 this.ddlb_1=create ddlb_1 this.cbx_modify=create cbx_modify this.sle_sqldb_mdf_sor=create sle_sqldb_mdf_sor this.sle_sqldb_ldf_sor=create sle_sqldb_ldf_sor this.sle_bookcode=create sle_bookcode this.gb_3=create gb_3 this.gb_1=create gb_1 this.gb_2=create gb_2 iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.cb_ok this.Control[iCurrent+2]=this.cb_connect this.Control[iCurrent+3]=this.st_1 this.Control[iCurrent+4]=this.sle_bookname this.Control[iCurrent+5]=this.st_2 this.Control[iCurrent+6]=this.sle_database this.Control[iCurrent+7]=this.st_10 this.Control[iCurrent+8]=this.rb_1 this.Control[iCurrent+9]=this.rb_2 this.Control[iCurrent+10]=this.cb_1 this.Control[iCurrent+11]=this.st_11 this.Control[iCurrent+12]=this.sle_fjname this.Control[iCurrent+13]=this.cb_ch3 this.Control[iCurrent+14]=this.sle_filename this.Control[iCurrent+15]=this.cb_ch2 this.Control[iCurrent+16]=this.st_13 this.Control[iCurrent+17]=this.sle_folder this.Control[iCurrent+18]=this.cb_2 this.Control[iCurrent+19]=this.st_8 this.Control[iCurrent+20]=this.cbx_fj this.Control[iCurrent+21]=this.cbx_yj this.Control[iCurrent+22]=this.sle_yjname this.Control[iCurrent+23]=this.cb_ch4 this.Control[iCurrent+24]=this.st_12 this.Control[iCurrent+25]=this.ddlb_1 this.Control[iCurrent+26]=this.cbx_modify this.Control[iCurrent+27]=this.sle_sqldb_mdf_sor this.Control[iCurrent+28]=this.sle_sqldb_ldf_sor this.Control[iCurrent+29]=this.sle_bookcode this.Control[iCurrent+30]=this.gb_3 this.Control[iCurrent+31]=this.gb_1 this.Control[iCurrent+32]=this.gb_2 end on on w_set_book.destroy call super::destroy destroy(this.cb_ok) destroy(this.cb_connect) destroy(this.st_1) destroy(this.sle_bookname) destroy(this.st_2) destroy(this.sle_database) destroy(this.st_10) destroy(this.rb_1) destroy(this.rb_2) destroy(this.cb_1) destroy(this.st_11) destroy(this.sle_fjname) destroy(this.cb_ch3) destroy(this.sle_filename) destroy(this.cb_ch2) destroy(this.st_13) destroy(this.sle_folder) destroy(this.cb_2) destroy(this.st_8) destroy(this.cbx_fj) destroy(this.cbx_yj) destroy(this.sle_yjname) destroy(this.cb_ch4) destroy(this.st_12) destroy(this.ddlb_1) destroy(this.cbx_modify) destroy(this.sle_sqldb_mdf_sor) destroy(this.sle_sqldb_ldf_sor) destroy(this.sle_bookcode) destroy(this.gb_3) destroy(this.gb_1) destroy(this.gb_2) end on event open;call super::open;s_set_book_parm s_parm s_parm = Message.PowerObjectParm IF IsNull(s_parm) THEN ins_bookid = 0 ins_ifguid = 0 ELSE ins_bookid = s_parm.bookid ins_ifguid = s_parm.ifguid END IF IF IsNull(ins_bookid) THEN ins_bookid = 0 END IF IF ins_bookid <= 0 THEN ins_bookid = 1 END IF IF ins_bookid > 20 THEN ins_bookid = 20 END IF sle_bookcode.Text = String(ins_bookid, '00') IF sys_cur_path = "" THEN Long rslt = 1 String lpBuffer lpBuffer = Fill('',200) Long lpfilepart,li_FileNum rslt = GetFullPathName(sys_inifilename,196,lpBuffer,lpfilepart) sys_cur_path = Left(lpBuffer,Len(lpBuffer)-Len(sys_inifilename)) END IF ins_servername = ProfileString (sys_inifilename, "database", "servername", "") ins_logid = ProfileString (sys_inifilename, "database", "logid", "SA") ins_logpass = f_psw_bczh(ProfileString (sys_inifilename, "database", "LogPassWord", ""),1,sys_power_key) sle_sqldb_mdf_sor.Text = ProfileString (sys_inifilename, "database", "sqldb_mdf_sor", '') sle_sqldb_ldf_sor.Text = ProfileString (sys_inifilename, "database", "sqldb_ldf_sor",'' ) String ls_fjname, ls_yjname ls_fjname = ProfileString (sys_inifilename, "database", "defaultfjdb",'' ) ls_yjname = ProfileString (sys_inifilename, "database", "defaultyjdb",'' ) IF ls_fjname = "" THEN ls_fjname = "企精灵附件数据库" END IF IF ls_yjname = "" THEN ls_yjname = "企精灵邮件数据库" END IF sle_fjname.Text = sys_cur_path + ls_fjname +'.dat' sle_yjname.Text = sys_cur_path + ls_yjname +'.dat' Long i String ls_temp FOR i = 1 To 3 ls_temp = ProfileString (sys_inifilename, "database", "demodb" + String(i), '') IF ls_temp <> '' THEN ddlb_1.AddItem (ls_temp) END IF IF i = 1 THEN ddlb_1.Text = ls_temp sle_filename.Text = sys_cur_path + ddlb_1.Text + '.dat' END IF NEXT masterpath = sys_cur_path + 'database' sle_folder.Text = masterpath String ls_ini_book String ins_bookcode Long ins_ifuse ls_ini_book = ProfileString (sys_inifilename_other,'sys_dl_book', String(ins_bookid), '') IF ls_ini_book <> '' THEN sle_bookname.Text = Mid(ls_ini_book,1,Pos(ls_ini_book,':') -1 ) ls_ini_book = Replace(ls_ini_book,1,Pos(ls_ini_book,':') ,'') sle_database.Text = Mid(ls_ini_book,1,Pos(ls_ini_book,':') -1 ) ls_ini_book = Replace(ls_ini_book,1,Pos(ls_ini_book,':') ,'') ins_bookcode = Mid(ls_ini_book,1,Pos(ls_ini_book,':') -1 ) ls_ini_book = Replace(ls_ini_book,1,Pos(ls_ini_book,':') ,'') ins_ifuse = Long(ls_ini_book) rb_2.Checked = True ELSE sle_database.Text = "EW5_DB" // rb_1.Checked = True END IF cb_1.Text = '︾' IF ins_ifguid = 1 THEN This.Title = '2.' + This.Title gb_1.Text = '2.' + gb_1.Text cb_ok.Text = '完成' END IF wf_facechange() end event event close;call super::close;closewithreturn(this, ins_rslt) end event type cb_func from w_publ_base`cb_func within w_set_book boolean visible = false end type type cb_exit from w_publ_base`cb_exit within w_set_book integer x = 1838 integer y = 1084 end type type cb_ok from uo_imflatbutton within w_set_book integer x = 1426 integer y = 1084 integer width = 311 integer height = 96 integer taborder = 20 boolean bringtotop = true string normalpicname = "ok.bmp" end type event clicked;call super::clicked;IF Trim(sle_bookname.Text) = '' THEN MessageBox('系统提示','请输入帐套!',information!,OK!) RETURN END IF IF Trim(sle_database.Text) = '' THEN MessageBox('系统提示','请输入数据库!',information!,OK!) RETURN END IF IF rb_1.Checked THEN String ls_msg Int ll_rslt ll_rslt = wf_buildsqldb(ls_msg) //1-成功 IF ll_rslt = 0 THEN //错误 MessageBox("提示",ls_msg,information!,OK!) RETURN ELSEIF ll_rslt = 2 THEN //取消 RETURN END IF END IF SetProfileString (sys_inifilename, "database", "bookname", sle_bookname.Text ) SetProfileString (sys_inifilename, "database", "database", sle_database.Text) SetProfileString (sys_inifilename, "database", "sqldb_mdf_sor", sle_sqldb_mdf_sor.Text) SetProfileString (sys_inifilename, "database", "sqldb_ldf_sor", sle_sqldb_ldf_sor.Text) //增加一个帐套 String ls_ini_book string is_bookcode Long id String ifuse is_bookcode = string(ins_bookid, '00') id = ins_bookid String ls_temp ls_temp = Trim(sle_bookname.Text) + ':'+& Trim(sle_database.Text)+ ':'+& is_bookcode+':'+& '1' //SetProfileString (sys_inifilename_other,'sys_dl_book', '1', f_psw_bczh(ls_temp,0,sys_power_key)) SetProfileString (sys_inifilename_other,'sys_dl_book', String(id), ls_temp) SetProfileString(sys_inifilename,'longjoews','LastAcount',Trim(sle_bookname.Text)) SetProfileString (sys_inifilename, "database", "firstrun","0") ins_rslt = 1 close(parent) //MessageBox('提示','设置保存完成!系统必须重启!') // //Restart() end event type cb_connect from uo_imflatbutton within w_set_book integer x = 283 integer y = 1084 integer width = 315 integer height = 96 integer taborder = 90 boolean bringtotop = true string text = "测试连接" end type event clicked;call super::clicked;String ls_database = "master" IF rb_2.Checked THEN ls_database = sle_database.Text END IF Open(w_sys_wait) w_sys_wait.wf_set_msg("正在尝试连接数据库,此过程预计需要用时1分钟...") Transaction db_Transaction db_Transaction = Create Transaction db_Transaction.DBMS = "SNC SQL Native Client(OLE DB)" db_Transaction.Database = ls_database db_Transaction.UserID = ins_logid db_Transaction.DBPass = ins_logpass db_Transaction.LogID = ins_logid db_Transaction.LogPass = ins_logpass db_Transaction.ServerName = ins_servername db_Transaction.Lock = "RU" db_Transaction.AutoCommit = False db_Transaction.DBParm = "Database= '" + ls_database + "',PBTrimCharColumns='YES'" CONNECT Using db_Transaction; Int rslt = 1 String arg_msg = '' IF db_Transaction.SQLCode < 0 THEN rslt = 0 arg_msg = "连接数据库失败!" IF Pos(db_Transaction.SQLErrText, "'"+ins_logid+"'") > 0 THEN arg_msg = arg_msg + "用户密码错误!" END IF IF Pos(db_Transaction.SQLErrText, "'"+ls_database+"'") > 0 THEN arg_msg = arg_msg + "数据库不存在!" END IF ELSE rslt = 1 END IF DISCONNECT Using db_Transaction; Destroy db_Transaction; Close(w_sys_wait) IF rslt = 0 THEN MessageBox("系统提示",arg_msg) ELSE MessageBox("系统提示","连接数据库成功!") END IF end event type st_1 from statictext within w_set_book integer x = 146 integer y = 128 integer width = 256 integer height = 60 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 long backcolor = 16777215 boolean enabled = false string text = "帐套名称:" alignment alignment = right! boolean focusrectangle = false end type type sle_bookname from singlelineedit within w_set_book integer x = 416 integer y = 116 integer width = 1504 integer height = 80 integer taborder = 20 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 string text = "演示帐套" boolean autohscroll = false borderstyle borderstyle = stylelowered! end type type st_2 from statictext within w_set_book integer x = 105 integer y = 228 integer width = 297 integer height = 60 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 long backcolor = 16777215 boolean enabled = false string text = "数据库名称:" alignment alignment = right! boolean focusrectangle = false end type type sle_database from singlelineedit within w_set_book integer x = 416 integer y = 216 integer width = 1655 integer height = 80 integer taborder = 30 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 boolean autohscroll = false borderstyle borderstyle = stylelowered! end type type st_10 from statictext within w_set_book integer x = 78 integer y = 328 integer width = 325 integer height = 60 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 long backcolor = 16777215 boolean enabled = false string text = "初始化类型:" alignment alignment = right! boolean focusrectangle = false end type type rb_1 from radiobutton within w_set_book integer x = 457 integer y = 336 integer width = 402 integer height = 60 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 boolean enabled = false string text = "新建数据库" end type event clicked;wf_facechange() end event type rb_2 from radiobutton within w_set_book integer x = 887 integer y = 336 integer width = 466 integer height = 60 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "连接现有数据库" boolean checked = true end type event clicked;wf_facechange() end event type cb_1 from commandbutton within w_set_book integer x = 1742 integer y = 316 integer width = 82 integer height = 84 integer taborder = 20 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "︾" end type event clicked;IF cb_1.Text = '︽' THEN cb_1.Text = '︾' ELSE cb_1.Text = '︽' END IF wf_facechange() end event type st_11 from statictext within w_set_book integer x = 1833 integer y = 332 integer width = 233 integer height = 48 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "高级选项" boolean focusrectangle = false end type type sle_fjname from singlelineedit within w_set_book integer x = 416 integer y = 744 integer width = 1655 integer height = 80 integer taborder = 170 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type cb_ch3 from commandbutton within w_set_book integer x = 2080 integer y = 744 integer width = 114 integer height = 84 integer taborder = 220 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "..." end type event clicked; Integer i String Pathname,Filename i = GetFileSaveName("选择备份文件",Pathname,Filename,"Dat","数据文件Dat,*.Dat") IF i = 1 AND Trim(Pathname) <> '' AND Trim(Filename) <> "" THEN sle_fjname.Text = Pathname END IF end event type sle_filename from singlelineedit within w_set_book integer x = 416 integer y = 640 integer width = 1655 integer height = 80 integer taborder = 160 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 boolean enabled = false borderstyle borderstyle = stylelowered! end type type cb_ch2 from commandbutton within w_set_book integer x = 2080 integer y = 640 integer width = 114 integer height = 84 integer taborder = 210 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" boolean enabled = false string text = "..." end type event clicked; Integer i String Pathname,Filename i = GetFileSaveName("选择备份文件",Pathname,Filename,"Dat","数据文件Dat,*.Dat") IF i = 1 AND Trim(Pathname) <> '' AND Trim(Filename) <> "" THEN sle_filename.Text = Pathname END IF end event type st_13 from statictext within w_set_book integer x = 32 integer y = 976 integer width = 370 integer height = 76 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 boolean enabled = false string text = "目标文件路径:" alignment alignment = right! boolean focusrectangle = false end type type sle_folder from singlelineedit within w_set_book integer x = 416 integer y = 960 integer width = 1655 integer height = 80 integer taborder = 200 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type cb_2 from commandbutton within w_set_book integer x = 2080 integer y = 960 integer width = 114 integer height = 84 integer taborder = 250 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "..." end type event clicked; // //GetFolder() //功 能:显示文件夹选择对话框。 //语 法:GetFolder (title , director ) //参 数:title:String类型,指定文件夹选择框的标题; // directory:String类型,文件夹的路径,即指定显示哪个文件夹下的子文件夹,又用于保存用户最终选择的文件夹的路径。 //返回值:Integer。函数执行成功时返回1,发生错误时返回-1。当用户选择了”取消”按钮或直接关闭对话框,函数返回0。 //示 例:This example displays the folder contents of the Sybase directory in a folder selection dialog box. The string passed in the title argument displays above the tree view: string ls_path integer li_result ls_path = mid(sys_cur_path,1,len(sys_cur_path )- 1) li_result = GetFolder( "目标文件路径", ls_path ) sle_folder.text=ls_path end event type st_8 from statictext within w_set_book integer x = 32 integer y = 652 integer width = 370 integer height = 76 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 boolean enabled = false string text = "主数据库:" alignment alignment = right! boolean focusrectangle = false end type type cbx_fj from checkbox within w_set_book integer x = 27 integer y = 756 integer width = 375 integer height = 60 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "附件数据库:" boolean checked = true end type event clicked;if rb_2.checked then return IF cbx_fj.Checked THEN sle_fjname.Enabled = TRUE cb_ch3.Enabled = TRUE ELSE sle_fjname.Enabled = FALSE cb_ch3.Enabled = FALSE END IF end event type cbx_yj from checkbox within w_set_book integer x = 27 integer y = 864 integer width = 384 integer height = 60 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "邮件数据库:" boolean checked = true end type event clicked;IF rb_2.Checked THEN RETURN IF cbx_yj.Checked THEN sle_yjname.Enabled = TRUE cb_ch4.Enabled = TRUE ELSE sle_yjname.Enabled = FALSE cb_ch4.Enabled = FALSE END IF end event type sle_yjname from singlelineedit within w_set_book integer x = 416 integer y = 852 integer width = 1655 integer height = 80 integer taborder = 180 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type cb_ch4 from commandbutton within w_set_book integer x = 2080 integer y = 852 integer width = 114 integer height = 84 integer taborder = 240 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "..." end type event clicked; Integer i String Pathname,Filename i = GetFileSaveName("选择备份文件",Pathname,Filename,"Dat","数据文件Dat,*.Dat") IF i = 1 AND Trim(Pathname) <> '' AND Trim(Filename) <> "" THEN sle_yjname.Text = Pathname END IF end event type st_12 from statictext within w_set_book integer x = 105 integer y = 540 integer width = 297 integer height = 60 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 long backcolor = 16777215 boolean enabled = false string text = "数据库来源:" alignment alignment = right! boolean focusrectangle = false end type type ddlb_1 from dropdownlistbox within w_set_book integer x = 416 integer y = 532 integer width = 1166 integer height = 300 integer taborder = 40 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type event selectionchanged;sle_filename.text = sys_cur_path + this.text + '.dat' end event type cbx_modify from checkbox within w_set_book integer x = 1600 integer y = 540 integer width = 311 integer height = 60 integer taborder = 50 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "手动修改" end type event clicked;IF THIS.Checked THEN ddlb_1.Enabled = FALSE cb_ch2.Enabled = TRUE sle_filename.Enabled = TRUE sle_filename.text = '' ELSE ddlb_1.Enabled = TRUE cb_ch2.Enabled = FALSE sle_filename.Enabled = FALSE sle_filename.text = sys_cur_path + ddlb_1.text + '.dat' END IF end event type sle_sqldb_mdf_sor from singlelineedit within w_set_book boolean visible = false integer x = 1582 integer y = 372 integer width = 1655 integer height = 80 integer taborder = 190 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type sle_sqldb_ldf_sor from singlelineedit within w_set_book boolean visible = false integer x = 1582 integer y = 464 integer width = 1655 integer height = 80 integer taborder = 230 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type type sle_bookcode from singlelineedit within w_set_book integer x = 1934 integer y = 116 integer width = 137 integer height = 80 integer taborder = 30 boolean bringtotop = true integer textsize = -8 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "MS Sans Serif" long textcolor = 41943040 boolean enabled = false string text = "none" boolean displayonly = true borderstyle borderstyle = stylelowered! end type type gb_3 from groupbox within w_set_book integer x = 416 integer y = 296 integer width = 1051 integer height = 120 integer taborder = 300 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 16711680 long backcolor = 16777215 end type type gb_1 from groupbox within w_set_book integer x = 18 integer y = 48 integer width = 2217 integer height = 388 integer taborder = 270 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "帐套设置" end type type gb_2 from groupbox within w_set_book integer x = 18 integer y = 452 integer width = 2217 integer height = 612 integer taborder = 280 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 16777215 string text = "高级选项" end type