IFM0030MF.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "CDSFacilityF.h"
  8. #include "CDSFacilityFailF.h"
  9. #include "ITSLangTransF.h"
  10. #pragma hdrstop
  11. #include "IFM0030MF.h"
  12. #include "IHS0050MF.h"
  13. //---------------------------------------------------------------------------
  14. #pragma package(smart_init)
  15. #pragma link "FRAME_FacilityFailF"
  16. #pragma link "FRAME_FacilityFailActionF"
  17. #pragma link "cxButtons"
  18. #pragma link "cxContainer"
  19. #pragma link "cxControls"
  20. #pragma link "cxEdit"
  21. #pragma link "cxGraphics"
  22. #pragma link "cxGroupBox"
  23. #pragma link "cxLookAndFeelPainters"
  24. #pragma link "cxLookAndFeels"
  25. #pragma link "cxSplitter"
  26. #pragma link "dxSkinBlack"
  27. #pragma link "dxSkinBlue"
  28. #pragma link "dxSkinsCore"
  29. #pragma resource "*.dfm"
  30. TIFM0030M *IFM0030M = NULL;
  31. //---------------------------------------------------------------------------
  32. __fastcall TIFM0030M::TIFM0030M(TComponent* Owner)
  33. : TForm(Owner)
  34. {
  35. LangTrans->Translate(this, ITSDb_GetConnection());
  36. ITSSkin_Load(this);
  37. CMM_LoadForm(g_sFormsDir, this);
  38. BtnErrorHistory->Visible = true;
  39. FRAMEFacilityList1->PnlTop->Visible = false;
  40. FRAMEFacilityList1->TvList->OptionsData->Editing = false;
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TIFM0030M::CommClose()
  44. {
  45. try
  46. {
  47. CMM_SaveForm(g_sFormsDir, this);
  48. }
  49. catch(...)
  50. {
  51. }
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TIFM0030M::FormInit()
  55. {
  56. m_pGDC = FRAMEFacilityList1->TvList->DataController;
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TIFM0030M::FormShow(TObject *Sender)
  60. {
  61. Refresh();
  62. FormInit();
  63. TmrShow->Enabled = true;
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TIFM0030M::TmrShowTimer(TObject *Sender)
  67. {
  68. TmrShow->Enabled = false;
  69. BtnSearchClick((TObject*)BtnSearch);
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TIFM0030M::BtnSearchClick(TObject *Sender)
  73. {
  74. Application->ProcessMessages();
  75. TSqlCursor sqlCrs((TControl*)BtnSearch);
  76. RefreshData();
  77. }
  78. //---------------------------------------------------------------------------
  79. void __fastcall TIFM0030M::RefreshData()
  80. {
  81. FRAMEFacilityList1->UpdateList();
  82. }
  83. //---------------------------------------------------------------------------
  84. void __fastcall TIFM0030M::BtnCloseClick(TObject *Sender)
  85. {
  86. Close();
  87. }
  88. //---------------------------------------------------------------------------
  89. void __fastcall TIFM0030M::FormClose(TObject *Sender, TCloseAction &Action)
  90. {
  91. CommClose();
  92. IFM0030M = NULL;
  93. Action = caFree;
  94. }
  95. //---------------------------------------------------------------------------
  96. void __fastcall TIFM0030M::FRAMEFacilityList1TvListFocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
  97. TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
  98. {
  99. if (!AFocusedRecord)
  100. {
  101. FRAMEFacilityFail1->UpdateCheck();
  102. FRAMEFacilityFail1->UpdateList(NULL);
  103. return;
  104. }
  105. if (FRAMEFacilityList1->TvList->ViewData->RecordCount <= 0) return;
  106. int nIndex = m_pGDC->FocusedRecordIndex;
  107. if (nIndex < 0) return;
  108. int nMemPtr = m_pGDC->Values[nIndex][FRAMEFacilityList1->Column99->Index];
  109. if (nMemPtr == 0) return;
  110. FRAMEFacilityFail1->UpdateCheck();
  111. FRAMEFacilityFail1->UpdateList((TItsFacility*)nMemPtr);
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TIFM0030M::FRAMEFacilityFail1TvListFocusedRecordChanged(TcxCustomGridTableView *Sender, TcxCustomGridRecord *APrevFocusedRecord,
  115. TcxCustomGridRecord *AFocusedRecord, bool ANewItemRecordFocusingChanged)
  116. {
  117. if (!AFocusedRecord)
  118. {
  119. FRAMEFacilityFailAction1->UpdateCheck();
  120. FRAMEFacilityFailAction1->UpdateList(NULL);
  121. return;
  122. }
  123. if (FRAMEFacilityFail1->TvList->ViewData->RecordCount <= 0) return;
  124. int nIndex = FRAMEFacilityFail1->TvList->DataController->FocusedRecordIndex;
  125. if (nIndex < 0) return;
  126. int nMemPtr = FRAMEFacilityFail1->TvList->DataController->Values[nIndex][FRAMEFacilityFail1->Column99->Index];
  127. if (nMemPtr == 0) return;
  128. FRAMEFacilityFailAction1->UpdateCheck();
  129. FRAMEFacilityFailAction1->UpdateList((TItsFacilityFail*)nMemPtr);
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TIFM0030M::FormCloseQuery(TObject *Sender, bool &CanClose)
  133. {
  134. FRAMEFacilityFailAction1->OnCloseQuery(CanClose);
  135. FRAMEFacilityFail1->OnCloseQuery(CanClose);
  136. try
  137. {
  138. if (ItsFacilityFailManager)
  139. {
  140. delete ItsFacilityFailManager;
  141. ItsFacilityFailManager = NULL;
  142. }
  143. }
  144. catch(...)
  145. {
  146. }
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TIFM0030M::BtnErrorHistoryClick(TObject *Sender)
  150. {
  151. if (IHS0050M)
  152. {
  153. try {
  154. ShowWindow(IHS0050M->Handle, SW_RESTORE);
  155. IHS0050M->BringToFront();
  156. } catch(...) {}
  157. }
  158. else
  159. {
  160. Application->CreateForm(__classid(TIHS0050M), &IHS0050M);
  161. if (IHS0050M) IHS0050M->Show();
  162. }
  163. }
  164. //---------------------------------------------------------------------------