| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628 | using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Collections;using Microsoft.Win32;using System.Diagnostics;namespace FPER{    public partial class frmReceiverConfig : Form    {        Boolean ThisRedundant_Flag = true;  //수신기 통신보드이중화        QUERYMode cmd;        //중계기 데이터 읽기 중복을 막기위해        int savBoardID = -1;        int savLoop = -1;        MDIParent mdi = null;        //Tooltip 설정 값...........        IWin32Window window;        //ToolTip tp;        // cyim 2014.5.7 : 수신기설정정보 변경 (하단 주석처리하고 변수는 전역으로 처리한다)        //수신기설정정보 변경여부        //Boolean receiverConfig_Change_Flag = false;        // cyim 2015.8.4 수신반을 위한 static 클래스 정리        private Boolean receiverConfig_Change_Flag = false;        private Boolean ThisReceiverConfig_Change_Flag        {            get            {                // cyim 2015.8.4 수신반을 위한 static 클래스 정리                //return _frmReceiverConfig_Data.receiverConfig_Change_Flag;                 return receiverConfig_Change_Flag;            }            set            {                // cyim 2015.8.4 수신반을 위한 static 클래스 정리                //_frmReceiverConfig_Data.receiverConfig_Change_Flag = value;                receiverConfig_Change_Flag = value;                //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag)                if (receiverConfig_Change_Flag)                {                    this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!";                    this.lblReceiverConfigChangeFlag.Visible = true;                }                else                {                    this.lblReceiverConfigChangeFlag.Visible = false;                }            }        }        //listview3의 선택 item        ListViewItem IOBoard_selectItem;        QUERYMode IOBoard_cmd;        ListViewItem IOBoardDevice_selectItem;        QUERYMode IOBoardDevice_cmd;        //QUERYMode Keypad_cmd;        public frmReceiverConfig()        {            InitializeComponent();            // cyim 2013.7.10 디자인개선작업 : 수신기설정 -> 초반에는 무조건 수신기버튼을 누른것처럼 보이도록 한다            this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;        }        public void Form_Init()        {            try            {            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);            }        }        private void frmTcpConfig_Load(object sender, EventArgs e)        {            // cyim 2013.8.1 : 더블버퍼링 적용            SetStyle(ControlStyles.UserPaint, true);            //this.UpdateStyles();            SetStyle(ControlStyles.AllPaintingInWmPaint, true);            //this.UpdateStyles();            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);            this.UpdateStyles();            try            {                mdi = (MDIParent)this.MdiParent;                this.mdi.SelectMenuIndex = 2;                this.Cursor = Cursors.WaitCursor;                window = this;                //tp = new ToolTip();                txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);                /** 설정(수신기) 시작**/                //VIEW모드로 변경한다.                Util.GroupUIChange(groubReceiver, UIMode.cancel);                //그룹의 데이터를 초기화한다.                GroupReceiverData(null);                //cboUse_Flag 에 item넣기                Util.ComboSetting(cboUse_Flag, Util.useFlagArray(), null);                Receiver_getData();                /** 설정(수신기) 끝**/                /** 설정(통신) 시작**/                //VIEW모드로 변경한다.                Util.GroupUIChange(groupComm1, UIMode.input);                if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel);                Util.GroupUIChange(groupComm3, UIMode.input);                Util.GroupUIChange(groupComm4, UIMode.input);                Comm_Init();                //통신설정 데이터 불러오기                Comm_getData();                /** 설정(통신) 끝**/                /** 설정(통신보드) 시작**/                Util.ComboSetting(cboBoardBaudRate, Util.baudRateArray(), null);                //Util.ComboSetting(cboLoop0BaudRate, Util.baudRateArray(), null);                //Util.ComboSetting(cboLoop1BaudRate, Util.baudRateArray(), null);                //VIEW모드로 변경한다.                Util.GroupUIChange(groubBoard, UIMode.cancel);                //그룹의 데이터를 초기화한다.                GroupBoardData(null);                Board_getData();                /** 설정(통신보드) 끝**/                /** IO보드 시작**/                Util.ComboSetting(cboIOBoardBaudRate, Util.baudRateArray(), null);                //VIEW모드로 변경한다.                Util.GroupUIChange(panelIOBoard, UIMode.cancel);                //그룹의 데이터를 초기화한다.                IOBoardSelectData(null);                IOBoard_getData();                IOBoardDevice_getData();                /** IO보드 끝**/                ///** KEYPAD 시작**/                //Util.ComboSetting(cboKeypadBaudRate, Util.baudRateArray(), null);                //////VIEW모드로 변경한다.                //Util.GroupUIChange(panelKeypad, UIMode.cancel);                //Keypad_getData();                ///** KEYPAD 끝**/                /** 설정(중계기) 시작**/                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi);                Util.ComboSetting(cboBoardList, ary, null);                ////입력회로 설정 Hash저장                //inputHash.Clear();                //DacDeviceConfig dacDeviceConfig = new DacDeviceConfig();                //DataTable dtable = dacDeviceConfig.Device_type_Select("I",null);                //if (dtable.Rows.Count > 0)                //{                //    foreach (DataRow dr in dtable.Rows)                //    {                //        //String cboText = dr["DEVICE_TYPE"].ToString() + "-" + dr["DEVICE_TYPE_NAME"].ToString();                //        String cboText = dr["DEVICE_TYPE_NAME"].ToString();                //        inputHash.Add(dr["DEVICE_TYPE"].ToString(), cboText);                //    }                //}                ////출력회로 설정 Hash저장                //outputHash.Clear();                //DataTable dtable2 = dacDeviceConfig.Device_type_Select("O",null);                //if (dtable2.Rows.Count > 0)                //{                //    foreach (DataRow dr2 in dtable2.Rows)                //    {                //        //String cboText = dr2["DEVICE_TYPE"].ToString() + "-" + dr2["DEVICE_TYPE_NAME"].ToString();                //        String cboText = dr2["DEVICE_TYPE_NAME"].ToString();                //        outputHash.Add(dr2["DEVICE_TYPE"].ToString(), cboText);                //    }                //}                Repeater_getDate();                /** 설정(중계기) 끝**/                this.Cursor = Cursors.Default;                // cyim 2015.8.4 수신반을 위한 static 클래스 정리                // cyim 2014.5.7 : 수신기설정정보 변경                //if (_frmReceiverConfig_Data.receiverConfig_Change_Flag)                if (receiverConfig_Change_Flag)                {                    this.lblReceiverConfigChangeFlag.Text = "설정 변경됨! 반드시 모든 데이타 저장 버튼 실행하십시요!";                    this.lblReceiverConfigChangeFlag.Visible = true;                }                else                {                    this.lblReceiverConfigChangeFlag.Visible = false;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void frmTcpConfig_Activated(object sender, EventArgs e)        {            try            {                this.mdi.SelectMenuIndex = 2;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /******************************************************************************************************/        /*                                                     설정정보 리셋                                                                             */        /******************************************************************************************************/        private void frmTcpConfig_Disposed(object sender, EventArgs e)        {            try            {                //설정정보가 변경되었다면 다시 읽어라~~~~~~                if (ThisReceiverConfig_Change_Flag)                {                    this.Cursor = Cursors.WaitCursor;                    mdi.ui.ReceiverDBRead();            //설정정보 변경                    mdi.FireReset_Process();        //데몬 RESET 명령                }                this.mdi.SelectMenuIndex = 0;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //throw ex;                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);            }            finally            {                this.Cursor = Cursors.Default;            }        }        /******************************************************************************************************/        /******************************************************************************************************/        #region 수신기 데이터 콘트롤        private void btnReceiverAdd_Click(object sender, EventArgs e)        {            try            {                //입력모드로 변경한다.                Util.GroupUIChange(groubReceiver, UIMode.input);                GroupReceiverData(null);                cmd = QUERYMode.insert;                DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                txtReceiverID.Text = dacReceiverConfig.ReceiverID_Max().ToString();                txtReceiveName.Focus();                btnReceiverAdd.Enabled = false;                btnReceiverEdit.Enabled = false;                btnReceiverDel.Enabled = false;                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //GroupBox에 자료 표시하기        private void GroupReceiverData(ListViewItem itm)        {            try            {                if (itm == null)                {                    txtReceiverID.Text = "";                    txtReceiveName.Text = "";                    cboUse_Flag.SelectedIndex = -1;                    txtIP_Address.Text = "";                    txtEvent_Port_No.Text = "";                    txtCommand_Port_No.Text = "";                    checkRedundant_Flag.Checked = false;                    btnReceiverEdit.Enabled = false;                    btnReceiverDel.Enabled = false;                }                else                {                    txtReceiverID.Text = itm.Text;                    txtReceiveName.Text = itm.SubItems[1].Text;                    txtIP_Address.Text = itm.SubItems[2].Text;                    txtEvent_Port_No.Text = itm.SubItems[3].Text;                    txtCommand_Port_No.Text = itm.SubItems[4].Text;                    checkRedundant_Flag.Checked = (itm.SubItems[5].Text == "Y" ? true : false);                    cboUse_Flag.SelectedValue = itm.SubItems[6].Text;                    btnReceiverEdit.Enabled = true;                    btnReceiverDel.Enabled = true;                }                btnReceiverAdd.Enabled = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnCancel_Click(object sender, EventArgs e)        {            try            {                //VIEW모드로 변경한다.                Util.GroupUIChange(groubReceiver, UIMode.cancel);                GroupReceiverData(null);                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnReceiverEdit_Click(object sender, EventArgs e)        {            try            {                //입력모드로 변경한다.                cmd = QUERYMode.update;                Util.GroupUIChange(groubReceiver, UIMode.input);                txtReceiverID.ReadOnly = true;                btnReceiverAdd.Enabled = false;                btnReceiverEdit.Enabled = false;                btnReceiverDel.Enabled = false;                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /****         * LISTVIEW에 데이터 불러오기         *          * ****/        private void Receiver_getData()        {            try            {                DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacReceiverConfig.Receiver_Select(null, null);                listView1.Items.Clear();                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        int ReceiverId = int.Parse(Convert.ToString(dr[0]));                        if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false;                        ListViewItem item = new ListViewItem(Convert.ToString(dr[0]));                        item.SubItems.Add(Convert.ToString(dr[1]));                        item.SubItems.Add(Convert.ToString(dr[2]));                        item.SubItems.Add(Convert.ToString(dr[3]));                        item.SubItems.Add(Convert.ToString(dr[4]));                        item.SubItems.Add(Convert.ToString(dr[5]));                        item.SubItems.Add(Convert.ToString(dr[6]));                        //item.SubItems.Add(""); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 리스트에 '상태' 컬럼은 필요없다                        listView1.Items.Add(item);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void listView1_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                ListView lv = (ListView)sender;                if (lv.SelectedItems.Count > 0)                {                    ListViewItem itm = lv.SelectedItems[0];                    //VIEW모드로 변경한다.                    Util.GroupUIChange(groubReceiver, UIMode.cancel);                    GroupReceiverData(itm);                }                else                {                    //VIEW모드로 변경한다.                    Util.GroupUIChange(groubReceiver, UIMode.cancel);                    GroupReceiverData(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void listView1_Click(object sender, EventArgs e)        {            try            {                listView1_SelectedIndexChanged(listView1, System.EventArgs.Empty);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnReceiverDel_Click(object sender, EventArgs e)        {            try            {                cmd = QUERYMode.delete;                String ReceiverID = txtReceiverID.Text.Trim();                String ReceiveName = txtReceiveName.Text.Trim();                String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", ReceiveName, ReceiverID);                if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacReceiverConfig.Receiver_Update(cmd, ReceiverID, null, null, null, null, null, null);                }                //VIEW모드로 변경한다.                Util.GroupUIChange(groubReceiver, UIMode.cancel);                //수신기정보 입력 CLEAR                GroupReceiverData(null);                //데이터 불러오기                Receiver_getData();                //수신기리스트 콤보에 넣기                //ComboReceiverList(mdi.MyReceiverId);                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        // 하위 루틴은 실제로 사용안함 (삭제 예정)        private void btnSaveOK_Click(object sender, EventArgs e)        {            try            {                if (cmd == QUERYMode.insert || cmd == QUERYMode.update)                {                    Util.ChkTxtBox(txtReceiverID, "수신기ID");                    Util.ChkTxtBox(txtReceiveName, "수신기명");                    Util.ChkTxtBox(txtIP_Address, "연결 IP");                    Util.ChkTxtBox(txtEvent_Port_No, "이벤트 PORT");                    Util.ChkTxtBox(txtCommand_Port_No, "명령 PORT");                    Util.ChkComboBox(cboUse_Flag, "사용여부");                    String ReceiverID = txtReceiverID.Text.Trim();                    String ReceiveName = txtReceiveName.Text.Trim();                    String Use_Flag = cboUse_Flag.SelectedValue == null ? "" : cboUse_Flag.SelectedValue.ToString();                    String Redundant_Flag = (checkRedundant_Flag.Checked ? "Y" : "N");                    String IP_Address = txtIP_Address.Text.Trim();                    String Event_Port_No = txtEvent_Port_No.Text.Trim();                    String Command_Port_No = txtCommand_Port_No.Text.Trim();                    this.ThisRedundant_Flag = Redundant_Flag == "Y" ? true : false;                    if (ThisRedundant_Flag) Util.GroupUIChange(groupComm2, UIMode.input); else Util.GroupUIChange(groupComm2, UIMode.cancel);                    if (!Util.onlyLiteral(ReceiverID)) throw new Exception("수신기ID는 숫자형만 입력해 주세요.");                    DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag);                    //수신기설정을 할때 기본으로 생성되어야 할 데이터를 저장한다..                    if (int.Parse(ReceiverID) == this.mdi.myReceiverID)                    {                        DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                        dacIOBoardConfig.Board_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, "IO보드15번(기본)", "Y", "Y", "N", 0, 0, 0, 0, 0);                        DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Input, "발신기", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Input, "전화", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Input, "교류전원", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 4, code_InOutType.Input, "예비전원이상", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 5, code_InOutType.Input, "출력전압", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 1, code_InOutType.Output, "표시등", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 2, code_InOutType.Output, "유도등", null, null);                        dacIODeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 15, 3, code_InOutType.Output, "전원릴레이", null, null);                        DacKeypadConfig dacKeypadConfig = new DacKeypadConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                        dacKeypadConfig.Keypad_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, "키패드(기본)", "Y", 0, 0, 0);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 0, code_InOutType.Input, "비상 방송 정지", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "지구 경종 정지", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "주음향 정지", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "화면 좌표 설정", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "예비 전원 시험", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "설비연동 화면", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "화재 복구", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "부저 정지", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Input, "주음향 정지", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Input, "지구 경종 정지", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Input, "비상 방송 정지", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Input, "화면 좌표 설정", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Input, "부저 정지", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Input, "설비연동 화면", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Input, "화재 복구", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Input, "예비 전원 시험", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 1, code_InOutType.Output, "화재 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 2, code_InOutType.Output, "발신기 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 3, code_InOutType.Output, "교류 전원 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 4, code_InOutType.Output, "예비 전원 이상 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 5, code_InOutType.Output, "전화 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 6, code_InOutType.Output, "통신상태 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 7, code_InOutType.Output, "축적 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 8, code_InOutType.Output, "회로 점검 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 9, code_InOutType.Output, "설비 작동 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 10, code_InOutType.Output, "비상 방송 정지 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 11, code_InOutType.Output, "지구 음향 정지 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 12, code_InOutType.Output, "주음향 정지 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 13, code_InOutType.Output, "부저정지 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 15, code_InOutType.Output, "예비 전원 시험 LED", null, null);                        //dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 14, code_InOutType.Output, "설비연동화면 LED", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 16, code_InOutType.Output, "주음향 부저", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 17, code_InOutType.Output, "Fault 부저", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 18, code_InOutType.Output, "전화 부저", null, null);                        dacKeypadConfig.Device_Update(QUERYMode.InsertAndUpdate, this.mdi.myReceiverID, 0, 19, code_InOutType.Output, "설비 부저", null, null);                        DacBoardConfig dacBoardConfig = new DacBoardConfig(this.mdi.myReceiverID);  // cyim 2015.7.30 데이타베이스 접속 루틴 변경                        if (cmd == QUERYMode.insert)                        {                            // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                            int boardID_init = 0;                            int boardID_cnt = 0;                            // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다                            if (mdi.ReceiverModel == "IFC3300")                            {                                boardID_init = 1;                                boardID_cnt = 64;                            }                            else                            {                                boardID_init = 1;                                boardID_cnt = 16;                            }                            // cyim 2016.11.03 : 통신보드(중계반)는 최대 64                            for (int i = boardID_init; i <= boardID_cnt; i++)                            {                                // cyim 2016.10.31 : 대용량 수신기용 UI 변경                                dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, i, string.Format("통신보드{0}", i)                                    , "N", "N", "N", "N", "N", 7, 7, 7, 7, 7, 0, 0);                            }                        }                        try                        {                            //통신연결 설정값을 다시 읽어서 접속한다.                            this.mdi.ui.SocketConfigRead();                            this.mdi.ui.ServiceStop();                            this.mdi.ui.ServiceStart();                        }                        catch (Exception ex)                        {                            Util.UErrorMessage(ex, 0, 0);                            //MessageBox.Show(ex.Message, Application.ProductName);                        }                        // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                        this.panel_Menu.Focus();                    }                }                //VIEW모드로 변경한다.                Util.GroupUIChange(groubReceiver, UIMode.cancel);                //데이터 불러오기                Receiver_getData();                //수신기리스트 콤보에 넣기                //ComboReceiverList(mdi.myReceiverID);                GroupReceiverData(null);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        #endregion        /******************************************************************************************************/        /******************************************************************************************************/        #region 통신설정 데이터 콘트롤        private void Comm_Init()        {            //try            {                ArrayList comport1 = Util.ArrayComport();                ArrayList comport2 = Util.ArrayComport();                ArrayList comport3 = Util.ArrayComport();                ArrayList comport4 = Util.ArrayComport();                ArrayList comport5 = Util.ArrayComport(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                 ArrayList speed1 = Util.ArraySpeed();                ArrayList speed2 = Util.ArraySpeed();                ArrayList speed3 = Util.ArraySpeed();                ArrayList speed4 = Util.ArraySpeed();                ArrayList speed5 = Util.ArraySpeed(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                 ArrayList databit1 = Util.ArrayDatabit();                ArrayList databit2 = Util.ArrayDatabit();                ArrayList databit3 = Util.ArrayDatabit();                ArrayList databit4 = Util.ArrayDatabit();                ArrayList databit5 = Util.ArrayDatabit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                 ArrayList stopbit1 = Util.ArrayStopbit();                ArrayList stopbit2 = Util.ArrayStopbit();                ArrayList stopbit3 = Util.ArrayStopbit();                ArrayList stopbit4 = Util.ArrayStopbit();                ArrayList stopbit5 = Util.ArrayStopbit(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                ArrayList parity1 = Util.ArrayParity();                ArrayList parity2 = Util.ArrayParity();                ArrayList parity3 = Util.ArrayParity();                ArrayList parity4 = Util.ArrayParity();                ArrayList parity5 = Util.ArrayParity(); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                Util.ComboSetting(cboSpeed1, speed1, "115200");                Util.ComboSetting(cboSpeed2, speed2, "115200");                Util.ComboSetting(cboSpeed3, speed3, "115200");                Util.ComboSetting(cboSpeed4, speed4, "115200");                Util.ComboSetting(cboSpeed5, speed5, "115200"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                Util.ComboSetting(cboDataBit1, databit1, "7");                Util.ComboSetting(cboDataBit2, databit2, "7");                Util.ComboSetting(cboDataBit3, databit3, "7");                Util.ComboSetting(cboDataBit4, databit4, "7");                Util.ComboSetting(cboDataBit5, databit5, "7"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                Util.ComboSetting(cboStopBit1, stopbit1, "1");                Util.ComboSetting(cboStopBit2, stopbit2, "1");                Util.ComboSetting(cboStopBit3, stopbit3, "1");                Util.ComboSetting(cboStopBit4, stopbit4, "1");                Util.ComboSetting(cboStopBit5, stopbit5, "1"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                Util.ComboSetting(cboParity1, parity1, "N");                Util.ComboSetting(cboParity2, parity2, "N");                Util.ComboSetting(cboParity3, parity3, "N");                Util.ComboSetting(cboParity4, parity4, "N");                Util.ComboSetting(cboParity5, parity5, "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                Util.ComboSetting(cboComPort1, comport1, null);                Util.ComboSetting(cboComPort2, comport2, null);                Util.ComboSetting(cboComPort3, comport3, null);                Util.ComboSetting(cboComPort4, comport4, null);                Util.ComboSetting(cboComPort5, comport5, null); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                //기본값 설정                int DelayInit = 200;                int TimeOutInit = 3000;                txtCommDelay1.Text = DelayInit.ToString();                txtCommTimeOut1.Text = TimeOutInit.ToString();                //txtIpAddress1.Text = "";                //txtPort1.Text = "";                //txtDelay1.Text = "";                //txtTimeOut1.Text = "";                tabControl1.SelectedIndex = 0;                txtCommDelay2.Text = DelayInit.ToString();                txtCommTimeOut2.Text = TimeOutInit.ToString();                //txtIpAddress2.Text = "";                //txtPort2.Text = "";                //txtDelay2.Text = "";                //txtTimeOut2.Text = "";                txtCommDelay3.Text = DelayInit.ToString();                txtCommTimeOut3.Text = TimeOutInit.ToString();                //txtIpAddress3.Text = "";                //txtPort3.Text = "";                //txtDelay3.Text = "";                //txtTimeOut3.Text = "";                //키패드 기본                 txtCommDelay4.Text = "50";                txtCommTimeOut4.Text = "1000";                //txtIpAddress4.Text = "";                //txtPort4.Text = "";                //txtDelay4.Text = "";                //txtTimeOut4.Text = "";                // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                txtCommDelay5.Text = DelayInit.ToString();                txtCommTimeOut5.Text = TimeOutInit.ToString();                //사용안함으로 통신설정값을 초기화한다.                CommFlagChage(1, "N", "N");                CommFlagChage(2, "N", "N");                CommFlagChage(3, "N", "N");                CommFlagChage(4, "N", "N");                CommFlagChage(5, "N", "N"); // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정                chkCommUseFlag1.Checked = false;                chkCommUseFlag2.Checked = false;                chkCommUseFlag3.Checked = false;                chkCommUseFlag4.Checked = false;                chkCommUseFlag5.Checked = false; // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신설정            }            //catch (Exception ex)            //{            //    Util.UErrorMessage(ex, 0, 0);            //    throw ex;            //}        }        /****         *통신설정 데이터 불러오기         *          * ****/        private void Comm_getData()        {            try            {                DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacCommConfig.Comm_Select(mdi.myReceiverID, 0, null);                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), dr["COMM_LOOP"].ToString());                        String typ = dr["COMM_TYPE"].ToString();                        if (commloop == COMMLOOP.FrontLoop)                        {                            chkCommUseFlag1.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;                            chkCommUseFlag1.CheckState = dr["USE_FLAG"].ToString() == "Y" ? CheckState.Checked : CheckState.Unchecked; ;                            chkLogFlag1.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;                            txtCommTimeOut1.Text = dr["COMM_TIMEOUT"].ToString();                            txtCommDelay1.Text = dr["COMM_DELAY"].ToString();                            //txtTimeOut1.Text = dr["COMM_TIMEOUT"].ToString();                            //txtDelay1.Text = dr["COMM_DELAY"].ToString();                            chkCommRs485_1.Checked = typ.Equals("R") ? true : false;                            if (typ.Equals("C") || typ.Equals("R"))   //232-C,485-R                            {                                cboComPort1.SelectedValue = dr["COMM_PORT"].ToString();                                cboSpeed1.SelectedValue = dr["BAUD_RATE"].ToString();                                cboDataBit1.SelectedValue = dr["DATA_BITS"].ToString();                                cboParity1.SelectedValue = dr["PARITY"].ToString();                                cboStopBit1.SelectedValue = dr["STOP_BITS"].ToString();                                tabControl1.SelectedIndex = 0;                            }                            else                            {                                //txtIpAddress1.Text = dr["IP_ADDRESS"].ToString();                                //txtPort1.Text = dr["PORT_NO"].ToString();                                tabControl1.SelectedIndex = 1;                            }                            CommFlagChage(1, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());                        }                        else if (commloop == COMMLOOP.BackLoop)                        {                            chkCommUseFlag2.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;                            chkLogFlag2.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;                            txtCommTimeOut2.Text = dr["COMM_TIMEOUT"].ToString();                            txtCommDelay2.Text = dr["COMM_DELAY"].ToString();                            //txtTimeOut2.Text = dr["COMM_TIMEOUT"].ToString();                            //txtDelay2.Text = dr["COMM_DELAY"].ToString();                            chkCommRs485_2.Checked = typ.Equals("R") ? true : false;                            if (typ.Equals("C") || typ.Equals("R"))   //232-C,485-R                            {                                cboComPort2.SelectedValue = dr["COMM_PORT"].ToString();                                cboSpeed2.SelectedValue = dr["BAUD_RATE"].ToString();                                cboDataBit2.SelectedValue = dr["DATA_BITS"].ToString();                                cboParity2.SelectedValue = dr["PARITY"].ToString();                                cboStopBit2.SelectedValue = dr["STOP_BITS"].ToString();                                tabControl2.SelectedIndex = 0;                            }                            else                            {                                //txtIpAddress2.Text = dr["IP_ADDRESS"].ToString();                                //txtPort2.Text = dr["PORT_NO"].ToString();                                tabControl2.SelectedIndex = 1;                            }                            CommFlagChage(2, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());                        }                        else if (commloop == COMMLOOP.IO)                        {                            chkCommUseFlag3.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;                            chkLogFlag3.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;                            txtCommTimeOut3.Text = dr["COMM_TIMEOUT"].ToString();                            txtCommDelay3.Text = dr["COMM_DELAY"].ToString();                            //txtTimeOut3.Text = dr["COMM_TIMEOUT"].ToString();                            //txtDelay3.Text = dr["COMM_DELAY"].ToString();                            chkCommRs485_3.Checked = typ.Equals("R") ? true : false;                            if (typ.Equals("C") || typ.Equals("R"))   //232-C,485-R                            {                                cboComPort3.SelectedValue = dr["COMM_PORT"].ToString();                                cboSpeed3.SelectedValue = dr["BAUD_RATE"].ToString();                                cboDataBit3.SelectedValue = dr["DATA_BITS"].ToString();                                cboParity3.SelectedValue = dr["PARITY"].ToString();                                cboStopBit3.SelectedValue = dr["STOP_BITS"].ToString();                                tabControl3.SelectedIndex = 0;                            }                            else                            {                                //txtIpAddress3.Text = dr["IP_ADDRESS"].ToString();                                //txtPort3.Text = dr["PORT_NO"].ToString();                                tabControl3.SelectedIndex = 1;                            }                            CommFlagChage(3, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());                        }                        else if (commloop == COMMLOOP.KEYPAD)                        {                            chkCommUseFlag4.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;                            chkLogFlag4.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;                            txtCommTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();                            txtCommDelay4.Text = dr["COMM_DELAY"].ToString();                            //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();                            //txtDelay4.Text = dr["COMM_DELAY"].ToString();                            chkCommRs485_4.Checked = typ.Equals("R") ? true : false;                            if (typ.Equals("C") || typ.Equals("R"))   //232-C,485-R                            {                                cboComPort4.SelectedValue = dr["COMM_PORT"].ToString();                                cboSpeed4.SelectedValue = dr["BAUD_RATE"].ToString();                                cboDataBit4.SelectedValue = dr["DATA_BITS"].ToString();                                cboParity4.SelectedValue = dr["PARITY"].ToString();                                cboStopBit4.SelectedValue = dr["STOP_BITS"].ToString();                                tabControl4.SelectedIndex = 0;                            }                            else                            {                                //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString();                                //txtPort4.Text = dr["PORT_NO"].ToString();                                tabControl4.SelectedIndex = 1;                            }                            CommFlagChage(4, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());                        }                        // cyim 2013.7.10 디자인개선작업 : 수신기설정                        else if (commloop == COMMLOOP.BroadCast)                        {                            chkCommUseFlag5.Checked = dr["USE_FLAG"].ToString() == "Y" ? true : false;                            chkLogFlag5.Checked = dr["LOG_FLAG"].ToString() == "Y" ? true : false;                            txtCommTimeOut5.Text = dr["COMM_TIMEOUT"].ToString();                            txtCommDelay5.Text = dr["COMM_DELAY"].ToString();                            //txtTimeOut4.Text = dr["COMM_TIMEOUT"].ToString();                            //txtDelay4.Text = dr["COMM_DELAY"].ToString();                            chkCommRs485_5.Checked = typ.Equals("R") ? true : false;                            if (typ.Equals("C") || typ.Equals("R"))   //232-C,485-R                            {                                cboComPort5.SelectedValue = dr["COMM_PORT"].ToString();                                cboSpeed5.SelectedValue = dr["BAUD_RATE"].ToString();                                cboDataBit5.SelectedValue = dr["DATA_BITS"].ToString();                                cboParity5.SelectedValue = dr["PARITY"].ToString();                                cboStopBit5.SelectedValue = dr["STOP_BITS"].ToString();                                tabControl5.SelectedIndex = 0;                            }                            else                            {                                //txtIpAddress4.Text = dr["IP_ADDRESS"].ToString();                                //txtPort4.Text = dr["PORT_NO"].ToString();                                tabControl5.SelectedIndex = 1;                            }                            CommFlagChage(5, dr["LOG_FLAG"].ToString(), dr["USE_FLAG"].ToString());                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnCommOK1_Click(object sender, EventArgs e)        {            try            {                if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    cmd = QUERYMode.InsertAndUpdate;                    Util.ChkComboBox(cboComPort1, "포트");                    Util.ChkComboBox(cboDataBit1, "데이터비트");                    Util.ChkComboBox(cboStopBit1, "정지비트");                    Util.ChkComboBox(cboSpeed1, "최대속도");                    Util.ChkComboBox(cboParity1, "패리티");                    Util.ChkTxtBox(txtCommDelay1, "Delay");                    Util.ChkTxtBox(txtCommTimeOut1, "Time Out");                    String ComPort = cboComPort1.SelectedValue.ToString();                    String DataBit = cboDataBit1.SelectedValue.ToString();                    String StopBit = cboStopBit1.SelectedValue.ToString();                    String Speed = cboSpeed1.SelectedValue.ToString();                    String Parity = cboParity1.SelectedValue.ToString();                    String CommTimeOut = txtCommTimeOut1.Text.Trim();                    String Delay = txtCommDelay1.Text.Trim();                    String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N";                    String LogFlag = chkLogFlag1.Checked ? "Y" : "N";                    if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");                    if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");                    string typ = chkCommRs485_1.Checked ? "R" : "C";                    DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, typ                        , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName);                    //VIEW모드로 변경한다.                    //Util.GroupUIChange(groupComm1, UIMode.cancel);                    //데이터 불러오기                    //Comm_getData();                    //수신기리스트 콤보에 넣기                    //ComboReceiverList(mdi.myReceiverID);                    // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                    this.panel_Menu.Focus();                    // cyim 2014.5.7 : 수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);            }        }        private void btnCommOK2_Click(object sender, EventArgs e)        {            try            {                if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    cmd = QUERYMode.InsertAndUpdate;                    Util.ChkComboBox(cboComPort2, "포트");                    Util.ChkComboBox(cboDataBit2, "데이터비트");                    Util.ChkComboBox(cboStopBit2, "정지비트");                    Util.ChkComboBox(cboSpeed2, "최대속도");                    Util.ChkComboBox(cboParity2, "패리티");                    Util.ChkTxtBox(txtCommDelay2, "Delay");                    Util.ChkTxtBox(txtCommTimeOut2, "Time Out");                    String ComPort = cboComPort2.SelectedValue.ToString();                    String DataBit = cboDataBit2.SelectedValue.ToString();                    String StopBit = cboStopBit2.SelectedValue.ToString();                    String Speed = cboSpeed2.SelectedValue.ToString();                    String Parity = cboParity2.SelectedValue.ToString();                    String CommTimeOut = txtCommTimeOut2.Text.Trim();                    String Delay = txtCommDelay2.Text.Trim();                    String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N";                    String LogFlag = chkLogFlag2.Checked ? "Y" : "N";                    string typ = chkCommRs485_2.Checked ? "R" : "C";                    if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");                    if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");                    DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, typ                        , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName);                    //VIEW모드로 변경한다.                    //Util.GroupUIChange(groupComm2, UIMode.cancel);                    //데이터 불러오기                    //Comm_getData();                    //수신기리스트 콤보에 넣기                    //ComboReceiverList(mdi.myReceiverID);                    // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                    this.panel_Menu.Focus();                    // cyim 2014.5.7 : 수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);            }        }        private void btnCommOK3_Click(object sender, EventArgs e)        {            try            {                if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    cmd = QUERYMode.InsertAndUpdate;                    Util.ChkComboBox(cboComPort3, "포트");                    Util.ChkComboBox(cboDataBit3, "데이터비트");                    Util.ChkComboBox(cboStopBit3, "정지비트");                    Util.ChkComboBox(cboSpeed3, "최대속도");                    Util.ChkComboBox(cboParity3, "패리티");                    Util.ChkTxtBox(txtCommDelay3, "Delay");                    Util.ChkTxtBox(txtCommTimeOut3, "Time Out");                    String ComPort = cboComPort3.SelectedValue.ToString();                    String DataBit = cboDataBit3.SelectedValue.ToString();                    String StopBit = cboStopBit3.SelectedValue.ToString();                    String Speed = cboSpeed3.SelectedValue.ToString();                    String Parity = cboParity3.SelectedValue.ToString();                    String CommTimeOut = txtCommTimeOut3.Text.Trim();                    String Delay = txtCommDelay3.Text.Trim();                    String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N";                    String LogFlag = chkLogFlag3.Checked ? "Y" : "N";                    string typ = chkCommRs485_3.Checked ? "R" : "C";                    if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");                    if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");                    DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, typ                        , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName);                    //VIEW모드로 변경한다.                    //Util.GroupUIChange(groupComm2, UIMode.cancel);                    //데이터 불러오기                    //Comm_getData();                    //수신기리스트 콤보에 넣기                    //ComboReceiverList(mdi.myReceiverID);                    // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                    this.panel_Menu.Focus();                    // cyim 2014.5.7 : 수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);            }        }        private void btnCommOK4_Click(object sender, EventArgs e)        {            try            {                if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    cmd = QUERYMode.InsertAndUpdate;                    Util.ChkComboBox(cboComPort4, "포트");                    Util.ChkComboBox(cboDataBit4, "데이터비트");                    Util.ChkComboBox(cboStopBit4, "정지비트");                    Util.ChkComboBox(cboSpeed4, "최대속도");                    Util.ChkComboBox(cboParity4, "패리티");                    Util.ChkTxtBox(txtCommDelay4, "Delay");                    Util.ChkTxtBox(txtCommTimeOut4, "Time Out");                    String ComPort = cboComPort4.SelectedValue.ToString();                    String DataBit = cboDataBit4.SelectedValue.ToString();                    String StopBit = cboStopBit4.SelectedValue.ToString();                    String Speed = cboSpeed4.SelectedValue.ToString();                    String Parity = cboParity4.SelectedValue.ToString();                    String CommTimeOut = txtCommTimeOut4.Text.Trim();                    String Delay = txtCommDelay4.Text.Trim();                    String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N";                    String LogFlag = chkLogFlag4.Checked ? "Y" : "N";                    string typ = chkCommRs485_4.Checked ? "R" : "C";                    if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");                    if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");                    DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, typ                        , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName);                    //VIEW모드로 변경한다.                    //Util.GroupUIChange(groupComm2, UIMode.cancel);                    //데이터 불러오기                    //Comm_getData();                    //수신기리스트 콤보에 넣기                    //ComboReceiverList(mdi.myReceiverID);                    // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                    this.panel_Menu.Focus();                    // cyim 2014.5.7 : 수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);            }        }        // EMERGENCY - 확인 버튼        private void btnCommOK5_Click(object sender, EventArgs e)        {            try            {                if (MessageBox.Show("경고! 수신기 동작에 문제가 생길수 있습니다! 확인 버튼 누르면, 반드시 상위의 모든 데이타 저장(수신기 쓰기) 버튼 눌러주시길 바랍니다. 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    cmd = QUERYMode.InsertAndUpdate;                    Util.ChkComboBox(cboComPort5, "포트");                    Util.ChkComboBox(cboDataBit5, "데이터비트");                    Util.ChkComboBox(cboStopBit5, "정지비트");                    Util.ChkComboBox(cboSpeed5, "최대속도");                    Util.ChkComboBox(cboParity5, "패리티");                    Util.ChkTxtBox(txtCommDelay5, "Delay");                    Util.ChkTxtBox(txtCommTimeOut5, "Time Out");                    String ComPort = cboComPort5.SelectedValue.ToString();                    String DataBit = cboDataBit5.SelectedValue.ToString();                    String StopBit = cboStopBit5.SelectedValue.ToString();                    String Speed = cboSpeed5.SelectedValue.ToString();                    String Parity = cboParity5.SelectedValue.ToString();                    String CommTimeOut = txtCommTimeOut5.Text.Trim();                    String Delay = txtCommDelay5.Text.Trim();                    String UseFlag = chkCommUseFlag5.Checked ? "Y" : "N";                    String LogFlag = chkLogFlag5.Checked ? "Y" : "N";                    string typ = chkCommRs485_5.Checked ? "R" : "C";                    if (!Util.onlyLiteral(CommTimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");                    if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");                    DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BroadCast, "BroadCast", COMMLOOP.BroadCast, typ                        , ComPort, int.Parse(Speed), Parity, DataBit, StopBit, null, 0, int.Parse(CommTimeOut), int.Parse(Delay), LogFlag, UseFlag);                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    MessageBox.Show("비상방송 통신설정값을 저장하였습니다.", Application.ProductName);                    //VIEW모드로 변경한다.                    //Util.GroupUIChange(groupComm2, UIMode.cancel);                    //데이터 불러오기                    //Comm_getData();                    //수신기리스트 콤보에 넣기                    //ComboReceiverList(mdi.myReceiverID);                    // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                    this.panel_Menu.Focus();                    // cyim 2014.5.7 : 수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);            }        }        private void CommFlagChage(int Comm_ID, String LogFlag, String UseFlag)        {            try            {                UIMode mode = UseFlag == "Y" ? UIMode.input : UIMode.cancel;                GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + Comm_ID.ToString());                TabControl tab = (TabControl)Util.FineControl(group, "tabControl" + Comm_ID.ToString());                if (tab != null)                    Util.GroupUIChange(tab, mode);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void chkCommUseFlag_CheckedChanged(object sender, EventArgs e)        {            try            {                CheckBox chk = (CheckBox)sender;                String ObjName = chk.Name;                int commId = int.Parse(ObjName.Replace("chkCommUseFlag", ""));                String UseFlag = chk.Checked ? "Y" : "N";                GroupBox group = (GroupBox)Util.FineControl(tabPage_CommSet, "groupComm" + commId.ToString());                CheckBox chk2 = (CheckBox)Util.FineControl(group, "chkLogFlag" + commId.ToString());                String LogFlag = chk2.Checked ? "Y" : "N";                CommFlagChage(commId, LogFlag, UseFlag);                DacCommConfig dacCommConfig = new DacCommConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                COMMLOOP commloop = (COMMLOOP)Enum.Parse(typeof(COMMLOOP), commId.ToString());                dacCommConfig.Comm_FlagUpdate(QUERYMode.InsertAndUpdate, mdi.myReceiverID, commloop, UseFlag, LogFlag);                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        //private void btnLanOK1_Click(object sender, EventArgs e)        //{        //    try        //    {        //        cmd = QUERYMode.InsertAndUpdate;        //        //Util.ChkTxtBox(txtIpAddress1, "IP");        //        //Util.ChkTxtBox(txtPort1, "PORT");        //        //Util.ChkTxtBox(txtDelay1, "Delay");        //        //Util.ChkTxtBox(txtTimeOut1, "Time Out");        //        //String IpAddress = txtIpAddress1.Text.Trim();        //        //String Port = txtPort1.Text.Trim();        //        //String Delay = txtDelay1.Text.Trim();        //        //String TimeOut = txtTimeOut1.Text.Trim();        //        String UseFlag = chkCommUseFlag1.Checked ? "Y" : "N";        //        String LogFlag = chkLogFlag1.Checked ? "Y" : "N";        //        //if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");        //        //if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");        //        //if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");        //        DacCommConfig dacCommConfig = new DacCommConfig();        //        dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.FrontLoop, "FRONT LOOP", COMMLOOP.FrontLoop, "L"        //            , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);        //        //수신기설정정보 변경        //        mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;        //        MessageBox.Show("FRONT LOOP 통신설정값을 저장하였습니다.", Application.ProductName);        //        //VIEW모드로 변경한다.        //        //Util.GroupUIChange(groupComm1, UIMode.cancel);        //        //데이터 불러오기        //        //Comm_getData();        //    }        //    catch (Exception ex)        //    {        //      Util.UErrorMessage(ex,0,0);        //        //MessageBox.Show(ex.Message, Application.ProductName);        //    }        //}        //private void btnLanOK2_Click(object sender, EventArgs e)        //{        //    try        //    {        //        cmd = QUERYMode.InsertAndUpdate;        //        Util.ChkTxtBox(txtIpAddress2, "IP");        //        Util.ChkTxtBox(txtPort2, "PORT");        //        Util.ChkTxtBox(txtDelay2, "Delay");        //        Util.ChkTxtBox(txtTimeOut2, "Time Out");        //        String IpAddress = txtIpAddress2.Text.Trim();        //        String Port = txtPort2.Text.Trim();        //        String Delay = txtDelay2.Text.Trim();        //        String TimeOut = txtTimeOut2.Text.Trim();        //        String UseFlag = chkCommUseFlag2.Checked ? "Y" : "N";        //        String LogFlag = chkLogFlag2.Checked ? "Y" : "N";        //        if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");        //        DacCommConfig dacCommConfig = new DacCommConfig();        //        dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.BackLoop, "BACK LOOP", COMMLOOP.BackLoop, "L"        //            , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);        //        //수신기설정정보 변경        //        mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;        //        MessageBox.Show("BACK LOOP 통신설정값을 저장하였습니다.", Application.ProductName);        //        //VIEW모드로 변경한다.        //        //Util.GroupUIChange(groupComm2, UIMode.cancel);        //        //데이터 불러오기        //        //Comm_getData();        //    }        //    catch (Exception ex)        //    {        //      Util.UErrorMessage(ex,0,0);        //        //MessageBox.Show(ex.Message, Application.ProductName);        //    }        //}        //private void btnLanOK3_Click(object sender, EventArgs e)        //{        //    try        //    {        //        cmd = QUERYMode.InsertAndUpdate;        //        Util.ChkTxtBox(txtIpAddress3, "IP");        //        Util.ChkTxtBox(txtPort3, "PORT");        //        Util.ChkTxtBox(txtDelay3, "Delay");        //        Util.ChkTxtBox(txtTimeOut3, "Time Out");        //        String IpAddress = txtIpAddress3.Text.Trim();        //        String Port = txtPort3.Text.Trim();        //        String Delay = txtDelay3.Text.Trim();        //        String TimeOut = txtTimeOut3.Text.Trim();        //        String UseFlag = chkCommUseFlag3.Checked ? "Y" : "N";        //        String LogFlag = chkLogFlag3.Checked ? "Y" : "N";        //        if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");        //        DacCommConfig dacCommConfig = new DacCommConfig();        //        dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.IO, "IO BOARD", COMMLOOP.IO, "L"        //            , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);        //        //수신기설정정보 변경        //        mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;        //        MessageBox.Show("IO BOARD 통신설정값을 저장하였습니다.", Application.ProductName);        //        //VIEW모드로 변경한다.        //        //Util.GroupUIChange(groupComm3, UIMode.cancel);        //        //데이터 불러오기        //        //Comm_getData();        //    }        //    catch (Exception ex)        //    {        //      Util.UErrorMessage(ex,0,0);        //        //MessageBox.Show(ex.Message, Application.ProductName);        //    }        //}        //private void btnLanOK4_Click(object sender, EventArgs e)        //{        //    try        //    {        //        cmd = QUERYMode.InsertAndUpdate;        //        Util.ChkTxtBox(txtIpAddress4, "IP");        //        Util.ChkTxtBox(txtPort4, "PORT");        //        Util.ChkTxtBox(txtDelay4, "Delay");        //        Util.ChkTxtBox(txtTimeOut4, "Time Out");        //        String IpAddress = txtIpAddress4.Text.Trim();        //        String Port = txtPort4.Text.Trim();        //        String Delay = txtDelay4.Text.Trim();        //        String TimeOut = txtTimeOut4.Text.Trim();        //        String UseFlag = chkCommUseFlag4.Checked ? "Y" : "N";        //        String LogFlag = chkLogFlag4.Checked ? "Y" : "N";        //        if (!Util.onlyLiteral(Port)) throw new Exception("Port은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(TimeOut)) throw new Exception("Time Out은 숫자형만 입력해 주세요.");        //        if (!Util.onlyLiteral(Delay)) throw new Exception("Delay은 숫자형만 입력해 주세요.");        //        DacCommConfig dacCommConfig = new DacCommConfig();        //        dacCommConfig.Comm_Update(cmd, mdi.myReceiverID, COMMLOOP.KEYPAD, "KEYPAD", COMMLOOP.KEYPAD, "L"        //            , null, 0, null, null, null, IpAddress, int.Parse(Port), int.Parse(TimeOut), int.Parse(Delay), "S", LogFlag,UseFlag);        //        //수신기설정정보 변경        //        mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;        //        MessageBox.Show("KEYPAD 통신설정값을 저장하였습니다.", Application.ProductName);        //        //VIEW모드로 변경한다.        //        //Util.GroupUIChange(groupComm4, UIMode.cancel);        //        //데이터 불러오기        //        //Comm_getData();        //    }        //    catch (Exception ex)        //    {        //      Util.UErrorMessage(ex,0,0);        //        //MessageBox.Show(ex.Message, Application.ProductName);        //    }        //}        #endregion        /******************************************************************************************************/        /******************************************************************************************************/        #region 통신보드 데이터 콘트롤        /****         * 통신보드 데이터 불러오기         *          * ****/        List<CTBoard> LTBoard = new List<CTBoard>();        private void LoadBoardData()        {            try            {                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null);                this.LTBoard.Clear();                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        CTBoard board = new CTBoard();                        board.boardID = Convert.ToInt32(dr["BOARD_ID"].ToString());                        board.name = dr["BOARD_NAME"].ToString();                        board.use = ((dr["USE_FLAG"].ToString() == "Y") ? true : false);                        // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경                        board.loop0Use = ((dr["LOOP0_USE_FLAG"].ToString() == "Y") ? true : false);                        board.loop1Use = ((dr["LOOP1_USE_FLAG"].ToString() == "Y") ? true : false);                        board.loop2Use = ((Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString() == "Y") ? true : false);                        board.loop3Use = ((Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString() == "Y") ? true : false);                        this.LTBoard.Add(board);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기         private DataTable LoadAnalogDetecterLevel(int ReceiverID, int CommBoard, int Loop, int RepeaterID)        {            // 전체 중계기 쓰기하는 경우에, DB 의 아날로그 감지기의 정보를 보드별,            try            {                // 전체                DacUIProcess dacUIProcess_TB_ANALOG_DEVICE = new DacUIProcess(ReceiverID);                String SQL = "";                SQL += " SELECT REPEATER_ID,FAULT_VALUE,PREFIRE_VALUE,FIRED_VALUE,FIREN_VALUE";                SQL += " FROM TB_ANALOG_DEVICE_2 ";                if (RepeaterID != 0)                    SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' AND REPEATER_ID='{4}'", ReceiverID, "1", CommBoard, Loop, RepeaterID);                else                    SQL += string.Format(" WHERE RECEIVER_ID='{0}' AND COMM_ID='{1}' AND BOARD_ID='{2}' AND LOOP_NO='{3}' ", ReceiverID, "1", CommBoard, Loop);                // cyim 2016.06.15 : 아날로그 감지기 출력 포인트 고려 : 레벨값은 입력포인트만 고려한다                // 출력포인트가 있을경우에는 레벨값 조회시 중계기 아이디가 중복되어 버린다                SQL += " AND INOUT_TYPE ='I' ";                DataSet dao_TB_ANALOG_DEVICE = dacUIProcess_TB_ANALOG_DEVICE.Select(SQL);                DataTable dt_TB_ANALOG_DEVICE = dao_TB_ANALOG_DEVICE.Tables[0];                return dt_TB_ANALOG_DEVICE;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                return null;            }        }        private void Board_getData()        {            try            {                //for (int i = 1; i <= 16; i++)                //{                //    checkPanelLoad(i, false, false, false);                //}                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, 0, null);                //if (dt.Rows.Count > 0)                //{                //    foreach (DataRow dr in dt.Rows)                //    {                //        int BoardId = int.Parse(Convert.ToString(dr[0]));                //        Boolean Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false;                //        Boolean Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false;                //        Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;                //        //checkPanelLoad(BoardId, UseFlag, Loop0UseFlag , Loop1UseFlag);                //    }                //}                listView_CommBoard.Items.Clear();                if (dt.Rows.Count > 0)                {                    String sUseFlag;                    foreach (DataRow dr in dt.Rows)                    {                        int ReceiverId = int.Parse(Convert.ToString(dr[0]));                        if (ReceiverId == mdi.myReceiverID) this.ThisRedundant_Flag = Convert.ToString(dr[5]) == "Y" ? true : false;                        // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                        int i;                        if (mdi.ReceiverModel == "IFC3300")                            i = 0;                        else                            i = 15;                        // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체                        // cyim 2013.7.10 디자인개선작업 : 수신기설정 - 통신보드 정보중에 15번 보드는 표시 하지 않도록한다                        if (dr["BOARD_ID"].ToString() != i.ToString())                        {                            ListViewItem item = new ListViewItem(dr["BOARD_ID"].ToString());                            //String version = dr["MAIN_VERSION"].ToString();                            //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString();                            //item.SubItems.Add(version);                            //item.SubItems.Add(" ");                            //item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString()));                            sUseFlag = (dr["USE_FLAG"].ToString());                            item.SubItems.Add(sUseFlag);                            if (sUseFlag == "Y")                            {                                // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경                                item.SubItems.Add(dr["LOOP0_USE_FLAG"].ToString());                                item.SubItems.Add(dr["LOOP1_USE_FLAG"].ToString());                                item.SubItems.Add(Util.NullToStr(dr["LOOP2_USE_FLAG"]).ToString());                                item.SubItems.Add(Util.NullToStr(dr["LOOP3_USE_FLAG"]).ToString());                            }                            else                            {                                item.SubItems.Add("-");                                item.SubItems.Add("-");                                item.SubItems.Add("-");                                item.SubItems.Add("-");                            }                            //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP0_BAUD_RATE"].ToString()));                            //item.SubItems.Add(Util.baudCodeToRate(dr["LOOP1_BAUD_RATE"].ToString()));                            listView_CommBoard.Items.Add(item);                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        delegate void devent(CheckBox c, System.EventArgs e);        //GroupBox에 자료 표시하기        private void GroupBoardData(ListViewItem itm)        {            try            {                if (itm == null)                {                    txtBoardID.Text = "";                    cboBoardBaudRate.SelectedIndex = -1;                    //txtMainVersion.Text = "";                    //txtSubVersion.Text = "";                    //txtCommTerm.Text = "";                    chkBoardUseFlag.Checked = false;                    chkLoop0UseFlag.Checked = false;                    chkLoop1UseFlag.Checked = false;                    chkLoop2UseFlag.Checked = false;                    chkLoop3UseFlag.Checked = false;                    //cboLoop0BaudRate.SelectedIndex = -1;                    //cboLoop1BaudRate.SelectedIndex = -1;                    btnBoardEdit.Enabled = false;                    btnBoardDel.Enabled = false;                }                else                {                    txtBoardID.Text = itm.Text;                    //String sVersion = itm.SubItems[1].Text;                    //if (sVersion.IndexOf(".") != -1)                    //{                    //    txtMainVersion.Text = sVersion.Substring(0, sVersion.IndexOf("."));                    //    txtSubVersion.Text = sVersion.Substring(sVersion.IndexOf(".") + 1);                    //}                    //else                    //{                    //    txtMainVersion.Text = sVersion;                    //}                    //txtCommTerm.Text = itm.SubItems[1].Text;                    //String baudrate = Util.baudRateToCode(itm.SubItems[2].Text);                    //if (baudrate != null) cboBoardBaudRate.SelectedValue = baudrate;                    //else cboBoardBaudRate.SelectedIndex = -1;                    chkBoardUseFlag.Checked = (itm.SubItems[1].Text == "Y" ? true : false);                    chkLoop0UseFlag.Checked = (itm.SubItems[2].Text == "Y" ? true : false);                    chkLoop1UseFlag.Checked = (itm.SubItems[3].Text == "Y" ? true : false);                    chkLoop2UseFlag.Checked = (itm.SubItems[4].Text == "Y" ? true : false);                    chkLoop3UseFlag.Checked = (itm.SubItems[5].Text == "Y" ? true : false);                    //String Loop0baudrate = Util.baudRateToCode(itm.SubItems[6].Text);                    //if (Loop0baudrate != null) cboLoop0BaudRate.SelectedValue = Loop0baudrate;                    //else cboLoop0BaudRate.SelectedIndex = -1;                    //String Loop1baudrate = Util.baudRateToCode(itm.SubItems[7].Text);                    //if (Loop1baudrate != null) cboLoop1BaudRate.SelectedValue = Loop1baudrate;                    //else cboLoop1BaudRate.SelectedIndex = -1;                    //cboLoop0BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[7].Text);                    //cboLoop1BaudRate.SelectedValue = Util.baudRateToCode(itm.SubItems[8].Text);                    btnBoardEdit.Enabled = true;                    btnBoardDel.Enabled = true;                }                btnBoardAdd.Enabled = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //통신보드 입력값 완료 버튼         private void btnBoardOK_Click(object sender, EventArgs e)        {            try            {                if (cmd == QUERYMode.insert || cmd == QUERYMode.update)                {                    Util.ChkTxtBox(txtBoardID, "통신보드ID");                    if (!Util.onlyLiteral(txtBoardID.Text.Trim())) throw new Exception("통신보드ID는 숫자형만 입력해 주세요.");                    if (chkBoardUseFlag.Checked)                    {                        //Util.ChkComboBox(cboBoardBaudRate, "통신보드 Baud Rate");                        //Util.ChkTxtBox(txtCommTerm, "송수신간격");                        //Util.ChkTxtBox(txtMainVersion, "메인버젼");                        //if (!Util.onlyLiteral(txtMainVersion.Text.Trim())) throw new Exception("메인버젼은 숫자형만 입력해 주세요.");                        //Util.ChkTxtBox(txtSubVersion, "서브버젼");                    }                    //if (chkLoop0UseFlag.Checked)                    //{                    //    Util.ChkComboBox(cboLoop0BaudRate, "Loop0 Baud Rate");                    //}                    //if (chkLoop1UseFlag.Checked)                    //{                    //    Util.ChkComboBox(cboLoop1BaudRate, "Loop1 Baud Rate");                    //}                    //if (txtSubVersion.Text.Length < 1) txtSubVersion.Text = "0";                    // cyim 2016.10.31 : 대용량 수신기용 UI 변경                    int BoardID = int.Parse(txtBoardID.Text.Trim());                    // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                    int i;                    if (mdi.ReceiverModel == "IFC3300")                        i = 64;                    else                        i = 16;                    if (BoardID > i)                    {                        MessageBox.Show("통신보드(중계반) 아이디는 64를 초과할 수 없습니다.", Application.ProductName);                        return;                    }                    String BoardUseFlag = (chkBoardUseFlag.Checked ? "Y" : "N");                    String Loop0UseFlag;                    String Loop1UseFlag;                    String Loop2UseFlag;                    String Loop3UseFlag;                    if (BoardUseFlag == "N")                    {                        Loop0UseFlag = "N";                        Loop1UseFlag = "N";                        Loop2UseFlag = "N";                        Loop3UseFlag = "N";                    }                    else                    {                        Loop0UseFlag = (chkLoop0UseFlag.Checked ? "Y" : "N");                        Loop1UseFlag = (chkLoop1UseFlag.Checked ? "Y" : "N");                        Loop2UseFlag = (chkLoop2UseFlag.Checked ? "Y" : "N");                        Loop3UseFlag = (chkLoop3UseFlag.Checked ? "Y" : "N");                    }                    //int BoardBaudRate = int.Parse(cboBoardBaudRate.SelectedValue == null ? "0" : cboBoardBaudRate.SelectedValue.ToString());                    //int Loop0BaudRate = int.Parse(cboLoop0BaudRate.SelectedValue == null ? "0" : cboLoop0BaudRate.SelectedValue.ToString());                    //int Loop1BaudRate = int.Parse(cboLoop1BaudRate.SelectedValue == null ? "0" : cboLoop1BaudRate.SelectedValue.ToString());                    //수신기설정정보 변경                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                    DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    //dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID                    //    , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, BoardBaudRate, Loop0BaudRate, Loop1BaudRate, CommTerm, 0, 0);                    dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, "통신보드" + BoardID                        , BoardUseFlag, Loop0UseFlag, Loop1UseFlag, Loop2UseFlag, Loop3UseFlag, 0, 0, 0, 0, 0, 0, 0);                    //중계기설정의 통신보드 콤보를 재설정                    //DacBoardConfig dacBoardConfig = new DacBoardConfig();                    ArrayList ary = dacBoardConfig.Board_List(mdi.myReceiverID, mdi);                    Util.ComboSetting(cboBoardList, ary, null);                    //통신보드설정쓰기                    //CmdInfo uiCmd = new CmdInfo(prt_cmd_define.write_tbd_state, mdi.myReceiverID, 0, BoardID, 0);                }                //VIEW모드로 변경한다.                Util.GroupUIChange(groubBoard, UIMode.cancel);                //데이터 불러오기                Board_getData();                //수신기리스트 콤보에 넣기                //ComboBoardList(mdi.MyBoardID);                GroupBoardData(null);                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);            }        }        //통신보드 입력값 취소 버튼        private void btnBoardCancel_Click(object sender, EventArgs e)        {            try            {                //VIEW모드로 변경한다.                Util.GroupUIChange(groubBoard, UIMode.cancel);                GroupBoardData(null);                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //통신보드 추가 버튼        private void btnBoardAdd_Click(object sender, EventArgs e)        {            try            {                //추가버튼을 누르면 기본설정값을 넣어준다...                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                int brdNo = dacBoardConfig.BoardID_Max(mdi.myReceiverID);                // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                int i;                if (mdi.ReceiverModel == "IFC3300")                    i = 64;                else                    i = 15;                // cyim 2016.10.24 : 통신보드 15번 -> 0번카드로 대체 (중계반 아이디는 최대 64번까지 있다)                // cyim 2013.7.10 디자인개선작업 : 수신기설정                string Comment = string.Format("통신보드ID는 {0}을 초과할 수 없습니다. 그래도 계속 진행하시겠습니까?", i);                if (brdNo > i && MessageBox.Show(Comment, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.No)                {                    return;                }                //입력모드로 변경한다.                Util.GroupUIChange(groubBoard, UIMode.input);                GroupBoardData(null);                cmd = QUERYMode.insert;                txtBoardID.Text = brdNo.ToString();                cboBoardBaudRate.SelectedValue = "7";                //txtMainVersion.Text = "0";                //txtSubVersion.Text = "0";                //txtCommTerm.Text = "200";                chkBoardUseFlag.Checked = true;                // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경                chkLoop0UseFlag.Checked = true;                chkLoop1UseFlag.Checked = true;                chkLoop2UseFlag.Checked = true;                chkLoop3UseFlag.Checked = true;                //cboLoop0BaudRate.SelectedValue = "7";                //cboLoop1BaudRate.SelectedValue = "7";                txtBoardID.Focus();                btnBoardAdd.Enabled = false;                btnBoardEdit.Enabled = false;                btnBoardDel.Enabled = false;                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //통신보드 수정 버튼        private void btnBoardEdit_Click(object sender, EventArgs e)        {            try            {                //입력모드로 변경한다.                cmd = QUERYMode.update;                Util.GroupUIChange(groubBoard, UIMode.input);                txtBoardID.ReadOnly = true;                btnBoardAdd.Enabled = false;                btnBoardEdit.Enabled = false;                btnBoardDel.Enabled = false;                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //통신보드 삭제 버튼        private void btnBoardDel_Click(object sender, EventArgs e)        {            try            {                cmd = QUERYMode.delete;                int BoardID = int.Parse(txtBoardID.Text.Trim());                String msg = string.Format("통신보드 {0}을/를 삭제하시겠습니까?", BoardID);                if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacBoardConfig.Board_Update(cmd, mdi.myReceiverID, BoardID, null, null, null, null, null, null, 0, 0, 0, 0, 0, 0, 0); // cyim 2016.10.31 : 대용량 수신기용 UI 변경                }                //VIEW모드로 변경한다.                Util.GroupUIChange(groubBoard, UIMode.cancel);                //수신기정보 입력 CLEAR                GroupBoardData(null);                //데이터 불러오기                Board_getData();                // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                this.panel_Menu.Focus();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);            }        }        //통신보드 리스트 선택 변경시        private void listView2_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                ListView lv = (ListView)sender;                if (lv.SelectedItems.Count > 0)                {                    ListViewItem itm = lv.SelectedItems[0];                    //VIEW모드로 변경한다.                    Util.GroupUIChange(groubBoard, UIMode.cancel);                    GroupBoardData(itm);                }                else                {                    //VIEW모드로 변경한다.                    Util.GroupUIChange(groubBoard, UIMode.cancel);                    GroupBoardData(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);            }        }        //통신보드 리스트 클릭시        private void listView2_Click(object sender, EventArgs e)        {            listView2_SelectedIndexChanged(listView_CommBoard, System.EventArgs.Empty);        }        #endregion        /******************************************************************************************************/        /******************************************************************************************************/        #region IO보드 데이터 콘트롤        private void mskIOBoardDeviceID_TextChanged(object sender, EventArgs e)        {            try            {                int caretPosition;                caretPosition = mskIOBoardDeviceID.SelectionStart;                mskIOBoardDeviceID.Text = mskIOBoardDeviceID.Text.ToUpper();                mskIOBoardDeviceID.Select(caretPosition, 0);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //IO보드 데이터 표시        private void IOBoardSelectData(ListViewItem itm)        {            try            {                IOBoard_selectItem = itm;                if (itm == null)                {                    txtIOBoardID.Text = "";                    txtIOBoardName.Text = "";                    cboIOBoardBaudRate.SelectedIndex = -1;                    //txtIOBoardMainVersion.Text = "";                    //txtIOBoardSubVersion.Text = "";                    txtIOBoardCommTerm.Text = "";                    if (IOBoard_cmd == QUERYMode.insert)                    {                        txtIOBoardID.ReadOnly = false;                        txtIOBoardID.BackColor = Color.White;                        txtIOBoardName.ReadOnly = false;                        btnIOBoardOK.Enabled = true;                    }                    else                    {                        txtIOBoardID.ReadOnly = true;                        txtIOBoardID.BackColor = SystemColors.Control;                        btnIOBoardAdd.Enabled = true;                        btnIOBoardDel.Enabled = false;                        btnIOBoardOK.Enabled = false;                    }                    btnIOBoardDeviceAdd.Enabled = false;                }                else                {                    txtIOBoardID.Text = itm.Text;                    txtIOBoardID.BackColor = SystemColors.Control;                    txtIOBoardName.Text = Util.NullToStr(itm.SubItems[1].Text);                    if (!itm.SubItems[2].Text.Equals(""))                        cboIOBoardBaudRate.SelectedValue = Util.baudRateToCode(Util.NullToStr(itm.SubItems[2].Text));                    //String Version = Util.NullToStr(itm.SubItems[3].Text);                    //if (Version.IndexOf(".") > -1)                    //{                    //    txtIOBoardMainVersion.Text = Version.Substring(0, Version.IndexOf("."));                    //    txtIOBoardSubVersion.Text = Version.Substring(Version.IndexOf(".") + 1);                    //}                    //else                    //{                    //    txtIOBoardMainVersion.Text = Version;                    //    txtIOBoardSubVersion.Text = "";                    //}                    txtIOBoardCommTerm.Text = itm.SubItems[3].Text;                    txtIOBoardID.ReadOnly = true;                    btnIOBoardAdd.Enabled = true;                    btnIOBoardDel.Enabled = true;                    btnIOBoardOK.Enabled = true;                    btnIOBoardDeviceAdd.Enabled = true;                }                IOBoardDeviceSelectData(null);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /*******************************************************        *          [IO보드] LISTVIEW에 데이터 불러오기        ******************************************************/        private void IOBoard_getData()        {            try            {                IOBoardSelectData(null);                DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacIOBoardConfig.Board_Select(mdi.myReceiverID, 0, "Y");                listView3.Items.Clear();                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        ListViewItem item = new ListViewItem(Convert.ToString(dr["BOARD_ID"]));                        item.SubItems.Add(dr["BOARD_NAME"].ToString());                        item.SubItems.Add(Util.baudCodeToRate(dr["BAUD_RATE"].ToString()));                        //String version = dr["MAIN_VERSION"].ToString();                        //if (!version.Equals("")) version += "." + dr["SUB_VERSION"].ToString();                        //item.SubItems.Add(version);                        item.SubItems.Add(" ");                        listView3.Items.Add(item);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnIOBoardAdd_Click(object sender, EventArgs e)        {            try            {                //입력모드로 변경한다.                IOBoard_cmd = QUERYMode.insert;                Util.GroupUIChange(panelIOBoard, UIMode.input);                IOBoardSelectData(null);                cboIOBoardBaudRate.SelectedValue = "7";                txtIOBoardCommTerm.Text = "200";                DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                txtIOBoardID.Text = dacIOBoardConfig.BoardID_Max(mdi).ToString();                txtIOBoardName.Focus();                btnIOBoardAdd.Enabled = false;                btnIOBoardDel.Enabled = false;                btnIOBoardCancel.Visible = true;                btnIOBoardOK.Enabled = true;                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnIOBoardOK_Click(object sender, EventArgs e)        {            try            {                if (IOBoard_cmd == QUERYMode.insert || IOBoard_cmd == QUERYMode.update)                {                    Util.ChkTxtBox(txtIOBoardID, "IO보드ID");                    Util.ChkTxtBox(txtIOBoardName, "IO보드명");                    Util.ChkComboBox(cboIOBoardBaudRate, "Baud Rate");                    //Util.ChkTxtBox(txtIOBoardMainVersion, "Version");                    Util.ChkTxtBox(txtIOBoardCommTerm, "송수신간격");                    //Util.ChkOnlyLiteralTextBox(txtIOBoardMainVersion, "Main Version");                    //Util.ChkOnlyLiteralTextBox(txtIOBoardSubVersion, "Sub Version");                    Util.ChkOnlyLiteralTextBox(txtIOBoardCommTerm, "송수신간격");                    int BoardID = Util.StrToInt(txtIOBoardID.Text, -1);                    String BoardName = txtIOBoardName.Text.Trim();                    int BaudRate = Util.StrToInt(cboIOBoardBaudRate.SelectedValue, -1);                    //int mainVer = Util.StrToInt(txtIOBoardMainVersion.Text, -1);                    //int subVer = Util.StrToInt(txtIOBoardSubVersion.Text, 0);                    //int CommTerm = Util.StrToInt(txtIOBoardCommTerm.Text, -1);                    DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, "Y", "Y", "N", BaudRate, 0, 0, 0, 0);                    //dacReceiverConfig.Receiver_Update(cmd, ReceiverID, ReceiveName, IP_Address, Event_Port_No, Command_Port_No, Redundant_Flag, Use_Flag);                }                IOBoard_cmd = QUERYMode.select;                //VIEW모드로 변경한다.                Util.GroupUIChange(panelIOBoard, UIMode.cancel);                //데이터 불러오기                IOBoard_getData();                IOBoardDevice_getData();                IOBoardSelectData(null);                btnIOBoardCancel.Visible = false;                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnIOBoardCancel_Click(object sender, EventArgs e)        {            try            {                //VIEW모드로 변경한다.                IOBoard_cmd = QUERYMode.select;                Util.GroupUIChange(panelIOBoard, UIMode.cancel);                IOBoardSelectData(null);                btnIOBoardCancel.Visible = false;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void listView3_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                ListView lv = (ListView)sender;                if (lv.SelectedItems.Count > 0)                {                    ListViewItem itm = lv.SelectedItems[0];                    IOBoard_cmd = QUERYMode.update;                    //VIEW모드로 변경한다.[IO보드]                    Util.GroupUIChange(panelIOBoard, UIMode.input);                    IOBoardSelectData(itm);                    IOBoardDevice_getData();                }                else                {                    IOBoard_cmd = QUERYMode.select;                    //VIEW모드로 변경한다.                    Util.GroupUIChange(panelIOBoard, UIMode.cancel);                    IOBoardSelectData(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnIOBoardDel_Click(object sender, EventArgs e)        {            try            {                IOBoard_cmd = QUERYMode.delete;                int BoardID = Util.StrToInt(txtIOBoardID.Text, -1);                String BoardName = txtIOBoardName.Text.Trim();                String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", BoardName, BoardID);                if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    DacIOBoardConfig dacIOBoardConfig = new DacIOBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacIOBoardConfig.Board_Update(IOBoard_cmd, mdi.myReceiverID, BoardID, BoardName, null, null, null, 0, 0, 0, 0, 0);                }                //VIEW모드로 변경한다.                IOBoard_cmd = QUERYMode.select;                Util.GroupUIChange(panelIOBoard, UIMode.cancel);                //입력 CLEAR                IOBoardSelectData(null);                //데이터 불러오기                IOBoard_getData();                IOBoardDevice_getData();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        /*******************************************************       *          [IO보드 회로정보] LISTVIEW에 데이터 불러오기       ******************************************************/        private void IOBoardDevice_getData()        {            try            {                IOBoardDeviceSelectData(null);                int board_id = Util.StrToInt(txtIOBoardID.Text, 0);                DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacIODeviceConfig.Device_Select(mdi.myReceiverID, board_id, 0, null);                listView4.Items.Clear();                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        String dev_id = dr["DEVICE_ID"].ToString();                        String dev_id_s = String.Format("I-{0}-{1:00}-{2:00}", dr["INOUT_TYPE"].ToString(), int.Parse(dr["BOARD_ID"].ToString()), int.Parse(dr["DEVICE_ID"].ToString()));                        ListViewItem item = new ListViewItem(dev_id_s);                        item.SubItems.Add(string.Format("{0}-{1}", dr["DEVICE_TYPE"].ToString(), dr["DEVICE_TYPE_NAME"].ToString()));                        item.SubItems.Add(string.Format("{0}-{1}", dr["POSITION_CODE"].ToString(), dr["POSITION_NAME"].ToString()));                        item.SubItems.Add(dr["DEVICE_NAME"].ToString());                        listView4.Items.Add(item);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnIODeviceOpen_Click(object sender, EventArgs e)        {            try            {                if (IOBoard_selectItem != null)                {                    String dev_id_s = mskIOBoardDeviceID.Text;                    String dev_s = "";                    String dev_io = "I";                    if (dev_id_s.Length > 8)                    {                        dev_s = dev_id_s.Substring(7, 2).Trim();                        dev_io = dev_id_s.Substring(2, 1).Trim();                    }                    InputIDVo vo = new InputIDVo();                    vo.ReceiverID = mdi.myReceiverID;                    vo.CommID = 3;                    vo.BoardID = Util.StrToInt(txtIOBoardID.Text, 0);                    vo.InoutType = dev_io;                    vo.LoopNo = 0;                    vo.RepeaterID = 0;                    vo.DeviceID = Util.StrToInt(dev_s, 1);                    IWin32Window window = this;                    frmModalIdInputIO frm = new frmModalIdInputIO();                    frm.InputVo = vo;                    frm.ShowDialog(window);                    vo = frm.InputVo;                    //입력한 코드가 있다면                    if (vo.InputOK)                    {                        //I-A-12-##                        mskIOBoardDeviceID.Text = String.Format("I{0}{1:00}{2:00}", vo.InoutType, vo.BoardID, vo.DeviceID);                    }                }                else                {                    MessageBox.Show("먼저 IO보드를 선택하여 주십시요.", Application.ProductName);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //IO보드 회로 데이터 표시        private void IOBoardDeviceSelectData(ListViewItem itm)        {            try            {                IOBoardDevice_selectItem = itm;                if (itm == null)                {                    mskIOBoardDeviceID.Text = "";                    txtIOBoardDeviceTypeCode.Text = "";                    txtIOBoardDeviceTypeName.Text = "";                    txtIOBoardDeviceMemo.Text = "";                    txtIOBoardPositionCode.Text = "";                    txtIOBoardPositionName.Text = "";                    if (IOBoardDevice_cmd == QUERYMode.insert)                    {                        mskIOBoardDeviceID.ReadOnly = false;                        mskIOBoardDeviceID.BackColor = Color.White;                        btnIOBoardDeviceOK.Enabled = true;                        btnDeviceTypeOpen.Enabled = true;                        btnIODeviceOpen.Enabled = true;                        btnIOBoardPositionOpen.Enabled = true;                    }                    else                    {                        mskIOBoardDeviceID.ReadOnly = true;                        mskIOBoardDeviceID.BackColor = SystemColors.Control;                        //btnIOBoardDeviceAdd.Enabled = true;                        btnIOBoardDeviceDel.Enabled = false;                        btnIOBoardDeviceOK.Enabled = false;                        btnDeviceTypeOpen.Enabled = false;                        btnIOBoardPositionOpen.Enabled = false;                        btnIODeviceOpen.Enabled = false;                    }                }                else                {                    String dev_id_s = itm.Text;                    dev_id_s = dev_id_s.Replace("-", "");                    mskIOBoardDeviceID.Text = dev_id_s;                    mskIOBoardDeviceID.BackColor = SystemColors.Control;                    string devType = itm.SubItems[1].Text;                    int pos = devType.IndexOf("-");                    if (pos != -1)                    {                        txtIOBoardDeviceTypeCode.Text = devType.Substring(0, pos);                        txtIOBoardDeviceTypeName.Text = devType.Substring(pos + 1);                    }                    string positionCode = itm.SubItems[2].Text;                    int pos2 = positionCode.IndexOf("-");                    if (pos2 != -1 && positionCode.Length > 1)                    {                        txtIOBoardPositionCode.Text = positionCode.Substring(0, pos);                        txtIOBoardPositionName.Text = positionCode.Substring(pos + 1);                    }                    txtIOBoardDeviceMemo.Text = itm.SubItems[3].Text;                    mskIOBoardDeviceID.ReadOnly = true;                    //btnIOBoardDeviceAdd.Enabled = true;                    btnIOBoardDeviceDel.Enabled = true;                    btnIOBoardDeviceOK.Enabled = true;                    btnDeviceTypeOpen.Enabled = true;                    btnIOBoardPositionOpen.Enabled = true;                    btnIODeviceOpen.Enabled = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnDeviceTypeOpen_Click(object sender, EventArgs e)        {            try            {                String dev_id_s = mskIOBoardDeviceID.Text;                String dev_io = null;                //I-A-12-##                if (dev_id_s.Length > 8)                {                    dev_io = dev_id_s.Substring(2, 1).Trim();                }                //코드를 찾는 모달창을 연다..                frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                SearchCodeVo vo = new SearchCodeVo(dev_io);                vo.Code = txtIOBoardDeviceTypeCode.Text;                vo.CodeName = txtIOBoardDeviceTypeName.Text;                frm.SearchCode = vo;                frm.ShowDialog();                vo = frm.SearchCode;                //선택한 코드가 있다면                if (vo.SearchOK)                {                    //선택한 코드값을 dataGridView2에 표시                    txtIOBoardDeviceTypeCode.Text = vo.Code;                    txtIOBoardDeviceTypeName.Text = vo.CodeName;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnIOBoardDeviceAdd_Click(object sender, EventArgs e)        {            try            {                //입력모드로 변경한다.                IOBoardDevice_cmd = QUERYMode.insert;                Util.GroupControlChange(panelIOBoardDevice, UIMode.input);                IOBoardDeviceSelectData(null);                mskIOBoardDeviceID.Focus();                btnIOBoardDeviceAdd.Enabled = false;                btnIOBoardDeviceDel.Enabled = false;                btnIOBoardDeviceCancel.Visible = true;                btnIOBoardDeviceOK.Enabled = true;                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnIOBoardDeviceCancel_Click(object sender, EventArgs e)        {            try            {                //VIEW모드로 변경한다.                IOBoardDevice_cmd = QUERYMode.select;                Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);                IOBoardDeviceSelectData(null);                btnIOBoardDeviceCancel.Visible = false;                btnIOBoardDeviceAdd.Enabled = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnIOBoardDeviceOK_Click(object sender, EventArgs e)        {            try            {                if (IOBoardDevice_cmd == QUERYMode.insert || IOBoardDevice_cmd == QUERYMode.update)                {                    Util.ChkTxtBox(mskIOBoardDeviceID, "회로번호");                    //Util.ChkTxtBox(txtIOBoardDeviceTypeCode, "연동타입코드");                    String dev_id_s = mskIOBoardDeviceID.Text;                    String dev_id = "";                    String dev_board_id = "";                    String dev_io = "I";                    String dev_type = txtIOBoardDeviceTypeCode.Text;                    String dev_name = txtIOBoardDeviceMemo.Text;                    String position_code = txtIOBoardPositionCode.Text;                    //I-A-12-##                    if (dev_id_s.Length > 8)                    {                        dev_id = dev_id_s.Substring(7, 2).Trim();                        dev_io = dev_id_s.Substring(2, 1).Trim();                        dev_board_id = dev_id_s.Substring(4, 2).Trim();                    }                    else                    {                        throw new Exception("회로번호를 올바르게 입력하세요.");                    }                    if (int.Parse(txtIOBoardID.Text) != int.Parse(dev_board_id))                    {                        throw new Exception(String.Format("등록하는 회로의 보드ID[{0}]와 회로번호의 보드ID[{1}]가 일치하지 않습니다."                            , txtIOBoardID.Text, int.Parse(dev_board_id)));                    }                    if (!Util.onlyLiteral(dev_id))                        throw new Exception("회로번호를 올바르게 입력하세요.");                    DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, Util.StrToInt(dev_board_id, 1)                        , Util.StrToInt(dev_id, 1), dev_io, dev_name, dev_type, position_code);                }                IOBoardDevice_cmd = QUERYMode.select;                //VIEW모드로 변경한다.                Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);                //데이터 불러오기                IOBoardDevice_getData();                IOBoardDeviceSelectData(null);                btnIOBoardDeviceCancel.Visible = false;                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void listView4_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                ListView lv = (ListView)sender;                if (lv.SelectedItems.Count > 0)                {                    ListViewItem itm = lv.SelectedItems[0];                    IOBoardDevice_cmd = QUERYMode.update;                    //VIEW모드로 변경한다.[IO보드]                    Util.GroupControlChange(panelIOBoardDevice, UIMode.input);                    IOBoardDeviceSelectData(itm);                }                else                {                    IOBoardDevice_cmd = QUERYMode.select;                    //VIEW모드로 변경한다.                    Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);                    IOBoardDeviceSelectData(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void txtIOBoardDeviceTypeCode_TextChanged(object sender, EventArgs e)        {            try            {                Util.ToUpper(txtIOBoardDeviceTypeCode);                String TypeValue = txtIOBoardDeviceTypeCode.Text.Trim();                if (TypeValue.Length == 2)                {                    String IOType = TypeValue.Substring(0, 1);                    DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    String type_name = dacDeviceConfig.Device_Type_Name(IOType, TypeValue);                    txtIOBoardDeviceTypeName.Text = type_name;                }                else                {                    txtIOBoardDeviceTypeName.Text = "";                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void txtIOBoardPositionCode_TextChanged(object sender, EventArgs e)        {            try            {                Util.ToUpper(txtIOBoardPositionCode);                String positionCode = txtIOBoardPositionCode.Text.Trim();                if (positionCode.Length == 2)                {                    DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    String positionName = dacDeviceConfig.Device_Position_Name(positionCode);                    txtIOBoardPositionName.Text = positionName;                }                else                {                    txtIOBoardPositionName.Text = "";                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnIOBoardDeviceDel_Click(object sender, EventArgs e)        {            try            {                String dev_id_s = mskIOBoardDeviceID.Text;                String dev_id = "";                String dev_board_id = "";                String dev_io = "I";                String dev_type = txtIOBoardDeviceTypeCode.Text;                String dev_name = txtIOBoardDeviceMemo.Text;                //I-A-12-##  : I(구분)-I,O(회로구분)-##(보드ID)-##(회로ID)                if (dev_id_s.Length > 8)                {                    dev_id = dev_id_s.Substring(7, 2).Trim();                    dev_io = dev_id_s.Substring(2, 1).Trim();                    dev_board_id = dev_id_s.Substring(4, 2).Trim();                }                else                {                    throw new Exception("회로번호가 올바르지 않습니다.");                }                String msg = string.Format("{0}[{1}]을/를 삭제하시겠습니까?", dev_name, dev_id_s);                IOBoardDevice_cmd = QUERYMode.delete;                if (MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    DacIODeviceConfig dacIODeviceConfig = new DacIODeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    dacIODeviceConfig.Device_Update(IOBoardDevice_cmd, mdi.myReceiverID, int.Parse(dev_board_id), int.Parse(dev_id), dev_io, null, null, null);                }                //VIEW모드로 변경한다.                IOBoardDevice_cmd = QUERYMode.select;                Util.GroupControlChange(panelIOBoardDevice, UIMode.cancel);                //입력 CLEAR                IOBoardDeviceSelectData(null);                //데이터 불러오기                IOBoardDevice_getData();                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnIOBoardPositionOpen_Click(object sender, EventArgs e)        {            try            {                String dev_id_s = mskIOBoardDeviceID.Text;                String dev_io = null;                //I-A-12-##                if (dev_id_s.Length > 8)                {                    dev_io = dev_id_s.Substring(2, 1).Trim();                }                //코드를 찾는 모달창을 연다..                frmModalPositionCode frm = new frmModalPositionCode();                SearchCodeVo vo = new SearchCodeVo(null);                vo.Code = txtIOBoardPositionCode.Text;                vo.CodeName = txtIOBoardPositionName.Text;                frm.setMdiParent(this.mdi);                frm.SearchCode = vo;                frm.ShowDialog();                vo = frm.SearchCode;                //선택한 코드가 있다면                if (vo.SearchOK)                {                    //선택한 코드값을 dataGridView2에 표시                    txtIOBoardPositionCode.Text = vo.Code;                    txtIOBoardPositionName.Text = vo.CodeName;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        #endregion        /******************************************************************************************************/        /******************************************************************************************************/        //#region 키패드 데이터 콘트롤        //private void btnKeypadEdit_Click(object sender, EventArgs e)        //{        //    //입력모드로 변경한다.        //    Keypad_cmd = QUERYMode.InsertAndUpdate;        //    Util.GroupUIChange(panelKeypad, UIMode.input);        //    btnKeypadEdit.Enabled = false;        //    btnKeypadOK.Enabled = true;        //    btnKeypadCancel.Enabled = true;        //}        //private void btnKeypadCancel_Click(object sender, EventArgs e)        //{        //    //입력모드로 변경한다.        //    Keypad_cmd = QUERYMode.select;        //    Util.GroupUIChange(panelKeypad, UIMode.cancel);        //    btnKeypadEdit.Enabled = true;        //    btnKeypadOK.Enabled = false;        //    btnKeypadCancel.Enabled = false;        //}        //private void btnKeypadOK_Click(object sender, EventArgs e)        //{        //    if (Keypad_cmd == QUERYMode.InsertAndUpdate)        //    {        //        Util.ChkTxtBox(txtKeypadID, "키패드ID");        //        Util.ChkTxtBox(txtKeypadName, "키패드명");        //        Util.ChkComboBox(cboKeypadBaudRate, "Baud Rate");        //        Util.ChkTxtBox(txtKeypadMainVersion, "Version");        //        Util.ChkTxtBox(txtKeypadCommTerm, "송수신간격");        //        Util.ChkOnlyLiteralTextBox(txtKeypadMainVersion, "Main Version");        //        Util.ChkOnlyLiteralTextBox(txtKeypadSubVersion, "Sub Version");        //        Util.ChkOnlyLiteralTextBox(txtKeypadCommTerm, "송수신간격");        //        int KeypadID = Util.StrToInt(txtKeypadID.Text, 1);        //        String KeypadName = txtKeypadName.Text.Trim();        //        int BaudRate = Util.StrToInt(cboKeypadBaudRate.SelectedValue.ToString(), -1);        //        int mainVer = Util.StrToInt(txtKeypadMainVersion.Text, -1);        //        int subVer = Util.StrToInt(txtKeypadSubVersion.Text, 0);        //        int CommTerm = Util.StrToInt(txtKeypadCommTerm.Text, -1);        //        DacKeypadConfig dacKeypadConfig = new DacKeypadConfig();        //        dacKeypadConfig.Keypad_Update(Keypad_cmd, mdi.myReceiverID, KeypadName, "Y", BaudRate, CommTerm, mainVer, subVer);        //    }        //    Keypad_cmd = QUERYMode.select;        //    //VIEW모드로 변경한다.        //    Util.GroupUIChange(panelKeypad, UIMode.cancel);        //    //데이터 불러오기        //    Keypad_getData();        //    btnKeypadEdit.Enabled = true;        //    btnKeypadOK.Enabled = false;        //    btnKeypadCancel.Enabled = false;        //}        //private void Keypad_getData()        //{        //    try        //    {        //        DacKeypadConfig dacKeypadConfig = new DacKeypadConfig();        //        DataTable dt = dacKeypadConfig.Keypad_Select(mdi.myReceiverID, "Y");        //        if (dt.Rows.Count > 0)        //        {        //            foreach (DataRow dr in dt.Rows)        //            {        //                txtKeypadID.Text = dr["BOARD_ID"].ToString();        //                txtKeypadName.Text = dr["BOARD_NAME"].ToString();        //                txtKeypadMainVersion.Text = dr["MAIN_VERSION"].ToString();        //                txtKeypadSubVersion.Text = dr["SUB_VERSION"].ToString();        //                cboKeypadBaudRate.SelectedValue = dr["BAUD_RATE"].ToString();        //                txtKeypadCommTerm.Text = dr["COMM_TERM"].ToString();        //            }        //        }        //    }        //    catch (Exception ex)        //    {        //MessageBox.Show(ex.Message, Application.ProductName);        //          MessageBox.Show(string.Format("[{0}]\r\n{1}",ex.Message,ex.StackTrace),Application.ProductName);        //    }        //}        //#endregion        public void ReceiverConfigWriteAll()        {            try            {                if (MessageBox.Show("[전체]수신기에 전체 중계기 정보 쓰기를 수행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    timer.Enabled = true;                    timer.Interval = 1000;                    timer.Tick += new EventHandler(time_tick);                    timer.Start();                    this.panel1.Enabled = false;                    mdi.panel8.Enabled = false;                    btnReceiverConfigWriteAll.Enabled = false;                    panel_Menu.Enabled = false;                    this.Cursor = Cursors.WaitCursor;                    // cyim 2015.2.10 수신기설정-전체중계기 쓰기 실행                                  mdi.CommandLog(MappingStatus.Log, string.Format("수신기설정-전체중계기 쓰기"));                    //2010.12.05, k.s.d, repeater information unit write -> don't use.                    ///******************************************/                    ///*        중계기 쓰기 Progress 표시             */                    ///******************************************/                    //frmProgress frm = new frmProgress();                    ////중계기 설정 데이터를 CmdInfo에 넣어준다..                    //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID);                    //cmd.boardNo = 0; //전체 보드ID                    ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo;       //수신기설정                    ////cmd.CommandData = Receiverinfo;  //화면에 설정된 데이터를 쓰기데이터로 이용한다.                    //frm.Commandinfo = cmd;                    //frm.ui = this.mdi.ui;                    //frm.ShowDialog();                    ///******************************************/                    ////lblReceiverConfigChangeFlag.ForeColor;                    //2010.12.05, k.s.d, repeater information block write.                    btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false;                    // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자                    InfoWriteBoardNo = 0;                    InfoWriteLoopNo = 0;                    if (formBoardDataDownload == null || formBoardDataDownload.Created != true)                    {                        formBoardDataDownload = new FormBoardDataDownload(this);                        //formBoardDataDownload.MdiParent = this.mdi;                    }                    progress = -1;                    this.downloadResult = true;                    this.LoadBoardData();                    formBoardDataDownload.SetBoardData(this.LTBoard, mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                    formBoardDataDownload.SetMessage("통신보드 데이터 다운로드");                    formBoardDataDownload.Show();                    formBoardDataDownload.Location = new Point(400, 200);                    // 간헐적으로 화면이 갱신이 되지 않는다                    formBoardDataDownload.Update();                    System.Threading.Thread.Sleep(1000);                    // LCH 2018.02.27 : 수정됨                    // 클리어                    ArrayList_ComInfo.Clear();                    ArrayList_ComLevelInfo.Clear();                    Hashtable_ComLevelInfo_Data.Clear();                    level_num = 0;                    DoWriteRepeaterInfoAll();                    this.Cursor = Cursors.Default;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                this.Cursor = Cursors.Default;            }        }        private int time = 0;        public Timer timer = new System.Windows.Forms.Timer();        private void time_tick(object sender, EventArgs e)        {            time++;            if (time > 60 * 5)            {                time = 0;                timer.Enabled = false;                panel_Menu.Enabled = true;                btnReceiverConfigWriteAll.Enabled = true;                mdi.panel8.Enabled = true;                this.panel1.Enabled = true;                this.formBoardDataDownload.button1.Text = "확인";                this.formBoardDataDownload.button1.Visible = true;                MessageBox.Show("시간이 초과되었습니다(5분).", Application.ProductName);                return;            }        }        private void btnReceiverConfigWriteAll_Click(object sender, EventArgs e)        {            // cyim 2013.7.10 디자인개선작업 : 버튼 클릭후 잔상                                this.panel_Menu.Focus();            this.ReceiverConfigWriteAll();        }        // cyim 2017.01.12 : 등록된 통신보드 및 중계반 계통만 전체중계기쓰기 시도하자        // 소스 분석결과 이는 응답이 오면 다시 호출되는 재귀함수이다. 문제는 등록되지 않는 중계기까지 접근하니 비효율적인 함수이다        // 하단의 중복된 코드들은 그대로 둔다... -_-;..재귀함수에다가 GetResponseWriteRepeaterInfoBlock(null); 도 그대로 일단 두도록 한다        //2010.12.05, k.s.d, repeater information block write.        int InfoWriteBoardNo = 0;        int InfoWriteLoopNo = 0;        int progress = 0;        FormBoardDataDownload formBoardDataDownload = null;        bool downloadResult = true;        // LCH 2018.02.27 : 수정됨        ArrayList ArrayList_ComInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 저장        ArrayList ArrayList_ComLevelInfo = new ArrayList(); // DB에 사용으로 되어 있는 통신보드,채널 정보 중에 실질적으로 레벨 정보를 전송할 통신보드,채널 정보 저장        Hashtable Hashtable_ComLevelInfo_Data = new Hashtable(); // key : Loop:Board,Data : CmdInfo // 레벨 전송 데이터 저장        private void DoWriteRepeaterInfoAll()        {            try            {                this.progress++;                if (mdi.ReceiverModel == "IFC3300")                {                    double tempcnt = this.progress;                    tempcnt = Math.Round((tempcnt / (65 * 4)) * 100);                    this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt));                }                else                {                    double tempcnt = this.progress;                    tempcnt = Math.Round((tempcnt / (17 * 4)) * 100);                    this.formBoardDataDownload.SetProgress(Convert.ToInt32(tempcnt));                }                // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                int boardID_cnt = 0;                // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다                if (mdi.ReceiverModel == "IFC3300")                {                    boardID_cnt = 65;                }                else                {                    boardID_cnt = 16;                }                // 단, 3300 이하 모델에서는 보드아이디 0 을 허용하지 않는다                if (mdi.ReceiverModel != "IFC3300" && InfoWriteBoardNo == 0)                    InfoWriteBoardNo = 1; // cyim 2017.01.19 : IFC3300 이하 모델에서 1번보드 부터 전체중계기 쓰기한다                // 등록중인 보드 아이디인지 체크                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID);                string sql = string.Format("select * from TB_BOARD where RECEIVER_ID='{0}' and BOARD_ID='{1}' and USE_FLAG='Y' and LOOP{2}_USE_FLAG='Y'",                    mdi.myReceiverID, InfoWriteBoardNo, InfoWriteLoopNo);                DataSet data = dacBoardConfig.Select(sql);                if (data.Tables[0].Rows != null && data.Tables[0].Rows.Count > 0)                {                    // cyim 2016.11.03 : 통신보드(중계반)는 최대 64                    if (InfoWriteBoardNo < boardID_cnt)                    {                        if (DoWriteRepeaterInfoBlock(InfoWriteLoopNo, InfoWriteBoardNo) == false)                        {                            Count_Edit();                            GetResponseWriteRepeaterInfoBlock(null);                        }                        else                            Count_Edit();                    }                    else // 초과하면                    {                        Count_Edit();                        GetResponseWriteRepeaterInfoBlock(null);                    }                }                else                {                    Count_Edit();                    GetResponseWriteRepeaterInfoBlock(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void Count_Edit()        {            //System.Threading.Thread.Sleep(300);            // IFC3300  모델은 초기값이 0으로 들어오면 된다            if (mdi.ReceiverModel == "IFC3300")            {                if (InfoWriteLoopNo == 3)                {                    InfoWriteLoopNo = 0;                    InfoWriteBoardNo++;                }                else if (InfoWriteLoopNo == 2)                    InfoWriteLoopNo = 3;                else if (InfoWriteLoopNo == 1)                    InfoWriteLoopNo = 2;                else                    InfoWriteLoopNo = 1;            }            else            {                if (InfoWriteLoopNo == 1)                {                    InfoWriteLoopNo = 0;                    InfoWriteBoardNo++;                }                else                {                    InfoWriteLoopNo = 1;                }            }        }        private bool DoWriteRepeaterInfoBlock(int LoopNo, int BoardNo)        {            //Util.UDebugMessage("+DoWriteRepeaterInfoBlock", 0, 0);            bool bret = false;            try            {                if (ISBoardAndLoop(BoardNo, LoopNo)) // cyim                {                    // LCH 2018.02.27 : 수정됨                    // DB에 사용으로 되어 있는 통신보드,채널 정보 저장                    ArrayList_ComInfo.Add(InfoWriteLoopNo.ToString() + ";" + InfoWriteBoardNo.ToString());                    CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);                    dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoBlock);                    commandinfo.dEvent = deleg;                    RepeaterDataAll RepaterDataAll = new RepeaterDataAll();                    RepeaterDeviceTypeInfo[] RepeaterInfo = new RepeaterDeviceTypeInfo[127];                    for (int i = 0; i < 127; i++)                    {                        RepeaterInfo[i] = new RepeaterDeviceTypeInfo(i + 1);                    }                    DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, BoardNo, LoopNo, 0, null);                    DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    if (dt.Rows.Count > 0)                    {                        foreach (DataRow dr in dt.Rows)                        {                            Boolean FireResetFlag = false;                            String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);                            int iRepeaterID = int.Parse(RepeaterID);                            if (iRepeaterID == 128)                                break;                            String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]);                            Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;                            Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false;                            Boolean sFireResetFlag = false;                            if (UseFlag && !FireResetFlag)                            {                                FireResetFlag = sFireResetFlag;                            }                            // cyim 2015.6.8 아날로그 감지기 연동 추가                            // '1' = A : 2X2                             // '2' = B : 4X4                             // '4' = C : 아날로그연감지기                             // '5' = D : 아날로그열감지기                             String repeaterType = "";                            if (RepeaterType.Equals("1"))                                repeaterType = "A";                            else if (RepeaterType.Equals("2"))                                repeaterType = "B";                            else if (RepeaterType.Equals("4"))                                repeaterType = "C";                            else if (RepeaterType.Equals("5"))                                repeaterType = "D";                            if (!repeaterType.Equals(""))                            {                                RepeaterInfo[iRepeaterID - 1].CutFlag = CutFlag;                                RepeaterInfo[iRepeaterID - 1].UseFlag = true;                                RepeaterInfo[iRepeaterID - 1].RepeaterType = repeaterType;                                RepeaterInfo[iRepeaterID - 1].FireResetFlag = sFireResetFlag;                            }                            else                            {                                RepeaterInfo[iRepeaterID - 1].UseFlag = false;                            }                        }                    }                    for (int i = 0; i < 127; i++)                    {                        int RepeaterSet = 0;                        if (RepeaterInfo[i].UseFlag)                        {                            if (RepeaterInfo[i].RepeaterType == "A")                                RepeaterSet = 1;                            else if (RepeaterInfo[i].RepeaterType == "B")                                RepeaterSet = 2;                            else if (RepeaterInfo[i].RepeaterType == "C")                                RepeaterSet = 4;                            else if (RepeaterInfo[i].RepeaterType == "D")                                RepeaterSet = 5;                        }                        RepaterDataAll.Data[i].Set_Info_Data(RepeaterInfo[i].CutFlag, RepeaterInfo[i].FireResetFlag, false, false, RepeaterSet);                    }                    commandinfo.CommandData = RepaterDataAll;                    this.mdi.ui.runCommand(commandinfo);                    bret = true;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }            //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0);            return bret;        }        // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경          private bool ISBoardAndLoop(int BoardNo, int LoopNo)        {            bool bret = false;            try            {                DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacBoardConfig.Board_Select(mdi.myReceiverID, BoardNo, null);                Boolean UseFlag = false;                Boolean Loop0UseFlag = false;                Boolean Loop1UseFlag = false;                Boolean Loop2UseFlag = false;                Boolean Loop3UseFlag = false;                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        int BoardId = int.Parse(Convert.ToString(dr[0]));                        if (BoardId == BoardNo)                        {                            Loop0UseFlag = Convert.ToString(dr["LOOP0_USE_FLAG"]) == "Y" ? true : false;                            Loop1UseFlag = Convert.ToString(dr["LOOP1_USE_FLAG"]) == "Y" ? true : false;                            Loop2UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP2_USE_FLAG"])) == "Y" ? true : false;                            Loop3UseFlag = Convert.ToString(Util.NullToStr(dr["LOOP3_USE_FLAG"])) == "Y" ? true : false;                            UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;                        }                    }                }                if (UseFlag)                {                    if (LoopNo == 0)                    {                        bret = Loop0UseFlag;                    }                    else if (LoopNo == 1)                    {                        bret = Loop1UseFlag;                    }                    else if (LoopNo == 2)                    {                        bret = Loop2UseFlag;                    }                    else if (LoopNo == 3)                    {                        bret = Loop3UseFlag;                    }                }                else                {                    bret = false;                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }            return bret;        }        public void GetResponseWriteRepeaterInfoBlock(CmdInfo resInfo)        {            try            {                if (resInfo != null)                {                    //general_ack = 0x81,     //응답-정상                    //general_nack = 0x80,   //응답-실패                    switch (resInfo.ResCommand)                    {                        case prt_res_define.general_ack:                            {                                this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 1, mdi);                                // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기                                 // 코드 분석 결과 대용량 수신기의 경우 아날로그 감지기 레벨을 일괄적으로 통신으로 보내야되는데                                // 기존의 통신보드 및 중계기 셋팅하는 코드 다음에 다시 사이클이 돌아가는 것보다 실제로 통신이 성공한 통신보드에 한해서                                // 레벨값을 일괄적으로 쓰는 것이 옳다고 판단한다                                // 테스트를 위해 잠시 삭제                                //DoWriteAnalogDetecterLevelBlock(resInfo.boardNo, resInfo.loopNo);                                break;                            }                        case prt_res_define.general_nack:                            {                                this.formBoardDataDownload.SetBoardDataDownloadResult(resInfo.boardNo, resInfo.loopNo, 0, mdi);                                this.downloadResult = false;                                break;                            }                        case 0:                            {                                if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created)                                {                                    this.formBoardDataDownload.Close();                                    this.formBoardDataDownload = null;                                }                                timer.Enabled = false;                                panel_Menu.Enabled = true;                                btnReceiverConfigWriteAll.Enabled = true;                                mdi.panel8.Enabled = true;                                this.panel1.Enabled = true;                                MessageBox.Show("통신데몬과 연결이 되어야합니다.", Application.ProductName);                                return;                            }                    }                }                // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경                int boardID_cnt = 0;                // cyim 2017.01.12 : IFC3300 은 통신보드 0번이 존재한다                if (mdi.ReceiverModel == "IFC3300")                {                    boardID_cnt = 64;//64                }                else                {                    boardID_cnt = 16;                }                // cyim 2016.11.03 : 통신보드(중계반)는 최대 64                if (InfoWriteBoardNo > boardID_cnt)                {                    // LCH 2018.02.27 : 수정됨                    if (ArrayList_ComInfo.Count != 0) // 전송할 정보 있음                    {                        // 레벨값 전송                        DoWriteAnalogDetecterLevelBlock(ArrayList_ComInfo);                    }                    else // 전송할 정보 없음                    {                        //FormBoardDataDownload.SetMessage("설정정보가 변경되어 데몬을 Reset하였습니다.");                        //mdi.ui.ReceiverDBRead();                        //mdi.FireReset_Process();                        this.Cursor = Cursors.Default;                        if (this.downloadResult)                        {                            this.formBoardDataDownload.SetSucess();                        }                        else                        {                            this.formBoardDataDownload.SetFalse();                        }                    }                }                else                {                    DoWriteRepeaterInfoAll();                }            }            catch (Exception ex)            {                this.Cursor = Cursors.Default;                Util.UErrorMessage(ex, 0, 0);            }        }        // LCH 2018.02.27 : 수정됨        // cyim 2016.10.28 : 대용량 수신기 아날로그 감지기 레벨 Block 쓰기         //private bool DoWriteAnalogDetecterLevelBlock(int LoopNo, int BoardNo)        private bool DoWriteAnalogDetecterLevelBlock(ArrayList ArrayList_ComInfo)        {            bool bret = false;            try            {                for (int i = 0; i < ArrayList_ComInfo.Count; i++)                {                    string[] temp = ((string)ArrayList_ComInfo[i]).Split(';');                    int LoopNo = Int32.Parse(temp[0]);                    int BoardNo = Int32.Parse(temp[1]);                    int boardID_cnt1;                    if (mdi.ReceiverModel == "IFC3300")                    {                        boardID_cnt1 = 64;//64                    }                    else                    {                        boardID_cnt1 = 16;                    }                    if (BoardNo > boardID_cnt1)                    {                        CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_analogdetecter_level_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);                        // 응답처리는 하지않음. 차후 삭제 예정                        dCommandResponse deleg = new dCommandResponse(GetResponseWriteAnalogDetecterLevelBlock);                        commandinfo.dEvent = deleg;                        RepeaterDataAll RepaterDataAll = new RepeaterDataAll();                        // 데이타베이스에는 아날로그 감지기 레벨값만 들어있는 테이블이 따로 존재한다                        DataTable dt = LoadAnalogDetecterLevel(mdi.myReceiverID, BoardNo, LoopNo, 0); // 아이디가 0 이면 해당 계통 전체를 검색                        if (dt.Rows.Count > 0)                        {                            foreach (DataRow dr in dt.Rows)                            {                                String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);                                int iRepeaterID = int.Parse(RepeaterID);                                RepaterDataAll.Data[iRepeaterID - 1].Set_Level_AnalogDetecter(                                    Convert.ToByte(dr["FAULT_VALUE"]),                                    Convert.ToByte(dr["PREFIRE_VALUE"]),                                    Convert.ToByte(dr["FIREN_VALUE"]),                                    Convert.ToByte(dr["FIRED_VALUE"])                                    );                            }                            // 단 해당하는 Loop 에 아날로그 감지기가 없으면 패킷 전송을 할 이유가 없다                            commandinfo.CommandData = RepaterDataAll;                            // 실질적으로 레벨 정보를 전송한 통신보드,채널 정보 저장                            ArrayList_ComLevelInfo.Add(LoopNo.ToString() + ";" + BoardNo.ToString());                            Hashtable_ComLevelInfo_Data.Add(LoopNo.ToString() + ";" + BoardNo.ToString(), commandinfo);                        }                    }                }                // 3300일때만 레벨을 전송한다                if (mdi.ReceiverModel == "IFC3300")                {                    // 레벨을 전송 할 수 있는지 확인                    if (ArrayList_ComLevelInfo.Count != 0)                    {                        // 첫번째만 출발                        this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[0]]);                        bret = true;                    }                    else // 전송할 레벨이 없다                    {                        this.formBoardDataDownload.SetFinish();                    }                }                else                {                    this.formBoardDataDownload.SetFinish();                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }            //Util.UDebugMessage("-DoWriteRepeaterInfoBlock", 0, 0);            return bret;        }        // LCH 2018.02.27 : 수정됨        int level_num = 0;        public void GetResponseWriteAnalogDetecterLevelBlock(CmdInfo resInfo)        {            try            {                if (resInfo != null)                {                    //general_ack = 0xA2,     //응답-정상                    //general_nack = 0x80,   //응답-실패                    switch (resInfo.ResCommand)                    {                        case prt_res_define.write_analogdetecter_level_all:                            {                                RCVData_ACK ResponseData = (RCVData_ACK)resInfo.ResponseData;                                GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo;                                int boardNo = baseInfo.UnitID_u;                                int loopNo = baseInfo.UnitID_d;                                this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 1, mdi);                                System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 1" + "\r\n");                                break;                            }                        case prt_res_define.general_nack:                            {                                RCVData_NACK ResponseData = (RCVData_NACK)resInfo.ErrResponseData;                                GeneralBaseInfo baseInfo = (GeneralBaseInfo)ResponseData.Baseinfo;                                int boardNo = baseInfo.UnitID_u;                                int loopNo = baseInfo.UnitID_d;                                this.formBoardDataDownload.SetBoardDataDownloadResult(boardNo, loopNo, 0, mdi);                                System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + boardNo.ToString() + " " + loopNo.ToString() + " 0" + "\r\n");                                break;                            }                    }                }                level_num++;                System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + " " + level_num + "\r\n");                // 완료 버튼을 보이게 한다 lch 20180101                if (level_num == ArrayList_ComLevelInfo.Count)                {                    this.formBoardDataDownload.SetFinish();                }                else                {                    // 다음 패킷 출발                    this.mdi.ui.runCommand((CmdInfo)Hashtable_ComLevelInfo_Data[(string)ArrayList_ComLevelInfo[level_num]]);                }            }            catch (Exception ex)            {                this.Cursor = Cursors.Default;                Util.UErrorMessage(ex, 0, 0);            }        }        public void ResetDemon()        {            //mdi.ui.ReceiverDBRead();            //mdi.FireReset_Process();            //            // cyim 2013.6.27 : 수신기 설정 -> 중계기 쓰기 버튼 이후 데몬 초기화 되지 않는 문제 (상위주석처리)            //            mdi.FireReset_Process();            mdi.socketUI.ReceiverDemonReset();        }        private void frmReceiverConfig_FormClosing(object sender, FormClosingEventArgs e)        {            if (this.formBoardDataDownload != null && this.formBoardDataDownload.Created)            {                this.formBoardDataDownload.Close();                this.formBoardDataDownload = null;            }        }        //        // cyim 2013.7.10 디자인개선작업 : 수신기설정        //        // 수신기 버튼        private void button_Menu_Receiver_Click(object sender, EventArgs e)        {            button_Menu_Color_Init();            this.tabControl_Main.SelectTab(0);            this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;            this.panel_Menu.Focus();        }        // 통신설정 버튼        private void button_Menu_CommSet_Click(object sender, EventArgs e)        {            // cyim 2014.5.7 : 통신설정메뉴 다시 불러오기            // 통신 설정의 경우 탭을 선택하면 무조건 데이타베이스에 있는 값을 읽어온다            Comm_getData();            button_Menu_Color_Init();            this.tabControl_Main.SelectTab(1);            this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;            this.panel_Menu.Focus();        }        // cyim 2016.12.13 : 수신기설정에서 IFC3300 의 경우에만 통신보드의 LOOP 0~3 으로 보여지도록 한다        private bool Check_List_ColumnText(string ColumnText)        {            for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++)            {                ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i];                if (col_hr.Text == ColumnText)                {                    return true;                }            }            return false;        }        private void CheckDel_List_ColumnText(string ColumnText)        {            ColumnHeader remove_col_hr = null;            for (int i = 0; i < this.listView_CommBoard.Columns.Count; i++)            {                ColumnHeader col_hr = (ColumnHeader)listView_CommBoard.Columns[i];                if (col_hr.Text == ColumnText)                {                    listView_CommBoard.Columns.Remove(col_hr);                    remove_col_hr = col_hr;                }            }            if (remove_col_hr != null)                listView_CommBoard.Columns.Remove(remove_col_hr);        }        // 통신보드 버튼        private void button_Menu_CommBoard_Click(object sender, EventArgs e)        {            // 통신보드 UI 컨셉이 변경될수 있다            if (mdi.ReceiverModel == "IFC3300")            {                this.chkLoop2UseFlag.Visible = true;                this.chkLoop3UseFlag.Visible = true;                if (Check_List_ColumnText("Loop2 사용여부") == false)                    this.listView_CommBoard.Columns.Add("columnHeader_2", "Loop2 사용여부", 170, HorizontalAlignment.Center, 0);                if (Check_List_ColumnText("Loop3 사용여부") == false)                    this.listView_CommBoard.Columns.Add("columnHeader_3", "Loop3 사용여부", 170, HorizontalAlignment.Center, 0);                this.listView_CommBoard.Update();            }            else            {                this.chkLoop2UseFlag.Visible = false;                this.chkLoop3UseFlag.Visible = false;                if (Check_List_ColumnText("Loop2 사용여부") == true)                    CheckDel_List_ColumnText("Loop2 사용여부");                if (Check_List_ColumnText("Loop3 사용여부") == true)                    CheckDel_List_ColumnText("Loop3 사용여부");                this.listView_CommBoard.Update();            }            button_Menu_Color_Init();            this.tabControl_Main.SelectTab(2);            this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;            this.panel_Menu.Focus();        }        // IO보드 버튼        private void button_Menu_IOBoard_Click(object sender, EventArgs e)        {            button_Menu_Color_Init();            this.tabControl_Main.SelectTab(3);            this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;            this.panel_Menu.Focus();        }        // 중계기 버튼        private void button_Menu_Repeater_Click(object sender, EventArgs e)        {            button_Menu_Color_Init();            this.tabControl_Main.SelectTab(4);            this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_주황_100_30;            this.panel_Menu.Focus();        }        // 버튼 색상 초기화        private void button_Menu_Color_Init()        {            this.button_Menu_Receiver.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;            this.button_Menu_CommSet.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;            this.button_Menu_CommBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;            this.button_Menu_IOBoard.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;            this.button_Menu_Repeater.BackgroundImage = (Image)Properties.Resources.탭메뉴버튼_회색_100_30;        }        /******************************************************************************************************/        #region 중계기 및 회로 설정        //중계기및 회로 설정정보        RepeaterDeviceTypeInfo[] REP = new RepeaterDeviceTypeInfo[127];        private void cboBoardList_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                if (cboBoardList.SelectedValue != null)                {                    String BoardId = cboBoardList.SelectedValue.ToString();                    //cboLoopList                    DacBoardConfig dacBoardConfig = new DacBoardConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                    ArrayList ary = dacBoardConfig.Loop_List(mdi.myReceiverID, int.Parse(BoardId));                    Util.ComboSetting(cboLoopList, ary, null);                }                else                {                    Util.ComboSetting(cboLoopList, null, null);                }                Repeater_getDate();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void Repeater_init()        {            try            {                //dataGridView1,dataGridView2                try                {                    this.dataGridView_Repeater_Main.Columns.Clear();                }                catch (Exception ex)                {                    Util.UErrorMessage(ex, 0, 0);                }                /************************************************************************/                /*   dataGridView1  헤더 설정                                                                  */                /************************************************************************/                DataGridViewCellStyle sty = new DataGridViewCellStyle();                sty.Alignment = DataGridViewContentAlignment.MiddleCenter;                for (int col = 0; col < 10; col++)                {                    dataGridView_Repeater_Main.Columns.Add(new DataGridViewTextBoxColumn());                    dataGridView_Repeater_Main.Columns[col].ReadOnly = true;                    dataGridView_Repeater_Main.Columns[col].Resizable = DataGridViewTriState.False;                    dataGridView_Repeater_Main.Columns[col].Width = 70;                    dataGridView_Repeater_Main.Columns[col].DefaultCellStyle = sty;                }                /************************************************************************/                /************************************************************************/                /*   dataGridView1  Row 생성.. 총 127개 Cell                                            */                /************************************************************************/                this.dataGridView_Repeater_Main.Rows.Clear();                DataGridViewRowCollection rows = this.dataGridView_Repeater_Main.Rows;                for (int row = 0; row <= 12; row++)                {                    String[] rowData = new String[10];                    for (int col = 1; col <= 10; col++)                    {                        int no = row * 10 + col;                        if (no <= 127)                        {                            rowData[col - 1] = String.Format("{0:000}", no);                            REP[no - 1] = new RepeaterDeviceTypeInfo(no);    //중계기및 회로 설정정보                        }                    }                    rows.Add(rowData);                }                /************************************************************************/                //중계기 설정내용 표시                RepeaterStatus("");                chkSelectAll.Text = "전체선택";                chkSelectAll.Checked = false;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                throw ex;            }        }        private void Device_Init(String Type)        {            try            {                this.dataGridView_Repeater_Sub.Columns.Clear();                mskDeviceID.Text = "";                txtDeviceTypeCode.Text = "";                txtDeviceTypeName.Text = "";                txtPositionCode.Text = "";                txtPositionName.Text = "";                txtDeviceMemo.Text = "";            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }            try            {                if (Type == null) return;                /************************************************************************/                /*   dataGridView2  헤더 설정                                                                  */                /************************************************************************/                // 사용                DataGridViewCellStyle sty2 = new DataGridViewCellStyle();                sty2.Alignment = DataGridViewContentAlignment.MiddleCenter;                sty2.BackColor = System.Drawing.Color.White;                sty2.Font = new System.Drawing.Font("굴림", 12);                // 비사용                DataGridViewCellStyle styGray = new DataGridViewCellStyle();                styGray.Alignment = DataGridViewContentAlignment.MiddleLeft;                styGray.BackColor = System.Drawing.Color.LightGray;                styGray.SelectionBackColor = System.Drawing.Color.Gray;                styGray.Font = new System.Drawing.Font("굴림", 12);                // cyim 2015.6.8 아날로그 감지기 연동 추가                // 아래의 타입 전부 허용                // '1' = A : 2X2                 // '2' = B : 4X4                 // '4' = C : 아날로그연감지기                 // '5' = D : 아날로그열감지기                 for (int i = 0; i < 8; i++)                {                    dataGridView_Repeater_Sub.Columns.Add(new DataGridViewTextBoxColumn());                    ((DataGridViewTextBoxColumn)dataGridView_Repeater_Sub.Columns[i]).MaxInputLength = 2;                    dataGridView_Repeater_Sub.Columns[i].ReadOnly = true;                    dataGridView_Repeater_Sub.Columns[i].Resizable = DataGridViewTriState.False;                    dataGridView_Repeater_Sub.Columns[i].Width = 70;                    if (Type.Equals("A") && (i == 2 || i == 3 || i == 6 || i == 7))                        dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray;                    else if ((Type.Equals("C") || Type.Equals("D")) && (i == 1 || i == 2 || i == 3 || i == 5 || i == 6 || i == 7))                        dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = styGray;                    else                        dataGridView_Repeater_Sub.Columns[i].DefaultCellStyle = sty2;                    dataGridView_Repeater_Sub.Columns[i].HeaderText = i < 4 ? "I" : "O";                    dataGridView_Repeater_Sub.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;                }                // 하단 문구 초기화                mskDeviceID.Text = "";                txtDeviceTypeCode.Text = "";                txtDeviceTypeName.Text = "";                txtPositionCode.Text = "";                txtPositionName.Text = "";                txtDeviceMemo.Text = "";            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시        private void dataGridView1_SelectionChanged(object sender, EventArgs e)        {            try            {                if (dataGridView_Repeater_Main.SelectedCells.Count > 1)                {                    lblRepeaterID.Text = "";                    String RepeaterTypeSaved = "";                    Boolean RepeaterUse = true;                    //Boolean outFlag = true;                    foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)                    {                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            if (value.Length > 3)                            {                                String RepeaterType = value.Substring(0, 1);                                if (RepeaterTypeSaved.Equals("")) RepeaterTypeSaved = RepeaterType;                                else if (!RepeaterTypeSaved.Equals(RepeaterType)) RepeaterTypeSaved = "Un Incorrect";                                //if (cell.Style.BackColor == System.Drawing.Color.Silver && outFlag) outFlag = true; else outFlag = false;                            }                            else                            {                                RepeaterTypeSaved = "Un Incorrect";                                RepeaterUse = false;                            }                            // cyim 2015.6.8 아날로그 감지기 연동 추가                            if (RepeaterUse && !(RepeaterTypeSaved.Equals("A") || RepeaterTypeSaved.Equals("B") || RepeaterTypeSaved.Equals("C") || RepeaterTypeSaved.Equals("D")))                                RepeaterTypeSaved = "USED";                            RepeaterTypeRadio(RepeaterTypeSaved);                        }                    }                }                else                {                    try                    {                        DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];                        object value = cell.Value;                        if (value == null) RepeaterStatus("");                        else                        {                            //Boolean outFlag = false;                            //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;                            RepeaterStatus(value.ToString());                            //RepeaterTypeRadio(value.ToString(), outFlag);                        }                    }                    catch (Exception ex)                    {                        Util.UErrorMessage(ex, 0, 0);                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //cell값으로 중계기 설정을 Radio버튼에 표시        private void RepeaterStatus(String CellText)        {            try            {                String RepeaterID = CellText;                String RepeaterType = "";                if (CellText.Length > 3)                {                    RepeaterType = CellText.Substring(0, 1);                    RepeaterID = CellText.Substring(1, 3);                }                // cyim 2015.6.8 아날로그 감지기 연동 추가                lblRepeaterID.Text = RepeaterID;                switch (RepeaterType)                {                    case "A":                    case "B":                        lblRepeaterName.Text = "중계기";                        break;                    case "C":                        lblRepeaterName.Text = "연감지기";                        break;                    case "D":                        lblRepeaterName.Text = "열감지기";                        break;                }                RepeaterTypeRadio(RepeaterType);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //셀의 타입으로 중계기 설정을 Radio버튼에 표시        private void RepeaterTypeRadio(String tp)        {            try            {                // cyim 2015.6.8 아날로그 감지기 연동 추가                if (tp.Equals("A"))                {                    rdoRepeaterType_A.Checked = true;                    rdoRepeaterType_B.Checked = false;                    rdoRepeaterType_C.Checked = false;                    rdoRepeaterType_D.Checked = false;                    chkRepeaterUse.Checked = true;                    rdoRepeaterType1_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);                }                else if (tp.Equals("B"))                {                    rdoRepeaterType_A.Checked = false;                    rdoRepeaterType_B.Checked = true;                    rdoRepeaterType_C.Checked = false;                    rdoRepeaterType_D.Checked = false;                    chkRepeaterUse.Checked = true;                    rdoRepeaterType2_CheckedChanged(rdoRepeaterType_B, System.EventArgs.Empty);                }                else if (tp.Equals("C"))                {                    rdoRepeaterType_A.Checked = false;                    rdoRepeaterType_B.Checked = false;                    rdoRepeaterType_C.Checked = true;                    rdoRepeaterType_D.Checked = false;                    chkRepeaterUse.Checked = true;                    rdoRepeaterType3_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);                }                else if (tp.Equals("D"))                {                    rdoRepeaterType_A.Checked = false;                    rdoRepeaterType_B.Checked = false;                    rdoRepeaterType_C.Checked = false;                    rdoRepeaterType_D.Checked = true;                    chkRepeaterUse.Checked = true;                    rdoRepeaterType4_CheckedChanged(rdoRepeaterType_A, System.EventArgs.Empty);                }                else if (tp.Equals("USED"))                {                    rdoRepeaterType_A.Checked = false;                    rdoRepeaterType_B.Checked = false;                    rdoRepeaterType_C.Checked = false;                    rdoRepeaterType_D.Checked = false;                    chkRepeaterUse.Checked = true;                }                else                {                    rdoRepeaterType_A.Checked = false;                    rdoRepeaterType_B.Checked = false;                    rdoRepeaterType_C.Checked = false;                    rdoRepeaterType_D.Checked = false;                    chkRepeaterUse.Checked = false;                    DeviceStatus(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // cyim 2015.6.8 아날로그 감지기 연동 추가        // '1' = A : 2X2         // '2' = B : 4X4         // '4' = C : 아날로그연감지기         // '5' = D : 아날로그열감지기         private void rdoRepeaterType1_Click(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_A.Checked)                    rdoRepeaterTypeChange("A");            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void rdoRepeaterType2_Click(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_B.Checked)                    rdoRepeaterTypeChange("B");            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void rdoRepeaterType3_Click(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_C.Checked)                    rdoRepeaterTypeChange("C");            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void rdoRepeaterType4_Click(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_D.Checked)                    rdoRepeaterTypeChange("D");            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //회로타입 표시        private void rdoRepeaterTypeChange(String RepeaterType)        {            try            {                DataGridViewCellStyle sty = new DataGridViewCellStyle();                sty.Alignment = DataGridViewContentAlignment.MiddleCenter;                sty.BackColor = System.Drawing.Color.Aqua;                foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)                {                    if (cell.Value != null)                    {                        String value = cell.Value.ToString();                        String RepeaterID = value;                        if (value.Length > 3)                        {                            RepeaterID = value.Substring(1, 3);                        }                        cell.Value = RepeaterType + RepeaterID;                        cell.Style = sty;                        REP[int.Parse(RepeaterID) - 1].RepeaterType = RepeaterType;                        REP[int.Parse(RepeaterID) - 1].UseFlag = true;                        REP[int.Parse(RepeaterID) - 1].CutFlag = false;                    }                }                //사용회로로 표시                chkRepeaterUse.Checked = true;                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void chkRepeaterUse_Click(object sender, EventArgs e)        {            try            {                //사용-->비사용으로                if (chkRepeaterUse.Checked)                {                    DataGridViewCellStyle sty = new DataGridViewCellStyle();                    sty.Alignment = DataGridViewContentAlignment.MiddleCenter;                    sty.BackColor = System.Drawing.Color.White;                    foreach (DataGridViewCell cell in dataGridView_Repeater_Main.SelectedCells)                    {                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            String RepeaterID = value;                            if (value.Length > 3)                            {                                RepeaterID = value.Substring(1, 3);                                REP[int.Parse(RepeaterID) - 1].UseFlag = false;                                REP[int.Parse(RepeaterID) - 1].RepeaterType = "";                            }                            cell.Value = RepeaterID;                            cell.Style = sty;                        }                    }                    //비사용회로로 표시                    chkRepeaterUse.Checked = false;                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //dataGridView2에 중계기 회로설정 화면생성        private void DeviceStatus(RepeaterDeviceTypeInfo dt)        {            try            {                if (dt == null)                {                    Device_Init(null);                    return;                }                Device_Init(dt.RepeaterType);                this.dataGridView_Repeater_Sub.Rows.Clear();                if (dt != null)                {                    DataGridViewCellStyle sty_in = new DataGridViewCellStyle();                    sty_in.Alignment = DataGridViewContentAlignment.MiddleCenter;                    sty_in.BackColor = System.Drawing.Color.Gold;                    DataGridViewCellStyle sty_out = new DataGridViewCellStyle();                    sty_out.Alignment = DataGridViewContentAlignment.MiddleCenter;                    sty_out.BackColor = System.Drawing.Color.MintCream;                    if (dt.RepeaterType.Equals("A"))                    {                        string[] row1 = new string[] { "1", "2", "", "", "1", "2", "", "" };                        this.dataGridView_Repeater_Sub.Rows.Add(row1);                        DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;                        //입력설정값                        for (int i = 0; i < 2; i++)                            rows2[0].Cells[i].Style = sty_in;                        //출력설정값                        for (int i = 0; i < 2; i++)                            rows2[0].Cells[i + 4].Style = sty_out; // 인덱스 오류 수정                        rows2[0].Height = 40;                    }                    else if (dt.RepeaterType.Equals("B"))                    {                        string[] row2 = new string[] { "1", "2", "3", "4", "1", "2", "3", "4" };                        this.dataGridView_Repeater_Sub.Rows.Add(row2);                        DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;                        //입력설정값                        for (int i = 0; i < 4; i++)                            rows2[0].Cells[i].Style = sty_in;                        //출력설정값                        for (int i = 0; i < 4; i++)                            rows2[0].Cells[i + 4].Style = sty_out;                        rows2[0].Height = 40;                    }                    // cyim 2015.6.8 아날로그 감지기 연동 추가                    else if (dt.RepeaterType.Equals("C") || dt.RepeaterType.Equals("D"))                    {                        string[] row1 = new string[] { "1", "", "", "", "1", "", "", "" };                        this.dataGridView_Repeater_Sub.Rows.Add(row1);                        DataGridViewRowCollection rows2 = this.dataGridView_Repeater_Sub.Rows;                        //입력설정값                        for (int i = 0; i < 1; i++)                            rows2[0].Cells[i].Style = sty_in;                        //출력설정값                        for (int i = 0; i < 1; i++)                            rows2[0].Cells[i + 4].Style = sty_out;                        rows2[0].Height = 40;                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        // cyim 2015.6.8 아날로그 감지기 연동 추가        // '1' = A : 2X2         // '2' = B : 4X4         // '4' = C : 아날로그연감지기         // '5' = D : 아날로그열감지기         private void rdoRepeaterType1_CheckedChanged(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_A.Checked)                {                    if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)                    {                        DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            String RepeaterID = value;                            if (value.Length > 3)                            {                                RepeaterID = value.Substring(1, 3);                            }                            //Boolean outFlag = false;                            //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;                            //해당 중계기의 회로표시                            RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1];  //중계기및 회로 설정정보                            dev.RepeaterType = "A";                            DeviceStatus(dev);                        }                    }                    else                    {                        DeviceStatus(null);                    }                }                else                {                    DeviceStatus(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //중계기가 1개만 선택되었을때 회로 표시(4*4 회로)        private void rdoRepeaterType2_CheckedChanged(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_B.Checked)                {                    if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)                    {                        DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            String RepeaterID = value;                            if (value.Length > 3)                            {                                RepeaterID = value.Substring(1, 3);                            }                            //Boolean outFlag = false;                            //if (cell.Style.BackColor == System.Drawing.Color.Silver) outFlag = true;                            //해당 중계기의 회로표시                            RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1];  //중계기및 회로 설정정보                            dev.RepeaterType = "B";                            DeviceStatus(dev);                        }                    }                    else                    {                        DeviceStatus(null);                    }                }                else                {                    DeviceStatus(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void rdoRepeaterType3_CheckedChanged(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_C.Checked)                {                    if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)                    {                        DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            String RepeaterID = value;                            if (value.Length > 3)                            {                                RepeaterID = value.Substring(1, 3);                            }                            //해당 중계기의 회로표시                            RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1];  //중계기및 회로 설정정보                            dev.RepeaterType = "C";                            DeviceStatus(dev);                        }                    }                    else                    {                        DeviceStatus(null);                    }                }                else                {                    DeviceStatus(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void rdoRepeaterType4_CheckedChanged(object sender, EventArgs e)        {            try            {                if (rdoRepeaterType_D.Checked)                {                    if (this.dataGridView_Repeater_Main.SelectedCells.Count == 1)                    {                        DataGridViewCell cell = this.dataGridView_Repeater_Main.SelectedCells[0];                        if (cell.Value != null)                        {                            String value = cell.Value.ToString();                            String RepeaterID = value;                            if (value.Length > 3)                            {                                RepeaterID = value.Substring(1, 3);                            }                            //해당 중계기의 회로표시                            RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1];  //중계기및 회로 설정정보                            dev.RepeaterType = "D";                            DeviceStatus(dev);                        }                    }                    else                    {                        DeviceStatus(null);                    }                }                else                {                    DeviceStatus(null);                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //중계기 DB에서 자료가져오기        private void Repeater_getDate()        {            try            {                if (cboBoardList.Items.Count < 1 || cboLoopList.Items.Count < 1)                {                    this.dataGridView_Repeater_Main.Columns.Clear();                    //중계기 설정내용 표시                    RepeaterStatus("");                    savBoardID = -1;                    savLoop = -1;                    return;                }                if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) { Repeater_init(); return; }                String BoardID = cboBoardList.SelectedItem.ToString();                String Loop = cboLoopList.SelectedItem.ToString();                if (int.Parse(BoardID) == savBoardID && int.Parse(Loop) == savLoop) return;                savBoardID = int.Parse(BoardID);                savLoop = int.Parse(Loop);                Repeater_init();                DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DataTable dt = dacRepeaterConfig.Repeater_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), 0, null);                DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                Boolean FireResetFlag = false;                if (dt.Rows.Count > 0)                {                    foreach (DataRow dr in dt.Rows)                    {                        //중계기설정값                        String RepeaterID = Convert.ToString(dr["REPEATER_ID"]);                        // '1' = A : 2X2                         // '2' = B : 4X4                         // '4' = C : 아날로그연감지기                         // '5' = D : 아날로그열감지기                         String RepeaterType = Convert.ToString(dr["REPEATER_TYPE"]);                        Boolean UseFlag = Convert.ToString(dr["USE_FLAG"]) == "Y" ? true : false;                        Boolean CutFlag = Convert.ToString(dr["CUT_FLAG"]) == "Y" ? true : false;                        //사용중인 중계기의 비화재보호 FALG를 읽는다.                        Boolean sFireResetFlag = false;                        if (UseFlag && !FireResetFlag) FireResetFlag = sFireResetFlag;                        String repeaterType = "";                        if (RepeaterType.Equals("1")) repeaterType = "A";                        else if (RepeaterType.Equals("2")) repeaterType = "B";                        else if (RepeaterType.Equals("4")) repeaterType = "C";                        else if (RepeaterType.Equals("5")) repeaterType = "D";                        RepeaterDeviceTypeInfo dev = REP[int.Parse(RepeaterID) - 1];  //중계기및 회로 설정정보                        if (!repeaterType.Equals(""))                        {                            dev.UseFlag = true;                            dev.RepeaterType = repeaterType;                            dev.CutFlag = CutFlag;                            dev.FireResetFlag = sFireResetFlag;                        }                        else dev.UseFlag = false;                        //회로설정값                         //String[] InType = new String[4];                        //String[] InTypeName = new String[4];                        //String[] OutType = new String[4];                        //String[] OutTypeName = new String[4];                        DeviceTypeInfo[] inDeviceTypeInfo;                        DeviceTypeInfo[] outDeviceTypeInfo;                        if (repeaterType.Equals("A"))                        {                            inDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) };                            outDeviceTypeInfo = new DeviceTypeInfo[2] { new DeviceTypeInfo(1), new DeviceTypeInfo(2) };                            DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);                            foreach (DataRow dr2 in dt2.Rows)                            {                                int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());                                String InoutType = dr2["INOUT_TYPE"].ToString();                                if (InoutType.Equals(code_GroupIO.Input))                                {                                    inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                                else                                {                                    outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                            }                            dev.inDeviceTypeInfos = inDeviceTypeInfo;                            dev.outDeviceTypeInfos = outDeviceTypeInfo;                        }                        else if (repeaterType.Equals("B"))                        {                            inDeviceTypeInfo = new DeviceTypeInfo[4];                            outDeviceTypeInfo = new DeviceTypeInfo[4];                            DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);                            foreach (DataRow dr2 in dt2.Rows)                            {                                int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());                                String InoutType = dr2["INOUT_TYPE"].ToString();                                if (InoutType.Equals(code_GroupIO.Input))                                {                                    inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                                else                                {                                    outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                            }                            dev.inDeviceTypeInfos = inDeviceTypeInfo;                            dev.outDeviceTypeInfos = outDeviceTypeInfo;                        }                        // cyim 2015.6.8 아날로그 감지기 연동 추가                        else if (repeaterType.Equals("C") || repeaterType.Equals("D"))                        {                            inDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) };                            outDeviceTypeInfo = new DeviceTypeInfo[1] { new DeviceTypeInfo(1) };                            DataTable dt2 = dacDeviceConfig.Device_Select(mdi.myReceiverID, int.Parse(BoardID), int.Parse(Loop), int.Parse(RepeaterID), 0, null);                            foreach (DataRow dr2 in dt2.Rows)                            {                                int DeviceID = int.Parse(dr2["DEVICE_ID"].ToString());                                String InoutType = dr2["INOUT_TYPE"].ToString();                                if (InoutType.Equals(code_GroupIO.Input))                                {                                    inDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    inDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    inDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    inDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                                else                                {                                    outDeviceTypeInfo[DeviceID - 1] = new DeviceTypeInfo(DeviceID);                                    outDeviceTypeInfo[DeviceID - 1].DeviceType = dr2["DEVICE_TYPE"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].DeviceName = dr2["DEVICE_NAME"].ToString();                                    outDeviceTypeInfo[DeviceID - 1].CutFlag = dr2["CUT_FLAG"].ToString() == "Y" ? true : false;                                    outDeviceTypeInfo[DeviceID - 1].PositionCode = dr2["POSITION_CODE"].ToString();                                }                            }                            dev.inDeviceTypeInfos = inDeviceTypeInfo;                            dev.outDeviceTypeInfos = outDeviceTypeInfo;                        }                    }                }                int rowCnt = 0, colCnt = 0;                //중계기 비사용 스타일                DataGridViewCellStyle styUnUse = new DataGridViewCellStyle();                styUnUse.Alignment = DataGridViewContentAlignment.MiddleCenter;                styUnUse.BackColor = System.Drawing.Color.White;                //중계기 사용 스타일                DataGridViewCellStyle styUse = new DataGridViewCellStyle();                styUse.Alignment = DataGridViewContentAlignment.MiddleCenter;                styUse.BackColor = System.Drawing.Color.Aqua;                //중계기 차단 스타일                DataGridViewCellStyle styOut = new DataGridViewCellStyle();                styOut.Alignment = DataGridViewContentAlignment.MiddleCenter;                styOut.BackColor = System.Drawing.Color.Silver;                foreach (DataGridViewRow row in this.dataGridView_Repeater_Main.Rows)                {                    colCnt = 0;                    foreach (DataGridViewCell col in row.Cells)                    {                        ++colCnt;                        int no = rowCnt * 10 + colCnt;                        if (no <= 127)                        {                            RepeaterDeviceTypeInfo dev = REP[no - 1];  //중계기및 회로 설정정보                            col.Value = String.Format("{0}{1:000}", dev.RepeaterType, no);                            if (dev.CutFlag)                            {                                col.Style = styOut;                            }                            else if (dev.UseFlag)                            {                                col.Style = styUse;                            }                            else                            {                                col.Style = styUnUse;                            }                        }                    }                    ++rowCnt;                }                //비화재보호기능                chkFireResetFlag.Checked = FireResetFlag;                //첫번째 중계기가 선택되므로 회로 표시                RepeaterStatus(String.Format("{0}001", REP[0].RepeaterType));                DeviceStatus(REP[0]);                // cyim 2014.5.7 : 수신기설정정보 변경 (하단 코드로 인하여 강제로 삭제되버린다)                //표시된 보드가 변경되면 수신기 변경은 무효됨...                //mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        //중계기 회로 설정값 저장버튼 클릭시        private void btnRepeaterSave_Click(object sender, EventArgs e)        {            try            {                if (cboBoardList.Items.Count < 1) return;                if (cboLoopList.Items.Count < 1) return;                if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;                String BoardID = cboBoardList.SelectedItem.ToString();                String Loop = cboLoopList.SelectedItem.ToString();                int LoopNo = int.Parse(Loop);                //String FireResetFlag = chkFireResetFlag.Checked ? "Y" : "N";                this.Cursor = Cursors.WaitCursor;                DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                DacRepeaterConfig dacRepeaterConfig = new DacRepeaterConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                for (int i = 0; i < 127; i++)                {                    int RepeaterId = i + 1;                    //중계기및 회로 설정정보                    RepeaterDeviceTypeInfo dev = REP[i];                    String RepeaterType = dev.RepeaterType == null ? "" : dev.RepeaterType;                    if (RepeaterType.Equals(""))                    {                        //중계기 타입이 없는경우는 삭제한다.                        dacRepeaterConfig.Repeater_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                            , RepeaterId, "중계기" + RepeaterId.ToString(), "", "");                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo, RepeaterId, 0, "", "", "", "");                    }                    else                    {                        //차단된 중계기는 비사용으로 저장한다.                        //String UseFlag = dev.CutFlag ? "N" : "Y";                        String UseFlag = "Y";                        // cyim 2015.6.8 아날로그 감지기 연동 추가                        // '1' = A : 2X2                         // '2' = B : 4X4                         // '4' = C : 아날로그연감지기                         // '5' = D : 아날로그열감지기                         if (dev.RepeaterType == "A")                            RepeaterType = "1";                        else if (dev.RepeaterType == "B")                            RepeaterType = "2";                        else if (dev.RepeaterType == "C")                            RepeaterType = "4";                        else if (dev.RepeaterType == "D")                            RepeaterType = "5";                        //중계기 설정값 저장                        dacRepeaterConfig.Repeater_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                            , RepeaterId, "중계기" + RepeaterId.ToString()                            , RepeaterType, UseFlag);                        DeviceTypeInfo[] inDeviceTypeInfo = dev.inDeviceTypeInfos;                        DeviceTypeInfo[] outDeviceTypeInfo = dev.outDeviceTypeInfos;                        if (dev.RepeaterType.Equals("A"))                        {                            for (int DevID = 1; DevID <= 2; DevID++)                            {                                if (inDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                                if (outDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                            }                        }                        else if (dev.RepeaterType.Equals("B"))                        {                            for (int DevID = 1; DevID <= 4; DevID++)                            {                                if (inDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                                if (outDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                            }                        }                        // cyim 2015.6.8 아날로그 감지기 연동 추가                        else if (dev.RepeaterType.Equals("C") || dev.RepeaterType.Equals("D"))                        {                            for (int DevID = 1; DevID <= 1; DevID++)                            {                                if (inDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (inDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "I", inDeviceTypeInfo[DevID - 1].DeviceName, inDeviceTypeInfo[DevID - 1].DeviceType, inDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                                if (outDeviceTypeInfo[DevID - 1] != null)                                {                                    //회로타입이 없는경우 삭제한다..                                    if (outDeviceTypeInfo[DevID - 1].DeviceType.Equals(""))                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.delete, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                    else                                    {                                        dacDeviceConfig.Device_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID, int.Parse(BoardID), LoopNo                                            , RepeaterId, DevID, "O", outDeviceTypeInfo[DevID - 1].DeviceName, outDeviceTypeInfo[DevID - 1].DeviceType, outDeviceTypeInfo[DevID - 1].PositionCode);                                    }                                }                            }                        }                    }                }                //수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;                //MessageBox.Show("저장되었습니다.", Application.ProductName);            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }            finally            {                this.Cursor = Cursors.Default;            }        }        //Loop선택을 변경하면 데이터를 다시 읽는다        private void cboLoopList_SelectedIndexChanged(object sender, EventArgs e)        {            try            {                Repeater_getDate();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //1Page로 이동        private void btnPage1_Click(object sender, EventArgs e)        {            try            {                Point pos = dataGridView_Repeater_Main.Location;                pos.Y = 0;                dataGridView_Repeater_Main.Location = pos;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //2Page로 이동        private void btnPage2_Click(object sender, EventArgs e)        {            try            {                Point pos = dataGridView_Repeater_Main.Location;                pos.Y = -(23 * 7 + 1);  //row height : 23, 페이지row수: 7                dataGridView_Repeater_Main.Location = pos;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        //수신기쓰기 버튼        private void btnReceiverWrite_Click(object sender, EventArgs e)        {            try            {                if (cboBoardList.Items.Count < 1) return;                if (cboLoopList.Items.Count < 1) return;                //btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);                if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;                String BoardID = cboBoardList.SelectedItem.ToString();                String Loop = cboLoopList.SelectedItem.ToString();                int LoopNo = int.Parse(Loop);                int BoardNo = int.Parse(BoardID);                bool FireResetFlag = chkFireResetFlag.Checked;                if (MessageBox.Show("모든 데이타 저장(수신기 쓰기) 버튼을 실행하시겠습니까?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)                {                    this.Cursor = Cursors.WaitCursor;                    btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);                    //2010.12.05, k.s.d, repeater information unit write -> don't use.                    /******************************************/                    /*        중계기 쓰기 Progress 표시             */                    /******************************************/                    //frmProgress frm = new frmProgress();                    ////중계기 설정 데이터를 CmdInfo에 넣어준다..                    //CmdInfo cmd = new CmdInfo(prt_cmd_define.write_repeater_info_unit, mdi.myReceiverID, 1, LoopNo, BoardNo, null);                    ////ReceiverTypeInfo Receiverinfo = this.mdi.ui.MyReceiverTypeInfo;       //수신기설정                    ////BoardTypeInfo brdinfo = Receiverinfo.Get_RepeaterType(BoardNo);     //통신보드savBoardID의  설정값                    ////RepeaterDeviceTypeInfo[] repinfo;      //중계기설정정보-설정쓰기를 위해                    ////if (LoopNo == 0)                    ////{                    ////    repinfo = brdinfo.Loop0_RepeaterType;         //통신보드 + Loop0 + 127개 중계기 설정값                    ////}                    ////else                    ////{                    ////    repinfo = brdinfo.Loop1_RepeaterType;         //통신보드 + Loop1 + 127개 중계기 설정값                    ////}                    ////cmd.CommandData = repinfo;                    //cmd.CommandData = REP;  //화면에 설정된 데이터를 쓰기데이터로 이용한다.                    //frm.Commandinfo = cmd;                    //frm.ui = this.mdi.ui;                    ////frm.ShowDialog();                    ///******************************************/                    //2010.12.05, k.s.d, repeater information block write.                    DoWriteRepeaterInfoBoard_Loop(LoopNo, BoardNo);                    btnRepeaterSave_Click(btnReceiverWrite, System.EventArgs.Empty);                    this.Cursor = Cursors.Default;                    mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = false; //수신기쓰기완료                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(ex.Message, Application.ProductName);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);            }            finally            {                this.Cursor = Cursors.Default;            }        }        //2010.12.05, k.s.d, repeater information block write.        private void DoWriteRepeaterInfoBoard_Loop(int LoopNo, int BoardNo)        {            CmdInfo commandinfo = new CmdInfo(prt_cmd_define.write_repeater_info_all, mdi.myReceiverID, 1, LoopNo, BoardNo, null);            dCommandResponse deleg = new dCommandResponse(GetResponseWriteRepeaterInfoAll);            commandinfo.dEvent = deleg;            RepeaterDataAll RepaterDataAll = new RepeaterDataAll();            for (int i = 0; i < 127; i++)            {                int RepeaterSet = 0;                if (REP[i].UseFlag)                {                    // cyim 2015.6.8 아날로그 감지기 연동 추가                    if (REP[i].RepeaterType == "A")                        RepeaterSet = 1;                    else if (REP[i].RepeaterType == "B")                        RepeaterSet = 2;                    else if (REP[i].RepeaterType == "C")                        RepeaterSet = 4;                    else if (REP[i].RepeaterType == "D")                        RepeaterSet = 5;                }                RepaterDataAll.Data[i].Set_Info_Data(REP[i].CutFlag, REP[i].FireResetFlag, false, false, RepeaterSet);            }            commandinfo.CommandData = RepaterDataAll;            this.mdi.ui.runCommand(commandinfo);        }        public void GetResponseWriteRepeaterInfoAll(CmdInfo resInfo)        {            mdi.ui.ReceiverDBRead();            //DB Read            mdi.FireReset_Process();        //demon RESET            this.lblReceiverConfigChangeFlag.Text = "모든 데이타 저장 (수신기 쓰기)이 완료되었습니다.";            this.lblReceiverConfigChangeFlag.Visible = true;            this.Cursor = Cursors.Default;            MessageBox.Show("설정정보가 변경되어 데몬을 Reset하였습니다.", Application.ProductName);        }        //선택값이 틀릴때마다 해당중계기 설정내용 radio에 표시        private void dataGridView2_SelectionChanged(object sender, EventArgs e)        {            if (dataGridView_Repeater_Sub.SelectedCells.Count > 0)            {                try                {                    if (cboBoardList.Items.Count < 1) return;                    if (cboLoopList.Items.Count < 1) return;                    DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                    int devNo = selectCell.ColumnIndex;                    string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                    devNo = (devNo % 4);                    int RepeaterID = Util.StrToInt(lblRepeaterID.Text, 0);                    if (cboBoardList.SelectedItem == null || cboLoopList.SelectedItem == null) return;                    int BoardID = Util.StrToInt(cboBoardList.SelectedItem, -1);                    int LoopNo = Util.StrToInt(cboLoopList.SelectedItem, -1);                    MskDeviceIDString device_str = new MskDeviceIDString(1, BoardID                        , LoopNo, RepeaterID, devNo + 1, inputType);                    mskDeviceID.Text = device_str.MskId;                    RepeaterDeviceTypeInfo rep = REP[RepeaterID - 1];    //중계기및 회로 설정정보                    if (rep != null)                    {                        DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                        if (inputType.Equals(code_InOutType.Input))                        {                            DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                            if (dev != null)                            {                                txtDeviceTypeCode.Text = dev.DeviceType;                                String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType);                                txtDeviceTypeName.Text = type_name;                                txtPositionCode.Text = dev.PositionCode;                                String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode);                                txtPositionName.Text = position_name;                                txtDeviceMemo.Text = dev.DeviceName;                            }                            else                            {                                mskDeviceID.Text = "";                                txtDeviceTypeCode.Text = "";                                txtDeviceTypeName.Text = "";                                txtPositionCode.Text = "";                                txtPositionName.Text = "";                                txtDeviceMemo.Text = "";                            }                        }                        else if (inputType.Equals(code_InOutType.Output))                        {                            DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                            if (dev != null)                            {                                txtDeviceTypeCode.Text = dev.DeviceType;                                String type_name = dacDeviceConfig.Device_Type_Name(inputType, dev.DeviceType);                                txtDeviceTypeName.Text = type_name;                                txtPositionCode.Text = dev.PositionCode;                                String position_name = dacDeviceConfig.Device_Position_Name(dev.PositionCode);                                txtPositionName.Text = position_name;                                txtDeviceMemo.Text = dev.DeviceName;                            }                            else                            {                                mskDeviceID.Text = "";                                txtDeviceTypeCode.Text = "";                                txtDeviceTypeName.Text = "";                                txtPositionCode.Text = "";                                txtPositionName.Text = "";                                txtDeviceMemo.Text = "";                            }                        }                    }                    else                    {                        mskDeviceID.Text = "";                        txtDeviceTypeCode.Text = "";                        txtDeviceTypeName.Text = "";                        txtPositionCode.Text = "";                        txtPositionName.Text = "";                        txtDeviceMemo.Text = "";                    }                }                catch (Exception ex)                {                    Util.UErrorMessage(ex, 0, 0);                    //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);                }            }        }        private void btnDeviceSearchOpen_Click(object sender, EventArgs e)        {            try            {                if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return;                //코드를 찾는 모달창을 연다..                DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                int devNo = selectCell.ColumnIndex;                string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                devNo = (devNo % 4);                frmModalDeviceType frm = new frmModalDeviceType(mdi.myReceiverID); // cyim 2015.7.30 데이타베이스 접속 루틴 변경                SearchCodeVo vo = new SearchCodeVo(inputType);                vo.Code = txtDeviceTypeCode.Text.Trim();                vo.CodeName = txtDeviceTypeName.Text.Trim();                frm.SearchCode = vo;                frm.ShowDialog();                vo = frm.SearchCode;                //선택한 코드가 있다면                if (vo.SearchOK)                {                    //선택한 코드값을 dataGridView2에 표시                    txtDeviceTypeCode.Text = vo.Code;                    txtDeviceTypeName.Text = vo.CodeName;                    //변경값 저장                    String RepeaterID = lblRepeaterID.Text;                    if (!RepeaterID.Equals(""))                    {                        RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                        if (rep != null)                        {                            if (inputType.Equals(code_InOutType.Input))                            {                                DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.DeviceType = vo.Code;                                //dev.DeviceName = txtDeviceMemo.Text.Trim();                                //dev.PositionCode = txtPositionCode.Text.Trim();                                //REP[int.Parse(RepeaterID) - 1].setInputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(),txtPositionCode.Text.Trim(), false);                                rep.setDeviceTypeInfo(dev, code_InOutType.Input);    //저장                                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.                                //DeviceStatus(rep);                            }                            else if (inputType.Equals(code_InOutType.Output))                            {                                DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.DeviceType = vo.Code;                                //dev.DeviceName = txtDeviceMemo.Text.Trim();                                //dev.PositionCode = txtPositionCode.Text.Trim();                                //REP[int.Parse(RepeaterID) - 1].setOutputDeviceTypeInfo(devNo + 1, vo.Code, txtDeviceMemo.Text.Trim(), txtPositionCode.Text.Trim(), false);                                rep.setDeviceTypeInfo(dev, code_InOutType.Output);      //저장                                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.                            }                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void btnPositionSearchOpen_Click(object sender, EventArgs e)        {            try            {                if (this.dataGridView_Repeater_Sub.SelectedCells.Count < 1) return;                //코드를 찾는 모달창을 연다..                DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                int devNo = selectCell.ColumnIndex;                string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                devNo = (devNo % 4);                frmModalPositionCode frm = new frmModalPositionCode();                SearchCodeVo vo = new SearchCodeVo(null);                vo.Code = txtPositionCode.Text.Trim();                vo.CodeName = txtPositionName.Text.Trim();                frm.setMdiParent(this.mdi);                frm.SearchCode = vo;                frm.ShowDialog();                vo = frm.SearchCode;                //선택한 코드가 있다면                if (vo.SearchOK)                {                    //선택한 코드값을 dataGridView2에 표시                    txtPositionCode.Text = vo.Code;                    txtPositionName.Text = vo.CodeName;                    //변경값 저장                    String RepeaterID = lblRepeaterID.Text;                    if (!RepeaterID.Equals(""))                    {                        RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                        if (rep != null)                        {                            if (inputType.Equals(code_InOutType.Input))                            {                                DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.PositionCode = vo.Code;                                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.                            }                            else if (inputType.Equals(code_InOutType.Output))                            {                                DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.PositionCode = vo.Code;                                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;  //설정변경됨.                            }                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);                //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);            }        }        private void txtDeviceMemo_TextChanged(object sender, EventArgs e)        {            try            {                //코드를 찾는 모달창을 연다..                if (txtDeviceMemo.Text.Trim().Equals("")) return;                if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)                {                    DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                    int devNo = selectCell.ColumnIndex;                    string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                    devNo = (devNo % 4);                    String RepeaterID = lblRepeaterID.Text;                    if (!RepeaterID.Equals(""))                    {                        RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                        if (rep != null)                        {                            if (inputType.Equals(code_InOutType.Input))                            {                                DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.DeviceName = txtDeviceMemo.Text.Trim();                                rep.setDeviceTypeInfo(dev, code_InOutType.Input);    //저장                            }                            else if (inputType.Equals(code_InOutType.Output))                            {                                DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                dev.DeviceName = txtDeviceMemo.Text.Trim();                                rep.setDeviceTypeInfo(dev, code_InOutType.Output);    //저장                            }                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void txtDeviceTypeCode_TextChanged(object sender, EventArgs e)        {            try            {                Util.ToUpper(txtDeviceTypeCode);                String typeCode = txtDeviceTypeCode.Text.Trim();                if (typeCode.Length == 2)                {                    if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)                    {                        DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                        int devNo = selectCell.ColumnIndex;                        string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                        devNo = (devNo % 4);                        DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경                        String type_name = dacDeviceConfig.Device_Type_Name(inputType, typeCode);                        txtDeviceTypeName.Text = type_name;                        String RepeaterID = lblRepeaterID.Text;                        if (!RepeaterID.Equals(""))                        {                            RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                            if (rep != null)                            {                                if (inputType.Equals(code_InOutType.Input))                                {                                    DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                    if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                    dev.DeviceType = typeCode;                                    rep.setDeviceTypeInfo(dev, code_InOutType.Input);    //저장                                }                                else if (inputType.Equals(code_InOutType.Output))                                {                                    DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                    if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                    dev.DeviceType = typeCode;                                    rep.setDeviceTypeInfo(dev, code_InOutType.Output);    //저장                                }                            }                        }                    }                }                else                {                    txtDeviceTypeName.Text = "";                    if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)                    {                        DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                        int devNo = selectCell.ColumnIndex;                        string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                        devNo = (devNo % 4);                        String RepeaterID = lblRepeaterID.Text;                        if (!RepeaterID.Equals(""))                        {                            RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                            if (rep != null)                            {                                if (inputType.Equals(code_InOutType.Input))                                {                                    DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                    if (dev != null)                                    {                                        dev.DeviceType = "";                                        rep.setDeviceTypeInfo(dev, code_InOutType.Input);    //저장                                    }                                }                                else if (inputType.Equals(code_InOutType.Output))                                {                                    DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                    if (dev != null)                                    {                                        dev.DeviceType = "";                                        rep.setDeviceTypeInfo(dev, code_InOutType.Output);    //저장                                    }                                }                            }                        }                    }                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void txtPositionCode_TextChanged(object sender, EventArgs e)        {            try            {                Util.ToUpper(txtPositionCode);                String positionCode = txtPositionCode.Text.Trim();                if (positionCode.Length == 2)                {                    if (this.dataGridView_Repeater_Sub.SelectedCells.Count > 0)                    {                        DataGridViewCell selectCell = this.dataGridView_Repeater_Sub.SelectedCells[0];                        int devNo = selectCell.ColumnIndex;                        string inputType = Util.NullToStr(dataGridView_Repeater_Sub.Columns[devNo].HeaderText);                        devNo = (devNo % 4);                        DacDeviceConfig dacDeviceConfig = new DacDeviceConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경                        String position_name = dacDeviceConfig.Device_Position_Name(positionCode);                        txtPositionName.Text = position_name;                        String RepeaterID = lblRepeaterID.Text;                        if (!RepeaterID.Equals(""))                        {                            RepeaterDeviceTypeInfo rep = REP[int.Parse(RepeaterID) - 1];    //중계기및 회로 설정정보                            if (rep != null)                            {                                if (inputType.Equals(code_InOutType.Input))                                {                                    DeviceTypeInfo dev = rep.inDeviceTypeInfos[devNo];                                    if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                    dev.PositionCode = positionCode;                                    rep.setDeviceTypeInfo(dev, code_InOutType.Input);    //저장                                }                                else if (inputType.Equals(code_InOutType.Output))                                {                                    DeviceTypeInfo dev = rep.outDeviceTypeInfos[devNo];                                    if (dev == null) dev = new DeviceTypeInfo(devNo + 1);                                    dev.PositionCode = positionCode;                                    rep.setDeviceTypeInfo(dev, code_InOutType.Output);    //저장                                }                            }                        }                    }                }                else                {                    txtPositionName.Text = "";                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void chkSelectAll_CheckedChanged(object sender, EventArgs e)        {            try            {                if (chkSelectAll.Checked)                {                    dataGridView_Repeater_Main.SelectAll();                    chkSelectAll.Text = "선택해제";                }                else                {                    int rowIndx = this.dataGridView_Repeater_Main.Rows.Count;                    int colIndx = this.dataGridView_Repeater_Main.ColumnCount;                    for (int i = 0; i < rowIndx; i++)   //전체 셀 숫자에 따라서..                    {                        for (int j = 0; j < colIndx; j++)   //전체 셀 숫자에 따라서..                            dataGridView_Repeater_Main.Rows[i].Cells[j].Selected = false;                    }                    chkSelectAll.Text = "전체선택";                }            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void btnWinClose_Click(object sender, EventArgs e)        {            try            {                if (mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag == true)                {                    MessageBox.Show("설정 변경되었음. 반드시 모든 데이타 저장(수신기 쓰기) 버튼을 실행하십시요!");                    return;                }                this.Close();            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)        {            try            {                chkSelectAll.Text = "전체선택";                chkSelectAll.Checked = false;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        private void chkNoFireResetFlag_CheckedChanged(object sender, EventArgs e)        {            try            {                bool FireResetFlag = chkFireResetFlag.Checked;                int rowIndx = this.dataGridView_Repeater_Main.Rows.Count;                int colIndx = this.dataGridView_Repeater_Main.ColumnCount;                for (int i = 0; i < rowIndx; i++)   //전체 셀 숫자에 따라서..                {                    for (int j = 0; j < colIndx; j++)   //전체 셀 숫자에 따라서..                    {                        int RepeaterID = i * 10 + j;                        if (RepeaterID < 127)                        {                            RepeaterDeviceTypeInfo dev = REP[RepeaterID];  //중계기및 회로 설정정보                            if (!dev.RepeaterType.Equals("")) dev.FireResetFlag = FireResetFlag;                        }                    }                }                // cyim 2014.5.7 : 수신기설정정보 변경                mdi.MDIReceiverConfig_Change_Flag = ThisReceiverConfig_Change_Flag = true;            }            catch (Exception ex)            {                Util.UErrorMessage(ex, 0, 0);            }        }        /******************************************************************************************************/        #endregion    }    public class CTBoard    {        public int boardID;        public string name;        public bool use;        // cyim 2016.10.31 : 계통정보는 0,1,2,3 으로 변경        public bool loop0Use;        public bool loop1Use;        public bool loop2Use;        public bool loop3Use;    }}
 |