コード例 #1
0
        private void accept_Click(object sender, RoutedEventArgs e)
        {
            Stars star = new WPF_Material_Design.Source.Stars();

            decimal?weight;
            decimal?radius;

            decimal?apparent_Star_Magnitude;
            decimal?star_Luminosity;


            try
            {
                weight = Convert.ToDecimal(Weight.Text);
            }

            catch (Exception ex)
            {
                Weight.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                radius = Convert.ToDecimal(Radius.Text);
            }

            catch (Exception ex)
            {
                Radius.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                apparent_Star_Magnitude = Convert.ToDecimal(Apparent_Star_Magnitude.Text);
            }

            catch (Exception ex)
            {
                Apparent_Star_Magnitude.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                star_Luminosity = Convert.ToDecimal(Star_Luminosity.Text);
            }

            catch (Exception ex)
            {
                Star_Luminosity.Clear();

                MessageBox.Show("Введите заново");
                return;
            }


            if (new_star)
            {
                star.Create(Name.Text, Constellatoin.Text, Declination.Text, Right_Ascension.Text, weight, radius, apparent_Star_Magnitude, star_Luminosity, Star_Type.Text, Info.Text);
                Stars.Add(star);
            }
            else
            {
                this.star.Create(Name.Text, Constellatoin.Text, Declination.Text, Right_Ascension.Text, weight, radius, apparent_Star_Magnitude, star_Luminosity, Star_Type.Text, Info.Text);
            }

            Close();
        }
コード例 #2
0
        private void accept_Click(object sender, RoutedEventArgs e)
        {
            Planets planet = new WPF_Material_Design.Source.Planets();



            decimal?radius;
            decimal?weigth;
            decimal?circulation_Period_Axis;
            decimal?circulation_Period;
            decimal?orbit_Radius;
            decimal?eccentricity;

            try
            {
                radius = Convert.ToDecimal(Radius.Text);
            }
            catch (Exception ex)
            {
                Radius.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                weigth = Convert.ToDecimal(Weigth.Text);
            }
            catch (Exception ex)
            {
                Weigth.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                circulation_Period_Axis = Convert.ToDecimal(Circulation_Period_Axis.Text);
            }
            catch (Exception ex)
            {
                Circulation_Period_Axis.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                circulation_Period = Convert.ToDecimal(Circulation_Period.Text);
            }
            catch (Exception ex)
            {
                Circulation_Period.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                orbit_Radius = Convert.ToDecimal(Orbit_Radius.Text);
            }
            catch (Exception ex)
            {
                Orbit_Radius.Clear();

                MessageBox.Show("Введите заново");
                return;
            }

            try
            {
                eccentricity = Convert.ToDecimal(Eccentricity.Text);
            }
            catch (Exception ex)
            {
                Eccentricity.Clear();

                MessageBox.Show("Введите заново");
                return;
            }


            if (new_planet)
            {
                planet.Create(Name.Text, radius, weigth, circulation_Period_Axis, circulation_Period, Center_body.Text, orbit_Radius, eccentricity, Info.Text);
                Planets.Add(planet);
            }
            else
            {
                this.planet.Create(Name.Text, radius, weigth, circulation_Period_Axis, circulation_Period, Center_body.Text, orbit_Radius, eccentricity, Info.Text);
            }

            Close();
        }