| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758 | using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using Janus.Windows.GridEX;using System.Collections;using Janus.Windows.GridEX.EditControls;namespace IControls_FireManager{    public partial class Form_AddDevice : Form    {        //** CheckedComboBox_DeviceType콤보박스에 체크되어 있는 것만 알기 위해서 사용되는 ArrayList        ArrayList DeviceType = new ArrayList();        //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다        ArrayList Sequence = new ArrayList();        //** 나중에 DB에 출력그룹을 ADD할 때 수신기 ID도 알아야 한다        string Receiver_ID = null;        //** 어느 버튼에서 이 폼을 실행시켰는지 알기 위해서 저장        string form_type = null;        //** 현재폼이 생성될 때 In디바이스만 출력할 것인지 Out디바이스만 출력 할것인지 결정해준다        // 그 디바이스 타입 정보를 받아서 저장하기 위해서 생성        string device_type = null;        public Form_AddDevice(string RECEIVER_ID, string Form_Type, string InOutType)        {            InitializeComponent();            // 수신기 아이디 저장            Receiver_ID = RECEIVER_ID;            //** 어느 버튼에서 이 폼을 실행시켰는지 알기 위해서 저장            form_type = Form_Type;            //** 여기서 해당 디바이스 타입 정보를 저장            device_type = InOutType;            //** 폼 텍스트 변경            if (device_type == "I")                this.Text = "입력 회로조회";            if (device_type == "O")                this.Text = "출력 회로조회";            //** 초기값 셋팅            UI_Initialize();            // 이전 값을 불러온다            this.EditBox_Position.Text = _Data.Temp_Position;            this.EditBox_DeviceName.Text = _Data.Temp_DeviceName;            ///            /// 폼이 생성되는 위치            ///             this.StartPosition = FormStartPosition.Manual;            //this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.X);            this.Location = new System.Drawing.Point(550, 200);        }        //** 초기값 셋팅        public void UI_Initialize()        {            // 해당 수신기를 수신기 콤보박스에 띄움            UiComboBox_Board_Receiver.Text = Receiver_ID;            UiComboBox_IO_Receiver.Text = Receiver_ID;            // 입력 회로조회일 경우, 수신기 콤보박스를 disable 처리            if (device_type == "I")            {                UiComboBox_Board_Receiver.Enabled = false;                UiComboBox_IO_Receiver.Enabled = false;            }            // 출력 그룹에서 출력 디바이스를 추가할 경우, 수신기 콤보박스를 disable 처리            if (device_type == "O" && form_type == "Group")            {                UiComboBox_Board_Receiver.Enabled = false;                UiComboBox_IO_Receiver.Enabled = false;            }            //** CheckedComboBox_DeviceType 콤보박스 셋팅            // 먼저 CheckedComboBox_DeviceType 콤보박스를 클리어시킴            CheckedComboBox_DeviceType.Clear();            // TB_DEVICE_TYPE테이블에 접근            DataRowCollection DB_TABLE_DEVICE_TYPE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_DEVICE_TYPE", null));            if (DB_TABLE_DEVICE_TYPE != null && CheckedComboBox_DeviceType.DropDownList != null)            {                foreach (DataRow dr in DB_TABLE_DEVICE_TYPE)                {                    // GridEx에 내용 채우기                    GridEXRow row;                    row = CheckedComboBox_DeviceType.DropDownList.AddItem();                    row.BeginEdit();                    row.Cells["Device_Type"].Value = dr["DEVICE_TYPE_NAME"].ToString();                    row.EndEdit();                }            }        }        //** 폼 클로우즈        private void Form_AddDevice_FormClosed(object sender, FormClosedEventArgs e)        {            if (form_type == "Group")            {                //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌                _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP_SELECTIONMODE);            }            else if (form_type == "Map")            {                //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌                _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP_SELECTIONMODE);            }        }        //** 조회 버튼        private void UiButton_Search_Click(object sender, EventArgs e)        {            // 이전 값을 저장해둔다            _Data.Temp_Position = this.EditBox_Position.Text;            _Data.Temp_DeviceName = this.EditBox_DeviceName.Text;            //            //** uiTabPage_board 탭이 선택되어 있을 경우            //            if (uiTabPage_board.Selected == true)            {                // 그리드이엑스 클리어 시키고 다시 조회                GridEX_Device.ClearItems();                // No.를 출력하기 위해서                int i = 1;                // 아래와 같이 하는 이유는 통신보드를 1~14까지만 조회하기 위해서다                // 조회하려는 통신보드에 값이 없으면 if문을 타고 값이 있으면 else 문을 탄다. SQL문이 달라지는 것이다                DataRowCollection DB_TABLE_DEVICE = null;                if (UiComboBox_Board.Text.Length == 0)                {                    // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                    if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")                    {                        DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable_NoneBoardID_BigReceiver("1", device_type, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));                    }                    else                    {                        // 통신보드를 선택하지 않았으면, 15번 통신보드만 빼고 모든 통신보드의 디바이스를 다 보여준다                        DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable("1", device_type, "15", _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));                    }                }                else                {                    // 통신보드를 선택했으면, 특정 통신보드의 디바이스를 다 보여준다                    DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DeviceTable("1", device_type, UiComboBox_Board.Text, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Repeater.Text, EditBox_Position.Text, "", EditBox_DeviceName.Text, UiComboBox_Board_Receiver.Text));                }                if (DB_TABLE_DEVICE != null)                {                    foreach (DataRow dr in DB_TABLE_DEVICE)                    {                        try                        {                            if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)                            {                                // 디바이스 타입에 관계없이 모두 출력                                if (DeviceType.Count == 0)                                {                                    // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                                    MskDeviceIDString dev_s = new MskDeviceIDString(                                        _Convert.Null_to_IntZero(dr[3].ToString()),                                        _Convert.Null_to_IntZero(dr[4].ToString()),                                        _Convert.Null_to_IntZero(dr[5].ToString()),                                        _Convert.Null_to_IntZero(dr[6].ToString()),                                        _Convert.Null_to_IntZero(dr[7].ToString()),                                        dr[8].ToString(), Receiver_ID); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                                    GridEXRow row;                                    row = GridEX_Device.AddItem();                                    row.BeginEdit();                                    row.Cells["Number"].Value = i++;                                    row.Cells["ID"].Value = dev_s.MskId;                                    row.Cells["DeviceType"].Value = dr[0].ToString();                                    row.Cells["Position"].Value = dr[1].ToString();                                    row.Cells["DeviceName"].Value = dr[2].ToString();                                    row.Cells["Receiver_ID"].Value = dr[9].ToString();                                    row.EndEdit();                                }                                else // 조회문에 있는 디바이스 타입만 출력                                {                                    if (DeviceType.Contains(dr[0].ToString()) == true)                                    {                                        // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                                        MskDeviceIDString dev_s = new MskDeviceIDString(                                            _Convert.Null_to_IntZero(dr[3].ToString()),                                            _Convert.Null_to_IntZero(dr[4].ToString()),                                            _Convert.Null_to_IntZero(dr[5].ToString()),                                            _Convert.Null_to_IntZero(dr[6].ToString()),                                            _Convert.Null_to_IntZero(dr[7].ToString()),                                            dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                                        GridEXRow row;                                        row = GridEX_Device.AddItem();                                        row.BeginEdit();                                        row.Cells["Number"].Value = i++;                                        row.Cells["ID"].Value = dev_s.MskId;                                        row.Cells["DeviceType"].Value = dr[0].ToString();                                        row.Cells["Position"].Value = dr[1].ToString();                                        row.Cells["DeviceName"].Value = dr[2].ToString();                                        row.Cells["Receiver_ID"].Value = dr[9].ToString();                                        row.EndEdit();                                    }                                }                            }                        }                        catch (Exception Err1)                        {                            // LOG                                            _Event.DebugView_SendMessage_Write(Err1.ToString());                            // 정보를 가지고 오는데 문제가 발생하였습니다                            _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);                        }                    }                }            }            //            // uiTabPage_IOboard 탭이 선택되어 있을 경우            //            if (uiTabPage_IOboard.Selected == true)            {                // 그리드이엑스 클리어 시키고 다시 조회                GridEX_Device.ClearItems();                // No.를 출력하기 위해서                int i = 1;                // UiComboBox_IOBoard 콤보박스의 텍스트가 null이면 전체조회                if (UiComboBox_IOBoard.Text.Length == 0)                {                    DataRowCollection DB_TABLE_DEVICE = null;                    // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                    if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")                    {                        DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable_NoneBoardID_BigReceiver("3", device_type, "", "", "", "", "", UiComboBox_IO_Receiver.Text));                    }                    else                    {                        DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DEVICETable("3", device_type, "15", "", "", "", "", "", UiComboBox_IO_Receiver.Text));                    }                    if (DB_TABLE_DEVICE != null)                    {                        foreach (DataRow dr in DB_TABLE_DEVICE)                        {                            try                            {                                if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)                                {                                    // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                                    MskDeviceIDString dev_s = new MskDeviceIDString(                                        _Convert.Null_to_IntZero(dr[3].ToString()),                                        _Convert.Null_to_IntZero(dr[4].ToString()),                                        _Convert.Null_to_IntZero(dr[5].ToString()),                                        _Convert.Null_to_IntZero(dr[6].ToString()),                                        _Convert.Null_to_IntZero(dr[7].ToString()),                                        dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                                    GridEXRow row;                                    row = GridEX_Device.AddItem();                                    row.BeginEdit();                                    row.Cells["Number"].Value = i++;                                    row.Cells["ID"].Value = dev_s.MskId;                                    row.Cells["DeviceType"].Value = dr[0].ToString();                                    row.Cells["Position"].Value = dr[1].ToString();                                    row.Cells["DeviceName"].Value = dr[2].ToString();                                    row.Cells["Receiver_ID"].Value = dr[9].ToString();                                    row.EndEdit();                                }                            }                            catch (Exception Err3)                            {                                // LOG                                                _Event.DebugView_SendMessage_Write(Err3.ToString());                                // 정보를 가지고 오는데 문제가 발생하였습니다                                _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);                            }                        }                    }                }                // UiComboBox_IOBoard 콤보박스의 텍스트를 이용해 조회                else                {                    DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_DeviceTable("3", device_type, UiComboBox_IOBoard.Text, "", "", "", "", "", UiComboBox_IO_Receiver.Text));                    if (DB_TABLE_DEVICE != null)                    {                        foreach (DataRow dr in DB_TABLE_DEVICE)                        {                            try                            {                                if (_Convert.Exception_Into_object(dr[3], dr[4], dr[5], dr[6], dr[7]) == true)                                {                                    // 매개변수 순서 => COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                                    MskDeviceIDString dev_s = new MskDeviceIDString(                                        _Convert.Null_to_IntZero(dr[3].ToString()),                                        _Convert.Null_to_IntZero(dr[4].ToString()),                                        _Convert.Null_to_IntZero(dr[5].ToString()),                                        _Convert.Null_to_IntZero(dr[6].ToString()),                                        _Convert.Null_to_IntZero(dr[7].ToString()),                                        dr[8].ToString(), dr[9].ToString()); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                                    GridEXRow row;                                    row = GridEX_Device.AddItem();                                    row.BeginEdit();                                    row.Cells["Number"].Value = i++;                                    row.Cells["ID"].Value = dev_s.MskId;                                    row.Cells["DeviceType"].Value = dr[0].ToString();                                    row.Cells["Position"].Value = dr[1].ToString();                                    row.Cells["DeviceName"].Value = dr[2].ToString();                                    row.Cells["Receiver_ID"].Value = dr[9].ToString();                                    row.EndEdit();                                }                            }                            catch (Exception Err4)                            {                                // LOG                                                _Event.DebugView_SendMessage_Write(Err4.ToString());                                // 정보를 가지고 오는데 문제가 발생하였습니다                                _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ProblemMessage, 0);                            }                        }                    }                }            }        }        //** 디바이스 추가버튼        private void UiButton_AddDevice_Click(object sender, EventArgs e)        {            int SelectRowCount = GridEX_Device.SelectedItems.Count;            //** 선택한 행이 하나도 없다면....            if (SelectRowCount == 0)            {                // 회로를 선택해 주세요                _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.DeviceNotChoice, 0);                return;            }            // 프로젝트 수정            _Data.ProJect_Save_Complete = false;            for (int number = 0; number < SelectRowCount; number++)            {                GridEXRow row = GridEX_Device.SelectedItems[number].GetRow();                string Real_RECEIVER_ID = row.Cells["Receiver_ID"].Value.ToString();                string Device_ID = row.Cells["ID"].Value.ToString();                // MI-##-#-###-#  :M(구분 M-중계기,O-출력그룹)I,O(회로구분)-##(보드ID)-##(회로ID)                MskDeviceIDString device_id = new MskDeviceIDString(Device_ID, Real_RECEIVER_ID); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                //                //** 그룹설정에서 출력을 그룹으로 묶을때 사용                //                if (form_type == "Group")                {                    //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.                    // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다                    if (_Data.Group_ID != null)                    {                        // COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                        DataRowCollection DB_TABLE_GROUP_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(                            "TB_GROUP_DEVICE", "GROUP_ID", _Data.Group_ID, "COMM_ID", device_id.Comm_id, "BOARD_ID", device_id.Board_id,                                               "LOOP_NO", device_id.Loop_no, "REPEATER_ID", device_id.Repeater_id,                                               "DEVICE_ID", device_id.Device_id, "INOUT_TYPE", device_id.Inout_type, "GROUP_RECEIVER_ID", Receiver_ID, Real_RECEIVER_ID));                        if (DB_TABLE_GROUP_DEVICE != null)                        {                            //** 저장되어 있지 않다면 DB에 ADD                            if (DB_TABLE_GROUP_DEVICE.Count == 0)                            {                                // "TB_GROUP"에 DB 삽입                                _Db.ADD("TB_GROUP_DEVICE",                                "GROUP_RECEIVER_ID=" + Receiver_ID +                                ";GROUP_ID=" + _Data.Group_ID +                                ";RECEIVER_ID=" + Real_RECEIVER_ID +                                ";COMM_ID=" + device_id.Comm_id +                                ";BOARD_ID=" + device_id.Board_id +                                ";LOOP_NO=" + device_id.Loop_no +                                ";REPEATER_ID=" + device_id.Repeater_id +                                ";DEVICE_ID=" + device_id.Device_id +                                ";INOUT_TYPE=" + device_id.Inout_type +                                ";USE_FLAG=" + "Y");                            }                        }                        ////** 해당 그룹의 디바이스 변경되었다고 알려줌                        //_Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP);                    }                    else                    {                        // 그룹을 선택해 주세요                        _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.GroupNameNotChoice, 0);                        return;                    }                }                //                //** 연동설정에 있는 입력 및 출력회로를 추가 할때 사용                //                else if (form_type == "Map")                {                    //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.                    // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다                    if (_Data.Map_No != null)                    {                        int MaxValue = 1;                        // 시컨스 결정하기                        DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_MapProcess_MaxValue("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", device_type, Receiver_ID));                        if (DB_TABLE_MAP_PROCESS != null)                        {                            foreach (DataRow Record in DB_TABLE_MAP_PROCESS)                            {                                // 시컨스                                if (Record[0] == null || Record[0].ToString().Trim().Length == 0) MaxValue = 1;                                else MaxValue = Int32.Parse(Record[0].ToString()) + 1;                            }                        }                        // COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                        DataRowCollection DB_TABLE_GROUP_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(                            "TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "COMM_ID", device_id.Comm_id, "BOARD_ID", device_id.Board_id,                                               "LOOP_NO", device_id.Loop_no, "REPEATER_ID", device_id.Repeater_id,                                               "DEVICE_ID", device_id.Device_id, "INOUT_TYPE", device_id.Inout_type, "MAP_RECEIVER_ID", Receiver_ID, Real_RECEIVER_ID));                        if (DB_TABLE_GROUP_DEVICE != null)                        {                            //** 저장되어 있지 않다면 DB에 ADD                            if (DB_TABLE_GROUP_DEVICE.Count == 0)                            {                                // "TB_GROUP"에 DB 삽입                                _Db.ADD("TB_MAP_PROCESS",                                "MAP_RECEIVER_ID=" + Receiver_ID +                                ";MAP_NO=" + _Data.Map_No +                                ";MAP_TYPE=" + device_type +                                ";SEQ_NO=" + MaxValue +                                ";PROCESS_TYPE=" + "D" +                                ";GROUP_ID=" + null +                                ";RECEIVER_ID=" + Real_RECEIVER_ID +                                ";COMM_ID=" + device_id.Comm_id +                                ";BOARD_ID=" + device_id.Board_id +                                ";LOOP_NO=" + device_id.Loop_no +                                ";REPEATER_ID=" + device_id.Repeater_id +                                ";DEVICE_ID=" + device_id.Device_id +                                ";INOUT_TYPE=" + device_id.Inout_type +                                ";USE_FLAG=" + "Y");                            }                        }                        ////** 해당 그룹의 디바이스 변경되었다고 알려줌                        //_Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP);                    }                    else                    {                        // 맵명을 선택해 주세요                        _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.MapChoice, 0);                        return;                    }                }            }            // 이벤트로 한번만 알려주면 된다(수정)            if (SelectRowCount != 0)            {                if (form_type == "Group")                {                    //** 해당 그룹의 디바이스 변경되었다고 알려줌                    _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.GROUP);                }                else if (form_type == "Map")                {                    //** 해당 그룹의 디바이스 변경되었다고 알려줌                    _Event.Form_AddDevice_SendMessage_Write(DEVICE_EVENT.MAP);                }            }        }        //** CheckedComboBox_DeviceType콤보박스에 체크가 변경될때마다 발생하는 이벤트        private void CheckedComboBox_DeviceType_CheckedValuesChanged(object sender, EventArgs e)        {            //** DeviceType을 ArrayList에 저장하기 위해서            DeviceType.Clear();            //** sender을 이용하는 이유는 clear를 했을때를 알기 위해서            CheckedComboBox checkedcombobox = (CheckedComboBox)sender;            //** 이렇게 하는 이유는 clear버튼을 사용해 텍스트를 클리어 했을 때에, 콤보박스는 이전에 선택했을 값을 가지고 있다고 여김            // 그래서 아래의 속성으로 clear버튼을 클릭했을 때에는 해당 루틴을 타지 못하게 함            if (checkedcombobox.Text.Length != 0)            {                // 아래와 같이 포커스를 주는 이유는 야누스 콤포넌트의 에러 때문이다                UiButton_Search.Focus();                // 콤보박스에 체크되어 있는 것만 알기 위해서                GridEXRow[] GridEx_Rows = this.CheckedComboBox_DeviceType.DropDownList.GetRows();                foreach (GridEXRow row in GridEx_Rows)                {                    if (row.Cells["Check"].Value.ToString() == "True")                        DeviceType.Add(row.Cells["Device_Type"].Value.ToString());                }            }        }        //** 탭 전환시 발생하는 이벤트        private void uiTab_Device_SelectedTabChanged(object sender, Janus.Windows.UI.Tab.TabEventArgs e)        {            // 그리드이엑스 클리어 시키고 다시 조회            GridEX_Device.ClearItems();            // 클리어            // 통신보드            UiComboBox_Board.Text = null;            UiComboBox_Channel.Text = null;            UiComboBox_Repeater.Text = null;            EditBox_Position.Text = null;            CheckedComboBox_DeviceType.Text = null;            EditBox_DeviceName.Text = null;            //IO보드            UiComboBox_IOBoard.Text = null;        }        // 수신기 콤보박스를 드라핑다운        private void UiComboBox_Board_Receiver_DroppingDown(object sender, CancelEventArgs e)        {            // 사용하는 수신기를 콤보박스에 추가한다            UiComboBox_Board_Receiver.Items.Clear();            UiComboBox_Board_Receiver.Items.Add(_Text.Null);            foreach (string receive in _Data.LIST_XMLRECEIVER_ID)            {                UiComboBox_Board_Receiver.Items.Add(receive);            }            // 수신기를 선택했으니까 나머지는 다시 클리어            UiComboBox_Board.Text = null;            UiComboBox_Channel.Text = null;            UiComboBox_Repeater.Text = null;        }        // 통신보드 콤보박스 드라핑다운        private void UiComboBox_Board_DroppingDown(object sender, CancelEventArgs e)        {            // 일단 무조건 클리어            UiComboBox_Board.Text = null;            UiComboBox_Board.Items.Clear();            // 수신기를 선택하지 않았으면 리턴            if (UiComboBox_Board_Receiver.Text.Length == 0) return;            UiComboBox_Board.Items.Clear();            DataRowCollection DB_TABLE_BOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("1", "", "Y", UiComboBox_Board_Receiver.Text));            if (DB_TABLE_BOARD != null)            {                // 공백도 하나 넣어둠                UiComboBox_Board.Items.Add("");                foreach (DataRow dr in DB_TABLE_BOARD)                {                    // UiComboBox_Board 콤보박스에 아이템 ADD                    UiComboBox_Board.Items.Add(dr["BOARD_ID"]);                }            }            // 통신보드를 선택했으니까 나머지는 다시 클리어            UiComboBox_Channel.Text = null;            UiComboBox_Repeater.Text = null;        }        // 채널 콤보박스 드라핑다운        private void UiComboBox_Channel_DroppingDown(object sender, CancelEventArgs e)        {            // 일단 무조건 클리어            UiComboBox_Channel.Text = null;            UiComboBox_Channel.Items.Clear();            // 통신보드를 선택하지 않았으면 리턴            if (UiComboBox_Board.Text.Length == 0) return;            // 채널 콤보박스 클리어            UiComboBox_Channel.Items.Clear();            DataRowCollection DB_TABLE_BOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("1", UiComboBox_Board.Text, "Y", UiComboBox_Board_Receiver.Text));            if (DB_TABLE_BOARD != null)            {                // 공백도 하나 넣어둠                if (UiComboBox_Channel.Items.Contains("") == false) UiComboBox_Channel.Items.Add("");                foreach (DataRow dr in DB_TABLE_BOARD)                {                    if (dr["LOOP0_USE_FLAG"].ToString() == "Y")                    {                        if (UiComboBox_Channel.Items.Contains("0") == false)                            UiComboBox_Channel.Items.Add("CH1");                    }                    if (dr["LOOP1_USE_FLAG"].ToString() == "Y")                    {                        if (UiComboBox_Channel.Items.Contains("1") == false)                            UiComboBox_Channel.Items.Add("CH2");                    }                    if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300")                    {                        if (dr["LOOP2_USE_FLAG"].ToString() == "Y")                        {                            if (UiComboBox_Channel.Items.Contains("2") == false)                                UiComboBox_Channel.Items.Add("CH3");                        }                        if (dr["LOOP3_USE_FLAG"].ToString() == "Y")                        {                            if (UiComboBox_Channel.Items.Contains("3") == false)                                UiComboBox_Channel.Items.Add("CH4");                        }                    }                }            }            // 채널을 선택했으니까 나머지는 다시 클리어            UiComboBox_Repeater.Text = null;        }        // 중계기 콤보박스 드라핑다운        private void UiComboBox_Repeater_DroppingDown(object sender, CancelEventArgs e)        {            // 일단 무조건 클리어            UiComboBox_Repeater.Text = null;            UiComboBox_Repeater.Items.Clear();            // 채널을 선택하지 않았으면 리턴            if (UiComboBox_Channel.Text.Length == 0) return;            DataRowCollection DB_TABLE_TB_REPEATER = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_RepeaterTable("1", UiComboBox_Board.Text, _Data.UI_CH_TO_LOOP(UiComboBox_Channel.Text), UiComboBox_Board_Receiver.Text));            if (DB_TABLE_TB_REPEATER != null)            {                // 공백도 하나 넣어둠                if (UiComboBox_Repeater.Items.Contains("") == false) UiComboBox_Repeater.Items.Add("");                foreach (DataRow dr in DB_TABLE_TB_REPEATER)                {                    if (UiComboBox_Repeater.Items.Contains(dr["REPEATER_ID"].ToString()) == false)                        UiComboBox_Repeater.Items.Add(dr["REPEATER_ID"].ToString());                }            }        }        // 수신기 콤보박스를 드라핑다운        private void UiComboBox_IO_Receiver_DroppingDown(object sender, CancelEventArgs e)        {            // 사용하는 수신기를 콤보박스에 추가한다            UiComboBox_IO_Receiver.Items.Clear();            UiComboBox_IO_Receiver.Items.Add(_Text.Null);            foreach (string receive in _Data.LIST_XMLRECEIVER_ID)            {                UiComboBox_IO_Receiver.Items.Add(receive);            }            // 수신기를 선택했으니까 나머지는 다시 클리어            UiComboBox_IOBoard.Text = null;        }        // IO보드 콤보박스 드라핑다운        private void UiComboBox_IOBoard_DroppingDown(object sender, CancelEventArgs e)        {            // 일단 무조건 클리어            UiComboBox_IOBoard.Text = null;            UiComboBox_IOBoard.Items.Clear();            // 수신기를 선택하지 않았으면 리턴            if (UiComboBox_IO_Receiver.Text.Length == 0) return;            DataRowCollection DB_TABLE_IOBOARD = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_BoardTable("3", "", "Y", UiComboBox_IO_Receiver.Text));            if (DB_TABLE_IOBOARD != null)            {                // 공백도 하나 넣어둠                UiComboBox_IOBoard.Items.Add("");                foreach (DataRow dr in DB_TABLE_IOBOARD)                {                    // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경                    if (                        (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300" && dr["BOARD_ID"].ToString() != "0")                        || (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL != "IFC3300" && dr["BOARD_ID"].ToString() != "15")                        )                    //if (dr["BOARD_ID"].ToString() != "0")                    {                        if (UiComboBox_IOBoard.Items.Contains(dr["BOARD_ID"].ToString()) == false)                            UiComboBox_IOBoard.Items.Add(dr["BOARD_ID"]);                        //// COMM_ID, BOARD_ID, LOOP_NO, REPEATER_ID, DEVICE_ID, INOUT_TYPE                        //DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value(                        //    "TB_DEVICE", "COMM_ID", "3", "BOARD_ID", dr["BOARD_ID"].ToString(),                        //                       "LOOP_NO", "0", "REPEATER_ID", "0",                        //                       "INOUT_TYPE", device_type, Receiver_ID));                        //if (DB_TABLE_DEVICE != null)                        //{                        //    //** 위의 조건에 만족하는 IO출력디바이스가 TB_DEVICE에 있으면 UiComboBox_IOBoard에 추가 할 수 있다                        //    if (DB_TABLE_DEVICE.Count != 0)                        //    {                        //        // UiComboBox_Board 콤보박스에 아이템 ADD                        //        UiComboBox_IOBoard.Items.Add(dr["BOARD_ID"]);                        //    }                        //}                    }                }            }        }        //** 클리어 버튼        private void UiButton_Clear_Click(object sender, EventArgs e)        {            // 통신보드            UiComboBox_Board_Receiver.Text = null;            UiComboBox_Board.Text = null;            UiComboBox_Channel.Text = null;            UiComboBox_Repeater.Text = null;            EditBox_Position.Text = null;            CheckedComboBox_DeviceType.Text = null;            EditBox_DeviceName.Text = null;            //IO보드            UiComboBox_IO_Receiver.Text = null;            UiComboBox_IOBoard.Text = null;        }        //** 닫기 버튼        private void UiButton_Close_Click(object sender, EventArgs e)        {            this.Close();        }    }}
 |