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 { // // 기존의 Form_AddDevice.cs 를 복사하여 사용 // 비상방송 편집을 위한 별도의 폼이 필요함 // 컬럼을 추가하여 사용하기로 함 - 2015.6.2 // public partial class Form_AddDevice_Emergency : Form { //** 대화 팝업용 Form DialogPopup_Del = new Form(); Form DialogPopup_Save = new 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_Emergency(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.CenterScreen; this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.Y); // 비상방송 편집의 경우 IO 보드 내용은 필요없다 this.uiTabPage_IOboard.TabVisible = false; } //** 초기값 셋팅 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; // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경 if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") { DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY_BigReceiver("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, editBoxArea.Text, editBoxStair.Text, editBoxFloor.Text, this.uiCheckBox_Emergency.Checked)); } else { if (UiComboBox_Board.Text.Length == 0) { // 통신보드를 선택하지 않았으면, 15번 통신보드만 빼고 모든 통신보드의 디바이스를 다 보여준다 DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY("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, editBoxArea.Text, editBoxStair.Text, editBoxFloor.Text, this.uiCheckBox_Emergency.Checked)); } else { // 통신보드를 선택했으면, 특정 통신보드의 디바이스를 다 보여준다 DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY("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, editBoxArea.Text, editBoxStair.Text, editBoxFloor.Text, this.uiCheckBox_Emergency.Checked)); } } 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(), 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.Cells["Emergency"].Value = dr[10].ToString() + "-" + dr[11].ToString() + "-" + dr[12].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.Cells["Emergency"].Value = dr[10].ToString() + "-" + dr[11].ToString() + "-" + dr[12].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.Cells["Emergency"].Value = dr[10].ToString() + "-" + dr[11].ToString() + "-" + dr[12].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.Cells["Emergency"].Value = dr[10].ToString() + "-" + dr[11].ToString() + "-" + dr[12].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); // // // //** 그룹설정에서 출력을 그룹으로 묶을때 사용 // // // 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 = ""; UiComboBox_Board.Text = ""; UiComboBox_Channel.Text = ""; UiComboBox_Repeater.Text = ""; EditBox_Position.Text = ""; CheckedComboBox_DeviceType.Text = ""; EditBox_DeviceName.Text = ""; //IO보드 UiComboBox_IO_Receiver.Text = ""; UiComboBox_IOBoard.Text = ""; // 비상방송 editBoxArea.Text = ""; editBoxStair.Text = ""; editBoxFloor.Text = ""; uiCheckBox_Emergency.Checked = false; } //** 닫기 버튼 private void UiButton_Close_Click(object sender, EventArgs e) { this.Close(); } // 비상방송 삭제 버튼 private void UiButton_DelDevice_Click(object sender, EventArgs e) { //** GridEX_InDevice에서 선택한 행의 갯수를 알기 위해서 int SelectRowCount = GridEX_Device.SelectedItems.Count; //** 선택한 행이 없으면 팝업을 띄운다 if (SelectRowCount == 0) { // 먼저 입력디바이스를 선택해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.InDeviceNotChoice, 0); return; } // 비상방송코드를 삭제하시겠습니까? DialogPopup_Del = _Popup.Create(Popup_Type.Dialog, Popup_Style.Normal, _Text.OK, 300, 150, _Text.BroadcastionInfo_Delete_Continue, 0); // 대화 팝업은 특별처리 _Event.PopupClose_SendMessage_Event += new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event_DeletBroadcastion); } public void _Event_PopupClose_SendMessage_Event_DeletBroadcastion(object sender, object etc) { // 대화 팝업 주체 Form popup = (Form)sender; if (DialogPopup_Del.Name == popup.Name && etc.ToString() == _Text.OK) { // 프로젝트 수정 _Data.ProJect_Save_Complete = false; //** GridEX_InDevice에서 선택한 행의 갯수를 알기 위해서 int SelectRowCount = GridEX_Device.SelectedItems.Count; for (int number = 0; number < SelectRowCount; number++) { GridEXRow row = GridEX_Device.SelectedItems[number].GetRow(); string Broadcation_Receiver = 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, Broadcation_Receiver); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경 int COMM_ID = device_id.Comm_id; int BOARD_ID = device_id.Board_id; int LOOP_NO = device_id.Loop_no; int REPEATER_ID = device_id.Repeater_id; int DEVICE_ID = device_id.Device_id; string INOUT_TYPE = device_id.Inout_type; // 비상방송 코드 삭제 _Db.Execute(_Sql.Delete_Table("TB_EMERGENCY_BROADCASTION", "RECEIVER_ID", Receiver_ID, "COMM_ID", COMM_ID, "BOARD_ID", BOARD_ID, "LOOP_NO", LOOP_NO, "REPEATER_ID", REPEATER_ID, "DEVICE_ID", DEVICE_ID, "INOUT_TYPE", INOUT_TYPE, Broadcation_Receiver)); // UI 편집 row.BeginEdit(); // 비상방송 row.Cells["Emergency"].Value = "-" + "-"; row.EndEdit(); } // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경 if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") { // IN_Points , 즉 워크뷰에서 보여지는 정보를 업데이트 한다 ((_ImportPoint)_Data.Hash_ImportPoint[Receiver_ID]).IN_Points = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY_BigReceiver("1", "I", "", "", "", "", "", "", Receiver_ID, "", "", "", false)); } else { // IN_Points , 즉 워크뷰에서 보여지는 정보를 업데이트 한다 ((_ImportPoint)_Data.Hash_ImportPoint[Receiver_ID]).IN_Points = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY("1", "I", "15", "", "", "", "", "", Receiver_ID, "", "", "", false)); } // 워크뷰의 내용을 입출력 포인트 전부 보이는 화면으로 전환 _Event.EmergencyCodeEdit_SendMessage_Write(Receiver_ID); // 삭제되었습니다 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.DelInform, 0); } // 대화 팝업은 특별처리 _Event.PopupClose_SendMessage_Event -= new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event_DeletBroadcastion); } // 비상방송 추가 버튼 private void UiButton_AddDevice_Click(object sender, EventArgs e) { //** GridEX_InDevice에서 선택한 행의 갯수를 알기 위해서 int SelectRowCount = GridEX_Device.SelectedItems.Count; //** 선택한 행이 없으면 팝업을 띄운다 if (SelectRowCount == 0) { // 먼저 입력디바이스를 선택해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.InDeviceNotChoice, 0); return; } if (EditBox_Area.Text.Length == 0) { // 비상방송코드 AREA를 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.AreaNotInput, 0); return; } if (EditBox_Area.Text.Length != 2) { // 비상방송코드 AREA를 2자리로 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.AreaProblemInput, 0); return; } if (EditBox_Stair.Text.Length == 0) { // 비상방송코드 STAIR를 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.StairNotInput, 0); return; } if (EditBox_Stair.Text.Length != 2) { // 비상방송코드 STAIR를 2자리로 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.StairProblemInput, 0); return; } if (EditBox_Floor.Text.Length == 0) { // 비상방송코드 FLOOR를 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.FloorNotInput, 0); return; } if (EditBox_Floor.Text.Length != 2) { // 비상방송코드 FLOOR를 2자리로 입력해 주세요 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.FloorProblemInput, 0); return; } // 변경된 코드정보를 적용하시겠습니까? DialogPopup_Save = _Popup.Create(Popup_Type.Dialog, Popup_Style.Normal, _Text.OK, 300, 150, _Text.BroadcastionInfo_Update_Continue, 0); // 대화 팝업은 특별처리 _Event.PopupClose_SendMessage_Event += new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event_AddBroadcastion); } public void _Event_PopupClose_SendMessage_Event_AddBroadcastion(object sender, object etc) { // 대화 팝업 주체 Form popup = (Form)sender; if (DialogPopup_Save.Name == popup.Name && etc.ToString() == _Text.OK) { // 프로젝트 수정 _Data.ProJect_Save_Complete = false; //** GridEX_InDevice에서 선택한 행의 갯수를 알기 위해서 int SelectRowCount = GridEX_Device.SelectedItems.Count; for (int number = 0; number < SelectRowCount; number++) { GridEXRow row = GridEX_Device.SelectedItems[number].GetRow(); string Broadcation_Receiver = 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, Broadcation_Receiver); // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경 int COMM_ID = device_id.Comm_id; int BOARD_ID = device_id.Board_id; int LOOP_NO = device_id.Loop_no; int REPEATER_ID = device_id.Repeater_id; int DEVICE_ID = device_id.Device_id; string INOUT_TYPE = device_id.Inout_type; // UPDATE로 해결하자 //_Db.UPDATE("TB_EMERGENCY_BROADCASTION", // "RECEIVER_ID=" + Broadcation_Receiver + ";COMM_ID=" + COMM_ID + ";BOARD_ID=" + BOARD_ID + // ";LOOP_NO=" + LOOP_NO + ";REPEATER_ID=" + REPEATER_ID + ";DEVICE_ID=" + DEVICE_ID + ";INOUT_TYPE=" + INOUT_TYPE, // "AREA_CODE=" + EditBox_Area.Text + ";STAIR_CODE=" + EditBox_Stair.Text + ";FLOOR_CODE=" + EditBox_Floor.Text); // UPDATE 로 처리루틴은 여기서 제외함, 기존의 루틴대로라면 비상방송을 삭제한 후에 새로 저장을 하려면 할수가 없다 // 비상방송 코드 삭제 _Db.Execute(_Sql.Delete_Table("TB_EMERGENCY_BROADCASTION", "RECEIVER_ID", Receiver_ID, "COMM_ID", COMM_ID, "BOARD_ID", BOARD_ID, "LOOP_NO", LOOP_NO, "REPEATER_ID", REPEATER_ID, "DEVICE_ID", DEVICE_ID, "INOUT_TYPE", INOUT_TYPE, Broadcation_Receiver)); // 비상방송 코드 추가 _Db.ADD("TB_EMERGENCY_BROADCASTION", "RECEIVER_ID=" + Receiver_ID + ";COMM_ID=" + COMM_ID + ";BOARD_ID=" + BOARD_ID + ";LOOP_NO=" + LOOP_NO + ";REPEATER_ID=" + REPEATER_ID + ";DEVICE_ID=" + DEVICE_ID + ";INOUT_TYPE=" + INOUT_TYPE + ";AREA_CODE=" + EditBox_Area.Text + ";STAIR_CODE=" + EditBox_Stair.Text + ";FLOOR_CODE=" + EditBox_Floor.Text + ";UPDATE_TIME=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); // UI 편집 row.BeginEdit(); // 비상방송 row.Cells["Emergency"].Value = EditBox_Area.Text + "-" + EditBox_Stair.Text + "-" + EditBox_Floor.Text; row.EndEdit(); } // cyim 2016.12.05 : 수신기 모델별 내부 로직 변경 if (((_RECEIVER)_Data.HASH_RECEIVER[Receiver_ID]).MODEL == "IFC3300") { // IN_Points , 즉 워크뷰에서 보여지는 정보를 업데이트 한다 ((_ImportPoint)_Data.Hash_ImportPoint[Receiver_ID]).IN_Points = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY_BigReceiver("1", "I", "", "", "", "", "", "", Receiver_ID, "", "", "", false)); } else { // IN_Points , 즉 워크뷰에서 보여지는 정보를 업데이트 한다 ((_ImportPoint)_Data.Hash_ImportPoint[Receiver_ID]).IN_Points = _Db.ExecuteRead_SqlDataAdapter( _Sql.Search_DEVICETable_With_EMERGENCY("1", "I", "15", "", "", "", "", "", Receiver_ID, "", "", "", false)); } // 워크뷰의 내용을 입출력 포인트 전부 보이는 화면으로 전환 _Event.EmergencyCodeEdit_SendMessage_Write(Receiver_ID); // 저장하였습니다 _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.SaveInform, 0); } // 대화 팝업은 특별처리 _Event.PopupClose_SendMessage_Event -= new _Event.PopupClose_SendMessage_Handler(_Event_PopupClose_SendMessage_Event_AddBroadcastion); } } }