public void UpdateEditedAuthor(Autor authorsNewData)
 {
     int index = Authors.FindIndex(x => x.id == selectedAuthor.id);
     Authors[index].imie = authorsNewData.imie;
     Authors[index].nazwisko = authorsNewData.nazwisko;
     Authors[index].rokUrodzenia = authorsNewData.rokUrodzenia;
     ClearRows();
     DisplayData();
 }
        private void AuthorsItemSet_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (addingRows == true) return;
            if (dgv.Rows.Count == 0) return;
            int index = e.SelectedIndex;
            int selectedAuthorID = -1;
            try
            {
                selectedAuthorID = int.Parse(dgv.Rows[index].Cells[0].Value.ToString());
            }
            catch (Exception) { }

            if (selectedAuthorID != -1)
            {
                selectedAuthor = Authors.Where(x => x.id == selectedAuthorID).Single();
            }
        }
 private void DisplayData()
 {
     int firstIndex = CurrentPage * RowsPerPage;
     int lastIndex = CurrentPage * RowsPerPage + RowsPerPage;
     if (lastIndex > Authors.Count) lastIndex = Authors.Count;
     addingRows = true;
     for (int i = 0; i < lastIndex - firstIndex; i++)
     {
         dgv.Rows.Add();
         Autor a = Authors[i + firstIndex];
         dgv.Rows[i].Cells[0].Value = a.id.ToString();
         dgv.Rows[i].Cells[1].Value = a.imie;
         dgv.Rows[i].Cells[2].Value = a.nazwisko;
         dgv.Rows[i].Cells[3].Value = a.rokUrodzenia.ToString();
     }
     addingRows = false;
     dgv.ClearSelection();
     selectedAuthor = null;
 }
 private void ChangeSelectedAuthor()
 {
     selectedAuthor = dgvAuthors.SelectedAuthor;
     if (selectedAuthor == null)
     {
         ButtonOK.Enabled = false;
     }
     else
     {
         ButtonOK.Enabled = true;
     }
 }
 private void ButtonClose_Click(object sender, EventArgs e)
 {
     selectedAuthor = null;
     DialogResult = DialogResult.Abort;
 }
 partial void DeleteAutor(Autor instance);
 partial void UpdateAutor(Autor instance);
 partial void InsertAutor(Autor instance);