Example #1
0
        public override void UpdateInfo(AIOCommonInfo info)
        {
            base.UpdateInfo(info);

            AIOBook book = (AIOBook)info;
            //Be careful: year is a SQL Keyword. Put it into square brackets.
            string       sql = "UPDATE Book SET title = ?, authorID = ?, genreID = ?, publisherID = ?, [year] = ? WHERE ID = ?";
            OleDbCommand cmd = aioDb.CreateSqlWithParam(sql, new object[] { book.title, book.authorID, book.genreID, book.publisherID, book.year, book.ID });

            //Execute it
            aioDb.ExecuteCommand(cmd);
        }
        public frmBookInfo(AIODatabase aioDb, AIOCommonController controller, string ID)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.aioDb = aioDb;
            this.controller = (AIOBookController)controller;
            this.book = (AIOBook)this.controller.Select(ID);

            //Init for udYear
            udYear.Maximum = DateTime.Now.Year;
        }
        public override AIOCommonInfo Select(string ID)
        {
            AIOBook book = new AIOBook(base.Select(ID));

            string sql = "SELECT * FROM Book WHERE ID = '" + ID + "'";
            DataTable table = aioDb.ExecuteSelect(sql);
            //ID - Title - AuthorID - GenreID - Year - PublisherID - Cover
            object [] obj = table.Rows[0].ItemArray;
            book.title = obj[1].ToString();
            book.authorID = obj[2].ToString();
            book.genreID = obj[3].ToString();
            book.year = Convert.ToInt32(obj[4]);
            book.publisherID = obj[5].ToString();
            book.cover = Encoding.UTF8.GetBytes(obj[6].ToString());

            return book;
        }
Example #4
0
        public override AIOCommonInfo Select(string ID)
        {
            AIOBook book = new AIOBook(base.Select(ID));

            string    sql   = "SELECT * FROM Book WHERE ID = '" + ID + "'";
            DataTable table = aioDb.ExecuteSelect(sql);

            //ID - Title - AuthorID - GenreID - Year - PublisherID - Cover
            object [] obj = table.Rows[0].ItemArray;
            book.title       = obj[1].ToString();
            book.authorID    = obj[2].ToString();
            book.genreID     = obj[3].ToString();
            book.year        = Convert.ToInt32(obj[4]);
            book.publisherID = obj[5].ToString();
            book.cover       = Encoding.UTF8.GetBytes(obj[6].ToString());

            return(book);
        }