private void btnsure_Click(object sender, EventArgs e) { double lon = 0.0, lat = 0.0, alt = 0.0; List <VibrationCableList> tmpVibrationCableList = new List <VibrationCableList>(); VibrationCableList _VibrationCableList = new VibrationCableList(); VibrationCable_Command tmpVibrationCable_Command = new VibrationCable_Command(); if (txtname.Text.Trim() == "") { MessageBox.Show("请填写设备名字"); return; } if (txtlon.Text.Trim() == "") { MessageBox.Show("请填写经度"); } else { if (!double.TryParse(txtlon.Text.Trim(), out lon)) { MessageBox.Show("经度为数值类型"); return; } } if (txtlat.Text.Trim() == "") { MessageBox.Show("请填写纬度"); return; } else { if (!double.TryParse(txtlat.Text.Trim(), out lat)) { MessageBox.Show("纬度为数值类型"); return; } } if (txtalt.Text.Trim() == "") { MessageBox.Show("请填写海拔"); return; } else { if (!double.TryParse(txtalt.Text.Trim(), out alt)) { MessageBox.Show("海拔为数值类型"); return; } } if (tmpStation != null) { _VibrationCableList.DeviceID = tmpStation.DeviceID; } _VibrationCableList.Name = txtname.Text.Trim(); if (comboBox1.SelectedValue.ToString() != "") { _VibrationCableList.StationID = new Guid(comboBox1.SelectedValue.ToString()); } else { _VibrationCableList.StationID = null; } _VibrationCableList.TypeID = Convert.ToInt32(DeviceParamType.VibrationCableDevice); _VibrationCableList.Lon = Convert.ToDouble(txtlon.Text.Trim()); _VibrationCableList.Lat = Convert.ToDouble(txtlat.Text.Trim()); _VibrationCableList.Alt = Convert.ToDouble(txtalt.Text.Trim()); if (comboBoxProtocolType.SelectedValue.ToString() != "") { _VibrationCableList.ProtocolType = Convert.ToInt32(comboBoxProtocolType.SelectedValue); } else { _VibrationCableList.ProtocolType = 0; } if (comboBoxCommunicationInternet.SelectedValue.ToString() != "") { _VibrationCableList.CommunicationType = Convert.ToInt32(comboBoxCommunicationInternet.SelectedValue); } else { _VibrationCableList.CommunicationType = 0; } if (comboBox3.SelectedValue.ToString() == "") { _VibrationCableList.CommunicationID = null; } else { _VibrationCableList.CommunicationID = new Guid(comboBox3.SelectedValue.ToString()); } _VibrationCableList.Description = txtdescription.Text.Trim(); tmpVibrationCableList.Add(_VibrationCableList); if (tmpStation == null) { tmpVibrationCable_Command._AddData(tmpVibrationCableList); result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK); } else if (tmpStation != null) { tmpVibrationCable_Command._ReviseData(tmpVibrationCableList); result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK); } this.Close(); }