Esempio n. 1
0
        private void btnsure_Click(object sender, EventArgs e)
        {
            double           lon = 0.0, lat = 0.0, alt = 0.0, height = 0.0;
            List <RadarList> tmpRadarList     = new List <RadarList>();
            RadarList        _RadarList       = new RadarList();
            Radar_Command    tmpRadar_Command = new Radar_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 (txterectingheight.Text.Trim() == "")
            {
                MessageBox.Show("请填写架设高度"); return;
            }
            else
            {
                if (!double.TryParse(txterectingheight.Text.Trim(), out height))
                {
                    MessageBox.Show("架设高度为数值类型"); return;
                }
            }
            if (tmpStation != null)
            {
                _RadarList.DeviceID = tmpStation.DeviceID;
            }

            _RadarList.Name = txtname.Text.Trim();
            if (comboBox1.SelectedValue.ToString() != "")
            {
                _RadarList.StationID = new Guid(comboBox1.SelectedValue.ToString());
            }
            else
            {
                _RadarList.StationID = null;
            }

            _RadarList.TypeId         = Convert.ToInt32(DeviceParamType.RadarDevice);
            _RadarList.Lon            = Convert.ToDouble(txtlon.Text.Trim());
            _RadarList.Lat            = Convert.ToDouble(txtlat.Text.Trim());
            _RadarList.Alt            = Convert.ToDouble(txtalt.Text.Trim());
            _RadarList.ErectingHeight = Convert.ToDouble(txterectingheight.Text.Trim());
            if (comboBoxProtocolType.SelectedValue.ToString() != "")
            {
                _RadarList.ProtocolType = Convert.ToInt32(comboBoxProtocolType.SelectedValue);
            }
            else
            {
                _RadarList.ProtocolType = 0;
            }
            if (comboBoxCommunicationInternet.SelectedValue.ToString() != "")
            {
                _RadarList.CommunicationType = Convert.ToInt32(comboBoxCommunicationInternet.SelectedValue);
            }
            else
            {
                _RadarList.CommunicationType = 0;
            }

            if (comboBox3.SelectedValue.ToString() == "")
            {
                _RadarList.CommunicationID = null;
            }
            else
            {
                _RadarList.CommunicationID = new Guid(comboBox3.SelectedValue.ToString());
            }

            _RadarList.Description = txtdescription.Text.Trim();
            tmpRadarList.Add(_RadarList);
            if (tmpStation == null)
            {
                tmpRadar_Command._AddData(tmpRadarList);
                result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
            }
            else if (tmpStation != null)
            {
                tmpRadar_Command._ReviseData(tmpRadarList);
                result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
            }
            this.Close();
        }