protected void CreateControlDated(DataSet dataSet, NewsCategoryContainer categCont) { TableCell cell = new TableCell(); HtmlGenericControl h2 = new HtmlGenericControl(); h2.TagName = "H2"; cell.Controls.Add(h2); int i = 0; foreach (NewsCategory item in categCont.All.SortBy("Rank", true)) { //TableCell cellSpace = new TableCell(); //cellSpace.Text = " "; rowCat.Cells.Add(cell); //cell.Wrap = false; HyperLink lnkCat = new HyperLink(); lnkCat.NavigateUrl = string.Format("NewsByCategory.aspx?CatID={0}", item.ID); lnkCat.Text = item.Name; HtmlGenericControl span = new HtmlGenericControl(); span.TagName = "SPAN"; span.InnerHtml = " - "; i++; h2.Controls.Add(lnkCat); if (i < categCont.AllCount) h2.Controls.Add(span); } NewsByCategoryControl control = (NewsByCategoryControl)LoadControl("Controls/NewsByCategoryControl.ascx"); if (dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { SelectedGridOrder = "Descending"; SelectedGridSort = "CreatedDate"; control.DataSource = dataSet; pnlNewsList.Controls.Add(control); } }
public virtual NewsCategoryContainer NewsCategorySelectAll() { TraceCallEnterEvent.Raise(); try { NewsCategoryContainer result; DataSet entitySet = m_DataContext.ndihdNewsCategorySelectAll(); result = new NewsCategoryContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
protected void Page_Load(object sender, EventArgs e) { // Check permission: anybody can use this page try { bool all = false; INewsCategoryService srvNewsCateg = ServiceFactory.GetNewsCategoryService(); NewsCategoryContainer categCont = new NewsCategoryContainer(); if (Request["CatID"] != null) { Guid categoryID = Guid.Empty; categoryID = new Guid(Request["CatID"]); NewsCategory newsCat = srvNewsCateg.NewsCategorySelect(categoryID); categCont.Add(newsCat); all = true; } else { categCont = srvNewsCateg.NewsCategorySelectAll(); } //Categória nevének lekérdezése foreach (NewsCategory item in categCont.All.SortBy("Rank", true)) { CreateControl(item.ID, item.Name, all); } categCont = srvNewsCateg.NewsCategorySelectAll(); CreateNewsCategoryBottom(categCont, rowCat); //lehetnek olyan cikkek is amelyekmég nem lettek hozzárendelve egyik kategóriához sem //CreateControl(Guid.Empty, "Egyéb"); } catch (Exception ex) { errorPanel.Exception = ex; } }
public NewsCategoryContainer NewsCategorySelectFiltered(DBString cName, DBInt isActive) { //check permission: Admin PrincipalPermission permAdm = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permAdm.Demand(); TraceCallEnterEvent.Raise(); try { if (isActive == null) { isActive = DBInt.Null; } NewsCategoryContainer result; DataSet entitySet = m_DataContext.ndihdNewsCategorySelectFiltered(cName, isActive); result = new NewsCategoryContainer(entitySet.Tables[0]); TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
protected void CreateNewsCategoryBottomDated(NewsCategoryContainer categCont, TableRow rowCat) { TableCell cell = new TableCell(); HtmlGenericControl h2 = new HtmlGenericControl(); h2.TagName = "H2"; cell.Controls.Add(h2); int i = 0; foreach (NewsCategory item in categCont.All.SortBy("CreatedDate", true)) { CreateControlDated(item.ID, item.Name); //TableCell cellSpace = new TableCell(); //cellSpace.Text = " "; rowCat.Cells.Add(cell); //cell.Wrap = false; HyperLink lnkCat = new HyperLink(); lnkCat.NavigateUrl = string.Format("NewsByCategory.aspx?CatID={0}", item.ID); lnkCat.Text = item.Name; HtmlGenericControl span = new HtmlGenericControl(); span.TagName = "SPAN"; span.InnerHtml = " - "; i++; h2.Controls.Add(lnkCat); if (i < categCont.AllCount) h2.Controls.Add(span); } }
/// <summary> /// Fill datagrid with data /// </summary> // ------------------------------------------------------------------------------------- private void FillDatagrid(DBGuid ID) { try { string sortColumn = "Name"; int selectedRow = -1; // storing the previous sort order if (dtgMain.DataSource != null) { sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort; } // retrieving data from BusinessServices String name = ""; if (txtName.Text.Length > 0) { name = txtName.Text; } DBInt filterOnIsactive = DBInt.Null; if (cmbStatus.SelectedIndex > 0) { bool bIsActive = (cmbStatus.SelectedValue.ToString() == "1" ? true : false); filterOnIsactive = Convert.ToInt32(bIsActive); } INewsCategoryService srv = ServiceFactory.GetNewsCategoryService(); m_NewsCategoryContainer = srv.NewsCategorySelectFiltered(name, filterOnIsactive); DataTable dt = m_NewsCategoryContainer.AllAsDatatable; dt.DefaultView.Sort = sortColumn; dtgMain.DataSource = dt; // locates the row specified by ID param if (!ID.IsNull) { BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember]; DataRow dr; for (int i = 0; i < bm.Count; i++) { dr = ((DataRowView) bm.Current).Row; if (ID.Value.Equals(dr["ID"])) { selectedRow = i; break; } bm.Position += 1; } } // makes the row selected if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1) { dtgMain.Select(selectedRow); dtgMain.CurrentRowIndex = selectedRow; } else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0) { dtgMain.Select(0); } // Enabling or disabling the buttons according to record count. // And is because of previous disable state. bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0); tbbModify.Enabled = ! bIsEmptyGrid; tbbInactivate.Enabled = ! bIsEmptyGrid; } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex); } }