Exemple #1
0
 private void FoundBookbutton_Click(object sender, EventArgs e)
 {
     if (IDBooktextbox.Text != "")
     {
         int x = -1;
         try
         {
             x = Convert.ToInt32(IDBooktextbox.Text);
         }
         catch
         {
             MessageBox.Show("ID должен состоять только из цифр", "Неккоректный ввод", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             IDBooktextbox.Focus();
         }
         if (x <= 0)
         {
             MessageBox.Show("ID не может быть отрицательным или равным нулю.", "Неккоректный ввод", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             IDBooktextbox.Focus();
         }
         else
         {
             var query = from c in db.GetBooksTable()
                         join Author_Book in db.GetAuthor_BooksTable()
                         on c.Id equals Author_Book.IdBooks
                         join Author in db.GetAuthorsTable()
                         on Author_Book.IdAuthors equals Author.Id
                         select c.Id;
             var a = query.FirstOrDefault();
             if (a == 0)
             {
                 MessageBox.Show("Введен не существующий ID.", "ID не найден", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
             }
             else
             {
                 Tableindex = 1;
                 panel2.Show();
                 IDBooktextbox.Enabled = false;
                 dataGrid.DataSource   = db.GetUsersTable();
             }
         }
     }
     else
     {
         MessageBox.Show("Заполните поле \"ID\"", "Неккоректный ввод", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 private void FoundBookbutton_Click(object sender, EventArgs e)
 {
     if (IDBooktextbox.Text != "")
     {
         int x = -1;
         try
         {
             x = Convert.ToInt32(IDBooktextbox.Text);
         }
         catch
         {
             MessageBox.Show("ID должен состоять только из цифр", "Неккоректный ввод", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             IDBooktextbox.Focus();
         }
         if (x <= 0)
         {
             MessageBox.Show("ID не может быть отрицательным или равным нулю.", "Неккоректный ввод", MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
             IDBooktextbox.Focus();
         }
         else
         {
             var query = from rent in db.GetRentTable()
                         where rent.IdBooks == x
                         select rent.IdBooks;
             var a = query.FirstOrDefault();
             if (a == 0)
             {
                 MessageBox.Show("Введен не существующий ID.", "ID не найден", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
             }
             else
             {
                 index = 3;
                 panel3.Show();
                 IDBooktextbox.Enabled   = false;
                 FoundBookbutton.Enabled = false;
                 dataGrid.DataSource     = from rent in db.GetRentTable()
                                           join book in db.GetBooksTable()
                                           on rent.IdBooks equals book.Id
                                           join staff in db.GetStaffTable()
                                           on rent.IdStaff equals staff.Id
                                           join user in db.GetUsersTable()
                                           on rent.IdUsers equals user.Id
                                           where rent.IdBooks == x
                                           select new
                 {
                     IdBook = book.Id,
                     book.Title,
                     IdUser    = user.Id,
                     UserName  = user.LastName + " " + user.FirstName,
                     IDStaff   = staff.Id,
                     StaffName = staff.LastName + " " + staff.FirstName,
                     RentCount = rent.Count,
                     IssueDate = rent.Issue,
                 };
             }
         }
     }
     else
     {
         MessageBox.Show("Заполните поле \"ID\"", "Неккоректный ввод", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
 }