ATMLCommonLibrary.controls.switching.SwitchRelayForm.ControlsToData C# (CSharp) Method

ControlsToData() protected method

protected ControlsToData ( ) : void
return void
        protected void ControlsToData()
        {
            List<SwitchRelaySettingRelayConnection> list = new List<SwitchRelaySettingRelayConnection>();
            if (switchRelaySetting == null)
                switchRelaySetting = new SwitchRelaySetting();
            switchRelaySetting.name = edtName.GetValue<string>();
            foreach (DataGridViewRow row in dgRelayConnections.Rows)
            {
                SwitchRelaySettingRelayConnection connection = row.Tag as SwitchRelaySettingRelayConnection;
                if (connection == null)
                    connection = new SwitchRelaySettingRelayConnection();
                connection.from = row.Cells[0].Value as String;
                connection.to = row.Cells[1].Value as String;
                //----------------------------------------------------------------------//
                //--- Add the from and to ports as long as there are values for each ---//
                //----------------------------------------------------------------------//
                if (!String.IsNullOrEmpty(connection.from) && !String.IsNullOrEmpty(connection.to))
                    list.Add(connection);
            }
            switchRelaySetting.RelayConnection = list;
        }