Использование объектов ADO.NET для работы с базами данных. Приложение баз данных на основе Windows-форм, соответствующее предметной области, страница 5

            {

                if (oleDbDataAdapter_dgvTable != null)

                    oleDbDataAdapter_dgvTable.Update(dataSet_dgvTable1, "Послужной_список");

                MessageBox.Show("Изменения в таблице \"Послужной список\" успешно сохранены.",

                    "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            catch (Exception exp)

            {

                MessageBox.Show("Ошибка сохраненения.",

                    "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

        }

        private void RefreshTable()

        {

            dataSet_dgvTable1.Clear();

            if (cbFIO.SelectedIndex != 1 && cbPost.SelectedIndex != 1)

            {

                oleDbDataAdapter_dgvTable.SelectCommand.Parameters[1].Value = cbPost.SelectedValue;

                oleDbDataAdapter_dgvTable.SelectCommand.Parameters[0].Value = cbFIO.SelectedValue;

                oleDbDataAdapter_dgvTable.Fill(dataSet_dgvTable1);

            }

        }

        private void cbFIO_SelectedIndexChanged(object sender, EventArgs e)

        {

            RefreshTable();

        }

        private void cbPost_SelectedIndexChanged(object sender, EventArgs e)

        {

            RefreshTable();

        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)

        {

            if (dataGridView1.SelectedCells.Count > 0)

            {

                dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[3].Value = cbFIO.SelectedValue;

                dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[4].Value = cbPost.SelectedValue;

            }

        }

}


Длятаблицы «Заказы»


public partial class Olders : Form

    {

        public Olders()

        {

            InitializeComponent();

        }

        private void Olders_Load(object sender, EventArgs e)

        {

            oleDbDataAdapter_cbFIO.Fill(dataSet_cbFIO1);

            oleDbDataAdapter_cbUslugi.Fill(dataSet_cbUslugi1);

            oleDbDataAdapter_cbClients.Fill(dataSet_cbClients1);

            RefreshTable();

        }

        private void RefreshTable()

        {

            dataSet_orders1.Clear();

            if (cbFIO.SelectedIndex != 1 && cbUsluga.SelectedIndex != 1 && cbClient.SelectedIndex != 1)

            {

                oleDbDataAdapter_orders.SelectCommand.Parameters[0].Value = cbClient.SelectedValue;

                oleDbDataAdapter_orders.SelectCommand.Parameters[1].Value = cbFIO.SelectedValue;

                oleDbDataAdapter_orders.SelectCommand.Parameters[2].Value = cbUsluga.SelectedValue;

                oleDbDataAdapter_orders.Fill(dataSet_orders1);

            }

        }

        private void cbFIO_SelectedIndexChanged(object sender, EventArgs e)

        {

            RefreshTable();

        }

        private void cbUsluga_SelectedIndexChanged(object sender, EventArgs e)

        {

            RefreshTable();

        }

        private void cbClient_SelectedIndexChanged(object sender, EventArgs e)

        {

            RefreshTable();

        }

        private void dataGridView1_SelectionChanged(object sender, EventArgs e)

        {

            if (dataGridView1.SelectedCells.Count > 0)

            {

                dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value = cbClient.SelectedValue;

                dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[2].Value = cbFIO.SelectedValue;