ODBCDepartmentView.cpp
上传用户:benben_wyd
上传日期:2010-02-26
资源大小:1229k
文件大小:17k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // ODBCDepartmentView.cpp : implementation of the CODBCDepartmentView class
  2. //
  3. #include "stdafx.h"
  4. #include "ODBCDepartment.h"
  5. #include "ODBCDepartmentSet.h"
  6. #include "ODBCDepartmentDoc.h"
  7. #include "ODBCDepartmentView.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CODBCDepartmentView
  15. IMPLEMENT_DYNCREATE(CODBCDepartmentView, CRecordView)
  16. BEGIN_MESSAGE_MAP(CODBCDepartmentView, CRecordView)
  17. //{{AFX_MSG_MAP(CODBCDepartmentView)
  18. ON_COMMAND(ID_RECORD_DELETERECORD, OnRecordDeleterecord)
  19. ON_UPDATE_COMMAND_UI(ID_RECORD_DELETERECORD, OnUpdateRecordDeleterecord)
  20. ON_COMMAND(ID_RECORD_QUERYRECORD, OnRecordQueryrecord)
  21. ON_COMMAND(ID_FILE_NEW, OnFileNew)
  22. ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  23. ON_WM_DESTROY()
  24. ON_EN_CHANGE(IDC_DEPARTMENTCODE, OnChangeDepartmentcode)
  25. ON_EN_CHANGE(IDC_DEPARTMENTNAME, OnChangeDepartmentname)
  26. ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
  27. ON_EN_CHANGE(IDC_EMAIL, OnChangeEmail)
  28. ON_EN_CHANGE(IDC_INSTRUCTORNAME, OnChangeInstructorname)
  29. ON_EN_CHANGE(IDC_NOTES, OnChangeNotes)
  30. ON_COMMAND(ID_INSTRUCTOR_ADDINSTRUCTOR, OnInstructorAddinstructor)
  31. ON_COMMAND(ID_INSTRUCTOR_DELETEINSTRUCTOR, OnInstructorDeleteinstructor)
  32. ON_COMMAND(ID_INSTRUCTOR_FIRSTRECORD, OnInstructorFirstrecord)
  33. ON_COMMAND(ID_INSTRUCTOR_LASTRECORD, OnInstructorLastrecord)
  34. ON_COMMAND(ID_INSTRUCTOR_NEXTRECORD, OnInstructorNextrecord)
  35. ON_COMMAND(ID_INSTRUCTOR_PREVIOUSRECORD, OnInstructorPreviousrecord)
  36. ON_UPDATE_COMMAND_UI(ID_INSTRUCTOR_DELETEINSTRUCTOR, OnUpdateInstructorDeleteinstructor)
  37. ON_UPDATE_COMMAND_UI(ID_INSTRUCTOR_FIRSTRECORD, OnUpdateInstructorFirstrecord)
  38. ON_UPDATE_COMMAND_UI(ID_INSTRUCTOR_LASTRECORD, OnUpdateInstructorLastrecord)
  39. ON_UPDATE_COMMAND_UI(ID_INSTRUCTOR_NEXTRECORD, OnUpdateInstructorNextrecord)
  40. ON_UPDATE_COMMAND_UI(ID_INSTRUCTOR_PREVIOUSRECORD, OnUpdateInstructorPreviousrecord)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CODBCDepartmentView construction/destruction
  45. CODBCDepartmentView::CODBCDepartmentView()
  46. : CRecordView(CODBCDepartmentView::IDD)
  47. {
  48. //{{AFX_DATA_INIT(CODBCDepartmentView)
  49. m_pSet = NULL;
  50. m_FindDeptCode = _T("");
  51. //}}AFX_DATA_INIT
  52. m_bAddingRecord = FALSE;
  53. //Next two lines added by Chuck Wood for
  54. //instructor table support
  55. m_pInstructorSet = NULL;
  56. m_bAddingInstructor = FALSE;
  57. m_bFieldsChanged = FALSE;
  58. }
  59. CODBCDepartmentView::~CODBCDepartmentView()
  60. {
  61. }
  62. void CODBCDepartmentView::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CRecordView::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(CODBCDepartmentView)
  66. DDX_Text(pDX, IDC_FINDCODE, m_FindDeptCode);
  67. DDV_MaxChars(pDX, m_FindDeptCode, 4);
  68. DDX_FieldText(pDX, IDC_DEPARTMENTCODE, m_pSet->m_DepartmentCode, m_pSet);
  69. DDV_MaxChars(pDX, m_pSet->m_DepartmentCode, 4);
  70. DDX_FieldText(pDX, IDC_DEPARTMENTNAME, m_pSet->m_DepartmentName, m_pSet);
  71. DDV_MaxChars(pDX, m_pSet->m_DepartmentName, 50);
  72. //}}AFX_DATA_MAP
  73. //The rest of the lines in this function are added 
  74. //by Chuck Wood for instructor table support
  75. DDX_Text(pDX, IDC_EMAIL, m_pInstructorSet->m_EMAIL);
  76. DDV_MaxChars(pDX, m_pInstructorSet->m_EMAIL, 50);
  77. DDX_Text(pDX, IDC_INSTRUCTORNAME, m_pInstructorSet->m_Name);
  78. DDV_MaxChars(pDX, m_pInstructorSet->m_Name, 50);
  79. DDX_Text(pDX, IDC_NOTES, m_pInstructorSet->m_Notes);
  80. }
  81. BOOL CODBCDepartmentView::PreCreateWindow(CREATESTRUCT& cs)
  82. {
  83. return CRecordView::PreCreateWindow(cs);
  84. }
  85. void CODBCDepartmentView::OnInitialUpdate()
  86. {
  87. m_pSet = &GetDocument()->m_oDBCDepartmentSet;
  88. m_pInstructorSet = new CODBCInstructorSet(m_pSet->m_pDatabase);
  89. m_pInstructorSet->m_pDepartmentCode = 
  90. &GetDocument()->m_oDBCDepartmentSet.m_DepartmentCode;
  91.   CRecordView::OnInitialUpdate();
  92. GetParentFrame()->RecalcLayout();
  93. ResizeParentToFit();
  94. m_pSet->Close(); //Close to start transaction
  95. if (m_pSet->m_pDatabase->CanTransact()) {
  96. m_pSet->m_pDatabase->BeginTrans();
  97. }
  98. m_pSet->Open(); //Open after starting transaction
  99. m_pSet->MoveFirst();
  100. OpenInstructorRecordset(); // Display related instructors
  101. UpdateData(FALSE); //Update dialog box fields
  102. }
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CODBCDepartmentView diagnostics
  105. #ifdef _DEBUG
  106. void CODBCDepartmentView::AssertValid() const
  107. {
  108. CRecordView::AssertValid();
  109. }
  110. void CODBCDepartmentView::Dump(CDumpContext& dc) const
  111. {
  112. CRecordView::Dump(dc);
  113. }
  114. CODBCDepartmentDoc* CODBCDepartmentView::GetDocument() // non-debug version is inline
  115. {
  116. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CODBCDepartmentDoc)));
  117. return (CODBCDepartmentDoc*)m_pDocument;
  118. }
  119. #endif //_DEBUG
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CODBCDepartmentView database support
  122. CRecordset* CODBCDepartmentView::OnGetRecordset()
  123. {
  124. return m_pSet;
  125. }
  126. /////////////////////////////////////////////////////////////////////////////
  127. // CODBCDepartmentView message handlers
  128. BOOL CODBCDepartmentView::OnMove(UINT nIDMoveCommand) 
  129. {
  130. if (m_bAddingRecord) { //Currently adding?
  131. //If so, Update the record before the move
  132. UpdateData(TRUE); //Get data from dialog box
  133. m_pSet->Update(); //Update data if needed
  134. m_pSet->MoveLast(); //Go to the added record
  135. m_bAddingRecord = FALSE; //Reset flag
  136. }
  137. UpdateInstructor();
  138. BOOL returnCode = CRecordView::OnMove(nIDMoveCommand);
  139. m_pInstructorSet->Requery();
  140. CRecordsetStatus rStatus; //Status variable
  141. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  142. if (rStatus.m_lCurrentRecord < 0) { //no records Exist?
  143. //No isntructor records, so add one.
  144. AddInstructor();
  145. }
  146. UpdateData(FALSE); //Update dialog box fields
  147. return returnCode;
  148. }
  149. void CODBCDepartmentView::OnRecordDeleterecord() 
  150. {
  151. if (AfxMessageBox( //Be sure to verify your deletes
  152. "Are you sure you want to delete this department?",
  153. MB_YESNO)
  154. != IDYES) {
  155. return;
  156. }
  157. if (m_bAddingRecord) { //Currently adding?
  158. //Don't delete, just cancel add.
  159. m_pSet->CancelUpdate();
  160. m_bAddingRecord = FALSE;
  161. OnMove(ID_RECORD_PREV);
  162. return;
  163. }
  164. try {
  165. m_pSet->Delete(); //Delete record
  166. }
  167. catch(CDBException* e1) { //Failed
  168. AfxMessageBox("Delete Failed:n" +
  169. e1->m_strError,
  170. MB_ICONEXCLAMATION);
  171. OnMove(ID_RECORD_FIRST); //We lost our place.
  172. e1->Delete(); //Delete Error Message
  173. UpdateData(FALSE); //Update dialog box fields
  174. return;
  175. }
  176. try {
  177. OnMove(ID_RECORD_NEXT); //Go to next record
  178. if (m_pSet->IsDeleted()) { //Was there a next record?
  179. OnMove(ID_RECORD_FIRST); //Deleted last record
  180. }
  181. if (m_pSet->IsDeleted()) { //Can't find a record
  182. AfxThrowDBException(SQL_ERROR, 
  183. m_pSet->m_pDatabase,
  184. m_pSet->m_hstmt);   
  185. }
  186. UpdateData(FALSE); //Update dialog box fields
  187. }
  188. catch(CDBException* e2) { //No records exist
  189. AfxMessageBox("No more records",
  190. MB_ICONEXCLAMATION);
  191. e2->Delete(); //Delete Error Message
  192. //Close and Open to get rid of the Deleted record
  193. m_pSet->Close();
  194. m_pSet->Open();
  195. //No records, so set up an add record
  196. OnFileNew();
  197. }
  198. }
  199. void CODBCDepartmentView::OnUpdateRecordDeleterecord(CCmdUI* pCmdUI) 
  200. {
  201. //Disable delete functionality if no record is found
  202. pCmdUI->Enable( //Enable delete if there's a record
  203. !m_pSet->IsBOF() &&
  204. !m_pSet->IsDeleted() &&
  205. !m_pSet->IsEOF());
  206. }
  207. void CODBCDepartmentView::OnRecordQueryrecord() 
  208. {
  209. CString newFilter = ""; //Default is no filter
  210. UpdateData(TRUE); //Get data from dialog box
  211. if (!m_bAddingRecord) { //Currently adding?
  212. //Set to update
  213. m_pSet->Edit();
  214. }
  215. m_pSet->Update(); //Update data if needed
  216. m_bAddingRecord = FALSE; //Reset flag
  217. if (m_FindDeptCode != "") {
  218. //Setup new filter
  219. newFilter = "DepartmentCode = '" + m_FindDeptCode + "'";
  220. }
  221. if (newFilter != m_pSet->m_strFilter) { //Filter has changed
  222. m_pSet->m_strFilter = newFilter; //Assign new filter
  223. if (!m_pSet->Requery()) { //Requery
  224. AfxMessageBox("Requery has failed"); //Error occurred
  225. m_pSet->m_strFilter = ""; //Try to get back
  226. m_pSet->Requery(); //Requery again
  227. }
  228. try {
  229. //Go to the first record of the new filtered recordset
  230. OnMove(ID_RECORD_FIRST);
  231. }
  232. catch(CDBException* e)    {
  233. //Move failed because there are no records
  234. AfxMessageBox("No records were found", MB_ICONEXCLAMATION );
  235. e->Delete(); //Delete Error Message
  236. //No records, so set up an add record
  237. OnFileNew();
  238. }
  239. }
  240. UpdateData(FALSE); //Update dialog box fields
  241. }
  242. void CODBCDepartmentView::OnFileNew() 
  243. {
  244. CRecordsetStatus rStatus; //Status variable
  245. m_pSet->GetStatus(rStatus); //Get CRecordset status
  246. if (rStatus.m_lCurrentRecord >= 0) { //Records Exist?
  247. UpdateData(TRUE); //Get data from dialog box
  248. if (!m_bAddingRecord) { //Currently adding?
  249. //If not, set CRecordset in edit mode for updating
  250. m_pSet->Edit();
  251. }
  252. m_pSet->Update(); //Update data if needed
  253. OnMove(ID_RECORD_LAST); //Get off record 1
  254. }
  255. m_bAddingRecord = TRUE; //Set flag
  256. m_pSet->SetFieldNull(NULL); //Clear all fields
  257. m_pSet->AddNew(); //Set database in AddNew mode
  258. UpdateData(FALSE); //Update dialog box fields
  259. //No isntructor records, so add one.
  260. AddInstructor();
  261. }
  262. void CODBCDepartmentView::OnFileSave() 
  263. {
  264. if (m_bFieldsChanged && m_pSet->CanTransact()) {
  265. if (!m_bAddingRecord) { //Currently adding?
  266. m_pSet->Edit(); //If not, set edit mode
  267. }
  268. UpdateInstructor(); //Update Instructor too
  269. UpdateData(TRUE); //Get data from dialog box
  270. m_pSet->Update(); //Update data if needed
  271. m_bAddingRecord = FALSE; //Reset flag
  272. m_pSet->m_pDatabase->CommitTrans(); //Commit changes
  273. CRecordsetStatus rStatus; //Status variable
  274. m_pSet->GetStatus(rStatus); //Get CRecordset status
  275. m_pSet->Close(); //Close to start transaction
  276. CRecordsetStatus rStatus2; //Status variable
  277. m_pInstructorSet->GetStatus(rStatus2); //Get CRecordset status
  278. m_pInstructorSet->Close(); //Close second transaction
  279. m_pSet->m_pDatabase->BeginTrans(); //Start Transaction
  280. m_pSet->Open(); //Reopen CRecordset
  281. //Restore record position
  282. if (rStatus.m_lCurrentRecord >= 0) {
  283. m_pSet->SetAbsolutePosition(rStatus.m_lCurrentRecord+1);
  284. }
  285. m_bFieldsChanged = FALSE; //Reset flag
  286. OpenInstructorRecordset(
  287. rStatus2.m_lCurrentRecord); //Reopen second instructor
  288. UpdateData(FALSE); //Update dialog box fields
  289. }
  290. }
  291. void CODBCDepartmentView::OnDestroy() 
  292. {
  293. //Check for changed fields and transaction ability
  294. if (m_pSet->CanTransact()) {
  295. if (m_bFieldsChanged) {
  296. if (AfxMessageBox (
  297. "Records have been changed.  Do you want to save?", 
  298. MB_YESNO) == IDNO) {
  299. m_pSet->m_pDatabase->Rollback();
  300. }
  301. else {
  302. if (!m_bAddingRecord) { //Currently adding?
  303. //If not, set edit mode
  304. m_pSet->Edit();
  305. }
  306. UpdateInstructor();
  307. UpdateData(TRUE); //Get data from dialog box
  308. m_pSet->Update(); //Update data if needed
  309. m_pSet->m_pDatabase->CommitTrans();
  310. }
  311. }
  312. else {
  313. m_pSet->m_pDatabase->CommitTrans();
  314. }
  315. }
  316. if (m_pInstructorSet != NULL) {
  317. m_pInstructorSet->Close();
  318. delete m_pInstructorSet;
  319. }
  320. CRecordView::OnDestroy();
  321. }
  322. void CODBCDepartmentView::OnChangeDepartmentcode() 
  323. {
  324. m_bFieldsChanged = TRUE;
  325. }
  326. void CODBCDepartmentView::OnChangeDepartmentname() 
  327. {
  328. m_bFieldsChanged = TRUE;
  329. }
  330. void CODBCDepartmentView::OnUpdateFileSave(CCmdUI* pCmdUI) 
  331. { //Enable save functionality if a record has changed
  332. pCmdUI->Enable(m_bFieldsChanged);
  333. }
  334. /////////////////////////////////////////////////////////////////////////////
  335. // CODBCInstructorSet functions
  336. void CODBCDepartmentView::AddInstructor() 
  337. {
  338. m_bAddingInstructor = TRUE; //Set flag
  339. m_pInstructorSet->SetFieldNull(NULL); //Clear all fields
  340. m_pInstructorSet->AddNew(); //Set database in AddNew mode
  341. UpdateData(FALSE); //Update dialog box fields
  342. }
  343. void CODBCDepartmentView::OpenInstructorRecordset(long nRows)
  344. {
  345. m_pInstructorSet->Open();
  346. m_pInstructorSet->Requery();
  347. CRecordsetStatus rStatus; //Status variable
  348. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  349. if (rStatus.m_lCurrentRecord < 0) { //no records Exist?
  350. //No isntructor records, so add one.
  351. AddInstructor();
  352. }
  353. else {
  354. this->m_pInstructorSet->SetAbsolutePosition(nRows+1);
  355. }
  356. }
  357. void CODBCDepartmentView::UpdateInstructor()
  358. {
  359. if (!m_bAddingInstructor) {
  360. if (m_pInstructorSet->IsBOF() ||
  361. m_pInstructorSet->IsEOF() ||
  362. m_pInstructorSet->IsDeleted()) {
  363. return;
  364. }
  365. m_pInstructorSet->Edit();
  366. }
  367. m_bAddingInstructor = FALSE;
  368. UpdateData(TRUE); //Get data from dialog box
  369. m_pInstructorSet->m_DepartmentCode 
  370. = *m_pInstructorSet->m_pDepartmentCode;
  371. m_pInstructorSet->Update();
  372. }
  373. void CODBCDepartmentView::OnChangeEmail() 
  374. {
  375. m_bFieldsChanged = TRUE;
  376. }
  377. void CODBCDepartmentView::OnChangeInstructorname() 
  378. {
  379. m_bFieldsChanged = TRUE;
  380. }
  381. void CODBCDepartmentView::OnChangeNotes() 
  382. {
  383. m_bFieldsChanged = TRUE;
  384. }
  385. void CODBCDepartmentView::OnInstructorAddinstructor() 
  386. {
  387. UpdateInstructor();
  388. AddInstructor();
  389. }
  390. void CODBCDepartmentView::OnInstructorDeleteinstructor() 
  391. {
  392. if (AfxMessageBox( //Be sure to verify your deletes
  393. "Are you sure you want to delete this instructor?",
  394. MB_YESNO)
  395. != IDYES) {
  396. return;
  397. }
  398. if (m_bAddingInstructor) { //Currently adding?
  399. //Don't delete, just cancel add.
  400. m_pInstructorSet->CancelUpdate();
  401. m_bAddingInstructor = FALSE;
  402. OnInstructorPreviousrecord();
  403. return;
  404. }
  405. try {
  406. m_pInstructorSet->Delete(); //Delete record
  407. }
  408. catch(CDBException* e1) { //Failed
  409. AfxMessageBox("Delete Failed:n" +
  410. e1->m_strError,
  411. MB_ICONEXCLAMATION);
  412. e1->Delete(); //Delete Error Message
  413. OnInstructorFirstrecord(); //Recapture place
  414. return;
  415. }
  416. try {
  417. OnInstructorNextrecord(); //Go to the next record
  418. if (m_pSet->IsDeleted()) { //Was there a next record?
  419. OnInstructorFirstrecord(); //Deleted last record
  420. }
  421. if (m_pSet->IsDeleted()) { //Can't find a record
  422. AfxThrowDBException(SQL_ERROR, 
  423. m_pInstructorSet->m_pDatabase,
  424. m_pInstructorSet->m_hstmt);   
  425. }
  426. UpdateData(FALSE); //Update dialog box fields
  427. }
  428. catch(CDBException* e2) { //No records exist
  429. AfxMessageBox("No more Instructors for this department",
  430. MB_ICONEXCLAMATION);
  431. e2->Delete(); //Delete Error Message
  432. //Close and Open to get rid of the Deleted record
  433. m_pInstructorSet->Close();
  434. m_pInstructorSet->Open();
  435. //No records, so set up an add record
  436. OnInstructorAddinstructor();
  437. }
  438. }
  439. void CODBCDepartmentView::OnInstructorFirstrecord() 
  440. {
  441. UpdateInstructor();
  442. m_pInstructorSet->MoveFirst();
  443. UpdateData(FALSE); //Update dialog from database
  444. }
  445. void CODBCDepartmentView::OnInstructorLastrecord() 
  446. {
  447. UpdateInstructor();
  448. m_pInstructorSet->MoveLast();
  449. UpdateData(FALSE); //Update dialog from database
  450. }
  451. void CODBCDepartmentView::OnInstructorNextrecord() 
  452. {
  453. UpdateInstructor();
  454. m_pInstructorSet->MoveNext();
  455. if (m_pInstructorSet->IsEOF()) {
  456. m_pInstructorSet->MoveLast();
  457. }
  458. UpdateData(FALSE); //Update dialog from database
  459. }
  460. void CODBCDepartmentView::OnInstructorPreviousrecord() 
  461. {
  462. UpdateInstructor();
  463. m_pInstructorSet->MovePrev();
  464. if (m_pInstructorSet->IsBOF()) {
  465. m_pInstructorSet->MoveFirst();
  466. }
  467. UpdateData(FALSE); //Update dialog from database
  468. }
  469. void CODBCDepartmentView::OnUpdateInstructorDeleteinstructor(CCmdUI* pCmdUI) 
  470. {
  471. //Disable delete functionality if no record is found
  472. pCmdUI->Enable( //Enable delete if there's a record
  473. !m_pInstructorSet->IsBOF() &&
  474. !m_pInstructorSet->IsDeleted() &&
  475. !m_pInstructorSet->IsEOF());
  476. }
  477. void CODBCDepartmentView::OnUpdateInstructorFirstrecord(CCmdUI* pCmdUI) 
  478. {
  479. CRecordsetStatus rStatus; //Status variable
  480. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  481. pCmdUI->Enable( //Disable at first record
  482. rStatus.m_lCurrentRecord > 0);
  483. }
  484. void CODBCDepartmentView::OnUpdateInstructorLastrecord(CCmdUI* pCmdUI) 
  485. {
  486. CRecordsetStatus rStatus; //Status variable
  487. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  488. if (rStatus.m_bRecordCountFinal) {
  489. long recs = m_pInstructorSet->GetRecordCount() - 1;
  490. pCmdUI->Enable( //Disable at last record
  491. rStatus.m_lCurrentRecord < recs);
  492. }
  493. else { //Can't tell if we're at the end
  494. pCmdUI->Enable(TRUE);
  495. }
  496. }
  497. void CODBCDepartmentView::OnUpdateInstructorNextrecord(CCmdUI* pCmdUI) 
  498. {
  499. CRecordsetStatus rStatus; //Status variable
  500. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  501. if (rStatus.m_bRecordCountFinal) {
  502. long recs = m_pInstructorSet->GetRecordCount() - 1;
  503. pCmdUI->Enable( //Disable at last record
  504. rStatus.m_lCurrentRecord < recs);
  505. }
  506. else { //Can't tell if we're at the end
  507. pCmdUI->Enable(TRUE);
  508. }
  509. }
  510. void CODBCDepartmentView::OnUpdateInstructorPreviousrecord(CCmdUI* pCmdUI) 
  511. {
  512. CRecordsetStatus rStatus; //Status variable
  513. m_pInstructorSet->GetStatus(rStatus); //Get CRecordset status
  514. pCmdUI->Enable( //Disable at first record
  515. rStatus.m_lCurrentRecord > 0);
  516. }