Ejemplo n.º 1
0
        private void btnsure_Click(object sender, EventArgs e)
        {
            double lon = 0.0, lat = 0.0, alt = 0.0, height = 0.0;
            int    Taddr = 0, CCDaddr = 0, IRaddr = 0;
            List <TurnTableList> tmpTurnTableList = new List <TurnTableList>();
            TurnTableList        _TurnTableList = new TurnTableList();
            TurnTable_Command    tmpTurnTable_Command = new TurnTable_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 (txtazimuthangle.Text.Trim() == "")
            {
                MessageBox.Show("请填写偏北角"); return;
            }
            else
            {
                if (!double.TryParse(txtazimuthangle.Text.Trim(), out height))
                {
                    MessageBox.Show("偏北角为数值类型"); return;
                }
            }

            if (txtTurntableAddr.Text.Trim() == "")
            {
                MessageBox.Show("请填写转台地址"); return;
            }
            else
            {
                if (!Int32.TryParse(txtTurntableAddr.Text.Trim(), out Taddr))
                {
                    MessageBox.Show("转台地址为数值类型"); return;
                }
            }

            if (txtCCDAddr.Text.Trim() == "")
            {
                MessageBox.Show("请填写白光地址"); return;
            }
            else
            {
                if (!Int32.TryParse(txtCCDAddr.Text.Trim(), out CCDaddr))
                {
                    MessageBox.Show("白光地址为数值类型"); return;
                }
            }

            if (txtIRAddr.Text.Trim() == "")
            {
                MessageBox.Show("请填写红外地址"); return;
            }
            else
            {
                if (!Int32.TryParse(txtIRAddr.Text.Trim(), out IRaddr))
                {
                    MessageBox.Show("红外地址为数值类型"); return;
                }
            }
            if (tmpStation != null)
            {
                _TurnTableList.DeviceID = tmpStation.DeviceID;
            }

            _TurnTableList.Name = txtname.Text.Trim();

            if (comboBox1.SelectedValue.ToString() != null)
            {
                _TurnTableList.StationID = new Guid(comboBox1.SelectedValue.ToString());
            }
            else
            {
                _TurnTableList.StationID = null;
            }

            _TurnTableList.TypeID             = Convert.ToInt32(DeviceParamType.TurnTableDevice);
            _TurnTableList.Lon                = Convert.ToDouble(txtlon.Text.Trim());
            _TurnTableList.Lat                = Convert.ToDouble(txtlat.Text.Trim());
            _TurnTableList.Alt                = Convert.ToDouble(txtalt.Text.Trim());
            _TurnTableList.ErectingHeight     = Convert.ToDouble(txterectingheight.Text.Trim());
            _TurnTableList.ErectingHeightType = Convert.ToInt32(comboBox2.SelectedValue);
            _TurnTableList.AzimuthAngle       = Convert.ToInt32(txtazimuthangle.Text.Trim());
            _TurnTableList.ProtocolType       = Convert.ToInt32(comboBoxProtocolType.SelectedValue);
            _TurnTableList.TurntableAddr      = Convert.ToInt32(txtTurntableAddr.Text.Trim());
            _TurnTableList.CCDAddr            = Convert.ToInt32(txtCCDAddr.Text.Trim());
            _TurnTableList.IRAddr             = Convert.ToInt32(txtIRAddr.Text.Trim());
            _TurnTableList.CommunicationType  = Convert.ToInt32(comboBoxCommunicationInternet.SelectedValue);
            if (comboBox3.SelectedValue.ToString() != "")
            {
                _TurnTableList.CommunicationID = new Guid(comboBox3.SelectedValue.ToString());
            }
            else
            {
                _TurnTableList.CommunicationID = null;
            }

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