u_xls_dw.sru 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. $PBExportHeader$u_xls_dw.sru
  2. FORWARD
  3. GLOBAL TYPE u_xls_dw FROM datawindow
  4. END TYPE
  5. END FORWARD
  6. GLOBAL TYPE u_xls_dw FROM datawindow
  7. Integer Width = 2176
  8. Integer Height = 1096
  9. Integer TabOrder = 1
  10. EVENT refresh pbm_custom01
  11. EVENT newrow pbm_custom02
  12. EVENT DeleteRow pbm_custom03
  13. EVENT savedata pbm_custom04
  14. EVENT retrievedata pbm_custom05
  15. EVENT AcceptText pbm_custom06
  16. EVENT newfirstrow pbm_custom07
  17. EVENT newlastrow pbm_custom08
  18. EVENT postaccepttext pbm_custom09
  19. EVENT documentation pbm_custom75
  20. EVENT parentresize pbm_custom10
  21. END TYPE
  22. GLOBAL u_xls_dw u_xls_dw
  23. TYPE VARIABLES
  24. PUBLIC:
  25. Boolean bFailedAccept = FALSE, i_bFailedSave = FALSE
  26. Boolean i_bAutoResizeHorizontal = FALSE, i_bAutoResizeVertical = FALSE
  27. Integer i_nBottomGap, i_nRightGap, i_nMinWidth, i_nMaxWidth = -1, i_nMinHeight, i_nMaxHeight = -1
  28. Window i_wParent
  29. PRIVATE:
  30. Boolean i_bInAcceptText = FALSE
  31. END VARIABLES
  32. FORWARD PROTOTYPES
  33. PUBLIC SUBROUTINE uf_ChangeDataObject (String szdataobject, rowfocusind rfipointertype, picture ptrpointer, Integer nxlocation, Integer nylocation, Transaction trtransaction)
  34. PROTECTED FUNCTION Long uf_retrievedata ()
  35. END PROTOTYPES
  36. ON newrow;
  37. Long lRow
  38. lRow = THIS.GetRow()
  39. IF lRow = -1 THEN
  40. Error.Object = THIS.ClassName()
  41. Error.ObjectEvent = "NewRow"
  42. Error.Line = 3
  43. Error.Number = -1
  44. Error.Text = "Error get row information from the datawindow."
  45. ELSE
  46. lRow = THIS.InsertRow( lRow + 1)
  47. IF lRow = -1 THEN
  48. Error.Object = THIS.ClassName()
  49. Error.ObjectEvent = "NewRow"
  50. Error.Line = 12
  51. Error.Number = -1
  52. Error.Text = "Unable to insert a new row into the datawindow."
  53. ELSE
  54. THIS.SetColumn( 1)
  55. THIS.ScrollToRow( lRow)
  56. THIS.SetFocus()
  57. END IF
  58. END IF
  59. END ON
  60. ON DeleteRow;
  61. Long lRow
  62. lRow = THIS.GetRow()
  63. IF lRow = -1 THEN
  64. Error.Object = THIS.ClassName()
  65. Error.ObjectEvent = "DeleteRow"
  66. Error.Line = 3
  67. Error.Number = -1
  68. Error.Text = "Error get row information from the datawindow."
  69. ELSE
  70. IF THIS.DeleteRow( lRow) <> 1 THEN
  71. Error.Object = THIS.ClassName()
  72. Error.ObjectEvent = "DeleteRow"
  73. Error.Line = 12
  74. Error.Number = -1
  75. Error.Text = "Unable to Delete a new row into the datawindow."
  76. ELSE
  77. THIS.ScrollToRow( lRow - 1)
  78. THIS.SetFocus()
  79. END IF
  80. END IF
  81. END ON
  82. ON AcceptText;
  83. IF NOT i_bInAcceptText THEN
  84. i_bInAcceptText = TRUE
  85. IF THIS.AcceptText() = -1 THEN
  86. bFailedAccept = TRUE
  87. THIS.SetFocus()
  88. THIS.PostEvent( "PostAcceptText")
  89. RETURN
  90. ELSE
  91. bFailedAccept = FALSE
  92. END IF
  93. END IF
  94. i_bInAcceptText = FALSE
  95. END ON
  96. ON newfirstrow;
  97. Long lRow
  98. lRow = THIS.InsertRow( 1)
  99. IF lRow = -1 THEN
  100. Error.Object = THIS.ClassName()
  101. Error.ObjectEvent = "NewFirstRow"
  102. Error.Line = 3
  103. Error.Number = -1
  104. Error.Text = "Unable to insert a new row into the datawindow."
  105. ELSE
  106. THIS.SetColumn( 1)
  107. THIS.ScrollToRow( lRow)
  108. THIS.SetFocus()
  109. END IF
  110. END ON
  111. ON newlastrow;
  112. Long lRow
  113. lRow = THIS.InsertRow( 0)
  114. IF lRow = -1 THEN
  115. Error.Object = THIS.ClassName()
  116. Error.ObjectEvent = "NewLastRow"
  117. Error.Line = 3
  118. Error.Number = -1
  119. Error.Text = "Unable to insert a new row into the datawindow."
  120. ELSE
  121. THIS.SetColumn( 1)
  122. THIS.ScrollToRow( lRow)
  123. THIS.SetFocus()
  124. END IF
  125. END ON
  126. ON postaccepttext;
  127. i_bInAcceptText = FALSE
  128. END ON
  129. ON documentation;
  130. // Copyright Simon Gallagher 1993-1995
  131. //
  132. // This DataWindow object contains the following functionality:
  133. //
  134. // Events:
  135. // DeleteRow - Handles deleting the current row
  136. // SaveData - Handles saving the data
  137. // RetrieveData - Handles retrieving data for the dw, no parameters
  138. // NewRow - Inserts a new row after the current
  139. // NewFirstRow - Inserts a new row at the beginning of the dw
  140. // NewLastRow - Inserts a new row at the end of the dw
  141. // AcceptText - Handles the acceptance of data before focus leaves the window
  142. // ParentResize - On direction of a parent window, the datawindow will resize itself
  143. END ON
  144. ON parentresize;
  145. Integer nNewWidth, nNewHeight
  146. THIS.SetRedraw( FALSE)
  147. IF i_bAutoResizeHorizontal THEN
  148. nNewWidth = i_wParent.Width - THIS.X - i_nRightGap
  149. IF nNewWidth >= i_nMinWidth And (nNewWidth <= i_nMaxWidth OR i_nMaxWidth = -1) THEN
  150. THIS.Width = nNewWidth
  151. THIS.HScrollBar = TRUE
  152. ELSEIF nNewWidth < i_nMinWidth THEN
  153. THIS.Width = i_nMinWidth
  154. END IF
  155. END IF
  156. IF i_bAutoResizeVertical THEN
  157. nNewHeight = i_wParent.Height - THIS.Y - i_nBottomGap
  158. IF nNewHeight >= i_nMinHeight And (nNewHeight <= i_nMaxHeight OR i_nMaxHeight = -1) THEN
  159. THIS.Height = nNewHeight
  160. THIS.VScrollBar = TRUE
  161. ELSEIF nNewHeight < i_nMinHeight THEN
  162. THIS.Height = i_nMinHeight
  163. END IF
  164. END IF
  165. THIS.SetRedraw( TRUE)
  166. END ON
  167. PUBLIC SUBROUTINE uf_ChangeDataObject (String szdataobject, rowfocusind rfipointertype, picture ptrpointer, Integer nxlocation, Integer nylocation, Transaction trtransaction);
  168. THIS.DataObject = szdataobject
  169. IF IsValid( ptrpointer) THEN
  170. THIS.SetRowFocusIndicator( ptrpointer, nxlocation, nylocation)
  171. ELSE
  172. THIS.SetRowFocusIndicator( rfipointertype, nxlocation, nylocation)
  173. END IF
  174. THIS.SetTransObject( trtransaction)
  175. END SUBROUTINE
  176. PROTECTED FUNCTION Long uf_retrievedata ();
  177. RETURN THIS.Retrieve()
  178. END FUNCTION
  179. EVENT Constructor;
  180. IF THIS.SetTransObject( SQLCA) <> 1 THEN
  181. Error.Object = THIS.ClassName()
  182. Error.ObjectEvent = "Constructor"
  183. Error.Line = 1
  184. Error.Number = SQLCA.SQLDBCode
  185. Error.Text = SQLCA.SQLErrText
  186. END IF
  187. END EVENT
  188. ON ItemError;
  189. i_bInAcceptText = TRUE
  190. END ON
  191. ON LoseFocus;
  192. THIS.PostEvent( "accepttext")
  193. END ON
  194. EVENT DBError;
  195. // Open the standard error window, no values can be passed from this level
  196. // any information displayed apart from error text will have to be defined
  197. // at the child level
  198. Error.Text = SQLErrText
  199. Error.Number = SQLDBCode
  200. //
  201. // Scroll to the row causing the error, if it is in the visible, PRIMARY!, buffer
  202. //
  203. IF buffer = PRIMARY! THEN
  204. THIS.ScrollToRow( row)
  205. THIS.SetFocus()
  206. END IF
  207. // Do Not process message any further
  208. RETURN 1
  209. END EVENT
  210. ON u_xls_dw.CREATE
  211. END ON
  212. ON u_xls_dw.DESTROY
  213. END ON