Example #1
0
        private void BuildDisplay()
        {
            try {
                this.Controls.Clear();
                _updatePnl = new UpdatePanel();
                _updatePnl.ChildrenAsTriggers = true;
                _updatePnl.UpdateMode         = UpdatePanelUpdateMode.Conditional;
                Table MainTable = new Table();
                MainTable.CellPadding = 2;
                MainTable.CellSpacing = 0;
                //MainTable.BorderStyle = BorderStyle.Solid;
                //MainTable.BorderWidth = Unit.Pixel(1);
                //MainTable.BorderColor = System.Drawing.Color.Gainsboro;
                MainTable.Width = Unit.Percentage(100);
                TableRow tr = new TableRow();

                TableCell td = new TableCell();
                //td.Font.Name = "tahoma,sans-serif";
                //td.Font.Size = new FontUnit(8);

                SPA.User currentUser       = new SPA.User(Context.User.Identity.Name);
                bool     IsAdmin           = currentUser.InRole(RoleType.Administrator.ToString());
                bool     IsManager         = currentUser.InRole(RoleType.Manager.ToString());
                bool     IsTrngAdmin       = currentUser.InRole(RoleType.TrngAdmin.ToString());
                bool     IsTrngCourseAdmin = TrngCourseAdmin.IsAdmin(currentUser.ID);

                DataTable courseCatalog = TrngCourse.ReleasedItems().Tables[0];
                foreach (DataRow dr in courseCatalog.Rows)
                {
                    if (TrngRecord.AssignedCourse(currentUser.ID, int.Parse(dr["ID"].ToString())))
                    {
                        dr.Delete();
                    }
                }

                _dt                  = courseCatalog;
                _dt.PrimaryKey       = new DataColumn[] { _dt.Columns["ID"] };
                _dt.DefaultView.Sort = ViewState["MyCatalogSortExpression"].ToString() + (ViewState["MyCatalogSortDirection"].ToString() == SortDirection.Ascending.ToString() ? " ASC" : " DESC");
                _gridView.DataSource = _dt;
                _gridView.DataBind();
                td.Controls.Add(_gridView);
                tr.Controls.Add(td);
                MainTable.Controls.Add(tr);
                _updatePnl.ContentTemplateContainer.Controls.Add(MainTable);
                if (IsAdmin || IsManager || IsTrngAdmin || IsTrngCourseAdmin)
                {
                    _updatePnl.ContentTemplateContainer.Controls.Add(BuildFooterTable());
                }
                this.Controls.Add(_updatePnl);
            } catch (Exception ex) {
                Error.WriteError(ex);
            }
        }
Example #2
0
        private void BuildDisplay()
        {
            try {
                this.Controls.Clear();
                _updatePnl = new UpdatePanel();
                _updatePnl.ChildrenAsTriggers = true;
                _updatePnl.UpdateMode         = UpdatePanelUpdateMode.Conditional;
                Table MainTable = new Table();
                MainTable.CellPadding = 2;
                MainTable.CellSpacing = 0;
                MainTable.Width       = Unit.Percentage(100);
                TableRow tr = new TableRow();

                TableCell td = new TableCell();

                SPA.User currentUser       = new SPA.User(Context.User.Identity.Name);
                bool     IsAdmin           = currentUser.InRole(RoleType.Administrator.ToString());
                bool     IsManager         = currentUser.InRole(RoleType.Manager.ToString());
                bool     IsUserAdmin       = currentUser.InRole(RoleType.UserAdmin.ToString());
                bool     IsTrngAdmin       = currentUser.InRole(RoleType.TrngAdmin.ToString());
                bool     IsTrngCourseAdmin = TrngCourseAdmin.IsAdmin(currentUser.ID);

                int userID          = currentUser.ID;
                int coursesAssigned = TrngRecord.Assigned(userID);

                // assign default courses
                DataView dvCourses = new DataView(TrngSetMembership.CourseSetMembershipItems(1).Tables[0]);
                foreach (DataRowView drvCourse in dvCourses)
                {
                    int        courseID = int.Parse(drvCourse["TrngCourseID"].ToString());
                    TrngCourse course   = new TrngCourse(courseID);
                    TrngRecord record   = new TrngRecord(courseID, userID);
                    record.CourseName        = course.Name;
                    record.CourseDescription = course.Description;
                    record.CourseCode        = course.Code; if (record.ID == 0)
                    {
                        record.CourseID = courseID;
                        record.UserID   = userID;
                        if (record.Insert())
                        {
                        }
                    }
                }
                // assign orggroup courses if not exempt
                if (!currentUser.ExcludeOrgTrngAssignments)
                {
                    int userOrgGroupID = SPA.User.OrgGroupID(userID);
                    dvCourses = new DataView(TrngSetMembership.CourseSetMembershipItemsByOrgGroup(userOrgGroupID).Tables[0]);
                    foreach (DataRowView drvCourse in dvCourses)
                    {
                        int        courseID = int.Parse(drvCourse["TrngCourseID"].ToString());
                        TrngCourse course   = new TrngCourse(courseID);
                        TrngRecord record   = new TrngRecord(courseID, userID);
                        record.CourseName        = course.Name;
                        record.CourseDescription = course.Description;
                        record.CourseCode        = course.Code;
                        if (record.ID == 0)
                        {
                            record.CourseID = courseID;
                            record.UserID   = userID;
                            if (record.Insert())
                            {
                            }
                        }
                    }
                }

                _dt                  = TrngRecord.CBTItems(currentUser.ID).Tables[0];
                _dt.PrimaryKey       = new DataColumn[] { _dt.Columns["ID"] };
                _dt.DefaultView.Sort = ViewState["MyTrngSortExpression"].ToString() + (ViewState["MyTrngSortDirection"].ToString() == SortDirection.Ascending.ToString() ? " ASC" : " DESC");
                _gridView.DataSource = _dt;
                _gridView.DataBind();
                td.Controls.Add(_gridView);
                tr.Controls.Add(td);
                MainTable.Controls.Add(tr);
                _updatePnl.ContentTemplateContainer.Controls.Add(MainTable);
                if (IsAdmin || IsManager || IsUserAdmin || IsTrngAdmin || IsTrngCourseAdmin)
                {
                    _updatePnl.ContentTemplateContainer.Controls.Add(BuildFooterTable());
                }
                this.Controls.Add(_updatePnl);
            } catch (Exception ex) {
                Error.WriteError(ex);
            }
        }