예제 #1
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            bool isConnect = false;                                 // 连接是否成功

            if (cb_ConnectType.SelectedIndex == 0)
            {
                if (cb_ComNum.SelectedIndex >= 0 && cb_BPS.SelectedIndex >= 0)
                {
                    this.tb_ConnParam.Text = cb_ComNum.Text + ":" + cb_BPS.Text;
                    isConnect = CLReader.CreateSerialConn(this.tb_ConnParam.Text, contextForm);
                }
                // Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/ConnectDeviceT", "SerialConnect", tb_ConnParam.Text.Trim());
            }
            else if (cb_ConnectType.SelectedIndex == 1)
            {
                isConnect = CLReader.CreateTcpConn(tb_ConnParam.Text.Trim(), contextForm);
                ////Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/ConnectDeviceT", "TcpConnect", tb_ConnParam.Text.Trim());
            }
            else if (cb_ConnectType.SelectedIndex == 2)
            {
                if (cb_ComNum.SelectedIndex >= 0 && cb_BPS.SelectedIndex >= 0 && !String.IsNullOrEmpty(tb_485Address.Text))
                {
                    this.tb_ConnParam.Text = tb_485Address.Text.Trim() + ":" + cb_ComNum.Text + ":" + cb_BPS.Text;
                    isConnect = CLReader.Create485Conn(this.tb_ConnParam.Text, contextForm);
                }
                // Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/ConnectDeviceT", "_485Connect", tb_ConnParam.Text.Trim());
            }
            if (isConnect)                                          // 如果连接成功
            {
                ////if (contextForm.IsMultiConnect == false)            // 单读写器模式
                ////{
                ////    contextForm.CloseNowConnect();
                ////}
                ////else
                ////{
                if (!String.IsNullOrEmpty(contextForm.ConnID))
                {
                    ClouReaderAPI.CLReader.DIC_CONNECT[contextForm.ConnID].log = null;
                }
                ////}
                contextForm.ConnID = tb_ConnParam.Text.Trim();
                this.DialogResult  = DialogResult.OK;

                //if (this.DialogResult != DialogResult.OK)
                //{
                ////Save to Registry for the connection type
                //RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\AssetSystemInfo");

                ////storing the values
                //key.SetValue("ConnectionType", cb_ConnectType.Text);
                //key.SetValue("ConnectionParam", cb_ComNum.Text);
                //key.SetValue("ConnectionParam2", cb_BPS.Text);
                //key.Close();
                //}
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
        }
예제 #2
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            string param = this.tb_SerialParam.Text.Trim();

            if (CLReader.CreateSerialConn(param, contextForm))
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
        }
예제 #3
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            bool isConnect = false;                                 // 连接是否成功

            if (cb_ConnectType.SelectedIndex == 0)
            {
                if (cb_ComNum.SelectedIndex >= 0 && cb_BPS.SelectedIndex >= 0)
                {
                    this.tb_ConnParam.Text = cb_ComNum.Text + ":" + cb_BPS.Text;
                    isConnect = CLReader.CreateSerialConn(this.tb_ConnParam.Text, contextForm);
                }
                // Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/AddConnect", "SerialConnect", tb_ConnParam.Text.Trim());
            }
            else if (cb_ConnectType.SelectedIndex == 1)
            {
                isConnect = CLReader.CreateTcpConn(tb_ConnParam.Text.Trim(), contextForm);
                Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/AddConnect", "TcpConnect", tb_ConnParam.Text.Trim());
            }
            else if (cb_ConnectType.SelectedIndex == 2)
            {
                if (cb_ComNum.SelectedIndex >= 0 && cb_BPS.SelectedIndex >= 0 && !String.IsNullOrEmpty(tb_485Address.Text))
                {
                    this.tb_ConnParam.Text = tb_485Address.Text.Trim() + ":" + cb_ComNum.Text + ":" + cb_BPS.Text;
                    isConnect = CLReader.Create485Conn(this.tb_ConnParam.Text, contextForm);
                }
                // Helper.MyXmlHelper.UpdateInnerText(XMLFIENAME, "Root/AddConnect", "_485Connect", tb_ConnParam.Text.Trim());
            }
            if (isConnect)                                          // 如果连接成功
            {
                if (contextForm.IsMultiConnect == false)            // 单读写器模式
                {
                    contextForm.CloseNowConnect();
                }
                else
                {
                    if (!String.IsNullOrEmpty(contextForm.ConnID))
                    {
                        ClouReaderAPI.CLReader.DIC_CONNECT[contextForm.ConnID].log = null;
                    }
                }
                contextForm.ConnID = tb_ConnParam.Text.Trim();
                this.DialogResult  = DialogResult.OK;
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
        }