private void BindGrid() { ArrayList objList = GetNowBookList(); BookBLL bookBLL = new BookBLL(); IList <RailExam.Model.Book> AllBookList = bookBLL.GetAllBookInfo(SessionSet.OrganizationID); IList <RailExam.Model.Book> NewBookList = new List <RailExam.Model.Book>(); foreach (RailExam.Model.Book book in AllBookList) { if (objList.IndexOf(book.bookId.ToString()) == -1) { NewBookList.Add(book); } } TrainTypeBLL trainTypeBLL = new TrainTypeBLL(); BookTrainTypeBLL bookTrainTypeBLL = new BookTrainTypeBLL(); foreach (RailExam.Model.Book book in NewBookList) { IList <BookTrainType> bookTrainTypeList = bookTrainTypeBLL.GetBookTrainTypeByBookID(book.bookId); string strTrainTypeNames = ""; foreach (BookTrainType bookTrainType in bookTrainTypeList) { if (strTrainTypeNames == "") { strTrainTypeNames = strTrainTypeNames + GetTrainTypeName("/" + bookTrainType.TrainTypeName, trainTypeBLL.GetTrainTypeInfo(bookTrainType.TrainTypeID).ParentID); } else { strTrainTypeNames = strTrainTypeNames + "," + GetTrainTypeName("/" + bookTrainType.TrainTypeName, trainTypeBLL.GetTrainTypeInfo(bookTrainType.TrainTypeID).ParentID); } } book.trainTypeNames = strTrainTypeNames; } gvBook.DataSource = NewBookList; gvBook.DataBind(); }
private void BindGrid() { string strSql; strSql = "select a.*,b.Short_Name from Book a inner join Org b on a.Publish_Org=b.Org_ID where Publish_org=" + SessionSet.OrganizationID + ViewState["QuerySql"].ToString() + " order by Book_Name"; DataSet ds = RunSqlDataSet(strSql); IList <RailExam.Model.Book> objList = new List <RailExam.Model.Book>(); ArrayList objBookList = GetBookList(); BookBLL objBookbll = new BookBLL(); IList <RailExam.Model.Book> objAllBookList = objBookbll.GetAllBookInfo(SessionSet.OrganizationID); foreach (DataRow dr in ds.Tables[0].Rows) { int n = objBookList.IndexOf(Convert.ToInt32(dr["Book_ID"].ToString())); if (n != -1) { RailExam.Model.Book objBookNew = new RailExam.Model.Book(); objBookNew.bookId = Convert.ToInt32(dr["Book_ID"].ToString()); objBookNew.bookName = dr["Book_Name"].ToString(); objBookNew.bookNo = dr["Book_No"].ToString(); objBookNew.authors = dr["Authors"].ToString(); objBookNew.bookmaker = dr["BookMaker"].ToString(); objBookNew.publishOrg = Convert.ToInt32(dr["Publish_Org"].ToString()); objBookNew.publishOrgName = dr["Short_Name"].ToString(); objBookNew.revisers = dr["Revisers"].ToString(); objBookNew.coverDesigner = dr["Cover_Designer"].ToString(); objBookNew.keyWords = dr["Keywords"].ToString(); objBookNew.pageCount = Convert.ToInt32(dr["Page_Count"].ToString()); objBookNew.wordCount = Convert.ToInt32(dr["Word_Count"].ToString()); objBookNew.Description = dr["Description"].ToString(); objBookNew.url = "../Book/" + dr["Book_ID"].ToString() + "/index.html"; objBookNew.Memo = dr["Remark"].ToString(); foreach (RailExam.Model.Book obj in objAllBookList) { if (obj.bookId == Convert.ToInt32(dr["Book_ID"].ToString())) { TrainTypeBLL objTrainTypeBll = new TrainTypeBLL(); objBookNew.knowledgeId = obj.knowledgeId; objBookNew.knowledgeName = obj.knowledgeName; BookTrainTypeBLL objBookTrainTypeBll = new BookTrainTypeBLL(); IList <BookTrainType> objBookTrainTypeList = objBookTrainTypeBll.GetBookTrainTypeByBookID(Convert.ToInt32(dr["Book_ID"].ToString())); string strTypeName = ""; foreach (BookTrainType obj1 in objBookTrainTypeList) { if (strTypeName == "") { strTypeName = strTypeName + GetType("/" + obj1.TrainTypeName, objTrainTypeBll.GetTrainTypeInfo(obj1.TrainTypeID).ParentID); } else { strTypeName = strTypeName + "," + GetType("/" + obj1.TrainTypeName, objTrainTypeBll.GetTrainTypeInfo(obj1.TrainTypeID).ParentID); } } objBookNew.trainTypeNames = strTypeName; } } objList.Add(objBookNew); } } gvBook.DataSource = objList; gvBook.DataBind(); }