private void btnsure_Click(object sender, EventArgs e) { double lon = 0.0, lat = 0.0; List <StationList> tmpStationList = new List <StationList>(); StationList _StationList = new StationList(); Station_Command tmpStationData_Command = new Station_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 (tmpStation != null) { _StationList.StationID = tmpStation.StationID; _StationList.PStationID = tmpStation.PStationID; } _StationList.Name = txtname.Text; if (comboBox1.SelectedValue.ToString() != "") { _StationList.PStationID = new Guid(comboBox1.SelectedValue.ToString()); } else { _StationList.PStationID = null; } _StationList.TypeID = Convert.ToInt32(cbxtypename.SelectedValue.ToString()); _StationList.Lon = Convert.ToDouble(txtlon.Text.Trim()); _StationList.Lat = Convert.ToDouble(txtlat.Text.Trim()); _StationList.Description = txtdescription.Text; _StationList.Mark = null; tmpStationList.Add(_StationList); if (tmpStation == null) { tmpStationData_Command._AddData(tmpStationList); result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK); } else { tmpStationData_Command._ReviseData(tmpStationList); result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK); } this.Close(); }