FrmVmsFormSelF.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <IOUtils.hpp>
  4. #include "ITSSkinF.h"
  5. #include "ITSUtilF.h"
  6. #include "AppGlobalF.h"
  7. #pragma hdrstop
  8. #include "FrmVmsFormSelF.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma link "cxButtons"
  12. #pragma link "cxCalendar"
  13. #pragma link "cxContainer"
  14. #pragma link "cxControls"
  15. #pragma link "cxDropDownEdit"
  16. #pragma link "cxEdit"
  17. #pragma link "cxGraphics"
  18. #pragma link "cxGroupBox"
  19. #pragma link "cxLabel"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxPC"
  24. #pragma link "cxPCdxBarPopupMenu"
  25. #pragma link "cxSpinEdit"
  26. #pragma link "cxSplitter"
  27. #pragma link "cxTextEdit"
  28. #pragma link "cxTimeEdit"
  29. #pragma link "dxSkinBlack"
  30. #pragma link "dxSkinBlue"
  31. #pragma link "dxSkinCaramel"
  32. #pragma link "dxSkinCoffee"
  33. #pragma link "dxSkinDarkRoom"
  34. #pragma link "dxSkinDarkSide"
  35. #pragma link "dxSkinFoggy"
  36. #pragma link "dxSkinGlassOceans"
  37. #pragma link "dxSkiniMaginary"
  38. #pragma link "dxSkinLilian"
  39. #pragma link "dxSkinLiquidSky"
  40. #pragma link "dxSkinLondonLiquidSky"
  41. #pragma link "dxSkinMcSkin"
  42. #pragma link "dxSkinMoneyTwins"
  43. #pragma link "dxSkinOffice2007Black"
  44. #pragma link "dxSkinOffice2007Blue"
  45. #pragma link "dxSkinOffice2007Green"
  46. #pragma link "dxSkinOffice2007Pink"
  47. #pragma link "dxSkinOffice2007Silver"
  48. #pragma link "dxSkinOffice2010Black"
  49. #pragma link "dxSkinOffice2010Blue"
  50. #pragma link "dxSkinOffice2010Silver"
  51. #pragma link "dxSkinsCore"
  52. #pragma link "dxSkinscxPCPainter"
  53. #pragma link "dxSkinSeven"
  54. #pragma link "dxSkinSharp"
  55. #pragma link "dxSkinSilver"
  56. #pragma link "dxSkinStardust"
  57. #pragma link "cxRadioGroup"
  58. #pragma link "cxClasses"
  59. #pragma link "cxCustomData"
  60. #pragma link "cxData"
  61. #pragma link "cxDataStorage"
  62. #pragma link "cxDBData"
  63. #pragma link "cxFilter"
  64. #pragma link "cxGrid"
  65. #pragma link "cxGridCustomTableView"
  66. #pragma link "cxGridCustomView"
  67. #pragma link "cxGridDBTableView"
  68. #pragma link "cxGridLevel"
  69. #pragma link "cxGridTableView"
  70. #pragma link "cxStyles"
  71. #pragma link "cxCheckBox"
  72. #pragma link "cxImage"
  73. #pragma link "cxButtonEdit"
  74. #pragma link "cxBlobEdit"
  75. #pragma resource "*.dfm"
  76. TFrmVmsFormSel *FrmVmsFormSel = NULL;
  77. //---------------------------------------------------------------------------
  78. __fastcall TFrmVmsFormSel::TFrmVmsFormSel(TComponent* Owner)
  79. : TForm(Owner)
  80. {
  81. ITSSkin_Load(this);
  82. //CMM_LoadForm(g_sFormsDir, this);
  83. FUpdate= false;
  84. FTitle = Caption;//"VMS 객체이미지 선택";
  85. FListSymb = new TList;
  86. EditMode = false;
  87. m_bSelected = false;
  88. EdVmsFormId->Clear();
  89. TvList->OptionsView->DataRowHeight = 0;
  90. TvList->OptionsView->CellAutoHeight = true;
  91. TvList->OptionsView->Indicator = true;
  92. TvList->OptionsCustomize->ColumnMoving = false;
  93. TvList->OptionsCustomize->ColumnSorting = false;
  94. //TvList->Columns[0]->Width = 50;
  95. //TvList->Columns[0]->Options->HorzSizing = false;
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TFrmVmsFormSel::CommClose()
  99. {
  100. try
  101. {
  102. ClearSymbloList();
  103. SAFE_DELETE(FListSymb);
  104. //CMM_SaveForm(g_sFormsDir, this);
  105. }
  106. catch(...)
  107. {
  108. }
  109. }
  110. //---------------------------------------------------------------------------
  111. void __fastcall TFrmVmsFormSel::FormShow(TObject *Sender)
  112. {
  113. Refresh();
  114. FormInit();
  115. TmrShow->Enabled = true;
  116. }
  117. //---------------------------------------------------------------------------
  118. void __fastcall TFrmVmsFormSel::FormInit()
  119. {
  120. EdVmsFormId->Clear();
  121. ImgPreView->Picture->Bitmap->FreeImage();
  122. ImgPreView->Picture->Bitmap = NULL;
  123. FNewDb = false;
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TFrmVmsFormSel::TmrShowTimer(TObject *Sender)
  127. {
  128. TmrShow->Enabled = false;
  129. LoadVmsForm();
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TFrmVmsFormSel::BtnCloseClick(TObject *Sender)
  133. {
  134. Close();
  135. }
  136. //---------------------------------------------------------------------------
  137. void __fastcall TFrmVmsFormSel::FormClose(TObject *Sender, TCloseAction &Action)
  138. {
  139. CommClose();
  140. FrmVmsFormSel = NULL;
  141. Action = caFree;
  142. }
  143. //---------------------------------------------------------------------------
  144. void __fastcall TFrmVmsFormSel::FormCloseQuery(TObject *Sender, bool &CanClose)
  145. {
  146. //
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TFrmVmsFormSel::DisplayInfo()
  150. {
  151. FormInit();
  152. int nRow = TvList->DataController->FocusedRecordIndex;
  153. if( nRow <= -1 )
  154. return;
  155. TcxGridDataController *pDc = TvList->DataController;
  156. nRow = pDc->FocusedRecordIndex;
  157. EdVmsFormId->Text = VarToStr(pDc->Values[nRow][ColPictId->Index]);
  158. EdVmsFormNm->Text = VarToStr(pDc->Values[nRow][ColPictNm->Index]);
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TFrmVmsFormSel::ClearSymbloList()
  162. {
  163. for(int ii = 0; ii < FListSymb->Count; ii++)
  164. {
  165. Graphics::TBitmap *bitmap = (Graphics::TBitmap *)FListSymb->Items[ii];
  166. delete bitmap;
  167. }
  168. FListSymb->Clear();
  169. }
  170. //---------------------------------------------------------------------------
  171. void __fastcall TFrmVmsFormSel::LoadVmsForm()
  172. {
  173. FormInit();
  174. CMM_ClearGridTableView(TvList);
  175. ClearSymbloList();
  176. String sQry;
  177. TADOQuery *pADO = NULL;
  178. sQry = "SELECT T.VMS_FORM_ID, \r\n"
  179. " T.VMS_MODL_KIND, \r\n"
  180. " T.VMS_FORM_TYPE, \r\n"
  181. " T.VMS_FORM_NM, \r\n"
  182. " T.VMS_FORM_IMG \r\n"
  183. " FROM TB_VMS_FORM T \r\n"
  184. " WHERE 1=1 \r\n"
  185. " AND T.VMS_MODL_KIND = :p01 \r\n"
  186. " AND T.VMS_FORM_TYPE = :p02 \r\n"
  187. " ORDER BY T.VMS_FORM_ID \r\n";
  188. int nRowHeight = 0;
  189. try
  190. {
  191. int nRow;
  192. TcxDataController *pGDC = TvList->DataController;
  193. TvList->BeginUpdate();
  194. try
  195. {
  196. pADO = new TADOQuery(NULL);
  197. pADO->Close();
  198. pADO->Connection = ITSDb_GetConnection();
  199. ITSDb_SQLText(pADO, sQry);
  200. ITSDb_SQLBind(pADO, "p01", FVmsModlKind);
  201. ITSDb_SQLBind(pADO, "p02", FVmsMsgType);
  202. ITSDb_SQLOpen(pADO);
  203. for( ; !pADO->Eof; pADO->Next()) {
  204. nRow = pGDC->AppendRecord();
  205. String VMS_FORM_ID = pADO->FieldByName("VMS_FORM_ID")->AsString;
  206. pGDC->Values[nRow][ColPictId->Index] = VMS_FORM_ID;
  207. pGDC->Values[nRow][ColPictNm->Index] = pADO->FieldByName("VMS_FORM_NM")->AsString;
  208. pGDC->Values[nRow][ColData->Index] = pADO->FieldByName("VMS_FORM_IMG")->AsVariant;
  209. }
  210. }
  211. catch(EDatabaseError &E)
  212. {
  213. DBERRORMSG("TFrmVmsFormSel::LoadVmsForm", String(E.ClassName()), E.Message, sQry);
  214. throw Exception(String(E.ClassName()) + E.Message);
  215. }
  216. catch(Exception &e)
  217. {
  218. DBERRORMSG("TFrmVmsFormSel::LoadVmsForm", String(e.ClassName()), e.Message, sQry);
  219. throw Exception(String(e.ClassName()) + e.Message);
  220. }
  221. }
  222. __finally
  223. {
  224. if (pADO)
  225. {
  226. pADO->Close();
  227. delete pADO;
  228. }
  229. //TvList->OptionsView->DataRowHeight = nRowHeight;
  230. TvList->EndUpdate();
  231. }
  232. }
  233. //---------------------------------------------------------------------------
  234. void __fastcall TFrmVmsFormSel::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  235. TMouseButton AButton, TShiftState AShift,
  236. bool &AHandled)
  237. {
  238. if (!ACellViewInfo) return;
  239. DisplayInfo();
  240. Sleep(200);
  241. BtnSelImageClick((TObject*)BtnSelImage);
  242. }
  243. //---------------------------------------------------------------------------
  244. void __fastcall TFrmVmsFormSel::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
  245. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  246. bool ANewItemRecordFocusingChanged)
  247. {
  248. if (!AFocusedRecord) return;
  249. DisplayInfo();
  250. }
  251. //---------------------------------------------------------------------------
  252. void __fastcall TFrmVmsFormSel::BtnSelImageClick(TObject *Sender)
  253. {
  254. if (EdVmsFormId->Text == "")
  255. {
  256. Application->MessageBox(L"VMS 메시지 폼 선택\r\nVMS 메시지 폼을 목록에서 선택하세요.",
  257. FTitle.c_str(),
  258. MB_OK|MB_ICONERROR|MB_APPLMODAL);
  259. return;
  260. }
  261. m_bSelected = true;
  262. Close();
  263. }
  264. //---------------------------------------------------------------------------