private void btnsure_Click(object sender, EventArgs e) { if (txtname.Text.Trim() == "") { MessageBox.Show("请填写串口名称!"); return; } SerialCOMList _SerialCOMList = new SerialCOMList(); List <SerialCOMList> tmpSerialCOMList = new List <SerialCOMList>(); SerialCOM_Command tmpSerialCOM_Command = new SerialCOM_Command(); if (tmpSerialCOM != null) { _SerialCOMList.DeviceID = tmpSerialCOM.DeviceID; } _SerialCOMList.Name = txtname.Text.Trim(); _SerialCOMList.COMNo = comboBoxCOMNo.SelectedValue.ToString(); _SerialCOMList.Baud = Convert.ToInt32(comboBoxBaud.Text); _SerialCOMList.CheckBit = Convert.ToInt32(comboBoxCheckBit.SelectedValue); _SerialCOMList.DataBit = Convert.ToInt32(comboBoxDataBit.SelectedValue); _SerialCOMList.StopBit = Convert.ToInt32(comboBoxStopBit.SelectedValue); _SerialCOMList.Description = txtdescription.Text.Trim(); tmpSerialCOMList.Add(_SerialCOMList); if (tmpSerialCOM == null) { tmpSerialCOM_Command._AddData(tmpSerialCOMList); result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK); } else { tmpSerialCOM_Command._ReviseData(tmpSerialCOMList); result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK); } this.Close(); }