w_sortrow.srw 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. $PBExportHeader$w_sortrow.srw
  2. $PBExportComments$排序窗口
  3. forward
  4. global type w_sortrow from w_publ_base
  5. end type
  6. type cb_del from uo_imflatbutton within w_sortrow
  7. end type
  8. type cb_add from uo_imflatbutton within w_sortrow
  9. end type
  10. type cb_1 from uo_imflatbutton within w_sortrow
  11. end type
  12. type dw_criteria from u_dw within w_sortrow
  13. end type
  14. end forward
  15. global type w_sortrow from w_publ_base
  16. integer x = 617
  17. integer y = 364
  18. integer width = 1385
  19. integer height = 716
  20. string title = "排序"
  21. boolean minbox = false
  22. windowtype windowtype = response!
  23. cb_del cb_del
  24. cb_add cb_add
  25. cb_1 cb_1
  26. dw_criteria dw_criteria
  27. end type
  28. global w_sortrow w_sortrow
  29. type variables
  30. Long i_lRow
  31. String i_aszTypes[]
  32. DataWindow i_dwToActOn
  33. end variables
  34. forward prototypes
  35. public subroutine wf_setdw_criteria (datawindow arg_dw, long ncolumncount)
  36. public subroutine wf_save (string arg_sortstr)
  37. end prototypes
  38. public subroutine wf_setdw_criteria (datawindow arg_dw, long ncolumncount);Long i,cnt,nColumnIndex
  39. string des_1,des_2
  40. string ls_str,oneText
  41. string sort_arr[],OneSort[]
  42. //ls_str = "u_cust_name A,u_bmsttakemx_billcode D"
  43. s_sort_col s_col[]
  44. LS_STR = f_find_sortset(arg_dw.Dataobject)
  45. IF nColumnCount <= 0 THEN RETURN
  46. IF ls_str = "" THEN RETURN
  47. f_split(ls_str,",",sort_arr)
  48. for i = 1 to upperbound(sort_arr)
  49. oneText = sort_arr[i]
  50. f_split(oneText," ",OneSort)
  51. IF upperbound(OneSort) <> 2 THEN CONTINUE
  52. cnt++
  53. s_col[cnt].column_name = OneSort[1]
  54. s_col[cnt].operators = OneSort[2]
  55. For nColumnIndex = 1 To nColumnCount
  56. des_1= i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".Name")
  57. des_2= i_dwtoacton.describe(des_1+ "_t.Text")
  58. IF des_1 = s_col[cnt].column_name THEN
  59. s_col[cnt].column_number = nColumnIndex
  60. s_col[cnt].column_name_text = des_2
  61. END IF
  62. Next
  63. next
  64. IF upperbound(s_col) > 0 THEN
  65. dw_criteria.reset()
  66. FOR i = 1 to upperbound(s_col)
  67. cnt = dw_criteria.insertrow(i)
  68. dw_criteria.object.column_number[cnt] = s_col[i].column_number
  69. dw_criteria.object.operators[cnt] = s_col[i].operators
  70. NEXT
  71. END IF
  72. end subroutine
  73. public subroutine wf_save (string arg_sortstr);String dwname
  74. dwname = i_dwToActOn.DataObject
  75. IF dwname = "" THEN RETURN
  76. UPDATE u_sortSet
  77. SET sortStr = :arg_sortStr
  78. WHERE dwname = :dwname;
  79. IF SQLCA.SQLCode = 0 THEN
  80. IF SQLCA.SQLNRows = 0 THEN
  81. INSERT INTO u_sortSet(dwname,sortStr)
  82. VALUES(:dwname,:arg_sortStr);
  83. END IF
  84. COMMIT;
  85. ELSE
  86. ROLLBACK;
  87. END IF
  88. RETURN
  89. end subroutine
  90. on w_sortrow.create
  91. int iCurrent
  92. call super::create
  93. this.cb_del=create cb_del
  94. this.cb_add=create cb_add
  95. this.cb_1=create cb_1
  96. this.dw_criteria=create dw_criteria
  97. iCurrent=UpperBound(this.Control)
  98. this.Control[iCurrent+1]=this.cb_del
  99. this.Control[iCurrent+2]=this.cb_add
  100. this.Control[iCurrent+3]=this.cb_1
  101. this.Control[iCurrent+4]=this.dw_criteria
  102. end on
  103. on w_sortrow.destroy
  104. call super::destroy
  105. destroy(this.cb_del)
  106. destroy(this.cb_add)
  107. destroy(this.cb_1)
  108. destroy(this.dw_criteria)
  109. end on
  110. event open;call super::open;Integer nColumnCount, nColumnIndex
  111. String szColumn
  112. Long lRow
  113. DataWindowChild dwcColumns
  114. string des_1,des_2
  115. i_dwToActOn = Message.PowerObjectParm
  116. i_lRow = 0
  117. nColumnCount = Integer( i_dwToActOn.Object.DataWindow.Column.Count)
  118. dw_criteria.GetChild( "column_number", dwcColumns)
  119. i_aszTypes[ nColumnCount] = ""
  120. For nColumnIndex = 1 To nColumnCount
  121. des_1= i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".Name")
  122. des_2= i_dwtoacton.describe(des_1+ "_t.Text")
  123. szColumn = f_strip( i_dwToActOn.Describe( i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".Name") + "_t.Text"))
  124. If szColumn <> "!" Then
  125. lRow = dwcColumns.InsertRow( 0)
  126. dwcColumns.SetItem( lRow, "column_name", szColumn)
  127. dwcColumns.SetItem( lRow, "column_number", nColumnIndex)
  128. i_aszTypes[ nColumnIndex] = i_dwToActOn.Describe( "#" + String(nColumnIndex) + ".ColType")
  129. End If
  130. Next
  131. dw_criteria.TriggerEvent( "NewRow")
  132. wf_SetDw_criteria(i_dwToActOn,nColumnCount)
  133. end event
  134. type cb_func from w_publ_base`cb_func within w_sortrow
  135. boolean visible = false
  136. integer y = 488
  137. boolean enabled = false
  138. end type
  139. type cb_exit from w_publ_base`cb_exit within w_sortrow
  140. integer x = 791
  141. integer y = 488
  142. integer width = 325
  143. string text = "取消"
  144. end type
  145. type cb_del from uo_imflatbutton within w_sortrow
  146. integer x = 1001
  147. integer y = 136
  148. integer width = 325
  149. integer height = 96
  150. integer taborder = 41
  151. string text = "删除行"
  152. end type
  153. event clicked;call super::clicked;dw_criteria.TriggerEvent( "DELETERow")
  154. end event
  155. type cb_add from uo_imflatbutton within w_sortrow
  156. integer x = 1001
  157. integer y = 16
  158. integer width = 325
  159. integer height = 96
  160. integer taborder = 41
  161. string text = "增加行"
  162. end type
  163. event clicked;call super::clicked;dw_criteria.TriggerEvent( "NewRow")
  164. end event
  165. type cb_1 from uo_imflatbutton within w_sortrow
  166. integer x = 311
  167. integer y = 488
  168. integer width = 325
  169. integer height = 96
  170. integer taborder = 41
  171. boolean default = true
  172. end type
  173. event clicked;call super::clicked;Long lNoOfCriteria, lRow, lColumnNo,lLen
  174. Integer nPos
  175. String szFind,szColumn,szOperator
  176. STRING szExpression=''
  177. lNoOfCriteria = dw_criteria.RowCount()
  178. For lRow = 1 To lNoOfCriteria
  179. lColumnNo = dw_criteria.GetItemNumber( lRow, "column_number")
  180. szColumn = i_dwToActOn.Describe( "#" + String( lColumnNo) + ".Name")//dbName //FILTER 与SELECT 区别
  181. If IsNull( dw_criteria.GetItemNumber( lrow, "column_number")) Then
  182. exit
  183. End If
  184. szOperator = ( dw_criteria.GetItemString( lRow, "operators"))
  185. szExpression = szExpression + szColumn +' '+ szOperator + ','
  186. Next
  187. SZFIND=trim(szExpression)
  188. if right(SZFIND,1)=',' THEN
  189. SZFIND=LEFT(SZFIND,LEN(SZFIND) - 1)
  190. END IF
  191. wf_save(SZFIND)
  192. Closewithreturn(parent,szfind)
  193. end event
  194. type dw_criteria from u_dw within w_sortrow
  195. integer x = 18
  196. integer y = 12
  197. integer width = 951
  198. integer height = 448
  199. integer taborder = 20
  200. boolean bringtotop = true
  201. string dataobject = "d_sort"
  202. boolean vscrollbar = true
  203. boolean border = false
  204. end type