コード例 #1
0
        private void ReservationUpdateButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (_selectedId != "")
                {
                    BookReservationDetailsView.Hide();
                    BookIssuedetailsSearchPanel.Hide();
                    BookissueUpdategroupBox.Show();
                    PagingPanel.Hide();
                    closeUpdateToolStripMenuItem.Enabled = true;

                    this.Width  = 1151;
                    this.Height = 415;
                    using (
                        var connection =
                            new SqlConnection(ConnectionString)
                        )
                    {
                        var command =
                            new SqlCommand(
                                "select Isbn,Title,br.DayOfBorrowed,br.DayOfReturn  from Borrow br join Book b on br.BookId=b.BookId join Student s on br.StudentId=s.Id where s.StudentId=@StudentId",
                                connection);
                        command.Parameters.AddWithValue("@StudentId", _selectedId);

                        connection.Open();

                        SqlDataReader reader = command.ExecuteReader();
                        reader.Read();
                        IsbnUpdateTextBox.Text = reader[0].ToString();

                        IssueDatePicker.Text  = reader[2].ToString();
                        ReturnDatePicker.Text = reader[3].ToString();
                    }
                }
                else
                {
                    var objDialogWindow = new DialogWindow("Please select an ID to Update", "Warning Dialog", DialogWindow.DialogBoxIconType.Exclamation);
                    objDialogWindow.ShowDialog();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }