$PBExportHeader$w_billstyle_import.srw forward global type w_billstyle_import from window end type type sle_filename_in from singlelineedit within w_billstyle_import end type type cb_1 from commandbutton within w_billstyle_import end type type cb_exit from commandbutton within w_billstyle_import end type type cb_import from commandbutton within w_billstyle_import end type type cb_ch from commandbutton within w_billstyle_import end type type sle_filename_out from singlelineedit within w_billstyle_import end type type cb_export from commandbutton within w_billstyle_import end type type gb_1 from groupbox within w_billstyle_import end type type gb_2 from groupbox within w_billstyle_import end type end forward global type w_billstyle_import from window integer x = 814 integer y = 864 integer width = 2304 integer height = 900 boolean titlebar = true string title = "单据抬头导入导出" boolean controlmenu = true windowtype windowtype = response! long backcolor = 134217739 sle_filename_in sle_filename_in cb_1 cb_1 cb_exit cb_exit cb_import cb_import cb_ch cb_ch sle_filename_out sle_filename_out cb_export cb_export gb_1 gb_1 gb_2 gb_2 end type global w_billstyle_import w_billstyle_import type variables BOOLEAN OL_BACKUP=TRUE end variables on w_billstyle_import.create this.sle_filename_in=create sle_filename_in this.cb_1=create cb_1 this.cb_exit=create cb_exit this.cb_import=create cb_import this.cb_ch=create cb_ch this.sle_filename_out=create sle_filename_out this.cb_export=create cb_export this.gb_1=create gb_1 this.gb_2=create gb_2 this.Control[]={this.sle_filename_in,& this.cb_1,& this.cb_exit,& this.cb_import,& this.cb_ch,& this.sle_filename_out,& this.cb_export,& this.gb_1,& this.gb_2} end on on w_billstyle_import.destroy destroy(this.sle_filename_in) destroy(this.cb_1) destroy(this.cb_exit) destroy(this.cb_import) destroy(this.cb_ch) destroy(this.sle_filename_out) destroy(this.cb_export) destroy(this.gb_1) destroy(this.gb_2) end on event open;IF Message.DoubleParm = 1 THEN OL_BACKUP=FALSE END IF end event type sle_filename_in from singlelineedit within w_billstyle_import event key pbm_keydown integer x = 133 integer y = 428 integer width = 1586 integer height = 92 integer taborder = 40 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type event key;if trim(this.text)="" then cb_import.enabled=false else cb_import.enabled=OL_BACKUP end if end event event modified;if trim(this.text)="" then cb_import.enabled=false else cb_import.enabled=OL_BACKUP end if end event type cb_1 from commandbutton within w_billstyle_import integer x = 1719 integer y = 428 integer width = 114 integer height = 92 integer taborder = 20 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "..." end type event clicked;//new integer i string pathname,filename i=getfilesavename("选择备份文件",pathname,filename,"Dbf","数据文件Dbf,*.Dbf") IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN cb_import.enabled=OL_BACKUP sle_filename_in.text=pathname END IF end event type cb_exit from commandbutton within w_billstyle_import integer x = 1838 integer y = 668 integer width = 320 integer height = 96 integer taborder = 80 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "退出" end type event clicked;close(parent) end event type cb_import from commandbutton within w_billstyle_import integer x = 1838 integer y = 428 integer width = 320 integer height = 96 integer taborder = 50 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" boolean enabled = false string text = "导入" end type event clicked;IF NOT sys_power_issuper THEN MessageBox('提示','你没有使用权限!', Information!, OK! ) RETURN END IF datastore ds_setting ds_setting = CREATE datastore ds_setting.DataObject = 'ds_billstyle_import' ds_setting.SetTransObject(sqlca) ds_setting.ImportFile(sle_filename_in.Text) ds_setting.AcceptText() IF ds_setting.RowCount() <= 0 THEN MessageBox('提示','你导入的系统单据抬头文件没有数据', Information!, OK! ) RETURN END IF Long ll_id_arr[] String ls_firststr_arr[] String ls_datestyle_arr[] String ls_dscrp_arr[] Long ll_cnt = 1 DECLARE cur_billcode CURSOR FOR SELECT u_billcode.id, u_billcode.firststr, u_billcode.datestyle, u_billcode.dscrp FROM u_billcode Where u_billcode.firststr <> '' or u_billcode.datestyle <> 'yymmdd'; OPEN cur_billcode; FETCH cur_billcode INTO :ll_id_arr[ll_cnt], :ls_firststr_arr[ll_cnt], :ls_datestyle_arr[ll_cnt], :ls_dscrp_arr[ll_cnt]; DO WHILE sqlca.SQLCode = 0 ll_cnt++ FETCH cur_billcode INTO :ll_id_arr[ll_cnt], :ls_firststr_arr[ll_cnt], :ls_datestyle_arr[ll_cnt], :ls_dscrp_arr[ll_cnt]; LOOP CLOSE cur_billcode; ll_cnt = ll_cnt - 1 DELETE FROM u_billcode; IF sqlca.SQLCode <> 0 THEN MessageBox('错误','删除原系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! ) RETURN END IF Long ll_i Long ll_id String ls_firststr String ls_datestyle String ls_dscrp String ls_oldfirststr String ls_billstyle String ls_win1 String ls_win2 String ls_tablename String ls_codename String ls_module FOR ll_i = 1 TO ds_setting.RowCount() ll_id = ds_setting.Object.id[ll_i] ls_firststr = ds_setting.Object.firststr[ll_i] ls_datestyle = ds_setting.Object.datestyle[ll_i] ls_dscrp = ds_setting.Object.dscrp[ll_i] ls_oldfirststr = ds_setting.Object.oldfirststr[ll_i] ls_billstyle = ds_setting.Object.billstyle[ll_i] ls_win1 = ds_setting.Object.win1[ll_i] ls_win2 = ds_setting.Object.win2[ll_i] ls_tablename = ds_setting.Object.tablename[ll_i] ls_codename = ds_setting.Object.codename[ll_i] ls_module = ds_setting.Object.module[ll_i] INSERT INTO u_billcode(id, firststr, datestyle, dscrp, oldfirststr, billstyle, win1, win2, tablename, codename, module) VALUES(:ll_id, :ls_firststr, :ls_datestyle, :ls_dscrp, :ls_oldfirststr, :ls_billstyle, :ls_win1, :ls_win2, :ls_tablename, :ls_codename, :ls_module); IF sqlca.SQLCode <> 0 THEN MessageBox('错误','新增系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! ) ROLLBACK; RETURN END IF NEXT FOR ll_i = 1 TO ll_cnt UPDATE u_billcode SET firststr = :ls_firststr_arr[ll_i], datestyle = :ls_datestyle_arr[ll_i], dscrp = :ls_dscrp_arr[ll_i] Where id = :ll_id_arr[ll_i]; IF sqlca.SQLCode <> 0 THEN MessageBox('错误','更新改变系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! ) ROLLBACK; RETURN END IF NEXT COMMIT; MessageBox('提示','导入系统功能数据成功', Information!, OK! ) end event type cb_ch from commandbutton within w_billstyle_import integer x = 1719 integer y = 128 integer width = 114 integer height = 92 integer taborder = 20 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" string text = "..." end type event clicked;//new integer i string pathname,filename i=getfilesavename("选择导出文件",pathname,filename,"Dbf","数据文件Dbf,*.Dbf") IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN cb_export.enabled=OL_BACKUP sle_filename_out.text=pathname END IF end event type sle_filename_out from singlelineedit within w_billstyle_import event key pbm_keydown integer x = 133 integer y = 128 integer width = 1586 integer height = 92 integer taborder = 10 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 borderstyle borderstyle = stylelowered! end type event key;if trim(this.text)="" then cb_export.enabled=false else cb_export.enabled=OL_BACKUP end if end event event modified;if trim(this.text)="" then cb_export.enabled=false else cb_export.enabled=OL_BACKUP end if end event type cb_export from commandbutton within w_billstyle_import integer x = 1838 integer y = 128 integer width = 320 integer height = 96 integer taborder = 30 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" boolean enabled = false string text = "导出" end type event clicked;IF NOT sys_power_issuper THEN MessageBox('提示','你没有使用权限!', Information!, OK! ) RETURN END IF string arg_filename,arg_msg blob arg_blob arg_filename = trim(sle_filename_out.text) if arg_filename = '' then messagebox('提示','请输入文件名称', Information!, OK! ) return end if if messagebox("询问","是否确定要将单据抬头导出成文件",question!,yesno!,1) = 2 then return end if datastore ds_setting ds_setting = create datastore ds_setting.dataobject = 'ds_billstyle_import' ds_setting.settransobject(sqlca) ds_setting.retrieve( ) if fileexists(arg_filename) then if messagebox("询问","指定文件已经存在,是否覆盖该文件?",question!,yesno!,2) = 2 then return end if end if if ds_setting.saveas(arg_filename,dbase2!,false) = 1 then arg_msg = '数据导出成功!' else arg_msg = '数据导出失败,如果该文件已打开请先关闭此文件再试!' end if messagebox('提示',arg_msg, Information!, OK! ) end event type gb_1 from groupbox within w_billstyle_import integer x = 73 integer y = 48 integer width = 2149 integer height = 216 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 134217739 string text = "导出文件路径" end type type gb_2 from groupbox within w_billstyle_import integer x = 73 integer y = 348 integer width = 2149 integer height = 216 integer taborder = 10 integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 134217739 string text = "导入文件路径" end type