Exemplo n.º 1
0
        //This is the GridView of all the items in the Table
        protected override void Fill()
        {
            try {
                bool successfullyAddedDefaultCourses = false;

                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())
                        {
                            successfullyAddedDefaultCourses = true;
                        }
                    }
                }
                if (successfullyAddedDefaultCourses)
                {
                    Action.Write(string.Format("Added default training courses"), CurrentUser.DisplayName);
                }

                // assign orggroup courses if not exempt
                if (!CurrentUser.ExcludeOrgTrngAssignments)
                {
                    bool     successfullyAddedOrgGroupCourses = false;
                    int      userOrgGroupID = SPA.User.OrgGroupID(userID);
                    DataView dvGrpCourses   = new DataView(TrngSetMembership.CourseSetMembershipItems(userOrgGroupID).Tables[0]);
                    foreach (DataRowView drvCourse in dvGrpCourses)
                    {
                        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())
                            {
                                successfullyAddedOrgGroupCourses = true;
                            }
                        }
                    }
                    if (successfullyAddedOrgGroupCourses)
                    {
                        Action.Write(string.Format("Added OrgGroup training courses"), CurrentUser.DisplayName);
                    }
                }

                DataView dv = new DataView();
                gvData.EmptyDataText = Message.EMPTY_LIST_SEARCHED;
                dv               = new DataView(SPA.TrngRecord.Items(CurrentUser.ID).Tables[0]);
                dv.Sort          = (GridSortDirection == SortDirection.Ascending) ? GridSortExpression + " ASC" : GridSortExpression + " DESC";
                gvData.PageSize  = GridViewPageSize;
                gvData.PageIndex = PageIndex;
                ItemCount        = dv.Table.Rows.Count;

                if (SetupPager())
                {
                    tablePager.Visible = true;
                }
                else
                {
                    tablePager.Visible = false;
                }

                gvData.DataSource = dv;
                gvData.DataBind();
                Action.Write(string.Format("Opened UserTrainingRecord UserID: {0}, UserName: {1}", CurrentUser.ID, CurrentUser.UserName), CurrentUser.DisplayName);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 2
0
        protected void TrainingSummary()
        {
            try {
                // Define Table
                jsActionTrngRecord = string.Format("window.location.replace('{0}/{1}'); return false;", SPContext.Current.Web.Url, UserTrainingRecord.PAGE_URL);
                Table tbl = new Table();
                tbl.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'black'");
                tbl.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
                tbl.Attributes.Add("onclick", jsActionTrngRecord);
                tbl.Attributes.Add("border-collapse", "separate");
                tbl.Attributes.Add("border-spacing", "0px 0px");
                tbl.BorderStyle = BorderStyle.Solid;
                tbl.BorderWidth = Unit.Pixel(1);
                tbl.BorderColor = System.Drawing.Color.Gainsboro;
                tbl.BackColor   = System.Drawing.Color.Gainsboro;
                tbl.Width       = Unit.Pixel(250);
                tbl.Height      = Unit.Pixel(5);

                // define header
                TableRow  trHeader = new TableRow();
                TableCell tdHeader = new TableCell();
                tdHeader.VerticalAlign   = VerticalAlign.Middle;
                tdHeader.HorizontalAlign = HorizontalAlign.Left;
                tdHeader.Style.Add("padding-left", "10px");
                tdHeader.Style.Add("padding-right", "10px");
                tdHeader.Style.Add("padding-top", "2px");
                tdHeader.Style.Add("padding-bottom", "2px");
                tdHeader.Style.Add("border-top-left-radius", "4px");
                tdHeader.Style.Add("border-top-right-radius", "4px");
                trHeader.BackColor = System.Drawing.Color.FromArgb(136, 117, 52);

                // define header link
                HyperLink hlHeader = new HyperLink();
                hlHeader.Text           = "Your Training Summary";
                hlHeader.NavigateUrl    = UserTrainingRecord.PAGE_URL;
                hlHeader.ForeColor      = System.Drawing.Color.White;
                hlHeader.Font.Size      = FontUnit.Point(9);
                hlHeader.Font.Bold      = true;
                hlHeader.Font.Underline = false;

                // add header controls
                tdHeader.Controls.Add(hlHeader);
                trHeader.Controls.Add(tdHeader);

                // define body
                TableRow  trBody = new TableRow();
                TableCell tdBody = new TableCell();
                tdBody.VerticalAlign   = VerticalAlign.Top;
                tdBody.HorizontalAlign = HorizontalAlign.Left;
                tdBody.Style.Add("padding-left", "10px");
                tdBody.Style.Add("padding-right", "10px");
                tdBody.Style.Add("padding-top", "2px");
                tdBody.Style.Add("padding-bottom", "2px");
                trBody.BackColor = System.Drawing.Color.White;

                Label lblBody          = new Label();
                int   coursesAssigned  = TrngRecord.Assigned(CurrentUser.ID);
                int   coursesCompleted = TrngRecord.Completed(CurrentUser.ID);
                int   coursesDue       = TrngRecord.Due(CurrentUser.ID);
                //lblBody.Text = "<ul>";
                lblBody.Text += string.Format("<img src='/_layouts/15/images/BCCUR.GIF' />&nbsp;Courses Assigned: {0}<br>", coursesAssigned);
                lblBody.Text += string.Format("<img src='/_layouts/15/images/BCCUR.GIF' />&nbsp;Courses Completed: {0}<br>", coursesCompleted);
                lblBody.Text += string.Format("<img src='/_layouts/15/images/BCCUR.GIF' />&nbsp;Courses Due: {0}<br>", coursesDue);
                //lblBody.Text += "<ul>";
                lblBody.ForeColor = System.Drawing.Color.Black;

                Image img = new Image();
                img.ImageUrl = "/_layouts/15/images/spa/Upcoming_learning_event.png";

                // add body controls
                //tdBody.Controls.Add(img);
                tdBody.Controls.Add(lblBody);
                trBody.Controls.Add(tdBody);

                // define footer
                TableRow  trFooter = new TableRow();
                TableCell tdFooter = new TableCell();
                tdFooter.VerticalAlign   = VerticalAlign.Middle;
                tdFooter.HorizontalAlign = HorizontalAlign.Left;
                tdFooter.Style.Add("padding-left", "10px");
                tdFooter.Style.Add("padding-right", "10px");
                tdFooter.Style.Add("padding-top", "2px");
                tdFooter.Style.Add("padding-bottom", "2px");
                trFooter.BackColor = System.Drawing.Color.White;

                Label lblFooter = new Label();
                lblFooter.Text     += "Click to review your training";
                lblFooter.ForeColor = System.Drawing.Color.Black;

                // add footer controls
                tdFooter.Controls.Add(lblFooter);
                trFooter.Controls.Add(tdFooter);

                // add rows to table and table to placeholder
                tbl.Controls.Add(trHeader);
                tbl.Controls.Add(trBody);
                tbl.Controls.Add(trFooter);
                phTrngSummary.Controls.Add(tbl);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 3
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);
            }
        }