コード例 #1
0
        public static ObservableCollection <Author> GetAuthorsForBook(int bookid)
        {
            ObservableCollection <Author> result = null;

            try
            {
                var reader = DataConnector.ExecuteQuery("select tg.MaTacGia, tg.TenTacGia from TacGia tg, ChiTietTacGiaSach ct where tg.MaTacGia = ct.MaTacGia and ct.MaSach = " + bookid);
                if (reader != null)
                {
                    result = new ObservableCollection <Author>();
                    while (reader.Read())
                    {
                        var item = new Author(reader.GetInt32(0));
                        item.BeginInit();
                        item.Name = (string)reader.GetValueDefault(1, null);
                        item.EndInit();
                        result.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.Current.DataCantBeRead.Call(ex.Message);
            }
            return(result);
        }
コード例 #2
0
        public static ObservableCollection <Author> GetAll()
        {
            ObservableCollection <Author> result = null;

            try
            {
                var reader = DataConnector.ExecuteQuery("select MaTacGia,TenTacGia from TacGia");
                if (reader != null)
                {
                    result = new ObservableCollection <Author>();
                    while (reader.Read())
                    {
                        var item = new Author(reader.GetInt32(0));
                        item.BeginInit();
                        item.Name = (string)reader.GetValueDefault(1, null);
                        item.EndInit();
                        result.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.Current.DataCantBeRead.Call(ex.Message);
            }
            return(result);
        }