123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- 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;
- namespace IControls_FireManager
- {
- public partial class Form_AddGroup : Form
- {
- //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다
- ArrayList Sequence = new ArrayList();
- // 수신기 ID를 저장하기 위해서
- string Receiver_ID = null;
- public Form_AddGroup(string RECEIVER_ID)
- {
- InitializeComponent();
- // 수신기 아이디 저장
- Receiver_ID = RECEIVER_ID;
- // 수신기 아이디 콤보박스 추가
- UI_ComboBox_ReceiverID_Initialize();
- //** 폼로드시 출입그룹에 있는 GridEx 셋팅
- UI_OutDeviceGroup_GridEx_Initialize();
- // 이전 값을 불러온다
- this.EditBox_GroupName.Text = _Data.Temp_GroupName;
- ///
- /// 폼이 생성되는 위치
- ///
- this.StartPosition = FormStartPosition.Manual;
- this.Location = new System.Drawing.Point(MousePosition.X, MousePosition.Y);
- }
- // 폼로드시에 수신기 아이디도 고려할수 있도록 콤보박스 추가
- public void UI_ComboBox_ReceiverID_Initialize()
- {
- this.UiComboBox_ReceiverID.Items.Clear();
- this.UiComboBox_ReceiverID.Items.Add(_Text.Null);
- foreach (string receive in _Data.LIST_XMLRECEIVER_ID)
- {
- UiComboBox_ReceiverID.Items.Add(receive);
- }
- }
- //** 폼로드시 출입그룹에 있는 GridEx 셋팅
- public void UI_OutDeviceGroup_GridEx_Initialize()
- {
- //
- //** 폼로드 할 때, 먼저 GridEX_GroupList 클리어
- //
- // GridEX_GroupList 클리어
- GridEX_GroupList.ClearItems();
- // No.를 출력하기 위해서
- int i = 1;
- //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
- DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_GROUP", null)); // 네트워크 수신기에서 그룹 아이디는 유일하다
- if (DB_TABLE_DEVICE != null)
- {
- foreach (DataRow dr in DB_TABLE_DEVICE)
- {
- GridEXRow row;
- row = GridEX_GroupList.AddItem();
- row.BeginEdit();
- row.Cells["Number"].Value = i++;
- row.Cells["ReceiverID"].Value = dr[0].ToString(); // 그룹이 속해 있는 수신기 아이디
- row.Cells["ID"].Value = dr[1].ToString();
- row.Cells["Group"].Value = dr[2].ToString();
- row.EndEdit();
- }
- }
- }
- //** 조회버튼
- private void UiButton_Search_Group_Click(object sender, EventArgs e)
- {
- // 이전 값을 저장해둔다
- _Data.Temp_GroupName = this.EditBox_GroupName.Text;
- // GridEX_GroupList 클리어
- GridEX_GroupList.ClearItems();
- // No.를 출력하기 위해서
- int i = 1;
- //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
- DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.Search_Table("TB_GROUP", "GROUP_ID", UiComboBox_GroupID.Text, "GROUP_NAME", EditBox_GroupName.Text, this.UiComboBox_ReceiverID.Text));
- if (DB_TABLE_DEVICE != null)
- {
- foreach (DataRow dr in DB_TABLE_DEVICE)
- {
- GridEXRow row;
- row = GridEX_GroupList.AddItem();
- row.BeginEdit();
- row.Cells["Number"].Value = i++;
- row.Cells["ReceiverID"].Value = dr[0].ToString(); // 그룹이 속해 있는 수신기 아이디
- row.Cells["ID"].Value = dr[1].ToString();
- row.Cells["Group"].Value = dr[2].ToString();
- row.EndEdit();
- }
- }
- }
- //** 추가버튼
- private void UiButton_AddDevice_Click(object sender, EventArgs e)
- {
- //** 회로추가나 그룹추가폼을 띄워둔 상태에서 그룹명이나 맵명을 추가하거나 삭제하면 selected 된 행이 없어진다.
- // 하지만 회로추가나 그룹추가는 할 수 있으므로 이를 방지해야한다
- if (_Data.Map_No != null)
- {
- //** 시컨스 클리어
- Sequence.Clear();
- int MaxValue = 0;
- int SelectRowCount = GridEX_GroupList.SelectedItems.Count;
- //** 선택한 행이 하나도 없다면....
- if (SelectRowCount == 0)
- {
- // 그룹을 선택해 주세요
- _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.GroupNameNotChoice, 0);
- return;
- }
- for (int number = 0; number < SelectRowCount; number++)
- {
- GridEXRow row = GridEX_GroupList.SelectedItems[number].GetRow();
- string Group_ID = row.Cells["ID"].Value.ToString();
- //** 어레이리스트를 만들어 시컨스 정보만 저장하여 가장 큰 Value를 찾아낸다
- Sequence.Add("0");
- //DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", "O", Receiver_ID));
-
- // 위와 같이 RECEIVER_ID 가 아닌 MAP_RECEIVER_ID으로 기준하여 쿼리해야한다
- DataRowCollection DB_TABLE_MAP_PROCESS = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value_MAP_RECEIVER_ID("TB_MAP_PROCESS", "MAP_NO", _Data.Map_No, "MAP_TYPE", "O", Receiver_ID));
- if (DB_TABLE_MAP_PROCESS != null)
- {
- foreach (DataRow dr in DB_TABLE_MAP_PROCESS)
- {
- if (dr[3] == null || dr[3].ToString().Trim().Length == 0)
- {
- ; // 오류
- }
- else
- Sequence.Add(dr[3].ToString());
- }
- }
- foreach (string Value in Sequence)
- {
- if (MaxValue <= Int32.Parse(Value))
- {
- MaxValue = Int32.Parse(Value) + 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, "GROUP_ID", Group_ID, null));// 맵연동 설정에서 확인하는 출력그룹은 오로지 그룹아이디로만 판단
- 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=" + "O" +
- ";SEQ_NO=" + MaxValue +
- ";PROCESS_TYPE=" + "G" +
- ";GROUP_ID=" + Group_ID +
- ";RECEIVER_ID=" + row.Cells["ReceiverID"].Value.ToString() + // 출력해야되는 회로 혹은 그룹의 수신기 아이디 : 엑셀로 Import 할때는 그룹 정보가 반드시 수신기 아이디에 해당하지 않는 타 수신기에 그룹일수도 있다.
- ";COMM_ID=" + null +
- ";BOARD_ID=" + null +
- ";LOOP_NO=" + null +
- ";REPEATER_ID=" + null +
- ";DEVICE_ID=" + null +
- ";INOUT_TYPE=" + null +
- ";USE_FLAG=" + "Y");
- }
- }
- //** 해당 그룹의 디바이스 변경되었다고 알려줌
- _Event.Form_AddGroup_SendMessage_Write(DEVICE_EVENT.MAP);
- }
- // 프로젝트 수정
- _Data.ProJect_Save_Complete = false;
- }
- else
- {
- // 맵명을 선택해 주세요
- _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.MapChoice, 0);
- return;
- }
- }
- //** 닫기버튼
- private void UiButton_Close_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- //** 폼 클로우즈
- private void Form_AddGroup_FormClosed(object sender, FormClosedEventArgs e)
- {
- //** 선택모드를 멀티로 전환하라고 맵설정 폼으로 보내줌
- _Event.Form_AddGroup_SendMessage_Write(DEVICE_EVENT.MAP_SELECTIONMODE);
- }
- // 수신기 아이디를 지정해야만 그룹아이디를 출력하게 한다
- private void UiComboBox_GroupID_DroppingDown(object sender, CancelEventArgs e)
- {
- if (this.UiComboBox_ReceiverID.Text == null || this.UiComboBox_ReceiverID.Text.Length == 0)
- {
- _Popup.Create(Popup_Type.Confirm, Popup_Style.Normal, _Text.OK, 250, 150, _Text.ReceiverIDNotInput, 0);
- return;
- }
- this.UiComboBox_GroupID.Items.Clear();
- this.UiComboBox_GroupID.Items.Add(_Text.Null);
-
- //** TB_GROUP 테이블에서 출력그룹을 모두 가지고 온다
- DataRowCollection DB_TABLE_DEVICE = _Db.ExecuteRead_SqlDataAdapter(_Sql.SearchAll_Table_Value("TB_GROUP", this.UiComboBox_ReceiverID.Text));
- if (DB_TABLE_DEVICE != null && DB_TABLE_DEVICE.Count != 0)
- {
- foreach (DataRow dr in DB_TABLE_DEVICE)
- {
- //** 폼로드시 UiComboBox_GroupID 셋팅
- UiComboBox_GroupID.Items.Add(dr[1].ToString());
- }
- }
- }
- }
- }
|