private void EditPub()
        {
            Edit win = new PostgreSQL_APP.Edit("pub");
            int  num = PubTable.SelectedIndex;

            if (num == -1)
            {
                throw new Exception("Не выбрана строка для изменения!");
            }
            int id = (int)pubDt.Rows[num][0];

            win.textBox.Text  = (string)pubDt.Rows[num][1];
            win.textBox1.Text = (string)pubDt.Rows[num][2];
            win.ShowDialog();
            if (win.ok)
            {
                Publishing p = win.Publishing();
                pgsql.SetParamsPublishing(p.GetEditProcName, p.PublishingName, p.PublishingCity, id);
                pgsql.Query();
                MessageBox.Show("Успешно изменено\nОбновите таблицу");
            }
        }
        private void EditShelf()
        {
            Edit win = new PostgreSQL_APP.Edit("shelf");
            int  num = ShelfTable.SelectedIndex;

            if (num == -1)
            {
                throw new Exception("Не выбрана строка для изменения!");
            }
            int id = (int)shelfDt.Rows[num][0];

            win.textBox.Text  = (string)shelfDt.Rows[num][1];
            win.textBox1.Text = (string)shelfDt.Rows[num][2];
            win.ShowDialog();
            if (win.ok)
            {
                BookShelf bs = win.BookShelf();
                pgsql.SetParamsBookShelf(bs.GetEditProcName, bs.ShelfName, bs.ShelfPosition, id);
                pgsql.Query();
                MessageBox.Show("Успешно изменено\nОбновите таблицу");
            }
        }
 private void EditAuthor()
 {
     try
     {
         Edit win = new PostgreSQL_APP.Edit("author");
         int  num = AuthorTable.SelectedIndex;
         if (num == -1)
         {
             throw new Exception("Не выбрана строка для изменения!");
         }
         int id = (int)authorDt.Rows[num][0];
         //pgsql.StartTransaction(id);
         win.textBox.Text  = (string)authorDt.Rows[num][1];
         win.textBox1.Text = (string)authorDt.Rows[num][2];
         win.textBox2.Text = (string)authorDt.Rows[num][3];
         win.textBox3.Text = authorDt.Rows[num][4].ToString();
         int version = Convert.ToInt32(pgsql.GetEditRecord("select version from \"Author\" where id=@id", id).Rows[0][0]);
         win.ShowDialog();
         if (win.ok)
         {
             Author a = win.Author();
             if (Convert.ToInt32(pgsql.GetEditRecord("select version from \"Author\" where id=@id", id).Rows[0][0]) != version)
             {
                 throw new Exception("Запись была изменена\nПожалуйста, измените запись снова");
             }
             pgsql.SetParamsAuthor(a.GetEditProcName, a.AuthorFirstName, a.AuthorName, a.AuthorPatronymic, a.AuthorCity, id);
             pgsql.Query();
             pgsql.EditVersionOfRecord(id);
             MessageBox.Show("Успешно изменено\nОбновите таблицу");
         }
         //pgsql.CompleteTransaction();
     }
     catch (Exception q)
     {
         //pgsql.RollBackTransaction();
         throw new Exception(q.Message);
     }
 }
        private void EditLoc()
        {
            Edit win = new PostgreSQL_APP.Edit("location");
            int  num = LocationTable.SelectedIndex;

            if (num == -1)
            {
                throw new Exception("Не выбрана строка для изменения!");
            }
            int id = (int)locationDt.Rows[num][0];

            authorDt = pgsql.OutTable("get_author()");
            win.comboBox.ItemsSource       = authorDt.DefaultView;
            win.comboBox.DisplayMemberPath = "name";
            win.comboBox.SelectedValuePath = "id";
            bookDt = pgsql.OutTable("get_book()");
            win.comboBox1.ItemsSource       = bookDt.DefaultView;
            win.comboBox1.DisplayMemberPath = "name";
            win.comboBox1.SelectedValuePath = "id";
            shelfDt = pgsql.OutTable("get_shelf()");
            win.comboBox2.ItemsSource       = shelfDt.DefaultView;
            win.comboBox2.DisplayMemberPath = "name";
            win.comboBox2.SelectedValuePath = "id";
            win.comboBox.Text  = locationDt.Rows[num][1].ToString();
            win.comboBox1.Text = locationDt.Rows[num][2].ToString();
            win.comboBox2.Text = locationDt.Rows[num][3].ToString();
            win.textBox3.Text  = locationDt.Rows[num][4].ToString();
            win.ShowDialog();
            if (win.ok)
            {
                Location l = win.Location();
                pgsql.SetParamsLocation(l.GetEditProcName, l.AuthorId, l.BookId, l.ShelfId, l.BooksCount, id);
                pgsql.Query();
                MessageBox.Show("Успешно изменено\nОбновите таблицу");
            }
        }
 private void EditBook()
 {
     try
     {
         // pgsql.StartTransaction();
         Edit win = new PostgreSQL_APP.Edit("book");
         int  num = BookTable.SelectedIndex;
         if (num == -1)
         {
             throw new Exception("Не выбрана строка для изменения!");
         }
         int id = (int)bookDt.Rows[num][0];
         pubDt = pgsql.OutTable("get_pub()");
         win.comboBox1.ItemsSource       = pubDt.DefaultView;
         win.comboBox1.DisplayMemberPath = "name";
         win.comboBox1.SelectedValuePath = "id";
         win.textBox.Text   = (string)bookDt.Rows[num][1];
         win.comboBox1.Text = (string)bookDt.Rows[num][2];
         win.textBox2.Text  = (string)bookDt.Rows[num][3];
         win.textBox3.Text  = bookDt.Rows[num][4].ToString();
         win.ShowDialog();
         if (win.ok)
         {
             Book b = win.Book();
             pgsql.SetParamsBook(b.GetEditProcName, b.BookName, b.BookPublishing, b.PublishingDate, b.PagesCount, id);
             pgsql.Query();
             MessageBox.Show("Успешно изменено\nОбновите таблицу");
             //pgsql.CompleteTransaction();
         }
     }
     catch (Exception q)
     {
         //pgsql.RollBackTransaction();
         throw new Exception(q.Message);
     }
 }