12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "ITSSkinF.h"
- #include "ITSUtilF.h"
- #include "AppGlobalF.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)
- {
- 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;
- }
- //---------------------------------------------------------------------------
- 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);
- }
- //---------------------------------------------------------------------------
- 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("TVMSEDT0M::DisplayFormInfo", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("TVMSEDT0M::DisplayFormInfo", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- TvForm->ApplyBestFit(NULL, false, false);
- 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_ID = B.VMS_CTLR_ID(+) \r\n";
- }
- else
- {
- sWhere = " AND A.VMS_CTLR_ID = B.VMS_CTLR_ID \r\n";
- }
- sQry = "SELECT A.VMS_CTLR_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_ID, NULL, 0, 1) AS FG \r\n"
- " FROM TB_VMS_CTLR A, \r\n"
- " (SELECT X.VMS_CTLR_ID, \r\n"
- " X.VMS_SCH_TYPE, \r\n"
- " X.VMS_SCH_FORM_TYPE, \r\n"
- " X.PHASE, \r\n"
- " X.VMS_FORM_ID, \r\n"
- " X.DSPL_STRT_HH, \r\n"
- " X.DSPL_END_HH, \r\n"
- " X.DSPL_HH, \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.FRST_IMG_IFSC_ID, \r\n"
- " X.SECD_IMG_IFSC_ID, \r\n"
- " X.THIR_IMG_IFSC_ID, \r\n"
- " X.FOUR_IMG_IFSC_ID, \r\n"
- " X.SYMB_LIB_NMBR, \r\n"
- " X.STRM_ADDR, \r\n"
- " X.USE_YN, \r\n"
- " Y.VMS_MODL_KIND, \r\n"
- " Y.VMS_FORM_TYPE_CD, \r\n"
- " Y.VMS_FORM_NM \r\n"
- " FROM TB_VMS_DSPL_SCH X, \r\n"
- " TB_VMS_FORM Y \r\n"
- " WHERE X.VMS_FORM_ID = Y.VMS_FORM_ID \r\n"
- " AND X.VMS_SCH_TYPE = :p02 \r\n"
- " AND X.VMS_SCH_FORM_TYPE = :p03 \r\n"
- " AND X.VMS_FORM_ID = :p04) B \r\n"
- " WHERE A.VMS_MODL_KIND = :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", FScheFormType);
- ITSDb_SQLBind(pADO, "p04", 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_ID")->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("TVMSEDT0M::DisplayVmsInfo", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- DBERRORMSG("TVMSEDT0M::DisplayVmsInfo", 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_DSPL_SCH \r\n"
- " WHERE VMS_CTLR_ID = :p01 \r\n"
- " AND VMS_SCH_TYPE = :p02 \r\n"
- " AND VMS_SCH_FORM_TYPE = :p03 \r\n"
- " AND PHASE = :p04 \r\n"
- " AND VMS_FORM_ID = :p05 \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 sScheFormType = FScheFormType;
- String sPhase = VarToStr(ARow->Values[Col07->Index]);
- String sFormId = FFormId;
- ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
- ITSDb_SQLBind(pADO, "p02", sScheType);
- ITSDb_SQLBind(pADO, "p03", sScheFormType);
- ITSDb_SQLBind(pADO, "p04", sPhase);
- ITSDb_SQLBind(pADO, "p05", sFormId);
- ITSDb_SQLExec(pADO);
- }
- //ITSDb_GetConnection()->CommitTrans();
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::DeleteVmsSchedule", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::DeleteVmsSchedule", 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_DSPL_SCH \r\n"
- " SET 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_ID = :p01 \r\n"
- " AND VMS_SCH_TYPE = :p09 \r\n"
- " AND VMS_SCH_FORM_TYPE = :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 sScheFormType = FScheFormType;
- 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", sScheFormType);
- 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_SQLBind(pADO, "p09", sScheType);
- ITSDb_SQLExec(pADO);
- }
- //ITSDb_GetConnection()->CommitTrans();
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::UpdateVmsSchedule", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::UpdateVmsSchedule", 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;
- #if 0
- sQry = "INSERT INTO TB_VMS_DSPL_SCH ( \r\n"
- " VMS_CTLR_ID, \r\n"
- " VMS_SCH_TYPE, \r\n"
- " VMS_SCH_FORM_TYPE, \r\n"
- " PHASE, \r\n"
- " VMS_FORM_ID, \r\n"
- " DSPL_HH, \r\n"
- " DSPL_STRT_HH, \r\n"
- " DSPL_END_HH, \r\n"
- " SYMB_LIB_NMBR, \r\n"
- " STRM_ADDR, \r\n"
- " USE_YN \r\n"
- " ) \r\n"
- " VALUES ( \r\n"
- " :p01, \r\n"
- " :p02, \r\n"
- " :p11, \r\n"
- " (SELECT NVL(MAX(PHASE), 0) + 1 \r\n"
- " FROM TB_VMS_DSPL_SCH \r\n"
- " WHERE VMS_CTLR_ID = :p08 \r\n"
- " AND VMS_SCH_TYPE = :p09 \r\n"
- " AND VMS_SCH_FORM_TYPE = :p10), \r\n"
- " :p03, \r\n"
- " :p04, \r\n"
- " :p05, \r\n"
- " :p06, \r\n"
- " :p12, \r\n"
- " :p13, \r\n"
- " :p07 \r\n"
- " ) \r\n";
- #else
- sQry = "INSERT INTO TB_VMS_DSPL_SCH ( \r\n"
- " VMS_CTLR_ID, \r\n"
- " VMS_SCH_TYPE, \r\n"
- " VMS_SCH_FORM_TYPE, \r\n"
- " PHASE, \r\n"
- " VMS_FORM_ID, \r\n"
- " DSPL_HH, \r\n"
- " DSPL_STRT_HH, \r\n"
- " DSPL_END_HH, \r\n"
- " SYMB_LIB_NMBR, \r\n"
- " STRM_ADDR, \r\n"
- " USE_YN \r\n"
- " ) \r\n"
- " VALUES ( \r\n"
- " :p01, \r\n"
- " :p02, \r\n"
- " :p11, \r\n"
- " (SELECT NVL(MAX(PHASE), 0) + 1 \r\n"
- " FROM TB_VMS_DSPL_SCH \r\n"
- " WHERE VMS_CTLR_ID = :p08 \r\n"
- " AND VMS_SCH_TYPE = :p09), \r\n"
- " :p03, \r\n"
- " :p04, \r\n"
- " :p05, \r\n"
- " :p06, \r\n"
- " :p12, \r\n"
- " :p13, \r\n"
- " :p07 \r\n"
- " ) \r\n";
- #endif
- 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 sScheFormType = FScheFormType;
- 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_SQLBind(pADO, "p10", sScheFormType);
- ITSDb_SQLBind(pADO, "p11", sScheFormType);
- ITSDb_SQLBind(pADO, "p12", FSymbLibNmbr);
- ITSDb_SQLBind(pADO, "p13", FStreamAddr);
- ITSDb_SQLExec(pADO);
- }
- //ITSDb_GetConnection()->CommitTrans();
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::InsertVmsSchedule", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::InsertVmsSchedule", 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;
- }
- //---------------------------------------------------------------------------
- bool __fastcall TVMSEDT0M::InsertVmsScheduleWeek()
- {
- bool bResult = false;
- #if 0
- String sQry;
- TADOQuery *pADO = NULL;
- sQry = "INSERT INTO TB_VMS_DSPL_SCH_WEEK ( \r\n"
- " VMS_CTLR_ID, \r\n"
- " VMS_SCH_TYPE, \r\n"
- " PHASE, \r\n"
- " WEEK_CD, \r\n"
- " SCH_HH \r\n"
- " ) \r\n"
- " VALUES( \r\n"
- " :p01, :p02, \r\n"
- " (SELECT NVL(MAX(PHASE), 0) \r\n"
- " FROM TB_VMS_DSPL_SCH \r\n"
- " WHERE VMS_CTLR_ID = :p05 \r\n"
- " AND VMS_SCH_TYPE = :p06 \r\n"
- " AND VMS_SCH_FORM_TYPE = :p07), \r\n"
- " :p03, :p04 \r\n"
- " ) \r\n";
- try
- {
- try
- {
- pADO = new TADOQuery(NULL);
- pADO->Close();
- pADO->Connection = ITSDb_GetConnection();
- ITSDb_SQLText(pADO, sQry);
- 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 sScheFormType = FScheFormType;
- for (int jj = 1; jj <= 7; jj++)
- {
- ITSDb_SQLBind(pADO, "p01", sVmsNmbr);
- ITSDb_SQLBind(pADO, "p02", sScheType);
- ITSDb_SQLBind(pADO, "p03", String(jj));
- ITSDb_SQLBind(pADO, "p04", "111111111111111111111111");
- ITSDb_SQLBind(pADO, "p05", sVmsNmbr);
- ITSDb_SQLBind(pADO, "p06", sScheType);
- ITSDb_SQLBind(pADO, "p07", sScheFormType);
- pADO->ExecSQL();
- }
- }
- bResult = true;
- }
- catch(EDatabaseError &E)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::InsertVmsScheduleWeek", String(E.ClassName()), E.Message, sQry);
- throw Exception(String(E.ClassName()) + E.Message);
- }
- catch(Exception &e)
- {
- ITSDb_GetConnection()->RollbackTrans();
- DBERRORMSG("TVMSEDT0M::InsertVmsScheduleWeek", String(e.ClassName()), e.Message, sQry);
- throw Exception(String(e.ClassName()) + e.Message);
- }
- }
- __finally
- {
- if (pADO)
- {
- pADO->Close();
- delete pADO;
- }
- }
- #endif
- return bResult;
- }
- //---------------------------------------------------------------------------
|