/// <summary>
        /// Initiates the connection process.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnOk_Click(object sender, RoutedEventArgs e)
        {
            // Clear the port connection status list
            _portConnectionStatusList.Clear();
            _curPortConnectionStatus = null;

            // Get the correct Connector
            IConnector connector = _conFactory.GetConnector(SelectedConnector, ConstructConnectionSettings());

            // Hook into the connector's events
            connector.CheckingPort          += Connector_NextPort;
            connector.UpdateMessages        += Connector_UpdateMessage;
            connector.ConnectionComplete    += Connector_Complete;
            connector.ConnectionEstablished += Connector_ConnectionEstablished;
            connector.PortSuccess           += Connector_PortSuccess;

            // If this application is already connected on a SerialPort, close the connection
            if (ELM327Connection.Connection != null && ELM327Connection.Connection.IsOpen)
            {
                lblStatus.Content = "Closing existing ELM327 connection on port " + ELM327Connection.Connection.PortName + "...";
                log.Info("Closing existing ELM327 connection on port [" + ELM327Connection.Connection.PortName + "].");
                ELM327Connection.DestroyConnection();
            }

            // Log
            log.Info("Spawning thread for finding an Elm327 port and connecting.");

            // Disable Controls
            btnOk.IsEnabled       = false;
            cmbPortList.IsEnabled = false;
            btnCancel.Content     = "Cancel";

            // Start our Progress Bar
            pbProgressBar.IsIndeterminate = true;

            // Update the Status
            lblStatus.Content = "Connecting...";

            // Store a reference to the new IConnector
            _runningConnector = connector;

            // Spawn a thread
            _getSerialPortThread = new Thread(new ThreadStart(connector.GetSerialPort));
            _getSerialPortThread.SetApartmentState(ApartmentState.STA);
            _getSerialPortThread.Start();
        }
Exemplo n.º 2
0
    protected void DeleteMajor_Click(object sender, EventArgs e)
    {
        int[] arr = { 0 };

        List <int> list = new List <int>();

        for (int i = 0; i < ViewData.Rows.Count; i++)
        {
            CheckBox ckbox = (CheckBox)ViewData.Rows[i].FindControl("ItemCkBox"); // 每行的确认控件

            if (ckbox.Checked)
            {
                // 法一:
                // ViewData.DeleteRow(i);

                int majorId = int.Parse(ViewData.Rows[i].Cells[1].Text.Trim()); // 被删课程ID
                list.Add(majorId);
            }
        }

        foreach (var id in list)
        {
            // 法二:

            Connector conn = ConnectorFactory.GetConnector("studentdb");

            // 连接模式

            //conn.Connect();
            //int row = conn.ManageData<int>(0, "delete from [Major] where [MajorId] = " + id);
            //ViewData.DataBind();
            //conn.CloseAll();

            // 断开模式

            conn.ManageDataOffMode("delete", "Major", id);
            ViewData.DataBind();
        }
    }
Exemplo n.º 3
0
 private void SetInput(ConnectorEnum pInConnector)
 {
     _inConnector = _connectorFactory.GetConnector(pInConnector);
 }
Exemplo n.º 4
0
 private WACControlConnector GetConnector(string _controlID, ConnectorFactory _cfac)
 {
     return(_cfac.GetConnector(_controlID));
 }