예제 #1
0
        public bool Get_Exists_Main(ComEntity currentNode)
        {
            bool      is_Exists_main = false;
            DeaEntity _deaNode       = new DeaEntity();
            ComEntity _comNodes      = new ComEntity();

            _comNodes = (ComEntity)currentNode;
            _deaNode  = (DeaEntity)_comNodes.Parent;
            foreach (var item in _deaNode.Children)
            {
                if (item.IS_MAIN)
                {
                    is_Exists_main = true;
                }
            }
            return(is_Exists_main);
        }
예제 #2
0
        private void is_ok_Click(object sender, RoutedEventArgs e)
        {
            _deaNode = _comNode.Parent as DeaEntity;
            if (!Get_Exists_Main(_comNode) || _comNode.CURRENT_STAT == CurrentOpCType.Modify)
            {
                if (grid_fault_site.Text != null &&
                    grid_fault_stop.Text != null &&
                    grid_spd.SelectedValue != null &&
                    grid_bit.SelectedValue != null &&
                    grid_sync_bit.SelectedValue != null &&
                    grid_stop_bit.SelectedValue != null &&
                    grid_protocol.SelectedValue != null &&
                    grid_protocol_device.SelectedValue != null)
                {
                    _comNode.SITE_ADD    = grid_fault_site.Text;
                    _comNode.STOP_ADD    = grid_fault_stop.Text;
                    _comNode.SPD         = Convert.ToInt32(grid_spd.SelectedValue.ToString());
                    _comNode.BIT         = Convert.ToInt32(grid_bit.SelectedValue.ToString());
                    _comNode.SYNC_BIT    = Convert.ToInt32(grid_sync_bit.SelectedValue.ToString());
                    _comNode.STOP_BIT    = Convert.ToInt32(grid_stop_bit.SelectedValue.ToString());
                    _comNode.PROTOCOL    = grid_protocol_device.Text;
                    _comNode.PROTOCOL_ID = Convert.ToInt32(grid_protocol_device.SelectedValue);
                    _comNode.IS_MAIN     = (bool)grid_is_main.SelectedValue;
                    _comNode.PRODUCTID   = Convert.ToInt32(grid_protocol.SelectedValue);
                    _comNode.PRODUCTNAME = grid_protocol.Text;
                    if (is_main)
                    {
                        //_deaNode.MAIN_EXISTS = 1;
                        if (_comNode.NAME.IndexOf("[主站]") <= 0)
                        {
                            _comNode.NAME = _comNode.NAME + "[主站]";
                        }
                        //_comNode.IS_MAIN = true;
                    }
                    else
                    {
                        if (_comNode.NAME.IndexOf("[主站]") > 0)
                        {
                            _comNode.NAME = _comNode.NAME.Replace("[主站]", "");
                        }
                    }

                    this.Close();
                }
                else
                {
                    MessageBox.Show("端口设置信息不完整!", "提示");
                }
            }
            else if (_comNode.CURRENT_STAT == CurrentOpCType.Add && grid_is_main.SelectedIndex != 0)
            {
                if (grid_fault_site.Text != null &&
                    grid_fault_stop.Text != null &&
                    grid_spd.SelectedValue != null &&
                    grid_bit.SelectedValue != null &&
                    grid_sync_bit.SelectedValue != null &&
                    grid_stop_bit.SelectedValue != null &&
                    grid_protocol.SelectedValue != null &&
                    grid_protocol_device.SelectedValue != null)
                {
                    _comNode.SITE_ADD    = grid_fault_site.Text;
                    _comNode.STOP_ADD    = grid_fault_stop.Text;
                    _comNode.SPD         = Convert.ToInt32(grid_spd.SelectedValue.ToString());
                    _comNode.BIT         = Convert.ToInt32(grid_bit.SelectedValue.ToString());
                    _comNode.SYNC_BIT    = Convert.ToInt32(grid_sync_bit.SelectedValue.ToString());
                    _comNode.STOP_BIT    = Convert.ToInt32(grid_stop_bit.SelectedValue.ToString());
                    _comNode.PROTOCOL    = grid_protocol_device.Text;
                    _comNode.PROTOCOL_ID = Convert.ToInt32(grid_protocol_device.SelectedValue);
                    _comNode.IS_MAIN     = (bool)grid_is_main.SelectedValue;
                    _comNode.PRODUCTID   = Convert.ToInt32(grid_protocol.SelectedValue);
                    _comNode.PRODUCTNAME = grid_protocol.Text;
                    if (is_main)
                    {
                        _deaNode.MAIN_EXISTS = 1;
                        _comNode.NAME        = _comNode.NAME + "[主站]";
                        _comNode.IS_MAIN     = true;
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show("端口设置信息不完整!", "提示");
                }
            }
            else
            {
                MessageBox.Show("同一台DEA只能设置一个COM口为主站!", "提示");
            }
        }