VMSM520MF.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /****************************************************************************
  2. * @source :
  3. * @description :
  4. ****************************************************************************
  5. * DATE AUTHOR DESCRIPTION
  6. * --------------------------------------------------------------------------
  7. * 2016/07/10 shjung 최초작성
  8. *
  9. ****************************************************************************/
  10. //---------------------------------------------------------------------------
  11. #include <vcl.h>
  12. #include "ITSSkinF.h"
  13. #include "ITSUtilF.h"
  14. #include "AppGlobalF.h"
  15. #pragma hdrstop
  16. #include "VMSM520MF.h"
  17. //---------------------------------------------------------------------------
  18. #pragma package(smart_init)
  19. #pragma link "cxButtons"
  20. #pragma link "cxCalendar"
  21. #pragma link "cxContainer"
  22. #pragma link "cxControls"
  23. #pragma link "cxDropDownEdit"
  24. #pragma link "cxEdit"
  25. #pragma link "cxGraphics"
  26. #pragma link "cxGroupBox"
  27. #pragma link "cxLabel"
  28. #pragma link "cxLookAndFeelPainters"
  29. #pragma link "cxLookAndFeels"
  30. #pragma link "cxMaskEdit"
  31. #pragma link "cxPC"
  32. #pragma link "cxPCdxBarPopupMenu"
  33. #pragma link "cxSpinEdit"
  34. #pragma link "cxSplitter"
  35. #pragma link "cxTextEdit"
  36. #pragma link "cxTimeEdit"
  37. #pragma link "dxSkinBlack"
  38. #pragma link "dxSkinBlue"
  39. #pragma link "dxSkinCaramel"
  40. #pragma link "dxSkinCoffee"
  41. #pragma link "dxSkinDarkRoom"
  42. #pragma link "dxSkinDarkSide"
  43. #pragma link "dxSkinFoggy"
  44. #pragma link "dxSkinGlassOceans"
  45. #pragma link "dxSkiniMaginary"
  46. #pragma link "dxSkinLilian"
  47. #pragma link "dxSkinLiquidSky"
  48. #pragma link "dxSkinLondonLiquidSky"
  49. #pragma link "dxSkinMcSkin"
  50. #pragma link "dxSkinMoneyTwins"
  51. #pragma link "dxSkinOffice2007Black"
  52. #pragma link "dxSkinOffice2007Blue"
  53. #pragma link "dxSkinOffice2007Green"
  54. #pragma link "dxSkinOffice2007Pink"
  55. #pragma link "dxSkinOffice2007Silver"
  56. #pragma link "dxSkinOffice2010Black"
  57. #pragma link "dxSkinOffice2010Blue"
  58. #pragma link "dxSkinOffice2010Silver"
  59. #pragma link "dxSkinsCore"
  60. #pragma link "dxSkinscxPCPainter"
  61. #pragma link "dxSkinSeven"
  62. #pragma link "dxSkinSharp"
  63. #pragma link "dxSkinSilver"
  64. #pragma link "dxSkinStardust"
  65. #pragma link "cxRadioGroup"
  66. #pragma link "cxClasses"
  67. #pragma link "cxCustomData"
  68. #pragma link "cxData"
  69. #pragma link "cxDataStorage"
  70. #pragma link "cxDBData"
  71. #pragma link "cxFilter"
  72. #pragma link "cxGrid"
  73. #pragma link "cxGridCustomTableView"
  74. #pragma link "cxGridCustomView"
  75. #pragma link "cxGridDBTableView"
  76. #pragma link "cxGridLevel"
  77. #pragma link "cxGridTableView"
  78. #pragma link "cxStyles"
  79. #pragma link "cxCheckBox"
  80. #pragma link "cxImage"
  81. #pragma link "cxButtonEdit"
  82. #pragma link "cxBlobEdit"
  83. #pragma resource "*.dfm"
  84. TVMSM520M *VMSM520M = NULL;
  85. //---------------------------------------------------------------------------
  86. __fastcall TVMSM520M::TVMSM520M(TComponent* Owner)
  87. : TForm(Owner)
  88. {
  89. ITSSkin_Load(this);
  90. //CMM_LoadForm(g_sFormsDir, this);
  91. FUpdate= false;
  92. FTitle = Caption;//"VMS 폼 유형 선택";
  93. FListSymb = new TList;
  94. EditMode = false;
  95. m_bSelected = false;
  96. TvList->OptionsView->DataRowHeight = 0;
  97. TvList->OptionsView->CellAutoHeight = true;
  98. TvList->OptionsView->Indicator = true;
  99. TvList->OptionsCustomize->ColumnMoving = false;
  100. TvList->OptionsCustomize->ColumnSorting = false;
  101. TvList->Columns[0]->Width = 60;
  102. TvList->Columns[0]->Options->HorzSizing = false;
  103. }
  104. //---------------------------------------------------------------------------
  105. /*
  106. * 닫기버튼 이나 x버튼 클릭시 공통으로 처리하는 로직이들어간다..
  107. * Form과 DataModule class를 delete시킨다.
  108. * arguments
  109. *
  110. * return
  111. * void
  112. */
  113. void __fastcall TVMSM520M::CommClose()
  114. {
  115. try
  116. {
  117. ClearSymbloList();
  118. SAFE_DELETE(FListSymb);
  119. //CMM_SaveForm(g_sFormsDir, this);
  120. }
  121. catch(...)
  122. {
  123. }
  124. }
  125. //---------------------------------------------------------------------------
  126. /*
  127. * Form을 보여줄때 호출되는 event 메서드이다.
  128. * arguments
  129. * Sender : event handler 객체
  130. * return
  131. * void
  132. */
  133. void __fastcall TVMSM520M::FormShow(TObject *Sender)
  134. {
  135. Refresh();
  136. FormInit();
  137. TmrShow->Enabled = true;
  138. }
  139. //---------------------------------------------------------------------------
  140. /*
  141. * form 초기화
  142. *
  143. * arguments
  144. *
  145. * return
  146. * void
  147. */
  148. void __fastcall TVMSM520M::FormInit()
  149. {
  150. EdNmbr->Text = "";
  151. ImgPreView->Picture->Bitmap->FreeImage();
  152. ImgPreView->Picture->Bitmap = NULL;
  153. FillVmsFormType();
  154. FNewDb = false;
  155. }
  156. //---------------------------------------------------------------------------
  157. void __fastcall TVMSM520M::FillVmsFormType()
  158. {
  159. String sQry;
  160. TADOQuery *pADO = NULL;
  161. CMM_ClearGridTableView(TvList);
  162. sQry = "SELECT VMS_FORM_TYPE_CD AS CD, \r\n"
  163. " VMS_FORM_TYPE_NM AS NM, \r\n"
  164. " EDTN_CD \r\n"
  165. " FROM TB_VMS_FORM_TYPE \r\n"
  166. " ORDER BY CD ASC \r\n";
  167. try
  168. {
  169. int nRow;
  170. TcxDataController *pGDC = TvList->DataController;
  171. TvList->BeginUpdate();
  172. try
  173. {
  174. pADO = new TADOQuery(NULL);
  175. pADO->Close();
  176. pADO->Connection = ITSDb_GetConnection();
  177. ITSDb_SQLText(pADO, sQry);
  178. ITSDb_SQLOpen(pADO);
  179. for( ; !pADO->Eof; pADO->Next())
  180. {
  181. String sUse = pADO->FieldByName("EDTN_CD")->AsString;
  182. if (sUse == "EDI2") continue;
  183. String sCd = pADO->FieldByName("CD")->AsString;
  184. String sNm = pADO->FieldByName("NM")->AsString;
  185. nRow = pGDC->AppendRecord();
  186. pGDC->Values[nRow][ColLink1->Index] = sCd;
  187. pGDC->Values[nRow][ColLink3->Index] = sNm;
  188. }
  189. }
  190. catch(EDatabaseError &E)
  191. {
  192. DBERRORMSG("FillVmsFormType", String(E.ClassName()), E.Message, sQry);
  193. throw Exception(String(E.ClassName()) + E.Message);
  194. }
  195. catch(Exception &exception)
  196. {
  197. DBERRORMSG("FillVmsFormType", String(exception.ClassName()), exception.Message, sQry);
  198. throw Exception(String(exception.ClassName()) + exception.Message);
  199. }
  200. }
  201. __finally
  202. {
  203. if (pADO)
  204. {
  205. pADO->Close();
  206. delete pADO;
  207. }
  208. TvList->EndUpdate();
  209. }
  210. }
  211. //---------------------------------------------------------------------------
  212. /*
  213. * Form이 Show되고 난 후 최초 1회 수행되는 타이머 이벤트
  214. * arguments
  215. * Sender : event handler 객체
  216. * return
  217. * void
  218. */
  219. void __fastcall TVMSM520M::TmrShowTimer(TObject *Sender)
  220. {
  221. TmrShow->Enabled = false;
  222. }
  223. //---------------------------------------------------------------------------
  224. /*
  225. * Close 버튼 클릭 이벤트 핸들러
  226. * arguments
  227. * Sender : event handler 객체
  228. * return
  229. * void
  230. */
  231. void __fastcall TVMSM520M::BtnCloseClick(TObject *Sender)
  232. {
  233. Close();
  234. }
  235. //---------------------------------------------------------------------------
  236. void __fastcall TVMSM520M::FormClose(TObject *Sender, TCloseAction &Action)
  237. {
  238. CommClose();
  239. VMSM520M = NULL;
  240. Action = caFree;
  241. }
  242. //---------------------------------------------------------------------------
  243. void __fastcall TVMSM520M::FormCloseQuery(TObject *Sender, bool &CanClose)
  244. {
  245. //
  246. }
  247. //---------------------------------------------------------------------------
  248. void __fastcall TVMSM520M::DisplayInfo()
  249. {
  250. //FormInit();
  251. int nRow = TvList->DataController->FocusedRecordIndex;
  252. if( nRow <= -1 )
  253. return;
  254. TcxGridDataController *pDc = TvList->DataController;
  255. nRow = pDc->FocusedRecordIndex;
  256. #if 0
  257. if (nRow < FListSymb->Count)
  258. {
  259. Graphics::TBitmap *bitmap = (Graphics::TBitmap*)FListSymb->Items[nRow];
  260. ImgPreView->Picture->Bitmap->Assign(bitmap);
  261. }
  262. #endif
  263. EdNmbr->Text = VarToStr(pDc->Values[nRow][ColLink1->Index]);
  264. }
  265. //---------------------------------------------------------------------------
  266. void __fastcall TVMSM520M::ClearSymbloList()
  267. {
  268. for(int ii = 0; ii < FListSymb->Count; ii++)
  269. {
  270. Graphics::TBitmap *bitmap = (Graphics::TBitmap *)FListSymb->Items[ii];
  271. delete bitmap;
  272. }
  273. FListSymb->Clear();
  274. }
  275. //---------------------------------------------------------------------------
  276. void __fastcall TVMSM520M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo,
  277. TMouseButton AButton, TShiftState AShift,
  278. bool &AHandled)
  279. {
  280. if (!ACellViewInfo) return;
  281. DisplayInfo();
  282. //Sleep(200);
  283. BtnSelImageClick((TObject*)BtnSelImage);
  284. }
  285. //---------------------------------------------------------------------------
  286. void __fastcall TVMSM520M::TvListFocusedRecordChanged(TcxCustomGridTableView *Sender,
  287. TcxCustomGridRecord *APrevFocusedRecord, TcxCustomGridRecord *AFocusedRecord,
  288. bool ANewItemRecordFocusingChanged)
  289. {
  290. if (!AFocusedRecord) return;
  291. DisplayInfo();
  292. }
  293. //---------------------------------------------------------------------------
  294. void __fastcall TVMSM520M::BtnSelImageClick(TObject *Sender)
  295. {
  296. if (EdNmbr->Text == "")
  297. {
  298. Application->MessageBox(MSG701, FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
  299. return;
  300. }
  301. m_bSelected = true;
  302. Close();
  303. }
  304. //---------------------------------------------------------------------------