/**************************************************************************** * @source : * @description : **************************************************************************** * DATE AUTHOR DESCRIPTION * -------------------------------------------------------------------------- * 2016/07/10 shjung ÃÖÃÊÀÛ¼º * ****************************************************************************/ //--------------------------------------------------------------------------- #include #include "ITSSkinF.h" #include "ITSUtilF.h" #include "AppGlobalF.h" #include "ITSLangTransF.h" #pragma hdrstop #include "VMSEDT0MF.h" #include "VMSSEL0MF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxButtons" #pragma link "cxCalendar" #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxDropDownEdit" #pragma link "cxEdit" #pragma link "cxGraphics" #pragma link "cxGroupBox" #pragma link "cxLabel" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "cxMaskEdit" #pragma link "cxPC" #pragma link "cxPCdxBarPopupMenu" #pragma link "cxSpinEdit" #pragma link "cxSplitter" #pragma link "cxTextEdit" #pragma link "cxTimeEdit" #pragma link "dxSkinBlack" #pragma link "dxSkinBlue" #pragma link "dxSkinCaramel" #pragma link "dxSkinCoffee" #pragma link "dxSkinDarkRoom" #pragma link "dxSkinDarkSide" #pragma link "dxSkinFoggy" #pragma link "dxSkinGlassOceans" #pragma link "dxSkiniMaginary" #pragma link "dxSkinLilian" #pragma link "dxSkinLiquidSky" #pragma link "dxSkinLondonLiquidSky" #pragma link "dxSkinMcSkin" #pragma link "dxSkinMoneyTwins" #pragma link "dxSkinOffice2007Black" #pragma link "dxSkinOffice2007Blue" #pragma link "dxSkinOffice2007Green" #pragma link "dxSkinOffice2007Pink" #pragma link "dxSkinOffice2007Silver" #pragma link "dxSkinOffice2010Black" #pragma link "dxSkinOffice2010Blue" #pragma link "dxSkinOffice2010Silver" #pragma link "dxSkinsCore" #pragma link "dxSkinscxPCPainter" #pragma link "dxSkinSeven" #pragma link "dxSkinSharp" #pragma link "dxSkinSilver" #pragma link "dxSkinStardust" #pragma link "cxRadioGroup" #pragma link "cxClasses" #pragma link "cxCustomData" #pragma link "cxData" #pragma link "cxDataStorage" #pragma link "cxDBData" #pragma link "cxFilter" #pragma link "cxGrid" #pragma link "cxGridCustomTableView" #pragma link "cxGridCustomView" #pragma link "cxGridDBTableView" #pragma link "cxGridLevel" #pragma link "cxGridTableView" #pragma link "cxStyles" #pragma link "cxCheckBox" #pragma link "cxImage" #pragma link "cxButtonEdit" #pragma link "cxBlobEdit" #pragma link "cxColorComboBox" #pragma link "cxCalc" #pragma resource "*.dfm" TVMSEDT0M *VMSEDT0M = NULL; //--------------------------------------------------------------------------- __fastcall TVMSEDT0M::TVMSEDT0M(TComponent* Owner) : TForm(Owner) { LangTrans->Translate(this, ITSDb_GetConnection()); ITSSkin_Load(this); //CMM_LoadForm(g_sFormsDir, this); FUpdate= false; FTitle = Caption;//"VMS Æû ½ºÄÉÁÙ Àϰý °ü¸®"; TvForm->OptionsView->DataRowHeight = 0; TvForm->OptionsView->CellAutoHeight = true; TvForm->OptionsView->Indicator = false; TvForm->OptionsCustomize->ColumnMoving = false; TvForm->OptionsCustomize->ColumnSorting = false; //TvForm->Columns[0]->Width = 40; //TvForm->Columns[0]->Options->HorzSizing = false; FStrTime = ""; FEndTime = ""; FSelected = false; } //--------------------------------------------------------------------------- /* * ´Ý±â¹öư À̳ª x¹öư Ŭ¸¯½Ã °øÅëÀ¸·Î ó¸®ÇÏ´Â ·ÎÁ÷À̵é¾î°£´Ù.. * Form°ú DataModule class¸¦ delete½ÃŲ´Ù. * arguments * * return * void */ void __fastcall TVMSEDT0M::CommClose() { try { //CMM_SaveForm(g_sFormsDir, this); } catch(...) { } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::FormCreate(TObject *Sender) { // } //--------------------------------------------------------------------------- /* * FormÀ» º¸¿©ÁÙ¶§ È£ÃâµÇ´Â event ¸Þ¼­µåÀÌ´Ù. * arguments * Sender : event handler °´Ã¼ * return * void */ void __fastcall TVMSEDT0M::FormShow(TObject *Sender) { #if 1 if (FMode == "A") { FTitle = lblText1->Caption;//"VMS Æû ½ºÄÉÁÙ Àϰý µî·Ï"; GrpObj->Caption = lblText2->Caption;//"¢º VMS ¸ñ·Ï"; BtnAllDel->Visible = false; } else { FTitle = lblText3->Caption;//"VMS Æû ½ºÄÉÁÙ Àϰý ÆíÁý"; GrpObj->Caption = lblText4->Caption;//"¢º ¼±ÅÃÆûÀ» ½ºÄÉÁÙ¿¡ »ç¿ëÁßÀÎ VMS ¸ñ·Ï"; } #else if (FMode == "A") { FTitle = "Batch add of VMS form schedule"; GrpObj->Caption = "¢º VMS List"; BtnAllDel->Visible = false; } else { FTitle = "Batch edit VMS form schedule"; GrpObj->Caption = "¢º List the VMS using to schedule the selection form"; } #endif Caption = FTitle; Refresh(); FormInit(); ChangeEditMode(1); TmrShow->Enabled = true; } //--------------------------------------------------------------------------- /* * form ÃʱâÈ­ * * arguments * * return * void */ void __fastcall TVMSEDT0M::FormInit() { FormObjectInit(); FNewDb = false; } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::FormObjectInit() { //TvList->OptionsView->NoDataToDisplayInfoText = "<°ü·Ã VMS Á¤º¸°¡ ¾ø½À´Ï´Ù>"; } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; BtnSearchClick(NULL); } //--------------------------------------------------------------------------- /* * Close ¹öư Ŭ¸¯ À̺¥Æ® Çڵ鷯 * arguments * Sender : event handler °´Ã¼ * return * void */ void __fastcall TVMSEDT0M::BtnCloseClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::FormClose(TObject *Sender, TCloseAction &Action) { CommClose(); VMSEDT0M = NULL; //Action = caFree; } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::ChangeEditMode(int AEdit) { } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::BtnSearchClick(TObject *Sender) { RefreshData(); EdFocus->SetFocus(); ChangeEditMode(1); if (FStrTime == "") { DtStrDate->Date = Now(); } else { TDateTime dtStrDate = APP_StrToDateTime(FStrTime); DtStrDate->Date = dtStrDate; DtStrTime->Date = dtStrDate; DtStrTime->Time = dtStrDate; } if (FEndTime == "") { TDateTime dtEndDate = EncodeDate(2099, 12, 31); TDateTime dtEndTime = EncodeTime(23, 59, 59, 0); DtEndDate->Date = dtEndDate; DtEndTime->Date = dtEndDate; DtEndTime->Time = dtEndTime; } else { TDateTime dtEndDate = APP_StrToDateTime(FEndTime); DtEndDate->Date = dtEndDate; DtEndTime->Date = dtEndDate; DtEndTime->Time = dtEndDate; } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::RefreshData() { // °Ë»öÁ¶°Ç¿¡ ÀÇÇÑ ¸µÅ© µ¥ÀÌÅÍ Á¶È¸ FormClear(); DisplayFormInfo(0); DisplayVmsInfo(0); } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::FormClear() { EdFormId->Clear(); EdObjId->Clear(); FNewDb = false; } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::DisplayInfo() { FormClear(); ChangeEditMode(3); } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::DisplayFormInfo(int AIdx) { CMM_ClearGridTableView(TvForm); String sQry; TADOQuery *pADO = NULL; sQry = "SELECT A.* \r\n" " FROM TB_VMS_FORM A \r\n" " WHERE A.VMS_FORM_ID = :p01 \r\n" " ORDER BY A.VMS_FORM_ID \r\n"; try { TvForm->BeginUpdate(); TcxDataController *pGDC = TvForm->DataController; int nRow; try { pADO = new TADOQuery(NULL); pADO->Close(); pADO->Connection = ITSDb_GetConnection(); ITSDb_SQLText(pADO, sQry); ITSDb_SQLBind(pADO, "p01", FFormId); ITSDb_SQLOpen(pADO); for( ; !pADO->Eof; pADO->Next()) { nRow = pGDC->AppendRecord(); pGDC->Values[nRow][0] = pADO->FieldByName("VMS_FORM_ID")->AsString; pGDC->Values[nRow][1] = pADO->FieldByName("VMS_FORM_IMAG")->AsVariant; } } catch(EDatabaseError &E) { DBERRORMSG("VMS Form Query", String(E.ClassName()), E.Message, sQry); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { DBERRORMSG("VMS Form Query", String(e.ClassName()), e.Message, sQry); throw Exception(String(e.ClassName()) + e.Message); } } __finally { if (pADO) { pADO->Close(); delete pADO; } TvForm->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::DisplayVmsInfo(int AIdx) { CMM_ClearGridTableView(TvList); String sQry; TADOQuery *pADO = NULL; String sWhere; if (FMode == "A") { sWhere = " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR(+) \r\n"; } else { sWhere = " AND A.VMS_CTLR_NMBR = B.VMS_CTLR_NMBR \r\n"; } sQry = "SELECT A.VMS_CTLR_NMBR, A.VMS_ID, A.VMS_CTLR_ID, A.VMS_NM, \r\n" " B.PHASE, B.DSPL_HH, B.DSPL_STRT_HH, B.DSPL_END_HH, \r\n" " B.USE_YN, B.VMS_FORM_ID, \r\n" " DECODE(B.VMS_CTLR_NMBR, NULL, 0, 1) AS FG \r\n" " FROM TB_VMS_CTLR A, \r\n" " (SELECT X.VMS_CTLR_NMBR, \r\n" " X.TRFC_SITU_TYPE_CD, \r\n" " X.PHASE, \r\n" " X.VMS_FORM_ID, \r\n" " X.FRST_VMS_IFSC_ID, \r\n" " X.SECD_VMS_IFSC_ID, \r\n" " X.THIR_VMS_IFSC_ID, \r\n" " X.FOUR_VMS_IFSC_ID, \r\n" " X.VMS_FORM_PRRT_CD, \r\n" " X.DSPL_HH, \r\n" " X.DSPL_STRT_HH, \r\n" " X.DSPL_END_HH, \r\n" " X.USE_YN, \r\n" " Y.VMS_TYPE_CD, \r\n" " Y.VMS_FORM_TYPE_CD, \r\n" " Y.VMS_FORM_NM \r\n" " FROM TB_VMS_TRFC_INFR_DSPL_SCH X, \r\n" " TB_VMS_FORM Y \r\n" " WHERE X.VMS_FORM_ID = Y.VMS_FORM_ID \r\n" " AND X.TRFC_SITU_TYPE_CD = :p02 \r\n" " AND X.VMS_FORM_ID = :p03) B \r\n" " WHERE A.VMS_TYPE_CD = :p01 \r\n"; sQry+= sWhere; try { TvList->BeginUpdate(); TcxDataController *pGDC = TvList->DataController; int nRow; try { pADO = new TADOQuery(NULL); pADO->Close(); pADO->Connection = ITSDb_GetConnection(); ITSDb_SQLText(pADO, sQry); ITSDb_SQLBind(pADO, "p01", FVmsTypeCd); ITSDb_SQLBind(pADO, "p02", FScheType); ITSDb_SQLBind(pADO, "p03", FFormId); ITSDb_SQLOpen(pADO); for( ; !pADO->Eof; pADO->Next()) { String sFormId = pADO->FieldByName("VMS_FORM_ID")->AsString; if (FMode == "A") { if (sFormId == FFormId) { //ÀüüÃß°¡Àε¥ ±âÁ¸¿¡ µî·ÏµÇ¾î ÀÖÀ¸¸é Ãß°¡ÇÏÁö ¾Ê´Â´Ù. //continue; } } nRow = pGDC->AppendRecord(); pGDC->Values[nRow][Col00->Index] = pADO->FieldByName("VMS_CTLR_NMBR")->AsString; pGDC->Values[nRow][Col01->Index] = pADO->FieldByName("VMS_CTLR_ID")->AsString; pGDC->Values[nRow][Col02->Index] = pADO->FieldByName("VMS_NM")->AsString; String sFlag = pADO->FieldByName("FG")->AsString; if (sFlag == "0") { pGDC->Values[nRow][ColumnSel->Index] = true; pGDC->Values[nRow][Col03->Index] = "4"; pGDC->Values[nRow][Col04->Index] = Now().FormatString(STR_HHNN); pGDC->Values[nRow][Col05->Index] = "2099-12-31 23:59"; pGDC->Values[nRow][Col06->Index] = "Y"; pGDC->Values[nRow][Col07->Index] = "1"; pGDC->Values[nRow][Col08->Index] = Now().FormatString("YYYYMMDDHHNN") + "00"; pGDC->Values[nRow][Col09->Index] = "20991231235959"; continue; } if (FMode == "A") { pGDC->Values[nRow][ColumnSel->Index] = false; } else { pGDC->Values[nRow][ColumnSel->Index] = true; } String sStrDate = pADO->FieldByName("DSPL_STRT_HH")->AsString; String sEndDate = pADO->FieldByName("DSPL_END_HH")->AsString; pGDC->Values[nRow][Col03->Index] = pADO->FieldByName("DSPL_HH")->AsString; pGDC->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN); pGDC->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN); pGDC->Values[nRow][Col06->Index] = pADO->FieldByName("USE_YN")->AsString; pGDC->Values[nRow][Col07->Index] = pADO->FieldByName("PHASE")->AsString; pGDC->Values[nRow][Col08->Index] = sStrDate; pGDC->Values[nRow][Col09->Index] = sEndDate; FStrTime = sStrDate; FEndTime = sEndDate; } } catch(EDatabaseError &E) { DBERRORMSG("VMS Query", String(E.ClassName()), E.Message, sQry); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { DBERRORMSG("VMS Query", String(e.ClassName()), e.Message, sQry); throw Exception(String(e.ClassName()) + e.Message); } } __finally { if (pADO) { pADO->Close(); delete pADO; } TvList->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::BtnAllSelectClick(TObject *Sender) { TcxButton *pBtn = (TcxButton*)Sender; CMM_CheckAllListItem(TvList, ColumnSel->Index, pBtn->Tag); } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::TvListCellDblClick(TcxCustomGridTableView *Sender, TcxGridTableDataCellViewInfo *ACellViewInfo, TMouseButton AButton, TShiftState AShift, bool &AHandled) { if (!ACellViewInfo) return; int nRow = Sender->DataController->FocusedRecordIndex; if( nRow <= -1 ) return; TcxGridDataController *pDc = (TcxGridDataController*)Sender->DataController; int nColIdx = ACellViewInfo->Item->Index; String sStrDate = VarToStr(pDc->Values[nRow][Col08->Index]); String sEndDate = VarToStr(pDc->Values[nRow][Col09->Index]); { //Ç¥Ãâ±â°£¼³Á¤ TVMSSEL0M *pSelDate = new TVMSSEL0M(this); pSelDate->FStrTime = sStrDate; pSelDate->FEndTime = sEndDate; pSelDate->ShowModal(); bool bSelected = pSelDate->FSelected; sStrDate = pSelDate->FStrTime; sEndDate = pSelDate->FEndTime; delete pSelDate; pSelDate = NULL; if (bSelected) { pDc->Values[nRow][Col04->Index] = ITSUtil_FormatStr(sStrDate, STR_HHNN);; pDc->Values[nRow][Col05->Index] = ITSUtil_FormatStr(sEndDate, STR_HHNN);; pDc->Values[nRow][Col08->Index] = sStrDate; pDc->Values[nRow][Col09->Index] = sEndDate; } return; } } //--------------------------------------------------------------------------- bool __fastcall TVMSEDT0M::CheckData(bool ACheckData) { int nSelCnt = CMM_GetCheckCount(TvList, ColumnSel->Index); if (nSelCnt <= 0) { //Application->MessageBox(L"VMS Schedule Batch Management\r\nSelect the VMS you want to work on from the VMS list.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL); Application->MessageBox(lblText5->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\nVMS ¸ñ·Ï¿¡¼­ ÀÛ¾÷´ë»ó VMS¸¦ ¸ÕÀú ¼±ÅÃÇϼ¼¿ä.", FTitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL); return false; } if (!ACheckData) return true; String sStrDate = DtStrDate->Date.FormatString("yyyymmdd"); String sStrTime = DtStrTime->DateTime.FormatString("HHnn"); String sEndDate = DtEndDate->Date.FormatString("yyyymmdd"); String sEndTime = DtEndTime->DateTime.FormatString("HHnn"); FStrTime = sStrDate + sStrTime; FEndTime = sEndDate + sEndTime; if (FStrTime > FEndTime) { //Application->MessageBox(L"The display start time is larger than the display end time.", L"Set VMS form expiration period", MB_OK|MB_ICONWARNING|MB_APPLMODAL); Application->MessageBox(lblText6->Caption.c_str(),//L"Ç¥Ãâ ½ÃÀ۽ð¢ÀÌ Ç¥Ãâ Á¾·á½Ã°¢ º¸´Ù Å®´Ï´Ù.", lblText7->Caption.c_str(),//L"VMS Æû Ç¥Ãâ±â°£ ¼³Á¤", MB_OK|MB_ICONWARNING|MB_APPLMODAL); ActiveControl = DtStrDate; return false; } FStrTime = FStrTime + "00"; FEndTime = FEndTime + "59"; return true; } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::UpdateEditData() { try { TvList->BeginUpdate(); int nRowCnt = TvList->ViewData->RecordCount; for (int ii = 0; ii < nRowCnt; ii++) { TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii]; if (!ARow->IsData) continue; if (!((bool)ARow->Values[ColumnSel->Index])) { continue; } ARow->Values[Col03->Index] = CbCycle->Text.Trim(); ARow->Values[Col04->Index] = ITSUtil_FormatStr(FStrTime, STR_HHNN); ARow->Values[Col05->Index] = ITSUtil_FormatStr(FEndTime, STR_HHNN); ARow->Values[Col06->Index] = CbUse->Text.Trim(); //ARow->Values[Col07->Index] = ""; //phase ARow->Values[Col08->Index] = FStrTime; ARow->Values[Col09->Index] = FEndTime; } } __finally { TvList->EndUpdate(); } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::BtnAllAddClick(TObject *Sender) { //µî·Ï - µî·Ï ¶Ç´Â ¼öÁ¤ INSERT or UPDATE if (!CheckData(true)) return; #if 1 if (Application->MessageBox(lblText8->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\n¼±ÅÃÇÑ VMS¿¡ ´ëÇÏ¿© ½ºÄÉÁÙ Á¤º¸¸¦ [[[µ¿Àϳ»¿ëÀ¸·Î]]] ÀúÀå ÇϽðڽÀ´Ï±î?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #else if (Application->MessageBox(L"VMS schedule management\r\nDo you want to save schedule information for selected VMS [[[Same as above]]]?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #endif UpdateEditData(); //µ¿ÀÏ ÆíÁý³»¿ëÀ» VMS¸ñ·Ï¿¡ Àû¿ë bool bResult; if (FMode == "A") { //INSERT bResult = InsertVmsSchedule(); } else { //UPDATE bResult = UpdateVmsSchedule(); } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::BtnAllEdtClick(TObject *Sender) { //¼öÁ¤ - µî·Ï ¶Ç´Â ¼öÁ¤ INSERT or UPDATE if (!CheckData(true)) return; #if 1 if (Application->MessageBox(lblText9->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\n¼±ÅÃÇÑ VMS¿¡ ´ëÇÏ¿© ½ºÄÉÁÙ Á¤º¸¸¦ ÀúÀå ÇϽðڽÀ´Ï±î?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #else if (Application->MessageBox(L"VMS schedule management\r\nDo you want to save schedule information for selected VMS?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #endif bool bResult; if (FMode == "A") { //INSERT bResult = InsertVmsSchedule(); } else { //UPDATE bResult = UpdateVmsSchedule(); } } //--------------------------------------------------------------------------- void __fastcall TVMSEDT0M::BtnAllDelClick(TObject *Sender) { //»èÁ¦ - ¹«Á¶°Ç DELETE if (!CheckData(false)) return; #if 1 if (Application->MessageBox(lblText10->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\n¼±ÅÃÇÑ VMS¿¡ ´ëÇÏ¿© ½ºÄÉÁÙ Á¤º¸¸¦ »èÁ¦ÇϽðڽÀ´Ï±î?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #else if (Application->MessageBox(L"VMS schedule management\r\nDo you want to delete the schedule information for the selected VMS?", FTitle.c_str(), MB_YESNO|MB_ICONQUESTION|MB_APPLMODAL) != IDYES) return; #endif bool bResult = true; if (bResult) { bResult = DeleteVmsSchedule(); } } //--------------------------------------------------------------------------- bool __fastcall TVMSEDT0M::DeleteVmsSchedule() { bool bResult = false; String sQry; TADOQuery *pADO = NULL; sQry = "DELETE TB_VMS_TRFC_INFR_DSPL_SCH \r\n" " WHERE VMS_CTLR_NMBR = :p01 \r\n" " AND TRFC_SITU_TYPE_CD = :p02 \r\n" " AND PHASE = :p03 \r\n" " AND VMS_FORM_ID = :p04 \r\n"; try { try { pADO = new TADOQuery(NULL); pADO->Close(); pADO->Connection = ITSDb_GetConnection(); ITSDb_SQLText(pADO, sQry); //ITSDb_GetConnection()->BeginTrans(); int nRowCnt = TvList->ViewData->RecordCount; for (int ii = 0; ii < nRowCnt; ii++) { TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii]; if (!ARow->IsData) continue; if (!((bool)ARow->Values[ColumnSel->Index])) { continue; } String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]); String sScheType = FScheType; String sPhase = VarToStr(ARow->Values[Col07->Index]); String sFormId = FFormId; ITSDb_SQLBind(pADO, "p01", sVmsNmbr); ITSDb_SQLBind(pADO, "p02", sScheType); ITSDb_SQLBind(pADO, "p03", sPhase); ITSDb_SQLBind(pADO, "p04", sFormId); ITSDb_SQLExec(pADO); } //ITSDb_GetConnection()->CommitTrans(); bResult = true; } catch(EDatabaseError &E) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule delete", String(E.ClassName()), E.Message, sQry); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule delete", String(e.ClassName()), e.Message, sQry); throw Exception(String(e.ClassName()) + e.Message); } } __finally { if (pADO) { pADO->Close(); delete pADO; } } if (bResult) { #if 1 Application->MessageBox(lblText11->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\nVMS ½ºÄÉÁÙ Á¤º¸¸¦ »èÁ¦ ÇÏ¿´½À´Ï´Ù.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #else Application->MessageBox(L"VMS schedule management\r\nDeleted the VMS schedule information.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #endif FSelected = true; Close(); } return bResult; } //--------------------------------------------------------------------------- bool __fastcall TVMSEDT0M::UpdateVmsSchedule() { bool bResult = false; String sQry; TADOQuery *pADO = NULL; sQry = "UPDATE TB_VMS_TRFC_INFR_DSPL_SCH SET \r\n" " DSPL_HH = :p05, \r\n" " DSPL_STRT_HH = :p06, \r\n" " DSPL_END_HH = :p07, \r\n" " USE_YN = :p08 \r\n" " WHERE VMS_CTLR_NMBR = :p01 \r\n" " AND TRFC_SITU_TYPE_CD = :p02 \r\n" " AND PHASE = :p03 \r\n" " AND VMS_FORM_ID = :p04 \r\n"; try { try { pADO = new TADOQuery(NULL); pADO->Close(); pADO->Connection = ITSDb_GetConnection(); ITSDb_SQLText(pADO, sQry); //ITSDb_GetConnection()->BeginTrans(); int nRowCnt = TvList->ViewData->RecordCount; for (int ii = 0; ii < nRowCnt; ii++) { TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii]; if (!ARow->IsData) continue; if (!((bool)ARow->Values[ColumnSel->Index])) { continue; } String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]); String sScheType = FScheType; String sPhase = VarToStr(ARow->Values[Col07->Index]); String sFormId = FFormId; String sDispHH = VarToStr(ARow->Values[Col03->Index]); String sStrTime = VarToStr(ARow->Values[Col08->Index]); String sEndTime = VarToStr(ARow->Values[Col09->Index]); String sUseYn = VarToStr(ARow->Values[Col06->Index]); ITSDb_SQLBind(pADO, "p01", sVmsNmbr); ITSDb_SQLBind(pADO, "p02", sScheType); ITSDb_SQLBind(pADO, "p03", sPhase); ITSDb_SQLBind(pADO, "p04", sFormId); ITSDb_SQLBind(pADO, "p05", sDispHH); ITSDb_SQLBind(pADO, "p06", sStrTime); ITSDb_SQLBind(pADO, "p07", sEndTime); ITSDb_SQLBind(pADO, "p08", sUseYn); ITSDb_SQLExec(pADO); } //ITSDb_GetConnection()->CommitTrans(); bResult = true; } catch(EDatabaseError &E) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule edit", String(E.ClassName()), E.Message, sQry); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule edit", String(e.ClassName()), e.Message, sQry); throw Exception(String(e.ClassName()) + e.Message); } } __finally { if (pADO) { pADO->Close(); delete pADO; } } if (bResult) { #if 1 Application->MessageBox(lblText12->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\nVMS ½ºÄÉÁÙ Á¤º¸¸¦ ¼öÁ¤ ÇÏ¿´½À´Ï´Ù.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #else Application->MessageBox(L"VMS schedule management\r\Edited the VMS schedule information.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #endif FSelected = true; Close(); } return bResult; } //--------------------------------------------------------------------------- bool __fastcall TVMSEDT0M::InsertVmsSchedule() { bool bResult = false; String sQry; TADOQuery *pADO = NULL; sQry = "INSERT INTO TB_VMS_TRFC_INFR_DSPL_SCH ( \r\n" " VMS_CTLR_NMBR, \r\n" " TRFC_SITU_TYPE_CD, \r\n" " PHASE, \r\n" " VMS_FORM_ID, \r\n" " DSPL_HH, \r\n" " DSPL_STRT_HH, \r\n" " DSPL_END_HH, \r\n" " USE_YN \r\n" " ) \r\n" " VALUES ( \r\n" " :p01, \r\n" " :p02, \r\n" " (SELECT NVL(MAX(PHASE), 0) + 1 \r\n" " FROM TB_VMS_TRFC_INFR_DSPL_SCH \r\n" " WHERE VMS_CTLR_NMBR = :p08 \r\n" " AND TRFC_SITU_TYPE_CD = :p09), \r\n" " :p03, \r\n" " :p04, \r\n" " :p05, \r\n" " :p06, \r\n" " :p07 \r\n" " ) \r\n"; try { try { pADO = new TADOQuery(NULL); pADO->Close(); pADO->Connection = ITSDb_GetConnection(); ITSDb_SQLText(pADO, sQry); //ITSDb_GetConnection()->BeginTrans(); int nRowCnt = TvList->ViewData->RecordCount; for (int ii = 0; ii < nRowCnt; ii++) { TcxCustomGridRow* ARow = TvList->ViewData->Rows[ii]; if (!ARow->IsData) continue; if (!((bool)ARow->Values[ColumnSel->Index])) { continue; } String sVmsNmbr = VarToStr(ARow->Values[Col00->Index]); String sScheType = FScheType; String sFormId = FFormId; String sDispHH = VarToStr(ARow->Values[Col03->Index]); String sStrTime = VarToStr(ARow->Values[Col08->Index]); String sEndTime = VarToStr(ARow->Values[Col09->Index]); String sUseYn = VarToStr(ARow->Values[Col06->Index]); ITSDb_SQLBind(pADO, "p01", sVmsNmbr); ITSDb_SQLBind(pADO, "p02", sScheType); ITSDb_SQLBind(pADO, "p03", sFormId); ITSDb_SQLBind(pADO, "p04", sDispHH); ITSDb_SQLBind(pADO, "p05", sStrTime); ITSDb_SQLBind(pADO, "p06", sEndTime); ITSDb_SQLBind(pADO, "p07", sUseYn); ITSDb_SQLBind(pADO, "p08", sVmsNmbr); ITSDb_SQLBind(pADO, "p09", sScheType); ITSDb_SQLExec(pADO); } //ITSDb_GetConnection()->CommitTrans(); bResult = true; } catch(EDatabaseError &E) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule save", String(E.ClassName()), E.Message, sQry); throw Exception(String(E.ClassName()) + E.Message); } catch(Exception &e) { ITSDb_GetConnection()->RollbackTrans(); DBERRORMSG("VMS Schedule save", String(e.ClassName()), e.Message, sQry); throw Exception(String(e.ClassName()) + e.Message); } } __finally { if (pADO) { pADO->Close(); delete pADO; } } if (bResult) { #if 1 Application->MessageBox(lblText13->Caption.c_str(),//L"VMS ½ºÄÉÁÙ Àϰý °ü¸®\r\nVMS ½ºÄÉÁÙ Á¤º¸¸¦ ÀúÀå ÇÏ¿´½À´Ï´Ù.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #else Application->MessageBox(L"VMS schedule management\r\nVMS schedule information saved.", FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL); #endif FSelected = true; Close(); } return bResult; } //---------------------------------------------------------------------------