private void BindRepeaters() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("sortName", typeof(string))); DataTable dt1 = new DataTable(); dt1.Columns.Add(new DataColumn("Name", typeof(string))); dt1.Columns.Add(new DataColumn("sortName", typeof(string))); DataRow dr; ReportInfo[] _ri = rs.GetReports(); foreach (ReportInfo ri in _ri) { if (!rs.CanUserRead(Security.CurrentUser.UserID, ri.Id)) { continue; } if (ri.Name == "ProjectTime" && !Configuration.ProjectManagementEnabled) { continue; } if (ri.Type == Mediachase.IBN.Business.UserReport.UserReportType.Personal) { dr = dt.NewRow(); dr["Name"] = String.Format("<a href='{0}'>{1}</a>", ResolveUrl("~" + ri.Url), ri.ShowName); dr["sortName"] = ri.ShowName; dt.Rows.Add(dr); } else if (ri.Type == Mediachase.IBN.Business.UserReport.UserReportType.Global) { dr = dt1.NewRow(); dr["Name"] = String.Format("<a href='{0}'>{1}</a>", ResolveUrl("~" + ri.Url), ri.ShowName); dr["sortName"] = ri.ShowName; dt1.Rows.Add(dr); } } DataView dv = dt.DefaultView; dv.Sort = "sortName"; repPerc.DataSource = dv; repPerc.DataBind(); if (dv.Count == 0) { trPersReps.Visible = false; } dv = dt1.DefaultView; dv.Sort = "sortName"; repGeneral.DataSource = dv; repGeneral.DataBind(); if (dv.Count == 0) { trGenReps.Visible = false; } }
private void BindDG() { int i = 2; grdMain.Columns[i++].HeaderText = LocRM.GetString("FieldName"); grdMain.Columns[i++].HeaderText = LocRM.GetString("tIsPersonal"); grdMain.Columns[i++].HeaderText = LocRM.GetString("tCategory"); foreach (DataGridColumn dgc in grdMain.Columns) { if (dgc.SortExpression == pc["rep_Config_Sort"].ToString()) { dgc.HeaderText += String.Format(" <img border='0' align='absmiddle' width='9px' height='5px' src='{0}'/>", ResolveUrl("~/layouts/images/upbtnF.jpg")); } else if (dgc.SortExpression + " DESC" == pc["rep_Config_Sort"].ToString()) { dgc.HeaderText += String.Format(" <img border='0' align='absmiddle' width='9px' height='5px' src='{0}'/>", ResolveUrl("~/layouts/images/downbtnF.jpg")); } } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Id", typeof(int))); dt.Columns.Add(new DataColumn("Name", typeof(string))); dt.Columns.Add(new DataColumn("sortName", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("Category", typeof(string))); dt.Columns.Add(new DataColumn("CategoryId", typeof(int))); dt.Columns.Add(new DataColumn("ActionVS", typeof(string))); dt.Columns.Add(new DataColumn("Type", typeof(string))); DataRow dr; ReportInfo[] _ri = rs.GetReports(); foreach (ReportInfo ri in _ri) { if (ri.Name == "ProjectTime" && !Configuration.ProjectManagementEnabled) { continue; } dr = dt.NewRow(); dr["Id"] = ri.Id; dr["Name"] = String.Format("<a href='{0}'>{1}</a>", ResolveUrl("~" + ri.Url), ri.ShowName); dr["sortName"] = ri.ShowName; dr["Description"] = ri.Description; dr["Category"] = ((ri.Category == null) || (ri.Category.Id == 0)) ? "" : ri.Category.Name; dr["CategoryId"] = (ri.Category == null) ? 0 : ri.Category.Id; dr["ActionVS"] = String.Format("<a href=\"{0}\"><img width='16' height='16' align='absmiddle' border='0' src='{1}' title='{2}'/></a>", String.Format("javascript:FolderSecurity({0});", ri.Id), ResolveUrl("~/layouts/images/icon-key.gif"), LocRM.GetString("tSecurity")); switch (ri.Type) { case Mediachase.IBN.Business.UserReport.UserReportType.Global: dr["Type"] = LocRM.GetString("tGlobalType"); break; case Mediachase.IBN.Business.UserReport.UserReportType.Personal: dr["Type"] = LocRM.GetString("tPersonalType"); break; case Mediachase.IBN.Business.UserReport.UserReportType.Project: dr["Type"] = LocRM.GetString("tProjectType"); break; default: break; } dt.Rows.Add(dr); } DataView dv = dt.DefaultView; dv.Sort = pc["rep_Config_Sort"].ToString(); if (pc["rep_Config_PageSize"] == null) { pc["rep_Config_PageSize"] = "10"; } grdMain.PageSize = int.Parse(pc["rep_Config_PageSize"].ToString()); if (pc["rep_Config_Page"] == null) { pc["rep_Config_Page"] = "0"; } int PageIndex = int.Parse(pc["rep_Config_Page"].ToString()); int ppi = dv.Count / grdMain.PageSize; if (dv.Count % grdMain.PageSize == 0) { ppi = ppi - 1; } if (PageIndex <= ppi) { grdMain.CurrentPageIndex = PageIndex; } else { grdMain.CurrentPageIndex = 0; pc["rep_Config_Page"] = "0"; } grdMain.DataSource = dv; grdMain.DataBind(); foreach (DataGridItem dgi in grdMain.Items) { DropDownList ddl = (DropDownList)dgi.FindControl("ddCategory"); if (ddl != null) { ddl.Items.Add(new ListItem(LocRM.GetString("tNotSet"), "0")); ReportCategoryInfo[] _ci = ReportStorage.GetCategories(); foreach (ReportCategoryInfo ci in _ci) { ddl.Items.Add(new ListItem(ci.Name, ci.Id.ToString())); } } } }