Ejemplo n.º 1
0
        private void btnsure_Click(object sender, EventArgs e)
        {
            List <SolarEnergyList> tmpListSolarEnergy    = new List <SolarEnergyList>();
            SolarEnergyList        _SolarEnergyList      = new SolarEnergyList();
            SolarEnergy_Command    tmpSolarEnergyCommand = new SolarEnergy_Command();

            double lon = 0.0, lat = 0.0, alt = 0.0, height = 0.0;

            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 (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("请填写架设高度"); return;
            }
            else
            {
                if (!double.TryParse(textBox1.Text.Trim(), out height))
                {
                    MessageBox.Show("架设高度为数值类型"); return;
                }
            }
            if (tmpStation != null)
            {
                _SolarEnergyList.DeviceID = tmpStation.DeviceID;
            }

            _SolarEnergyList.Name              = txtname.Text.Trim();
            _SolarEnergyList.TypeID            = Convert.ToInt32(DeviceParamType.SolarEnergyDevice);
            _SolarEnergyList.Lon               = Convert.ToDouble(txtlon.Text.Trim());
            _SolarEnergyList.Lat               = Convert.ToDouble(txtlat.Text.Trim());
            _SolarEnergyList.Alt               = Convert.ToDouble(txtalt.Text.Trim());
            _SolarEnergyList.ErectingHeight    = Convert.ToDouble(textBox1.Text.Trim());
            _SolarEnergyList.ProtocolType      = Convert.ToInt32(comboBoxProtocolType.SelectedValue);
            _SolarEnergyList.Description       = txtdescription.Text.Trim();
            _SolarEnergyList.CommunicationType = Convert.ToInt32(comboBoxCommunicationInternet.SelectedValue);
            _SolarEnergyList.CommunicationID   = new Guid(comboBox3.SelectedValue.ToString());
            if (comboBox1.SelectedValue.ToString() != null)
            {
                _SolarEnergyList.StationID = new Guid(comboBox1.SelectedValue.ToString());
            }
            else
            {
                _SolarEnergyList.StationID = null;
            }

            tmpListSolarEnergy.Add(_SolarEnergyList);
            if (tmpStation == null)
            {
                tmpSolarEnergyCommand._AddData(tmpListSolarEnergy);
                result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK);
            }
            else if (tmpStation != null)
            {
                tmpSolarEnergyCommand._ReviseData(tmpListSolarEnergy);
                result = MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK);
            }
            this.Close();
        }