using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class AddForm : Form
    {
        public AddForm()
        {
            InitializeComponent();
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void CloseBtn_Specialnost_Click(object sender, EventArgs e) // Кнопка "Закрыть" формы AddForm
        {
            {
                Close();
            }
        }

        private void AddBtn_Specialnost_Click(object sender, EventArgs e) // Тут прописываем функцию добавления записи при нажатии на кнопку "Добавить" формы AddForm 
        {
            Form1 main = this.Owner as Form1;
            if (main != null)
            {
                DataRow nRow = main.testDataSet.Tables[0].NewRow();
                nRow[0] = tbKod_spec.Text;
                nRow[1] = tbSpec.Text;
                main.testDataSet.Tables[0].Rows.Add(nRow);
                main.specialnostTableAdapter1.Update(main.testDataSet.Specialnost);
                main.testDataSet.Tables[0].AcceptChanges();
                main.dataGridView1.Refresh();
                tbKod_spec.Text = "";
                tbSpec.Text = "";

            }
        }
    }
}
