w_billstyle_import.srw 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. $PBExportHeader$w_billstyle_import.srw
  2. forward
  3. global type w_billstyle_import from window
  4. end type
  5. type sle_filename_in from singlelineedit within w_billstyle_import
  6. end type
  7. type cb_1 from commandbutton within w_billstyle_import
  8. end type
  9. type cb_exit from commandbutton within w_billstyle_import
  10. end type
  11. type cb_import from commandbutton within w_billstyle_import
  12. end type
  13. type cb_ch from commandbutton within w_billstyle_import
  14. end type
  15. type sle_filename_out from singlelineedit within w_billstyle_import
  16. end type
  17. type cb_export from commandbutton within w_billstyle_import
  18. end type
  19. type gb_1 from groupbox within w_billstyle_import
  20. end type
  21. type gb_2 from groupbox within w_billstyle_import
  22. end type
  23. end forward
  24. global type w_billstyle_import from window
  25. integer x = 814
  26. integer y = 864
  27. integer width = 2304
  28. integer height = 900
  29. boolean titlebar = true
  30. string title = "单据抬头导入导出"
  31. boolean controlmenu = true
  32. windowtype windowtype = response!
  33. long backcolor = 134217739
  34. sle_filename_in sle_filename_in
  35. cb_1 cb_1
  36. cb_exit cb_exit
  37. cb_import cb_import
  38. cb_ch cb_ch
  39. sle_filename_out sle_filename_out
  40. cb_export cb_export
  41. gb_1 gb_1
  42. gb_2 gb_2
  43. end type
  44. global w_billstyle_import w_billstyle_import
  45. type variables
  46. BOOLEAN OL_BACKUP=TRUE
  47. end variables
  48. on w_billstyle_import.create
  49. this.sle_filename_in=create sle_filename_in
  50. this.cb_1=create cb_1
  51. this.cb_exit=create cb_exit
  52. this.cb_import=create cb_import
  53. this.cb_ch=create cb_ch
  54. this.sle_filename_out=create sle_filename_out
  55. this.cb_export=create cb_export
  56. this.gb_1=create gb_1
  57. this.gb_2=create gb_2
  58. this.Control[]={this.sle_filename_in,&
  59. this.cb_1,&
  60. this.cb_exit,&
  61. this.cb_import,&
  62. this.cb_ch,&
  63. this.sle_filename_out,&
  64. this.cb_export,&
  65. this.gb_1,&
  66. this.gb_2}
  67. end on
  68. on w_billstyle_import.destroy
  69. destroy(this.sle_filename_in)
  70. destroy(this.cb_1)
  71. destroy(this.cb_exit)
  72. destroy(this.cb_import)
  73. destroy(this.cb_ch)
  74. destroy(this.sle_filename_out)
  75. destroy(this.cb_export)
  76. destroy(this.gb_1)
  77. destroy(this.gb_2)
  78. end on
  79. event open;IF Message.DoubleParm = 1 THEN
  80. OL_BACKUP=FALSE
  81. END IF
  82. end event
  83. type sle_filename_in from singlelineedit within w_billstyle_import
  84. event key pbm_keydown
  85. integer x = 133
  86. integer y = 428
  87. integer width = 1586
  88. integer height = 92
  89. integer taborder = 40
  90. integer textsize = -9
  91. integer weight = 400
  92. fontcharset fontcharset = gb2312charset!
  93. fontpitch fontpitch = variable!
  94. string facename = "宋体"
  95. long textcolor = 33554432
  96. borderstyle borderstyle = stylelowered!
  97. end type
  98. event key;if trim(this.text)="" then
  99. cb_import.enabled=false
  100. else
  101. cb_import.enabled=OL_BACKUP
  102. end if
  103. end event
  104. event modified;if trim(this.text)="" then
  105. cb_import.enabled=false
  106. else
  107. cb_import.enabled=OL_BACKUP
  108. end if
  109. end event
  110. type cb_1 from commandbutton within w_billstyle_import
  111. integer x = 1719
  112. integer y = 428
  113. integer width = 114
  114. integer height = 92
  115. integer taborder = 20
  116. integer textsize = -9
  117. integer weight = 400
  118. fontcharset fontcharset = gb2312charset!
  119. fontpitch fontpitch = variable!
  120. string facename = "宋体"
  121. string text = "..."
  122. end type
  123. event clicked;//new
  124. integer i
  125. string pathname,filename
  126. i=getfilesavename("选择备份文件",pathname,filename,"Dbf","数据文件Dbf,*.Dbf")
  127. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  128. cb_import.enabled=OL_BACKUP
  129. sle_filename_in.text=pathname
  130. END IF
  131. end event
  132. type cb_exit from commandbutton within w_billstyle_import
  133. integer x = 1838
  134. integer y = 668
  135. integer width = 320
  136. integer height = 96
  137. integer taborder = 80
  138. integer textsize = -9
  139. integer weight = 400
  140. fontcharset fontcharset = gb2312charset!
  141. fontpitch fontpitch = variable!
  142. string facename = "宋体"
  143. string text = "退出"
  144. end type
  145. event clicked;close(parent)
  146. end event
  147. type cb_import from commandbutton within w_billstyle_import
  148. integer x = 1838
  149. integer y = 428
  150. integer width = 320
  151. integer height = 96
  152. integer taborder = 50
  153. integer textsize = -9
  154. integer weight = 400
  155. fontcharset fontcharset = gb2312charset!
  156. fontpitch fontpitch = variable!
  157. string facename = "宋体"
  158. boolean enabled = false
  159. string text = "导入"
  160. end type
  161. event clicked;IF NOT sys_power_issuper THEN
  162. MessageBox('提示','你没有使用权限!', Information!, OK! )
  163. RETURN
  164. END IF
  165. datastore ds_setting
  166. ds_setting = CREATE datastore
  167. ds_setting.DataObject = 'ds_billstyle_import'
  168. ds_setting.SetTransObject(sqlca)
  169. ds_setting.ImportFile(sle_filename_in.Text)
  170. ds_setting.AcceptText()
  171. IF ds_setting.RowCount() <= 0 THEN
  172. MessageBox('提示','你导入的系统单据抬头文件没有数据', Information!, OK! )
  173. RETURN
  174. END IF
  175. Long ll_id_arr[]
  176. String ls_firststr_arr[]
  177. String ls_datestyle_arr[]
  178. String ls_dscrp_arr[]
  179. Long ll_cnt = 1
  180. DECLARE cur_billcode CURSOR FOR
  181. SELECT u_billcode.id,
  182. u_billcode.firststr,
  183. u_billcode.datestyle,
  184. u_billcode.dscrp
  185. FROM u_billcode
  186. Where u_billcode.firststr <> ''
  187. or u_billcode.datestyle <> 'yymmdd';
  188. OPEN cur_billcode;
  189. FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
  190. :ls_firststr_arr[ll_cnt],
  191. :ls_datestyle_arr[ll_cnt],
  192. :ls_dscrp_arr[ll_cnt];
  193. DO WHILE sqlca.SQLCode = 0
  194. ll_cnt++
  195. FETCH cur_billcode INTO :ll_id_arr[ll_cnt],
  196. :ls_firststr_arr[ll_cnt],
  197. :ls_datestyle_arr[ll_cnt],
  198. :ls_dscrp_arr[ll_cnt];
  199. LOOP
  200. CLOSE cur_billcode;
  201. ll_cnt = ll_cnt - 1
  202. DELETE FROM u_billcode;
  203. IF sqlca.SQLCode <> 0 THEN
  204. MessageBox('错误','删除原系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! )
  205. RETURN
  206. END IF
  207. Long ll_i
  208. Long ll_id
  209. String ls_firststr
  210. String ls_datestyle
  211. String ls_dscrp
  212. String ls_oldfirststr
  213. String ls_billstyle
  214. String ls_win1
  215. String ls_win2
  216. String ls_tablename
  217. String ls_codename
  218. String ls_module
  219. FOR ll_i = 1 TO ds_setting.RowCount()
  220. ll_id = ds_setting.Object.id[ll_i]
  221. ls_firststr = ds_setting.Object.firststr[ll_i]
  222. ls_datestyle = ds_setting.Object.datestyle[ll_i]
  223. ls_dscrp = ds_setting.Object.dscrp[ll_i]
  224. ls_oldfirststr = ds_setting.Object.oldfirststr[ll_i]
  225. ls_billstyle = ds_setting.Object.billstyle[ll_i]
  226. ls_win1 = ds_setting.Object.win1[ll_i]
  227. ls_win2 = ds_setting.Object.win2[ll_i]
  228. ls_tablename = ds_setting.Object.tablename[ll_i]
  229. ls_codename = ds_setting.Object.codename[ll_i]
  230. ls_module = ds_setting.Object.module[ll_i]
  231. INSERT INTO
  232. u_billcode(id,
  233. firststr,
  234. datestyle,
  235. dscrp,
  236. oldfirststr,
  237. billstyle,
  238. win1,
  239. win2,
  240. tablename,
  241. codename,
  242. module)
  243. VALUES(:ll_id,
  244. :ls_firststr,
  245. :ls_datestyle,
  246. :ls_dscrp,
  247. :ls_oldfirststr,
  248. :ls_billstyle,
  249. :ls_win1,
  250. :ls_win2,
  251. :ls_tablename,
  252. :ls_codename,
  253. :ls_module);
  254. IF sqlca.SQLCode <> 0 THEN
  255. MessageBox('错误','新增系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! )
  256. ROLLBACK;
  257. RETURN
  258. END IF
  259. NEXT
  260. FOR ll_i = 1 TO ll_cnt
  261. UPDATE u_billcode
  262. SET firststr = :ls_firststr_arr[ll_i],
  263. datestyle = :ls_datestyle_arr[ll_i],
  264. dscrp = :ls_dscrp_arr[ll_i]
  265. Where id = :ll_id_arr[ll_i];
  266. IF sqlca.SQLCode <> 0 THEN
  267. MessageBox('错误','更新改变系统单据抬头数据失败,'+sqlca.SQLErrText, StopSign!, OK! )
  268. ROLLBACK;
  269. RETURN
  270. END IF
  271. NEXT
  272. COMMIT;
  273. MessageBox('提示','导入系统功能数据成功', Information!, OK! )
  274. end event
  275. type cb_ch from commandbutton within w_billstyle_import
  276. integer x = 1719
  277. integer y = 128
  278. integer width = 114
  279. integer height = 92
  280. integer taborder = 20
  281. integer textsize = -9
  282. integer weight = 400
  283. fontcharset fontcharset = gb2312charset!
  284. fontpitch fontpitch = variable!
  285. string facename = "宋体"
  286. string text = "..."
  287. end type
  288. event clicked;//new
  289. integer i
  290. string pathname,filename
  291. i=getfilesavename("选择导出文件",pathname,filename,"Dbf","数据文件Dbf,*.Dbf")
  292. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  293. cb_export.enabled=OL_BACKUP
  294. sle_filename_out.text=pathname
  295. END IF
  296. end event
  297. type sle_filename_out from singlelineedit within w_billstyle_import
  298. event key pbm_keydown
  299. integer x = 133
  300. integer y = 128
  301. integer width = 1586
  302. integer height = 92
  303. integer taborder = 10
  304. integer textsize = -9
  305. integer weight = 400
  306. fontcharset fontcharset = gb2312charset!
  307. fontpitch fontpitch = variable!
  308. string facename = "宋体"
  309. long textcolor = 33554432
  310. borderstyle borderstyle = stylelowered!
  311. end type
  312. event key;if trim(this.text)="" then
  313. cb_export.enabled=false
  314. else
  315. cb_export.enabled=OL_BACKUP
  316. end if
  317. end event
  318. event modified;if trim(this.text)="" then
  319. cb_export.enabled=false
  320. else
  321. cb_export.enabled=OL_BACKUP
  322. end if
  323. end event
  324. type cb_export from commandbutton within w_billstyle_import
  325. integer x = 1838
  326. integer y = 128
  327. integer width = 320
  328. integer height = 96
  329. integer taborder = 30
  330. integer textsize = -9
  331. integer weight = 400
  332. fontcharset fontcharset = gb2312charset!
  333. fontpitch fontpitch = variable!
  334. string facename = "宋体"
  335. boolean enabled = false
  336. string text = "导出"
  337. end type
  338. event clicked;IF NOT sys_power_issuper THEN
  339. MessageBox('提示','你没有使用权限!', Information!, OK! )
  340. RETURN
  341. END IF
  342. string arg_filename,arg_msg
  343. blob arg_blob
  344. arg_filename = trim(sle_filename_out.text)
  345. if arg_filename = '' then
  346. messagebox('提示','请输入文件名称', Information!, OK! )
  347. return
  348. end if
  349. if messagebox("询问","是否确定要将单据抬头导出成文件",question!,yesno!,1) = 2 then
  350. return
  351. end if
  352. datastore ds_setting
  353. ds_setting = create datastore
  354. ds_setting.dataobject = 'ds_billstyle_import'
  355. ds_setting.settransobject(sqlca)
  356. ds_setting.retrieve( )
  357. if fileexists(arg_filename) then
  358. if messagebox("询问","指定文件已经存在,是否覆盖该文件?",question!,yesno!,2) = 2 then
  359. return
  360. end if
  361. end if
  362. if ds_setting.saveas(arg_filename,dbase2!,false) = 1 then
  363. arg_msg = '数据导出成功!'
  364. else
  365. arg_msg = '数据导出失败,如果该文件已打开请先关闭此文件再试!'
  366. end if
  367. messagebox('提示',arg_msg, Information!, OK! )
  368. end event
  369. type gb_1 from groupbox within w_billstyle_import
  370. integer x = 73
  371. integer y = 48
  372. integer width = 2149
  373. integer height = 216
  374. integer textsize = -9
  375. integer weight = 400
  376. fontcharset fontcharset = gb2312charset!
  377. fontpitch fontpitch = variable!
  378. string facename = "宋体"
  379. long textcolor = 33554432
  380. long backcolor = 134217739
  381. string text = "导出文件路径"
  382. end type
  383. type gb_2 from groupbox within w_billstyle_import
  384. integer x = 73
  385. integer y = 348
  386. integer width = 2149
  387. integer height = 216
  388. integer taborder = 10
  389. integer textsize = -9
  390. integer weight = 400
  391. fontcharset fontcharset = gb2312charset!
  392. fontpitch fontpitch = variable!
  393. string facename = "宋体"
  394. long textcolor = 33554432
  395. long backcolor = 134217739
  396. string text = "导入文件路径"
  397. end type