コード例 #1
0
        protected void Init_Author_List()
        {
            string    sqlStr = "select * from db_UserInfoTable";
            DataTable dt     = Class1.GetDsFromSql(sqlStr).Tables[0];

            if (dt.Rows.Count > 0)
            {
                Author_List.DataSource = dt;
                Author_List.DataBind();
            }
            else
            {
                Response.Write("<script>alert('数据库错误')</script>");
            }
        }
コード例 #2
0
ファイル: AddBook.cs プロジェクト: daVinay/AIT_Library_System
        //when the form is load
        private void AddBook_Load(object sender, EventArgs e)
        {
            dataGridView1.Visible = false;

            BookLogic bl = new BookLogic();

            //Get List of Category/Language/Author
            Category_List.DataSource    = bl.ListCategory();
            Category_List.DisplayMember = "PairName";
            Category_List.ValueMember   = "PairID";

            Language_List.DataSource    = bl.ListLanguage();
            Language_List.DisplayMember = "PairName";
            Language_List.ValueMember   = "PairID";

            Author_List.DataSource    = bl.ListAuthor();
            Author_List.DisplayMember = "PairName";
            Author_List.ValueMember   = "PairID";

            //If it's an update we change some information on the form
            if (bookStatus == "Update")
            {
                book_group.Text = "Update a book";              //name of the group box
                //We got the value from SearchBook
                Isbn_txtBox.Text            = SearchBook.isbn_db;
                Isbn_txtBox.Enabled         = false;
                BookName_txtBox.Text        = SearchBook.bookName_db;
                Publisher_txtBox.Text       = SearchBook.publisher_db;
                PublisherYear_txtBox.Text   = SearchBook.publishYear_db;
                Pages_txtBox.Text           = SearchBook.pages_db;
                Author_List.SelectedIndex   = Author_List.FindString(SearchBook.author_db);
                Category_List.SelectedIndex = Category_List.FindString(SearchBook.category_db);
                Language_List.SelectedIndex = Language_List.FindString(SearchBook.language_db);
                //We update the function after clicking on the button
                btnAddBook.Text   = "Update book";
                btnAddBook.Click -= btnAddBook_Click;
                btnAddBook.Click += btnUpdateBook_Click;
            }
        }