w_rpt_condition.srw 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. $PBExportHeader$w_rpt_condition.srw
  2. $PBExportComments$组合条件--窗口
  3. forward
  4. global type w_rpt_condition from Window
  5. end type
  6. type cb_3 from commandbutton within w_rpt_condition
  7. end type
  8. type dw1 from datawindow within w_rpt_condition
  9. end type
  10. type cb_2 from commandbutton within w_rpt_condition
  11. end type
  12. type cb_1 from commandbutton within w_rpt_condition
  13. end type
  14. end forward
  15. global type w_rpt_condition from Window
  16. int X=654
  17. int Y=604
  18. int Width=1920
  19. int Height=948
  20. boolean TitleBar=true
  21. string Title="打印条件"
  22. long BackColor=12632256
  23. boolean ControlMenu=true
  24. WindowType WindowType=response!
  25. cb_3 cb_3
  26. dw1 dw1
  27. cb_2 cb_2
  28. cb_1 cb_1
  29. end type
  30. global w_rpt_condition w_rpt_condition
  31. type variables
  32. int i,ii_rows,j
  33. datawindow id_dw
  34. string is_return,is_dwobject,is_con
  35. transaction it_dw=sqlca
  36. string is_chinese,is_english,is_type,is_dbms
  37. DataWindowChild idw_child
  38. str_rpt istr_rpt
  39. end variables
  40. forward prototypes
  41. public subroutine wf_dddw ()
  42. public subroutine wf_con ()
  43. end prototypes
  44. public subroutine wf_dddw ();int li_rows
  45. choose case left(is_type,5)
  46. case 'char(','char' //char(n)
  47. is_english='c'+is_english
  48. case 'date' //date
  49. is_english='d'+is_english
  50. case 'datet' //datetime
  51. is_english='d'+is_english
  52. case 'numbe','decim' //number,decimal(n)
  53. is_english='n'+is_english
  54. case 'time' //time
  55. is_english='i'+is_english
  56. case else
  57. is_english='n'+is_english
  58. end choose
  59. li_rows=idw_child.insertrow(0)
  60. idw_child.setitem(li_rows,1,is_chinese)
  61. idw_child.setitem(li_rows,2,is_english)
  62. end subroutine
  63. public subroutine wf_con ();if isvalid(w_rpt_preview) then
  64. //w_rpt_preview.istr_rpt.uservar="打印条件='"+is_con+"',"+w_rpt_preview.istr_rpt.uservar
  65. end if
  66. end subroutine
  67. on w_rpt_condition.create
  68. this.cb_3=create cb_3
  69. this.dw1=create dw1
  70. this.cb_2=create cb_2
  71. this.cb_1=create cb_1
  72. this.Control[]={this.cb_3,&
  73. this.dw1,&
  74. this.cb_2,&
  75. this.cb_1}
  76. end on
  77. on w_rpt_condition.destroy
  78. destroy(this.cb_3)
  79. destroy(this.dw1)
  80. destroy(this.cb_2)
  81. destroy(this.cb_1)
  82. end on
  83. event open;f_wcenter(this)
  84. istr_rpt=message.powerobjectparm
  85. if not isvalid(istr_rpt) then return
  86. it_dw=istr_rpt.transation
  87. id_dw=istr_rpt.userdw
  88. dw1.GetChild('s_field',idw_child)
  89. is_dwobject=id_dw.dataobject
  90. if is_dwobject='' then is_dwobject=string(istr_rpt.rid)//id_dw.tag
  91. ii_rows=long(id_dw.Object.DataWindow.Column.Count)
  92. for i=1 to ii_rows
  93. is_english=trim(id_dw.describe("#"+string(i)+'.name'))
  94. is_chinese=trim(id_dw.describe(is_english+'_t.text'))
  95. if is_chinese='!' then
  96. is_chinese=trim(id_dw.describe(is_english+'.tag'))
  97. end if
  98. if not(is_chinese='?') then
  99. is_type=id_dw.describe(is_english+'.coltype')
  100. wf_dddw()
  101. end if
  102. next
  103. dw1.SetTransobject(it_dw)
  104. f_myretrieve(dw1,"dwobject>='"+is_dwobject+"_1' and dwobject<='"+is_dwobject+"_6'")
  105. j=dw1.rowcount()
  106. for i=j+1 to 6
  107. dw1.insertrow(0)
  108. dw1.setitem(i,'dwobject',is_dwobject+'_'+string(i))
  109. next
  110. end event
  111. type cb_3 from commandbutton within w_rpt_condition
  112. int X=818
  113. int Y=708
  114. int Width=247
  115. int Height=108
  116. int TabOrder=30
  117. string Text="全部"
  118. int TextSize=-9
  119. int Weight=400
  120. string FaceName="宋体"
  121. FontCharSet FontCharSet=GB2312CharSet!
  122. FontPitch FontPitch=Variable!
  123. end type
  124. event clicked;f_mysave(dw1,it_dw,0)
  125. is_con='全部记录'
  126. wf_con()
  127. closewithreturn(parent,'1=1')
  128. end event
  129. type dw1 from datawindow within w_rpt_condition
  130. event ue_auto ( )
  131. int X=32
  132. int Y=28
  133. int Width=1829
  134. int Height=636
  135. int TabOrder=10
  136. string DataObject="dw_rpt_condition"
  137. BorderStyle BorderStyle=StyleLowered!
  138. boolean LiveScroll=true
  139. end type
  140. event ue_auto;int li_column_no,li_row
  141. string ls_get,ls_get2
  142. li_row=getrow()
  143. li_column_no=getcolumn()
  144. if li_row>0 then
  145. choose case li_column_no
  146. case 2
  147. ls_get=getitemstring(li_row,li_column_no)
  148. if ls_get>'' then
  149. ls_get=getitemstring(li_row,li_column_no - 1)
  150. if (isnull(ls_get) or ls_get='') then
  151. setitem(li_row,li_column_no - 1,'and')
  152. end if
  153. end if
  154. case 4
  155. ls_get=getitemstring(li_row,li_column_no - 2)
  156. ls_get2=getitemstring(li_row,li_column_no - 1)
  157. if ls_get>'' and (isnull(ls_get2) or ls_get2='') then
  158. setitem(li_row,li_column_no - 1,'=')
  159. end if
  160. end choose
  161. end if
  162. end event
  163. event clicked;if dwo.name='rowclear' then
  164. setitem(row,'s_relation','')
  165. setitem(row,'s_field','')
  166. setitem(row,'s_compare','')
  167. setitem(row,'s_value','')
  168. else
  169. event ue_auto()
  170. end if
  171. end event
  172. event itemchanged;event ue_auto()
  173. end event
  174. event itemfocuschanged;event ue_auto()
  175. end event
  176. event doubleclicked;//如果要开放以下通用数据字典代码,需要saledemo.pbl中的w_zkl_fzsr和dw_fzsr,以及report.db中的表fzsr才能运行
  177. //if row>0 then
  178. // if this.getcolumnname()='s_value' then
  179. // if left(this.getitemstring(row,'s_field'),1)='c' then
  180. // openwithparm(w_zkl_fzsr,this)
  181. // end if
  182. // end if
  183. //end if
  184. end event
  185. type cb_2 from commandbutton within w_rpt_condition
  186. int X=1243
  187. int Y=708
  188. int Width=247
  189. int Height=108
  190. int TabOrder=40
  191. string Text="取消"
  192. int TextSize=-9
  193. int Weight=400
  194. string FaceName="宋体"
  195. FontPitch FontPitch=Variable!
  196. end type
  197. event clicked;close(parent)
  198. end event
  199. type cb_1 from commandbutton within w_rpt_condition
  200. int X=402
  201. int Y=708
  202. int Width=247
  203. int Height=108
  204. int TabOrder=20
  205. string Text="确认"
  206. int TextSize=-9
  207. int Weight=400
  208. string FaceName="宋体"
  209. FontPitch FontPitch=Variable!
  210. end type
  211. event clicked;is_dbms=left(lower(it_dw.dbms),2)//用于判断数据库,o90为oracle9i
  212. f_mysave(dw1,it_dw,0)//err,ok
  213. is_return=''
  214. string ls1,ls2,ls3,ls4,lstype,ls2c
  215. for i=1 to 6
  216. ls1=f_myget(dw1,i,'s_relation')
  217. ls1=' '+ls1+' '
  218. ls2=f_myget(dw1,i,'s_field')
  219. ls3=f_myget(dw1,i,'s_compare')
  220. ls4=f_myget(dw1,i,'s_value')
  221. if not (ls2='' or ls3='') then
  222. ls4=f_replace(ls4,"'",'')
  223. ls4=f_replace(ls4,'"','')
  224. if trim(ls3)='like' then ls3=' like '
  225. if ls3=' like ' then ls4=ls4+'%'
  226. if is_return='' then ls1=''
  227. lstype=left(ls2,1)
  228. j=idw_child.find("#2='"+ls2+"'",1,ii_rows)
  229. if j>0 then
  230. ls2c=idw_child.getitemstring(j,1)//取中文字段名
  231. is_con=is_con+ls1+ls2c+ls3+ls4//中文打印条件
  232. end if
  233. ls2=mid(ls2,2)
  234. ls2=id_dw.Describe(ls2+".dbName")
  235. choose case lstype
  236. case 'c'
  237. if is_dbms>='o7' and is_dbms<='o9' and ls4='' then//对于oracle7i,8i,9i,''即为null值.
  238. if ls3='=' then
  239. is_return=is_return+ls1+ls2+" is null"
  240. elseif ls3='>' or ls3='>=' or ls3='<' or ls3='<=' then
  241. is_return=is_return+ls1+ls2+ls3+"' '"
  242. else
  243. is_return=is_return+ls1+ls2+ls3+"'"+ls4+"'"
  244. end if
  245. else
  246. is_return=is_return+ls1+ls2+ls3+"'"+ls4+"'"
  247. end if
  248. case 'n'
  249. is_return=is_return+ls1+ls2+ls3+string(dec(ls4))
  250. case 'd'
  251. if is_dbms>='o7' and is_dbms<='o9' then
  252. is_return=is_return+ls1+ls2+ls3+"to_date('"+string(date(ls4),'yyyy-mm-dd')+"','yyyy-mm-dd')"
  253. else
  254. is_return=is_return+ls1+ls2+ls3+"'"+string(date(ls4))+"'"
  255. end if
  256. case 't'
  257. is_return=is_return+ls1+ls2+ls3+"'"+string(date(ls4))+"'"
  258. case 'i'
  259. is_return=is_return+ls1+ls2+ls3+"'"+string(time(ls4))+"'"
  260. case else
  261. is_return=is_return+ls1+ls2+ls3+ls4
  262. end choose
  263. end if
  264. next
  265. is_con=f_replace(is_con,' like ',' 包含 ')
  266. is_con=f_replace(is_con,' and ',' 并且 ')
  267. is_con=f_replace(is_con,' or ',' 或者 ')
  268. is_con=f_replace(is_con,"'",'')
  269. wf_con()//中文打印条件赋值到w_rpt_preview
  270. closewithreturn(parent,is_return)
  271. end event