Exemple #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            AddJournalForm addJFrom = new AddJournalForm();

            addJFrom.Text = "Добавление журнала";
            DialogResult result = addJFrom.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            Journal journal = new Journal();

            int    num = 0;
            double k   = 0;

            journal.NameOfJournal = addJFrom.textBox1.Text;
            if (Int32.TryParse(addJFrom.textBox2.Text, out num))
            {
                journal.SumNumbersOfCitations = num;
            }
            if (Int32.TryParse(addJFrom.textBox3.Text, out num))
            {
                journal.SumNumbersOfArticles = num;
            }
            if (Double.TryParse(addJFrom.textBox4.Text, out k))
            {
                journal.AverageNumbersOfArticles = k;
            }
            if (Double.TryParse(addJFrom.textBox5.Text, out k))
            {
                journal.AverageMarkOfPublicExpertise = k;
            }
            if (Double.TryParse(addJFrom.textBox6.Text, out k))
            {
                journal.IndicatorInRating = k;
            }
            if (Double.TryParse(addJFrom.textBox7.Text, out k))
            {
                journal.PositionInScienceIndex = k;
            }

            journal.PositionInAlgorithm = Math.Round(Int32.Parse(addJFrom.textBox2.Text) / Double.Parse(addJFrom.textBox4.Text) /
                                                     Double.Parse(addJFrom.textBox3.Text) + 10 * Double.Parse(addJFrom.textBox5.Text) + Double.Parse(addJFrom.textBox6.Text), 1);

            db.Journals.Add(journal);
            db.SaveChanges();

            MessageBox.Show("Новый журнал добавлен");
        }
Exemple #2
0
        private void Button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                int  index     = dataGridView1.SelectedRows[0].Index;
                int  id        = 0;
                bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                if (converted == false)
                {
                    return;
                }

                Journal journal = db.Journals.Find(id);

                AddJournalForm addJFrom = new AddJournalForm();

                addJFrom.Text          = "Изменение журнала";
                addJFrom.textBox1.Text = journal.NameOfJournal.ToString();
                addJFrom.textBox2.Text = journal.SumNumbersOfCitations.ToString();
                addJFrom.textBox3.Text = journal.SumNumbersOfArticles.ToString();
                addJFrom.textBox4.Text = journal.AverageNumbersOfArticles.ToString();
                addJFrom.textBox5.Text = journal.AverageMarkOfPublicExpertise.ToString();
                addJFrom.textBox6.Text = journal.IndicatorInRating.ToString();
                addJFrom.textBox7.Text = journal.PositionInScienceIndex.ToString();

                DialogResult result = addJFrom.ShowDialog(this);

                if (result == DialogResult.Cancel)
                {
                    return;
                }

                int    num = 0;
                double k   = 0;

                journal.NameOfJournal = addJFrom.textBox1.Text;
                if (Int32.TryParse(addJFrom.textBox2.Text, out num))
                {
                    journal.SumNumbersOfCitations = num;
                }
                if (Int32.TryParse(addJFrom.textBox3.Text, out num))
                {
                    journal.SumNumbersOfArticles = num;
                }
                if (Double.TryParse(addJFrom.textBox4.Text, out k))
                {
                    journal.AverageNumbersOfArticles = k;
                }
                if (Double.TryParse(addJFrom.textBox5.Text, out k))
                {
                    journal.AverageMarkOfPublicExpertise = k;
                }
                if (Double.TryParse(addJFrom.textBox6.Text, out k))
                {
                    journal.IndicatorInRating = k;
                }
                if (Double.TryParse(addJFrom.textBox7.Text, out k))
                {
                    journal.PositionInScienceIndex = k;
                }

                journal.PositionInAlgorithm = Math.Round(Int32.Parse(addJFrom.textBox2.Text) / Double.Parse(addJFrom.textBox4.Text) /
                                                         Double.Parse(addJFrom.textBox3.Text) + 10 * Double.Parse(addJFrom.textBox5.Text) + Double.Parse(addJFrom.textBox6.Text), 1);

                db.SaveChanges();
                dataGridView1.Refresh(); // обновляем грид
                MessageBox.Show("Журнал обновлен");
            }
        }