Exemplo n.º 1
0
 private void FillCourses()
 {
     try {
         DataSet ds = new DataSet();
         if (IsAdmin || IsTrngAdmin)
         {
             ds = TrngCourse.Items();
         }
         else
         {
             ds = TrngCourse.CourseAdminItems(CurrentUser.ID);
         }
         DataView dv = new DataView(ds.Tables[0]);
         dv.Sort = "Name";
         ddlCourse.DataSource     = dv;
         ddlCourse.DataTextField  = "Name";
         ddlCourse.DataValueField = "ID";
         ddlCourse.DataBind();
         ddlCourse.Items.Insert(0, new ListItem("-- Select --", "0"));
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 2
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.º 3
0
        private void SetupContribute()
        {
            //if (IsTrngAdmin) {
            item = (ItemID == 0) ? new SPA.TrngCourse() : new SPA.TrngCourse(ItemID);
            //} else {
            //    Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.TrainingAdminAccessReq), false);

            //}
        }
Exemplo n.º 4
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.º 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
        protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try {
                switch (e.Row.RowType)
                {
                case DataControlRowType.DataRow:
                    e.Row.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'White'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
                    e.Row.Attributes["style"] = "cursor:pointer";

                    Label       lblItemID       = (Label)e.Row.FindControl("lblItemID");
                    int         id              = int.Parse(lblItemID.Text);
                    ImageButton ibtnEdit        = (ImageButton)e.Row.FindControl("ibtnEdit");
                    LinkButton  lbtnName        = (LinkButton)e.Row.FindControl("lbtnName");
                    Label       lblCompleted    = (Label)e.Row.FindControl("lblCompleted");
                    Label       lblDue          = (Label)e.Row.FindControl("lblDue");
                    Label       lblTrngCourseID = (Label)e.Row.FindControl("lblCourseID");
                    int         slideCnt        = TrngCourse.SlideCount(int.Parse(lblTrngCourseID.Text));

                    if (!lblCompleted.Text.Contains("1900"))
                    {
                        TrngCourse crs      = new TrngCourse(int.Parse(lblTrngCourseID.Text));
                        int        freq     = crs.Frequency;
                        DateTime   compDate = DateTime.Parse(lblCompleted.Text);
                        DateTime   dueDate  = compDate.AddMonths(freq);
                        lblDue.Text = dueDate.ToString("dd-MMM-yyyy");
                        if (freq == 0)
                        {
                            lblDue.Text = string.Empty;
                        }
                    }
                    else
                    {
                        lblCompleted.Text = "AWACT";
                        lblDue.Text       = string.Empty;
                    }
                    int rowID = int.Parse(lbtnName.CommandArgument.ToString());
                    break;

                case DataControlRowType.Header:
                    SetupSort(gvData, e);
                    break;
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 8
0
 protected override void Fill()
 {
     try {
         TrngCourse course = new TrngCourse(CourseID);
         lblCourseView.Text = course.Name;
         Action.Write(string.Format("Opened Slide Quick Build"), CurrentUser.DisplayName);
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 9
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.º 10
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                bool isUpdate = (IView == ItemView.Edit);
                item             = (isUpdate) ? new SPA.TrngSlide(ItemID) : new SPA.TrngSlide();
                item.CourseID    = CourseID;
                item.Name        = txtName.Text.Trim();
                item.Description = txtDescription.Text.Trim();
                item.ContentURL  = txtContentURL.Text.Trim();
                item.RichText    = txtRichText.Text.Trim();
                item.SlideTypeID = int.Parse(ddlSlideType.SelectedItem.Value);
                item.IsActive    = cbIsActive.Checked;
                item.ModifiedBy  = CurrentUser.DisplayName;
                if (item.Number == 0)
                {
                    item.Number = TrngCourse.SlideCount(CourseID) + 1;
                }

                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        Action.Write(string.Format("Inserted Slide ID: {0}, Name: {1}", item.ID, item.Name), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        Action.Write(string.Format("Updated Slide ID: {0}, Name: {1}", item.ID, item.Name), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }
Exemplo n.º 11
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                // verify valid values
                if (!Common.IsNumeric(txtNumberOfSlides.Text.Trim()))
                {
                    txtNumberOfSlides.Text = "0";
                }
                if (!Common.IsNumeric(txtStartingNumber.Text.Trim()))
                {
                    txtNumberOfSlides.Text = "1";
                }
                // create a slide for number of slides
                TrngCourse course         = new TrngCourse(CourseID);
                int        slidesToCreate = int.Parse(txtNumberOfSlides.Text);
                int        startingNumber = int.Parse(txtStartingNumber.Text);

                for (int i = 0; i < slidesToCreate; i++)
                {
                    TrngSlide slide = new TrngSlide();
                    slide.CourseID    = CourseID;
                    slide.Name        = string.Format("Slide {0}", startingNumber);
                    slide.Description = "";
                    slide.Number      = TrngCourse.SlideCount(CourseID) + 1;
                    slide.ContentURL  = string.Format("{0}{1}.png", txtContentURL.Text.Trim(), startingNumber);
                    slide.SlideTypeID = 1;
                    slide.IsActive    = true;
                    slide.ModifiedBy  = CurrentUser.DisplayName;
                    if (slide.Insert())
                    {
                        Action.Write(string.Format("AutoGenerated a slide [{0}] for {1}", slide.ContentURL, course.Name), CurrentUser.DisplayName);
                    }
                    startingNumber++;
                }
                success = true;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text += "<br>" + ex.ToString();
                }
            }
            return(success);
        }
Exemplo n.º 12
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.º 13
0
 private void FillCourses()
 {
     try {
         lbxCourses.Items.Clear();
         DataSet  ds = TrngCourse.Items();
         DataView dv = new DataView(ds.Tables[0]);
         dv.Sort = "Name";
         lbxCourses.DataSource     = dv;
         lbxCourses.DataTextField  = "Name";
         lbxCourses.DataValueField = "ID";
         lbxCourses.DataBind();
     } catch (Exception ex) {
         SPA.Error.WriteError(ex);
         if (ShowDebug)
         {
             lblErrorMessage.Text = ex.ToString();
         }
     }
 }
Exemplo n.º 14
0
        protected override void Fill()
        {
            // if the course number does not exist, them bad course
            TrngCourse course = new TrngCourse(CourseID);

            Session["CourseID"]         = course.ID.ToString();
            Session["QuestionsCorrect"] = 0;
            //lblErrorMessage.Text += "Correct Answers: " + Session["QuestionsCorrect"].ToString();
            if (course.ID == 0)
            {
                Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.TrainingCourseInvalid), false);
            }
            else if (TrngSlide.ActiveCount(CourseID) == 0)
            {
                Response.Redirect(string.Format("{0}/{1}?code={2}", SPContext.Current.Web.Url, Message.URL_USERMESSAGE, Message.Code.TrainingSlideCountZero), false);
            }
            else
            {
                Action.Write(string.Format("Started Course: {0}", course.Name), CurrentUser.DisplayName);
                BuildSlide(CourseID, SlideNumber);
            }
        }
Exemplo n.º 15
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.º 16
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.º 17
0
        protected void _gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'Black'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
                    e.Row.Attributes["style"] = "cursor:pointer";

                    Label      lblDateCompleted = new Label();
                    Label      lblDateDue       = new Label();
                    Label      lblBlank         = new Label();
                    Image      imgStatus        = new Image();
                    HyperLink  hlCourselink     = new HyperLink();
                    HyperLink  hlCourse         = new HyperLink();
                    LinkButton lbtnCourse       = new LinkButton();
                    LinkButton lbtnCBT          = new LinkButton();

                    ImageButton ibtnCert = new ImageButton();
                    ibtnCert.AlternateText = "Print Certificate";
                    ibtnCert.ToolTip       = "Print Certificate";
                    ibtnCert.ImageUrl      = "_layouts/15/images/spa/cer16.gif";
                    ibtnCert.CommandName   = "print";

                    string  ID      = _gridView.DataKeys[e.Row.RowIndex].Value.ToString();
                    DataRow dr      = _dt.Rows.Find(ID);
                    string  certUrl = string.Format("{0}/{1}?RecordID={2}", SPContext.Current.Web.Url, Pages.CourseCertificate.PAGE_URL, ID);
                    ibtnCert.OnClientClick = "openModalDialog('Certificate of Completion', '" + certUrl + "'); return false;";

                    // attempt to create a link to the completion certificate
                    e.Row.Cells[0].Controls.Clear();
                    if (!dr["DateCompleted"].ToString().Contains("1900"))
                    {
                        e.Row.Cells[0].Controls.Add(ibtnCert);
                    }
                    else
                    {
                        e.Row.Cells[0].Controls.Add(lblBlank);
                    }

                    // attempt to create course name link to user record for editing
                    try {
                        hlCourse.Text        = dr["CourseName"].ToString();
                        hlCourse.ForeColor   = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                        hlCourse.NavigateUrl = string.Format("{0}/{1}?View=View&ID={2}", SPContext.Current.Web.Url, "_layouts/15/spa/pages/UserTrainingRecordItem.aspx", ID);

                        string urlView = string.Format("{0}/{1}?View=View&ID={2}", SPContext.Current.Web.Url, Pages.UserTrainingRecordItem.PAGE_URL, ID);
                        lbtnCourse.Text          = dr["CourseName"].ToString();
                        lbtnCourse.OnClientClick = "openModalDialog('" + string.Format("Course: {0}", dr["CourseName"].ToString()) + "', '" + urlView + "'); return false;";
                        lbtnCourse.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                    } catch {
                        lbtnCourse.Text = "Error Rendering Course Name";
                    } finally {
                        e.Row.Cells[1].Controls.Clear();
                        e.Row.Cells[1].Controls.Add(lbtnCourse);
                    }
                    // attempt to display the completed date
                    try {
                        if (dr["DateCompleted"].ToString().Contains("1900"))
                        {
                            lblDateCompleted.Text = "&nbsp;&nbsp;&nbsp;AWACT";
                        }
                        else
                        {
                            lblDateCompleted.Text = "&nbsp;&nbsp;&nbsp;" + DateTime.Parse(dr["DateCompleted"].ToString()).ToString("MMMM dd, yyyy");
                        }
                    } catch {
                        lblDateCompleted.Text = "&nbsp;&nbsp;&nbsp;Error Rendering Date";
                    } finally {
                        e.Row.Cells[2].Controls.Clear();
                        e.Row.Cells[2].Controls.Add(lblDateCompleted);
                    }


                    // attempt to display the correctly calculated due date
                    try {
                        lblDateDue.Text = string.Empty;
                        if ((int.Parse(dr["Frequency"].ToString()) != 0) && (!dr["DateCompleted"].ToString().Contains("1900")))
                        {
                            if (dr["DateDue"].ToString().Contains("1900"))
                            {
                                lblDateDue.Text = "&nbsp;&nbsp;&nbsp;" + DateTime.Parse(dr["DateCompleted"].ToString()).AddMonths(int.Parse(dr["Frequency"].ToString())).ToString("MMMM dd, yyyy");
                            }
                            else
                            {
                                lblDateDue.Text = "&nbsp;&nbsp;&nbsp;" + DateTime.Parse(dr["DateDue"].ToString()).ToString("MMMM dd, yyyy");
                            }
                        }
                    } catch {
                        lblDateDue.Text = "&nbsp;&nbsp;&nbsp;Error Rendering Date";
                    } finally {
                        e.Row.Cells[3].Controls.Clear();
                        e.Row.Cells[3].Controls.Add(lblDateDue);
                    }
                    // attempt to display the correct image that reflects the current status
                    try {
                        if (dr["DateCompleted"].ToString().Contains("1900"))
                        {
                            // if training has never been completed it will always show as awaiting action
                            imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                            imgStatus.ToolTip  = "AWACT";
                        }
                        else
                        {
                            if (int.Parse(dr["Frequency"].ToString()) == 0)
                            {
                                // a frequency of zero means the training never needs to be reaccomplished
                                imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                imgStatus.ToolTip  = "Current";
                            }
                            else
                            {
                                if (dr["DateDue"].ToString().Contains("1900"))
                                {
                                    // due date calculated from completion date and frequency
                                    DateTime calcNextDue = DateTime.Parse(dr["DateCompleted"].ToString()).AddMonths(int.Parse(dr["Frequency"].ToString()));
                                    TimeSpan timeSpan    = calcNextDue.Subtract(DateTime.UtcNow);
                                    if (timeSpan.Days < 0)
                                    {
                                        // training overdue
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/red.gif";
                                        imgStatus.ToolTip  = "Overdue";
                                    }
                                    else if (timeSpan.Days > 90)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Current";
                                    }
                                    else if (timeSpan.Days > 30 && timeSpan.Days < 91)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Due within 90 days";
                                    }
                                    else if (timeSpan.Days >= 0 && timeSpan.Days < 31)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                                        imgStatus.ToolTip  = "Due within 30 days";
                                    }
                                }
                                else
                                {
                                    DateTime nextDue  = DateTime.Parse(dr["DateDue"].ToString());
                                    TimeSpan timeSpan = nextDue.Subtract(DateTime.UtcNow);
                                    if (timeSpan.Days < 0)
                                    {
                                        // training overdue
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/red.gif";
                                        imgStatus.ToolTip  = "Overdue";
                                    }
                                    else if (timeSpan.Days > 90)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Current";
                                    }
                                    else if (timeSpan.Days > 30 && timeSpan.Days < 91)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Due within 90 days";
                                    }
                                    else if (timeSpan.Days >= 0 && timeSpan.Days < 31)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                                        imgStatus.ToolTip  = "Due within 30 days";
                                    }
                                }
                            }
                        }
                    } catch {
                        imgStatus.ImageUrl = "/_layouts/15/images/ewr218m.gif";
                    } finally {
                        e.Row.Cells[4].Controls.Clear();
                        e.Row.Cells[4].Controls.Add(imgStatus);
                    }
                    // attempt to display the course URL
                    try {
                        int        courseID = int.Parse(dr["CourseID"].ToString());
                        TrngCourse course   = new TrngCourse(courseID);
                        lbtnCBT.Text = "Start Course";
                        string url = string.Empty;
                        lbtnCBT.Visible = false;

                        // if the course is not external, has slides, and is released, show link
                        if (course.IsCBT && TrngCourse.SlideCount(course.ID) > 0)
                        {
                            lbtnCBT.Visible       = true;
                            url                   = string.Format("{0}/{1}?courseid={2}&IsDlg=1", SPContext.Current.Web.Url, Pages.Course.PAGE_URL, courseID);
                            lbtnCBT.OnClientClick = "openModalDialog('CBT Viewer', '" + url + "'); return false;";
                            lbtnCBT.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                        }
                        // if course is external and released, show link.
                        if (course.IsCBT && course.IsExternal)
                        {
                            lbtnCBT.Visible = true;
                            string jsActionStartCourse = string.Format("window.location.replace('{0}'); return false;", course.ExternalURL.Trim().ToLower());
                            //url = string.Format("openModalDialog('{0}','{1}?courseid={2}', 'true'); return false;", "CBT Viewer", course.ExternalURL.Trim(), courseID);
                            url = string.Format("window.location.replace('{0}'); return false;", course.ExternalURL.Trim().ToLower());
                            lbtnCBT.OnClientClick = url;
                            lbtnCBT.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                        }
                    } catch (Exception ex) {
                        Error.WriteError("UserTraining", "GridViewRowDataBound", ex);
                    } finally {
                        e.Row.Cells[5].Controls.Clear();
                        e.Row.Cells[5].Controls.Add(lbtnCBT);
                    }
                }

                if (e.Row.RowType == DataControlRowType.Header)
                {
                    foreach (DataControlField field in _gridView.Columns)
                    {
                        TableCell td = e.Row.Cells[_gridView.Columns.IndexOf(field)];
                        td.Attributes["style"] = "border-bottom:1px solid gray;";
                        Label completed = new Label();
                        completed.Text = "&nbsp;&nbsp;&nbsp;Completed";
                        e.Row.Cells[2].Controls.Clear();
                        e.Row.Cells[2].Controls.Add(completed);
                        Label due = new Label();
                        due.Text = "&nbsp;&nbsp;&nbsp;Due";
                        e.Row.Cells[3].Controls.Clear();
                        e.Row.Cells[3].Controls.Add(due);

                        if (field.SortExpression != string.Empty)
                        {
                            //Add tooltips to headers
                            td.ToolTip = "Sort by " + field.HeaderText;

                            //Override width attibute from in style class
                            td.Style.Add(HtmlTextWriterStyle.Width, "Auto");

                            if (Page.IsPostBack)
                            {
                                //Add appropriate sort image to sorted column
                                if (field.SortExpression == ViewState["MyTrngSortExpression"].ToString())
                                {
                                    Image sortImage = new Image();
                                    if ((SortDirection)ViewState["MyTrngSortDirection"] == SortDirection.Descending)
                                    {
                                        sortImage.ImageUrl = SPContext.Current.Site.RootWeb.Url + "/_layouts/15/images/spa/rsort.gif";
                                        sortImage.ToolTip  = "Sort Descending";
                                    }
                                    else
                                    {
                                        sortImage.ImageUrl = SPContext.Current.Site.RootWeb.Url + "/_layouts/15/images/spa/sort.gif";
                                        sortImage.ToolTip  = "Sort Ascending";
                                    }
                                    td.Controls.Add(sortImage);
                                }
                            }
                        }
                    }
                }

                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    foreach (DataControlField field in _gridView.Columns)
                    {
                        TableCell td = e.Row.Cells[_gridView.Columns.IndexOf(field)];
                        td.Attributes["style"] = "border-top:1px solid gray;";
                    }
                }
            } catch (Exception ex) {
                Error.WriteError(ex);
            }
        }
Exemplo n.º 18
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.º 19
0
        protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try {
                switch (e.Row.RowType)
                {
                case DataControlRowType.DataRow:
                    e.Row.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'White'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
                    e.Row.Attributes["style"] = "cursor:pointer";

                    Label      lblItemID       = (Label)e.Row.FindControl("lblItemID");
                    int        id              = int.Parse(lblItemID.Text);
                    LinkButton lbtnName        = (LinkButton)e.Row.FindControl("lbtnName");
                    Label      lblCompleted    = (Label)e.Row.FindControl("lblCompleted");
                    Label      lblDue          = (Label)e.Row.FindControl("lblDue");
                    Label      lblFrequency    = (Label)e.Row.FindControl("lblFrequency");
                    Image      imgStatus       = (Image)e.Row.FindControl("imgStatus");
                    Label      lblTrngCourseID = (Label)e.Row.FindControl("lblCourseID");
                    HyperLink  hlURL           = (HyperLink)e.Row.FindControl("hlURL");
                    int        slideCnt        = TrngCourse.SlideCount(int.Parse(lblTrngCourseID.Text));
                    TrngCourse course          = new TrngCourse(int.Parse(lblTrngCourseID.Text));



                    // if the course is not external, has slides, and is released, show link
                    if (course.IsCBT && TrngCourse.SlideCount(course.ID) > 0)
                    {
                        hlURL.Text = "Start Course";
                        //hlURL.NavigateUrl = string.Format("{0}/{1}?courseid={2}", SPContext.Current.Web.Url, Course.PAGE_URL, int.Parse(lblTrngCourseID.Text));
                        string jsActionStartCourse = string.Format("openModalDialog('{0}','{1}/{2}?courseid={3}', 'true'); return false;", "CBT Viewer", SPContext.Current.Web.Url, Pages.Course.PAGE_URL, lblTrngCourseID.Text);
                        hlURL.Attributes.Add("onclick", jsActionStartCourse);
                    }
                    // if course is external and released, show link.
                    if (course.IsCBT && course.IsExternal)
                    {
                        hlURL.Text = "Start Course";
                        string jsActionStartCourse = string.Format("window.location.replace('{0}'); return false;", course.ExternalURL.Trim().ToLower());
                        //string jsActionStartCourse = string.Format("openModalDialog('{0}','{1}?courseid={2}', 'true'); return false;", "CBT Viewer", lblExternalURL.Text.Trim(), id);
                        hlURL.Attributes.Add("onclick", jsActionStartCourse);
                    }

                    TrngCourse crs      = new TrngCourse(int.Parse(lblTrngCourseID.Text));
                    int        freq     = crs.Frequency;
                    DateTime   compDate = DateTime.Parse(lblCompleted.Text);
                    DateTime   dueDate  = compDate.AddMonths(freq);

                    // calculate date due
                    if (!lblCompleted.Text.Contains("1900"))
                    {
                        lblDue.Text = dueDate.ToString("dd-MMM-yyyy");
                        if (freq == 0)
                        {
                            lblDue.Text = string.Empty;
                        }
                    }
                    else
                    {
                        lblCompleted.Text = "AWACT";
                        lblDue.Text       = string.Empty;
                    }

                    // attempt to display the correct image that reflects the current status
                    try {
                        if (compDate.ToString().Contains("1900"))
                        {
                            // if training has never been completed it will always show as awaiting action
                            imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                            imgStatus.ToolTip  = "AWACT";
                        }
                        else
                        {
                            if (freq == 0)
                            {
                                // a frequency of zero means the training never needs to be reaccomplished
                                imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                imgStatus.ToolTip  = "Current";
                            }
                            else
                            {
                                if (dueDate.ToString().Contains("1900"))
                                {
                                    // due date calculated from completion date and frequency
                                    DateTime calcNextDue = compDate.AddMonths(freq);
                                    TimeSpan timeSpan    = calcNextDue.Subtract(DateTime.UtcNow);
                                    if (timeSpan.Days < 0)
                                    {
                                        // training overdue
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/red.gif";
                                        imgStatus.ToolTip  = "Overdue";
                                    }
                                    else if (timeSpan.Days > 90)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Current";
                                    }
                                    else if (timeSpan.Days > 30 && timeSpan.Days < 91)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Due within 90 days";
                                    }
                                    else if (timeSpan.Days >= 0 && timeSpan.Days < 31)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                                        imgStatus.ToolTip  = "Due within 30 days";
                                    }
                                }
                                else
                                {
                                    DateTime nextDue  = dueDate;
                                    TimeSpan timeSpan = nextDue.Subtract(DateTime.UtcNow);
                                    if (timeSpan.Days < 0)
                                    {
                                        // training overdue
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/red.gif";
                                        imgStatus.ToolTip  = "Overdue";
                                    }
                                    else if (timeSpan.Days > 90)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Current";
                                    }
                                    else if (timeSpan.Days > 30 && timeSpan.Days < 91)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/green.gif";
                                        imgStatus.ToolTip  = "Due within 90 days";
                                    }
                                    else if (timeSpan.Days >= 0 && timeSpan.Days < 31)
                                    {
                                        imgStatus.ImageUrl = "/_layouts/15/images/spa/yellow.gif";
                                        imgStatus.ToolTip  = "Due within 30 days";
                                    }
                                }
                            }
                        }
                    } catch {
                        imgStatus.ImageUrl = "/_layouts/15/images/ewr218m.gif";
                    }

                    int rowID = int.Parse(lbtnName.CommandArgument.ToString());
                    break;

                case DataControlRowType.Header:
                    SetupSort(gvData, e);
                    break;
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 20
0
        private bool SaveItem()
        {
            bool success = false;

            try {
                bool isUpdate = (IView == ItemView.Edit);
                item                = (isUpdate) ? new SPA.TrngCourse(ItemID) : new SPA.TrngCourse();
                item.Name           = txtName.Text.Trim();
                item.Description    = txtDescription.Text.Trim();
                item.ModifiedBy     = CurrentUser.DisplayName;
                item.Code           = txtCode.Text.Trim();
                item.TrngCategoryID = int.Parse(ddlCategory.SelectedItem.Value);

                if (!Common.IsNumeric(txtFrequency.Text.Trim()))
                {
                    txtFrequency.Text = "12";
                }
                if (int.Parse(txtFrequency.Text.Trim()) > 60)
                {
                    txtFrequency.Text = "12";
                }
                if (int.Parse(txtFrequency.Text.Trim()) < 0)
                {
                    txtFrequency.Text = "12";
                }
                item.Frequency = int.Parse(txtFrequency.Text.Trim());

                item.IsCBT      = ckbxCBT.Checked;
                item.IsGraded   = ckbxGraded.Checked;
                item.IsExternal = ckbxExternal.Checked;

                item.ExternalURL = txtExternalURL.Text.Trim();

                if (!Common.IsNumeric(txtMinimumScore.Text.Trim()))
                {
                    txtMinimumScore.Text = "70";
                }
                if (int.Parse(txtMinimumScore.Text.Trim()) > 100)
                {
                    txtMinimumScore.Text = "70";
                }
                if (int.Parse(txtMinimumScore.Text.Trim()) < 0)
                {
                    txtMinimumScore.Text = "70";
                }
                item.MinimumScore = int.Parse(txtMinimumScore.Text.Trim());


                if (!isUpdate)
                {
                    item.CreatedBy = item.ModifiedBy;
                    if (item.Insert())
                    {
                        Action.Write(string.Format("Added New Course: {0}", item.Name), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                else
                {
                    if (item.Update())
                    {
                        Action.Write(string.Format("Updated Course: {0}", item.Name), CurrentUser.DisplayName);
                        success = true;
                    }
                }
                ItemID = (success) ? item.ID : 0;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
            return(success);
        }
Exemplo n.º 21
0
        protected override void Fill()
        {
            try {
                bool isView = (IView == ItemView.View);
                bool isNew  = (IView == ItemView.New);
                bool isEdit = (IView == ItemView.Edit);
                if (ItemID != 0 && isView || ItemID != 0 && isEdit)
                {
                    TrngCourse chk = new TrngCourse(ItemID);
                    if (chk.ID == 0)
                    {
                        tblItem.Visible    = false;
                        tblMessage.Visible = true;
                    }
                    else
                    {
                        tblItem.Visible    = true;
                        tblMessage.Visible = false;
                    }
                }
                if (IsAdmin || IsTrngAdmin || TrngCourseAdmin.IsAdmin(ItemID, CurrentUser.ID))
                {
                    lbtnEdit.Visible   = isView;
                    lbtnView.Visible   = !isView && ItemID != 0;
                    lbtnDelete.Visible = !isView && ItemID != 0;
                    lblReqMsg.Visible  = !isView;
                }
                else
                {
                    isView = true;
                }

                if (!IsPostBack)
                {
                    ddlCategory.DataSource     = SPA.TrngCategory.Items();
                    ddlCategory.DataTextField  = "Name";
                    ddlCategory.DataValueField = "ID";
                    ddlCategory.DataBind();
                    ddlCategory.Items.Insert(0, new ListItem("Choose", "0"));
                }

                txtName.Text            = item.Name;
                txtName.Visible         = !isView;
                lblNameView.Text        = item.Name;
                lblNameView.Visible     = isView;
                lblNameRequired.Visible = !isView;

                txtDescription.Text        = item.Description.ToString();
                txtDescription.Visible     = !isView;
                lblDescriptionView.Text    = item.Description.ToString();
                lblDescriptionView.Visible = isView;

                txtCode.Text        = item.Code.ToString();
                txtCode.Visible     = !isView;
                lblCodeView.Text    = item.Code.ToString();
                lblCodeView.Visible = isView;

                ddlCategory.SelectedIndex = -1;
                ddlCategory.Items.FindByValue(item.TrngCategoryID.ToString()).Selected = true;
                ddlCategory.Visible     = !isView;
                lblCategoryView.Text    = new TrngCategory(item.TrngCategoryID).Name;
                lblCategoryView.Visible = isView;

                txtFrequency.Text            = item.Frequency.ToString();
                txtFrequency.Visible         = !isView;
                lblFrequencyView.Text        = item.Frequency.ToString();
                lblFrequencyView.Visible     = isView;
                lblFrequencyRequired.Visible = !isView;

                ckbxCBT.Checked    = item.IsCBT;
                ckbxCBT.Visible    = !isView;
                lblCBTView.Text    = item.IsCBT ? "Yes" : "No";
                lblCBTView.Visible = isView;

                ckbxGraded.Checked    = item.IsGraded;
                ckbxGraded.Visible    = !isView;
                lblGradedView.Text    = item.IsGraded ? "Yes" : "No";
                lblGradedView.Visible = isView;

                ckbxExternal.Checked    = item.IsExternal;
                ckbxExternal.Visible    = !isView;
                lblExternalView.Text    = item.IsExternal ? "Yes" : "No";
                lblExternalView.Visible = isView;

                txtExternalURL.Text        = item.ExternalURL.ToString();
                txtExternalURL.Visible     = !isView;
                lblExternalURLView.Text    = item.ExternalURL.ToString();
                lblExternalURLView.Visible = isView;

                txtMinimumScore.Text        = item.MinimumScore.ToString();
                txtMinimumScore.Visible     = !isView;
                lblMinimumScoreView.Text    = item.MinimumScore.ToString();
                lblMinimumScoreView.Visible = isView;

                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);

                btnSave.Visible = !isView;
                btnCancel.Text  = isView ? "Close" : "Cancel";
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 22
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.º 23
0
        private void BuildSlide(int CourseID, int SlideNumber)
        {
            try {
                trFinished.Visible = false;
                int SlideCount = TrngSlide.ActiveCount(CourseID);
                btnPrevious.Enabled = SlideNumber > 1 ? true : false;
                //btnNext.Enabled = SlideNumber < SlideCount ? true : false;
                btnNext.Text = SlideNumber == SlideCount ? "Finish" : "Next";

                TrngSlide     slide  = new TrngSlide(CourseID, SlideNumber);
                TrngSlideType type   = new TrngSlideType(slide.SlideTypeID);
                TrngCourse    course = new TrngCourse(CourseID);
                lblHeader.Text          = course.Name;
                lblPageDescription.Text = course.Name;
                lblDescription.Text     = slide.Description;
                trDescription.Visible   = slide.Description.Length > 5 ? true : false;
                lblPager.Text           = string.Format("Slide Number: {0} of {1}</br>", slide.Number.ToString(), SlideCount);
                int displayWith = int.Parse(Setting.KeyValue("CourseSlideWidth"));
                if (course.IsGraded)
                {
                    btnPrevious.Enabled = false;
                }

                if (type.Name.ToUpper() == "CONTENT")
                {
                    trContent.Visible   = true;
                    trQuestion.Visible  = false;
                    trFreeText.Visible  = false;
                    trVideo.Visible     = false;
                    imgContent.ImageUrl = slide.ContentURL.Length > 5 ? slide.ContentURL : "/_layouts/15/images/SPA/SlideNotFound.PNG";
                    imgContent.Width    = Unit.Percentage(displayWith);
                }
                else if (type.Name.ToUpper() == "FREETEXT")
                {
                    trFreeText.Visible = true;
                    trContent.Visible  = false;
                    trQuestion.Visible = false;
                    trVideo.Visible    = false;
                    lblRichText.Text   = slide.RichText;
                    lblRichText.Width  = Unit.Percentage(displayWith);
                }
                else if (type.Name.ToUpper() == "VIDEO")
                {
                    trFreeText.Visible = false;
                    trContent.Visible  = false;
                    trQuestion.Visible = false;
                    trVideo.Visible    = true;

                    string media = slide.ContentURL.Length > 5 ? slide.ContentURL : string.Format("{0}/_layouts/15/spa/videoplayer/sample.wmv", SPContext.Current.Web.Url);

                    html.Text  = "<object data = 'data:application/x-silverlight-2,' type = 'application/x-silverlight-2' width = '640' height = '480'>" + Environment.NewLine;
                    html.Text += "<param name = 'source' value = '/_layouts/15/spa/videoplayer/videoplayer.xap' />" + Environment.NewLine;
                    html.Text += "<param name = 'background' value = 'white' />" + Environment.NewLine;
                    html.Text += string.Format("<param name = 'initParams' value = 'm=/{0},autostart=true' />", media) + Environment.NewLine;
                    html.Text += "<param name = 'minruntimeversion' value = '2.0.31005.0' />" + Environment.NewLine;
                    html.Text += "</object >" + Environment.NewLine;
                }
                else
                {
                    //tblQuestion.Width = string.Format("{0}%", displayWith);
                    trQuestion.Visible = true;
                    trContent.Visible  = false;
                    trFreeText.Visible = false;
                    trVideo.Visible    = false;
                    // build question for slide number
                    scoredQuestions++;
                    TrngQuestion question = new TrngQuestion(CourseID, slide.ID);
                    lblQuestion.Text = question.Question;
                    //lblQuestion.Width = Unit.Percentage(displayWith);
                    //lblQuestionComment.Text = string.Format("<br>{0}<br>", question.Comment);
                    //lblQuestionComment.Visible = question.Comment.Length > 5 ? true : false;
                    //lblQuestionComment.Width = Unit.Percentage(displayWith);

                    // get answer(s)
                    DataView dv = new DataView(TrngAnswer.Items(question.ID).Tables[0]);
                    rbtnlAnswers.DataSource     = dv;
                    rbtnlAnswers.DataTextField  = "Answer";
                    rbtnlAnswers.DataValueField = "ID";
                    rbtnlAnswers.DataBind();
                    //rbtnlAnswers.Width = Unit.Percentage(displayWith - 10);
                }
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
                if (ShowDebug)
                {
                    lblErrorMessage.Text = ex.ToString();
                }
            }
        }
Exemplo n.º 24
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.º 25
0
        protected void _gridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("onmouseover", "this.originalstyle = this.style.backgroundColor; this.style.backgroundColor = 'rgba( 156,206,240,0.5 )'; this.style.color = 'Black'");
                    e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;this.style.color=this.originalstyle;");
                    e.Row.Attributes["style"] = "cursor:pointer";

                    HyperLink  hlCourselink = new HyperLink();
                    HyperLink  hlCourse     = new HyperLink();
                    LinkButton lbtnCourse   = new LinkButton();
                    LinkButton lbtnCBT      = new LinkButton();

                    string  ID = _gridView.DataKeys[e.Row.RowIndex].Value.ToString();
                    DataRow dr = _dt.Rows.Find(ID);

                    // attempt to display the course URL
                    try {
                        int        courseID = int.Parse(dr["ID"].ToString());
                        TrngCourse course   = new TrngCourse(courseID);
                        lbtnCBT.Text = "Start Course";
                        string url = string.Empty;
                        lbtnCBT.Visible = false;

                        // if the course is not external, has slides, and is released, show link
                        if (course.IsCBT && TrngCourse.SlideCount(course.ID) > 0)
                        {
                            lbtnCBT.Visible       = true;
                            url                   = string.Format("{0}/{1}?courseid={2}&IsDlg=1", SPContext.Current.Web.Url, Pages.Course.PAGE_URL, courseID);
                            lbtnCBT.OnClientClick = "openModalDialog('CBT Viewer', '" + url + "'); return false;";
                            lbtnCBT.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                        }
                        // if course is external and released, show link.
                        if (course.IsCBT && course.IsExternal)
                        {
                            lbtnCBT.Visible       = true;
                            url                   = string.Format("openModalDialog('{0}','{1}?courseid={2}', 'true'); return false;", "CBT Viewer", course.ExternalURL.Trim(), courseID);
                            lbtnCBT.OnClientClick = url;
                            lbtnCBT.ForeColor     = System.Drawing.ColorTranslator.FromHtml("#0072c6");
                        }
                    } catch (Exception ex) {
                        Error.WriteError("UserCatalog", "GridViewRowDataBound", ex);
                    } finally {
                        e.Row.Cells[1].Controls.Clear();
                        e.Row.Cells[1].Controls.Add(lbtnCBT);
                    }
                }

                if (e.Row.RowType == DataControlRowType.Header)
                {
                    foreach (DataControlField field in _gridView.Columns)
                    {
                        TableCell td = e.Row.Cells[_gridView.Columns.IndexOf(field)];
                        td.Attributes["style"] = "border-bottom:1px solid gray;";

                        if (field.SortExpression != string.Empty)
                        {
                            //Add tooltips to headers
                            td.ToolTip = "Sort by " + field.HeaderText;

                            //Override width attibute from in style class
                            td.Style.Add(HtmlTextWriterStyle.Width, "Auto");

                            if (Page.IsPostBack)
                            {
                                //Add appropriate sort image to sorted column
                                if (field.SortExpression == ViewState["MyCatalogSortDirection"].ToString())
                                {
                                    Image sortImage = new Image();
                                    if ((SortDirection)ViewState["MyCatalogSortDirection"] == SortDirection.Descending)
                                    {
                                        sortImage.ImageUrl = SPContext.Current.Site.RootWeb.Url + "/_layouts/15/images/spa/rsort.gif";
                                        sortImage.ToolTip  = "Sort Descending";
                                    }
                                    else
                                    {
                                        sortImage.ImageUrl = SPContext.Current.Site.RootWeb.Url + "/_layouts/15/images/spa/sort.gif";
                                        sortImage.ToolTip  = "Sort Ascending";
                                    }
                                    td.Controls.Add(sortImage);
                                }
                            }
                        }
                    }
                }

                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    foreach (DataControlField field in _gridView.Columns)
                    {
                        TableCell td = e.Row.Cells[_gridView.Columns.IndexOf(field)];
                        td.Attributes["style"] = "border-top:1px solid gray;";
                        //td.Style.Add(HtmlTextWriterStyle.Width, "Auto");
                    }
                }
            } catch (Exception ex) {
                Error.WriteError(ex);
            }
        }
Exemplo n.º 26
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();
                }
            }
        }