PRK0014MF.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "AppGlobalF.h"
  6. #include "ITSLangTransF.h"
  7. #pragma hdrstop
  8. #include "PRK0014MF.h"
  9. #include "ITS_OPLibF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtons"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxEdit"
  16. #pragma link "cxGraphics"
  17. #pragma link "cxGroupBox"
  18. #pragma link "cxLookAndFeelPainters"
  19. #pragma link "cxLookAndFeels"
  20. #pragma link "dxSkinBlack"
  21. #pragma link "dxSkinMcSkin"
  22. #pragma link "dxSkinsCore"
  23. #pragma link "cxLabel"
  24. #pragma link "cxMaskEdit"
  25. #pragma link "cxSpinEdit"
  26. #pragma link "cxTextEdit"
  27. #pragma link "cxClasses"
  28. #pragma link "cxCustomData"
  29. #pragma link "cxData"
  30. #pragma link "cxDataStorage"
  31. #pragma link "cxFilter"
  32. #pragma link "cxGrid"
  33. #pragma link "cxGridCustomTableView"
  34. #pragma link "cxGridCustomView"
  35. #pragma link "cxGridLevel"
  36. #pragma link "cxGridTableView"
  37. #pragma link "cxStyles"
  38. #pragma link "dxSkinscxPCPainter"
  39. #pragma resource "*.dfm"
  40. TPRK0014M *PRK0014M = NULL;
  41. //---------------------------------------------------------------------------
  42. __fastcall TPRK0014M::TPRK0014M(TComponent* Owner, TPrkPlce *AObj)
  43. : TForm(Owner)
  44. {
  45. ITSSkin_Load(this);
  46. CMM_LoadForm(g_sFormsDir, this);
  47. Position = poOwnerFormCenter;
  48. FObj = AObj;
  49. //FFlrs = AFlrs;
  50. FSelected = false;
  51. //UpdateList();
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TPRK0014M::UpdateList()
  55. {
  56. CMM_ClearGridTableView(TvFlrNo);
  57. int nRow = 0;
  58. try
  59. {
  60. TcxDataController *pGDC = TvFlrNo->DataController;
  61. TvFlrNo->BeginUpdate();
  62. FOR_STL(TPrkPlceFlr*, pObj, FFlrs)
  63. {
  64. nRow = pGDC->AppendRecord();
  65. pGDC->Values[nRow][Col02->Index] = pObj->FLR_NO;
  66. pGDC->Values[nRow][Col03->Index] = pObj->FLR_PRK_CMPRT_CO;
  67. }
  68. }
  69. __finally
  70. {
  71. TvFlrNo->EndUpdate();
  72. TvFlrNo->DataController->GotoFirst();
  73. TvFlrNo->DataController->FocusedRecordIndex = 0;
  74. }
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TPRK0014M::BtnSelectClick(TObject *Sender)
  78. {
  79. bool dataOK = true;
  80. try {
  81. TvFlrNo->BeginUpdate();
  82. for (int ii = 0; ii < TvFlrNo->DataController->RecordCount; ii++)
  83. {
  84. String sCount = VarToStr(TvFlrNo->DataController->Values[ii][Col03->Index]);
  85. if (sCount == "" || sCount == "0") {
  86. dataOK = false;
  87. break;
  88. }
  89. }
  90. }
  91. __finally
  92. {
  93. TvFlrNo->EndUpdate();
  94. }
  95. if (!dataOK)
  96. {
  97. Application->MessageBox(L"층의 주차구획수가 잘 못 입력 되었습니다..",
  98. Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  99. return;
  100. }
  101. FSelected = true;
  102. Close();
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TPRK0014M::BtnCancelClick(TObject *Sender)
  106. {
  107. FSelected = false;
  108. Close();
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TPRK0014M::FormClose(TObject *Sender, TCloseAction &Action)
  112. {
  113. //CMM_SaveForm(g_sFormsDir, this);
  114. }
  115. //---------------------------------------------------------------------------
  116. void __fastcall TPRK0014M::TvFlrNoCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  117. TMouseButton AButton, TShiftState AShift, bool &AHandled)
  118. {
  119. if (!ACellViewInfo) return;
  120. int nRow = TvFlrNo->DataController->FocusedRecordIndex;
  121. if( nRow <= -1 )
  122. return;
  123. String SEL_FLR_NO = TvFlrNo->DataController->Values[nRow][Col02->Index];
  124. String SEL_FLR_PRK_CMPRT_CO = TvFlrNo->DataController->Values[nRow][Col03->Index];
  125. FLR_NO->Text = SEL_FLR_NO;
  126. FLR_PRK_CMPRT_CO->Value = SEL_FLR_PRK_CMPRT_CO.ToIntDef(0);
  127. }
  128. //---------------------------------------------------------------------------
  129. bool __fastcall TPRK0014M::FindParkingFloor(String ANmbr)
  130. {
  131. try {
  132. TvFlrNo->BeginUpdate();
  133. for (int ii = 0; ii < TvFlrNo->DataController->RecordCount; ii++)
  134. {
  135. String sNmbr = VarToStr(TvFlrNo->DataController->Values[ii][Col02->Index]);
  136. if (sNmbr == "") continue;
  137. if (sNmbr == ANmbr) return true;
  138. }
  139. }
  140. __finally
  141. {
  142. TvFlrNo->EndUpdate();
  143. }
  144. return false;
  145. }
  146. //---------------------------------------------------------------------------
  147. void __fastcall TPRK0014M::BtnListAddClick(TObject *Sender)
  148. {
  149. String sId = InputBox("층번호", "신규 주차장 층번호를 입력하세요(최대 10Byte).", "층번호" );
  150. sId = sId.Trim();
  151. if (sId == "층번호" || sId == "")
  152. {
  153. return;
  154. }
  155. if (AnsiString(sId).Length() > 10)
  156. {
  157. Application->MessageBox(L"주차장 층번호는 10Byte를 초과할 수 없습니다.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  158. return;
  159. }
  160. if (FindParkingFloor(sId))
  161. {
  162. Application->MessageBox(L"이미 등록되어 있는 층번호 입니다.", Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  163. return;
  164. }
  165. int nRow = TvFlrNo->DataController->AppendRecord();
  166. TvFlrNo->DataController->Values[nRow][Col02->Index] = sId;
  167. TvFlrNo->DataController->Values[nRow][Col03->Index] = 0;
  168. }
  169. //---------------------------------------------------------------------------
  170. void __fastcall TPRK0014M::BtnListDeleteClick(TObject *Sender)
  171. {
  172. int nSelRows = TvFlrNo->Controller->SelectedRowCount;
  173. if (nSelRows <= 0)
  174. {
  175. Application->MessageBox(L"삭제를 원하는 주차장 층을 목록에서 선택하세요.",
  176. Caption.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  177. return;
  178. }
  179. TvFlrNo->Controller->DeleteSelection();
  180. }
  181. //---------------------------------------------------------------------------