private void m_btnSaveParaToIni_Click(object sender, EventArgs e) { string strMsg = string.Format("确定要保存{0}的通讯参数吗?", m_cBoxSelHardware.Text); if (MessageBox.Show(strMsg, @"提醒", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } string strEquipment = m_cBoxSelHardware.Text; STRUCT_CMT_INFO tCmtInfo = new STRUCT_CMT_INFO { m_nType = m_cBoxCmtPattern.SelectedIndex }; switch (m_cBoxCmtPattern.SelectedIndex) { case 0: tCmtInfo.m_strSerialPortNum = m_cBoxPortNo.Text; tCmtInfo.m_nSerialBaudRate = Convert.ToInt32(m_cBoxBaudRate.Text); tCmtInfo.m_nSerialDateBits = Convert.ToInt32(m_cBoxDateBits.Text); tCmtInfo.m_strSerialStopBits = m_cBoxStopBits.Text; tCmtInfo.m_strSerialParity = m_cBoxParity.Text; break; case 1: tCmtInfo.m_strStcpAddress = m_tBoxAddress.Text; tCmtInfo.m_nStcpPort = Convert.ToInt32(m_tBoxPort.Text); break; } m_oKernel.SaveCmtParaToIni(strEquipment, tCmtInfo); }
private void m_cBoxSelHardware_SelectedIndexChanged(object sender, EventArgs e) { STRUCT_CMT_INFO tCmtInfo = m_oKernel.GetCmtPara(m_cBoxSelHardware.Text); m_cBoxCmtPattern.SelectedIndex = tCmtInfo.m_nType; //m_cBoxCmtPattern.SelectedIndex = 0; m_tBoxAddress.Text = tCmtInfo.m_strStcpAddress; m_tBoxPort.Text = tCmtInfo.m_nStcpPort.ToString(); m_cBoxPortNo.Text = tCmtInfo.m_strSerialPortNum; m_cBoxBaudRate.Text = tCmtInfo.m_nSerialBaudRate.ToString(); m_cBoxDateBits.Text = tCmtInfo.m_nSerialDateBits.ToString(); m_cBoxStopBits.Text = tCmtInfo.m_strSerialStopBits; m_cBoxParity.Text = tCmtInfo.m_strSerialParity; }