Exemplo n.º 1
0
        public void AssignTraining()
        {
            try {
                string summary          = string.Format("<b><u>Results</u></b><br>");
                int    unitsProcessed   = 0;
                int    usersProcessed   = 0;
                int    coursesProcessed = 0;
                int    coursesAssigned  = 0;
                int    coursesUpdated   = 0;

                DataView dvOrgUnits = new DataView(SPA.OrgUnit.Items().Tables[0]);
                foreach (DataRowView drvOrgUnit in dvOrgUnits)
                {
                    unitsProcessed++;
                    int      orgUnitID = int.Parse(drvOrgUnit["ID"].ToString());
                    DataView dvUsers   = new DataView(SPA.User.ByOrgUnit(orgUnitID).Tables[0]);
                    foreach (DataRowView drvUser in dvUsers)
                    {
                        usersProcessed++;
                        int      userID    = int.Parse(drvUser["ID"].ToString());
                        DataView dvCourses = new DataView(TrngSetMembership.CourseSetMembershipItems(1).Tables[0]);
                        foreach (DataRowView drvCourse in dvCourses)
                        {
                            coursesProcessed++;
                            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())
                                {
                                    coursesAssigned++;
                                }
                            }
                            else
                            {
                                if (record.Update())
                                {
                                    coursesUpdated++;
                                }
                            }
                        }
                    }
                }
                btnStart.Visible      = false;
                lblErrorMessage.Text  = summary;
                lblErrorMessage.Text += string.Format("- Units Processed: {0}<br>", unitsProcessed);
                lblErrorMessage.Text += string.Format("- Users Processed: {0}<br>", usersProcessed);
                lblErrorMessage.Text += string.Format("- Courses Processed: {0}<br>", coursesProcessed);
                lblErrorMessage.Text += string.Format("- Courses Assigned: {0}<br>", coursesAssigned);
                lblErrorMessage.Text += string.Format("- Courses Updated: {0}<br>", coursesUpdated);
            } catch (Exception ex) {
                lblErrorMessage.Text = ex.ToString();
            }
        }
Exemplo n.º 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            TrngRecord trngRecord = new TrngRecord(CourseID, UserID);

            if (trngRecord.Delete())
            {
                Response.Redirect(string.Format("{0}/{1}?CourseID={2}&OrgGroupID={3}&UserID={4}", SPContext.Current.Web.Url, CourseManager.PAGE_URL, CourseID, OrgGroupID, UserID), false);
            }
        }
Exemplo n.º 3
0
        private void LookupUser()
        {
            tdItem.Visible       = true;
            lblErrorMessage.Text = string.Empty;

            try {
                SPA.User   trngUser   = new SPA.User(UserID);
                TrngRecord trngRecord = new TrngRecord(CourseID, UserID);
                TrngCourse trngCourse = new TrngCourse(trngRecord.CourseID);
                // lblErrorMessage.Text = string.Format("UserID={0}, CourseID={1}, TrngRecord.ID={2}, TrngRecord.CourseID={3}&Filter={4}", UserID, CourseID, trngRecord.ID, trngRecord.CourseID, Filter);

                if (trngRecord.ID == 0)
                {
                    tdItem.Visible      = false;
                    tdAddCourse.Visible = true;
                }
                else
                {
                    tdItem.Visible                = true;
                    tdAddCourse.Visible           = false;
                    lblDisplayNameView.Text       = trngUser.DisplayName;
                    lblCourseNameView.Text        = trngCourse.Name;
                    lblCourseDescriptionView.Text = trngCourse.Description;
                    lblCourseCodeView.Text        = trngCourse.Code;
                    txtComment.Text               = trngRecord.Comment;
                    lblTimeToCompleteView.Text    = trngRecord.TimeToComplete;


                    if (trngRecord.DateCompleted.ToString().Contains("1900"))
                    {
                        dtcCompleted.ClearSelection();
                        lblDueView.Text = string.Empty;
                    }
                    else
                    {
                        // calculate due date based on course frequency
                        dtcCompleted.SelectedDate = trngRecord.DateCompleted;
                        int      freq          = trngCourse.Frequency;
                        DateTime dateCompleted = trngRecord.DateCompleted;
                        DateTime dateDue       = dateCompleted.AddMonths(freq);
                        lblDueView.Text = dateDue.ToString("dd-MMM-yyyy");
                    }

                    lblCreatedInfo.Text    = string.Format("Created at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, trngRecord.CreatedOn), trngRecord.CreatedBy);
                    lblCreatedInfo.Visible = (trngRecord.ID != 0);
                    lblUpdatedInfo.Text    = string.Format("Last modified at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, trngRecord.ModifiedOn), trngRecord.ModifiedBy);
                    lblUpdatedInfo.Visible = (trngRecord.ID != 0);
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 4
0
 private void SetupContribute()
 {
     if (IsManager)
     {
         item = (ItemID == 0) ? new SPA.TrngRecord() : new SPA.TrngRecord(ItemID);
     }
     else
     {
         Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.MngrAccessReq), false);
     }
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        protected void btnAssign_Click(object sender, EventArgs e)
        {
            TrngRecord newRecord = new TrngRecord();
            TrngCourse course    = new TrngCourse(CourseID);

            newRecord.UserID            = UserID;
            newRecord.CourseID          = CourseID;
            newRecord.CourseName        = course.Name;
            newRecord.CourseCode        = course.Code;
            newRecord.CourseDescription = course.Description;
            newRecord.Insert();
            Response.Redirect(string.Format("{0}/{1}?CourseID={2}&OrgGroupID={3}&UserID={4}", SPContext.Current.Web.Url, CourseManager.PAGE_URL, CourseID, OrgGroupID, UserID), false);
        }
Exemplo n.º 7
0
 private void GetCourseSummary(int CourseID, int OrgGroupID)
 {
     try {
         DataView dv = new DataView();
         dv = new DataView(TrngRecord.CourseSummary(CourseID, OrgGroupID).Tables[0]);
         gvCourseSummary.DataSource = dv;
         gvCourseSummary.DataBind();
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 8
0
 private void GetCourseMetrics(int CourseID)
 {
     try {
         TrngCourse course = new TrngCourse(CourseID);
         DataView   dv     = new DataView();
         dv = new DataView(TrngRecord.CourseCompletionsByMonth(CourseID, 6).Tables[0]);
         gvCourseMetrics.DataSource = dv;
         gvCourseMetrics.DataBind();
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 9
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            TrngRecord rec        = new TrngRecord(RecordID);
            int        recordID   = rec.ID;
            string     courseName = rec.CourseName;
            string     userName   = new User(rec.UserID).DisplayName;

            if (rec.Delete())
            {
                Action.Write(string.Format("Deleted {0} course for {1}", courseName, userName), CurrentUser.DisplayName);
            }
            else
            {
                Action.Write(string.Format("Failed to deleted {0} course for {1}, Check Error Log", courseName, userName), CurrentUser.DisplayName);
            }
            OpenTrainingRecord();
        }
Exemplo n.º 10
0
        protected void EditTrainingRecord()
        {
            tdHeader.Visible          = true;
            tdList.Visible            = false;
            tdItem.Visible            = true;
            lblErrorMessage.Text      = string.Empty;
            lblCompletedError.Visible = false;
            try {
                TrngRecord item = new TrngRecord(RecordID);
                lblCourseNameView.Text        = item.CourseName;
                lblCourseDescriptionView.Text = item.CourseDescription;
                lblCourseCodeView.Text        = item.CourseCode;
                txtComment.Text            = item.Comment;
                lblTimeToCompleteView.Text = item.TimeToComplete;


                if (item.DateCompleted.ToString().Contains("1900"))
                {
                    dtcCompleted.ClearSelection();
                    lblDueView.Text = string.Empty;
                }
                else
                {
                    // calculate due date based on course frequency
                    dtcCompleted.SelectedDate = item.DateCompleted;
                    TrngCourse crs           = new TrngCourse(item.CourseID);
                    int        freq          = crs.Frequency;
                    DateTime   dateCompleted = item.DateCompleted;
                    DateTime   dateDue       = dateCompleted.AddMonths(freq);
                    lblDueView.Text = dateDue.ToString("dd-MMM-yyyy");
                }

                lblCreatedInfo.Text    = string.Format("Created at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, item.CreatedOn), item.CreatedBy);
                lblCreatedInfo.Visible = (item.ID != 0);
                lblUpdatedInfo.Text    = string.Format("Last modified at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, item.ModifiedOn), item.ModifiedBy);
                lblUpdatedInfo.Visible = (item.ID != 0);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 11
0
        protected override void Fill()
        {
            try {
                bool isView = (IView == ItemView.View);
                bool isNew  = (IView == ItemView.New);
                item = new TrngRecord(ItemID);
                lblCourseNameView.Text        = item.CourseName;
                lblCourseDescriptionView.Text = item.CourseDescription;
                lblCourseCodeView.Text        = item.CourseCode;
                lblCommentView.Text           = item.Comment;
                lblTimeToCompleteView.Text    = item.TimeToComplete;
                lblCompletedView.Text         = item.DateCompleted.ToString();

                if (lblCompletedView.Text.Contains("1900"))
                {
                    lblCompletedView.Text = "AWACT";
                    lblDueView.Text       = string.Empty;
                    trTTC.Visible         = false;
                }
                else
                {
                    TrngCourse crs           = new TrngCourse(item.CourseID);
                    int        freq          = crs.Frequency;
                    DateTime   dateCompleted = item.DateCompleted;
                    DateTime   dateDue       = dateCompleted.AddMonths(freq);
                    lblDueView.Text = dateDue.ToString("dd-MMM-yyyy");
                }
                lblCreatedInfo.Text    = string.Format("Created at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, item.CreatedOn), item.CreatedBy);
                lblCreatedInfo.Visible = (item.ID != 0);
                lblUpdatedInfo.Text    = string.Format("Last modified at {0} by {1}", SPA.Common.ConvertUTCToWebLocalTime(this.Web, item.ModifiedOn), item.ModifiedBy);
                lblUpdatedInfo.Visible = (item.ID != 0);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 12
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                bool isUpdate = (IView == ItemView.Edit);
                item = (isUpdate) ? new SPA.TrngRecord(ItemID) : new SPA.TrngRecord();
                //item.Name = txtName.Text.Trim();
                //item.Description = txtDescription.Text.Trim();
                //item.Expiration = dtcExpiration.SelectedDate;
                item.ModifiedBy = CurrentUser.DisplayName;

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }
Exemplo n.º 13
0
        //protected void TrngOrgAdminSummary() {
        //    try {
        //        if (IsTrngAdmin || IsAdmin || TrngOrgAdmin.IsAdmin(CurrentUser.ID)) {
        //            // Define Table
        //            jsActionTrngRecord = string.Format("window.location.replace('{0}/{1}'); return false;", SPContext.Current.Web.Url, OrgTrngDashboard.PAGE_URL);
        //            Table tblCourse = new Table();
        //            tblCourse.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'black'");
        //            tblCourse.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
        //            tblCourse.Attributes.Add("onclick", jsActionTrngRecord);
        //            tblCourse.Attributes.Add("border-collapse", "separate");
        //            tblCourse.Attributes.Add("border-spacing", "0px 0px");
        //            tblCourse.BorderStyle = BorderStyle.Solid;
        //            tblCourse.BorderWidth = Unit.Pixel(1);
        //            tblCourse.BorderColor = System.Drawing.Color.Gainsboro;
        //            tblCourse.BackColor = System.Drawing.Color.Gainsboro;
        //            tblCourse.Width = Unit.Pixel(250);
        //            tblCourse.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 = "Organizational Training Manager for";
        //            hlHeader.NavigateUrl = OrgTrngDashboard.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();
        //            DataView dv = new DataView();
        //            if (IsTrngAdmin || IsAdmin) {
        //                dv = new DataView(SPA.OrgGroup.Items().Tables[0]);
        //            } else {
        //                dv = new DataView(SPA.TrngOrgAdmin.Memberships(CurrentUser.ID, false).Tables[0]);
        //            }
        //            foreach (DataRowView drv in dv) {
        //                lblBody.Text += string.Format("<img src='/_layouts/15/images/BCCUR.GIF' />&nbsp;{0}<br>", drv["Name"].ToString());
        //            }
        //            lblBody.ForeColor = System.Drawing.Color.Black;

        //            // add body controls
        //            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 manage organizational 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
        //            tblCourse.Controls.Add(trHeader);
        //            tblCourse.Controls.Add(trBody);
        //            tblCourse.Controls.Add(trFooter);
        //            phTrngOrgSummary.Controls.Add(tblCourse);
        //        }
        //    } catch (Exception ex) {
        //        SPA.Error.WriteError(ex);
        //        if (ShowDebug)
        //            lblErrorMessage.Text = ex.ToString();
        //    }

        //}
        protected void OrgTrainingSummary()
        {
            try {
                // Define Table
                jsActionTrngRecord = string.Format("window.location.replace('{0}/{1}'); return false;", SPContext.Current.Web.Url, OrgTrngDashboard.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           = "Organizationl Training Summary (Inwork)";
                hlHeader.NavigateUrl    = OrgTrngDashboard.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();
                DataView dv      = new DataView();
                if (CurrentUser.InRole("TrngAdmin") || CurrentUser.InRole("TrngAuditor"))
                {
                    dv = new DataView(SPA.OrgGroup.Items().Tables[0]);
                }
                else
                {
                    dv = new DataView(SPA.User.OrgGroupAdminMemberships(CurrentUser.ID, false).Tables[0]);
                }
                foreach (DataRowView drv in dv)
                {
                    lblBody.Text += string.Format("<img src='/_layouts/15/images/BCCUR.GIF' />&nbsp;{0}<br>", drv["Name"].ToString());
                    int OrgGroupID   = Int32.Parse(drv["OrgID"].ToString());
                    int userCount    = OrgGroup.UserCount(OrgGroupID);
                    int currentCount = 0;
                    int dueCount     = TrngRecord.DueByOrgGroupCount(OrgGroupID);
                    int awactCount   = 0;

                    lblBody.Text += string.Format("&nbsp;&nbsp;&nbsp;<img src='/_layouts/15/images/greybullet.gif' />&nbsp;Users: {0}<br>", userCount);
                    lblBody.Text += string.Format("&nbsp;&nbsp;&nbsp;<img src='/_layouts/15/images/greybullet.gif' />&nbsp;Current: {0}<br>", currentCount);
                    lblBody.Text += string.Format("&nbsp;&nbsp;&nbsp;<img src='/_layouts/15/images/greybullet.gif' />&nbsp;Due/Overdue: {0}<br>", dueCount);
                    lblBody.Text += string.Format("&nbsp;&nbsp;&nbsp;<img src='/_layouts/15/images/greybullet.gif' />&nbsp;Awaiting Action: {0}<br>", awactCount);
                }
                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 view trends";
                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);
                phOrgTrngSummary.Controls.Add(tbl);
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 14
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);
            }
        }
Exemplo n.º 15
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.º 16
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool save = false;

            lblCompletedError.Text = string.Empty;
            TrngRecord trngRecord    = new TrngRecord(CourseID, UserID);
            string     DateCompleted = ((TextBox)this.dtcCompleted.Controls[0]).Text;

            if (DateCompleted.Length > 0)
            {
                if (Common.IsDate(DateCompleted))
                {
                    DateTime newDate = DateTime.Parse(DateCompleted);
                    if (newDate > trngRecord.DateCompleted)
                    {
                        if (newDate > DateTime.Now.AddDays(1))
                        {
                            lblCompletedError.Text = "<br>Completed date must be today or previous date.";
                        }
                        else
                        {
                            // not a future date, so ok
                            save = true;
                        }
                    }
                    else
                    {
                        // older than previously recorded
                        save = true;
                    }
                }
                else
                {
                    lblCompletedError.Text = "<br/>The value of this field must be a valid date.";
                }
                lblErrorMessage.Text += save.ToString();
            }
            else
            {
                save = true;
            }
            if (save)
            {
                DateTime completedDate;
                if (String.IsNullOrWhiteSpace(DateCompleted))
                {
                    completedDate = new DateTime(1900, 1, 1);
                }
                else
                {
                    completedDate = Convert.ToDateTime(DateCompleted);
                }
                trngRecord.DateCompleted = completedDate;
                trngRecord.ModifiedBy    = CurrentUser.DisplayName;
                trngRecord.Comment       = Common.HtmlEncode(txtComment.Text);
                if (trngRecord.Update())
                {
                    Response.Redirect(string.Format("{0}/{1}?CourseID={2}&OrgGroupID={3}&UserID={4}", SPContext.Current.Web.Url, CourseManager.PAGE_URL, CourseID, OrgGroupID, UserID), false);
                }
            }
            else
            {
                lblCompletedError.Visible = true;
            }
        }
Exemplo n.º 17
0
        protected void OpenTrainingRecord()
        {
            lblErrorMessage.Text = string.Empty;
            try {
                tdHeader.Visible = true;
                tdList.Visible   = true;
                tdItem.Visible   = false;

                lblMembershipHeader.Text = string.Format("Training Record: {0} ({1})", new SPA.User(UserID).DisplayName, UserID);
                DataView dv = new DataView();


                // 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 (!new SPA.User(UserID).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())
                            {
                            }
                        }
                    }
                }

                gvData.EmptyDataText = Message.EMPTY_LIST_SEARCHED;
                dv = new DataView(SPA.TrngRecord.Items(UserID).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.º 18
0
        protected void btnAssignTraining_Click(object sender, EventArgs e)
        {
            try {
                this.DateCompleted = ((TextBox)this.dtcCompleted.Controls[0]).Text;
                if (ValidateRequiredFields())
                {
                    lblInvalidCourse.CssClass        = string.Empty;
                    lblInvalidCourse.Visible         = false;
                    lblInvalidCompletedDate.CssClass = string.Empty;
                    lblInvalidCompletedDate.Visible  = false;

                    string deniedUsers  = string.Empty;
                    string skippedUsers = string.Empty;

                    ArrayList usersOffLimits = new ArrayList();
                    ArrayList usersPreviouslyAssignedTraining = new ArrayList();

                    TrngCourse course      = new TrngCourse(int.Parse(ddlCourse.SelectedValue));
                    DateTime   retiredDate = DateTime.UtcNow;
                    DateTime   completedDate;

                    if (String.IsNullOrWhiteSpace(this.DateCompleted))
                    {
                        completedDate = new DateTime(1900, 1, 1);
                    }
                    else
                    {
                        completedDate = Convert.ToDateTime(this.DateCompleted);
                    }
                    foreach (ListItem trainee in lbxTrainees.Items)
                    {
                        User       user       = new User(int.Parse(trainee.Value));
                        TrngRecord trngRecord = new TrngRecord(course.ID, user.ID);
                        trngRecord.CourseID          = course.ID;
                        trngRecord.UserID            = user.ID;
                        trngRecord.DateCompleted     = completedDate;
                        trngRecord.CourseName        = course.Name;
                        trngRecord.CourseDescription = course.Description;
                        trngRecord.Comment           = Common.HtmlEncode(txtComment.Text);
                        trngRecord.CourseCode        = course.Code;
                        trngRecord.ModifiedBy        = CurrentUser.DisplayName;
                        trngRecord.CreatedBy         = CurrentUser.DisplayName;

                        if (trngRecord.ID != 0)
                        {
                            trngRecord.Update();
                        }
                        else
                        {
                            trngRecord.Insert();
                        }

                        //bool mayEdit = true; // TODO evaluate to determine if the current user has permissions to add/edit training for the user

                        //if (mayEdit) {
                        //    if (course.TrackHistory) {
                        //        trngRecord.Insert();
                        //    } else {
                        //        // does user already have a record for this course
                        //        // if not insert
                        //        // else update

                        //    }
                        //} else {
                        //    // capture permission issue for reporting
                        //}
                    }
                    lbxTrainees.Items.Clear();
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
            }
        }
Exemplo n.º 19
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.º 20
0
        protected void btnNext_Click(object sender, EventArgs e)
        {
            try {
                bool bContinue = true;
                lblWrong.Visible = false;
                TrngCourse course = new TrngCourse(CourseID);
                if (!rbtnlAnswers.SelectedValue.IsNullOrWhiteSpace())
                {
                    // answer selected
                    SPA.TrngAnswer answer = new SPA.TrngAnswer(int.Parse(rbtnlAnswers.SelectedValue.ToString()));
                    if (answer.IsCorrect)
                    {
                        // add 1 to correct answer count
                        Session["QuestionsCorrect"] = int.Parse(Session["QuestionsCorrect"].ToString()) + 1;
                        //lblErrorMessage.Text = "Correct Answers: " + Session["QuestionsCorrect"].ToString();
                        bContinue = true;
                    }
                    else
                    {
                        // do not add 1 to correct answer count
                        //lblErrorMessage.Text = "Correct Answers: " + Session["QuestionsCorrect"].ToString();
                        if (course.IsGraded)
                        {
                            bContinue = true;
                        }
                        else
                        {
                            bContinue        = false;
                            lblWrong.Text    = "Answer Wrong! Try Again!<br>";
                            lblWrong.Visible = true;
                        }
                    }
                }
                else if (rbtnlAnswers.SelectedIndex == -1 && trQuestion.Visible)
                {
                    bContinue        = false;
                    lblWrong.Visible = true;
                    lblWrong.Text    = "You Must Select an Answer! Try Again!<br>";
                }

                if (btnNext.Text == "Finish" && bContinue)   // on last step
                {
                    btnNext.Visible     = false;
                    btnPrevious.Visible = false;
                    trContent.Visible   = false;
                    trQuestion.Visible  = false;
                    trFinished.Visible  = true;

                    TrngRecord userRecord = new TrngRecord(CourseID, CurrentUser.ID);

                    string courseDuration = BuildDurationString(DateTime.Now);
                    userRecord.CourseName        = course.Name;
                    userRecord.CourseDescription = course.Description;
                    userRecord.CourseCode        = course.Code;
                    userRecord.DateCompleted     = DateTime.Now;
                    userRecord.TimeToComplete    = courseDuration;

                    // if course graded, check score for passing
                    bool completeCourse = true;
                    //lblErrorMessage.Text = "Finish - Correct Answers: " + Session["QuestionsCorrect"].ToString() + " Course Graded: " + course.IsGraded.ToString();
                    if (course.IsGraded)
                    {
                        int    questionCorrect = int.Parse(Session["QuestionsCorrect"].ToString());
                        int    minimumScore    = course.MinimumScore;
                        int    questionCount   = TrngCourse.QuestionCount(course.ID);
                        double score           = (double)questionCorrect / questionCount * 100;
                        //lblErrorMessage.Text += string.Format("</br> Correct: {0}, Minimum Score: {1}, Total Questions: {2}, Score: {3}", questionCorrect, minimumScore, questionCount, score);
                        if (score < minimumScore)
                        {
                            completeCourse = false;
                            Action.Write(string.Format("<font color='red'>Score of {0} <b>failed to meet minimum score</b> of {1} for {2}</font>", score, minimumScore, course.Name), CurrentUser.DisplayName);
                            lblFinished.Text    = string.Format("You failed to meet the minimum score and will need to reaccomplish the course!</br>Your score was {0}% and the minimum score to pass is {1}%</br></br>Select Close to return to your training record.", score, minimumScore);
                            btnClose.Visible    = true;
                            btnNext.Visible     = false;
                            btnPrevious.Visible = false;
                        }
                    }
                    if (completeCourse)
                    {
                        if (userRecord.ID != 0)
                        {
                            userRecord.ModifiedBy = CurrentUser.DisplayName;

                            if (userRecord.Update())
                            {
                                Action.Write(string.Format("Completed Course: {0}", course.Name), CurrentUser.DisplayName);
                                lblFinished.Text    = "Course completed and updated successfully!</br></br>Select Close to return to your training record.";
                                btnClose.Visible    = true;
                                btnNext.Visible     = false;
                                btnPrevious.Visible = false;
                            }
                            else
                            {
                                // record failure and send email to admins to investigate
                                Action.Write(string.Format("Course Failed to Finish: {0}", course.Name), CurrentUser.DisplayName);
                                lblFinished.Text    = "Course completion failed to update successfully!</br></br>The failure has been reported to the application administrators";
                                btnClose.Visible    = true;
                                btnNext.Visible     = false;
                                btnPrevious.Visible = false;
                            }
                        }
                        else
                        {
                            userRecord.CourseID   = course.ID;
                            userRecord.UserID     = CurrentUser.ID;
                            userRecord.CreatedBy  = CurrentUser.DisplayName;
                            userRecord.ModifiedBy = CurrentUser.DisplayName;
                            if (userRecord.Insert())
                            {
                                Action.Write(string.Format("Completed Course: {0}", course.Name), CurrentUser.DisplayName);
                                lblFinished.Text    = "Course completed and assigned successfully!</br></br>Select Close to return to your training record.";
                                btnClose.Visible    = true;
                                btnNext.Visible     = false;
                                btnPrevious.Visible = false;
                            }
                            else
                            {
                                // record failure and send email to admins to investigate
                                Action.Write(string.Format("Course Failed to Finish: {0}", course.Name), CurrentUser.DisplayName);
                                lblFinished.Text    = "Course failed to assign successfully!</br></br>The failure has been reported to the application administrators";
                                btnClose.Visible    = true;
                                btnNext.Visible     = false;
                                btnPrevious.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    if (bContinue)
                    {
                        SlideNumber++;
                        BuildSlide(CourseID, SlideNumber);
                    }
                }
                if (course.IsGraded)
                {
                    btnPrevious.Enabled = false;
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }