Esempio n. 1
0
        private void _editBtn_Click(object sender, EventArgs e)
        {
            if (DataGridView.Rows.Count == 0)
            {
                MessageBox.Show("Таблица пуста");
            }
            else
            {
                //Get selected row.
                int index = DataGridView.CurrentRow.Index;

                InsertForm f = new InsertForm();
                f.Owner = this;

                //Add data from DataGridView to InsertForm.
                f.Title    = (string)DataGridView.Rows[index].Cells[0].Value;
                f.Author   = (string)DataGridView.Rows[index].Cells[1].Value;
                f.Category = (string)DataGridView.Rows[index].Cells[2].Value;
                f.Price    = (string)DataGridView.Rows[index].Cells[3].Value;
                f.Year     = (string)DataGridView.Rows[index].Cells[4].Value;
                f.ShowDialog();

                AddingData(f, index);
            }
        }
Esempio n. 2
0
        private void _AddBtn_Click(object sender, EventArgs e)
        {
            InsertForm f = new InsertForm();

            //Link annex form to main one.
            f.Owner = this;
            f.ShowDialog();
            //If user presses "Отмена", do nothing.
            if (f.ActiveControl.Text != "Отмена")
            {
                AddingData(f, -1);
            }
        }