/// <summary> /// Add units to the criteria list via a csv list of course id's /// </summary> /// <param name="strUnitIDs">Csv list of units.</param> public void AddUnits(string strUnitIDs) { // Local variables if (strUnitIDs != null && strUnitIDs.Length > 0) { string[] astrUnitIDs = strUnitIDs.Split(','); string strUnitNames = ""; // Get Unit List BusinessServices.Unit objUnit = new BusinessServices.Unit(); DataTable dtbUnit; // Loop through all Units foreach (string strUnitID in astrUnitIDs) { dtbUnit = objUnit.GetUnit(Int32.Parse(strUnitID)); strUnitNames += dtbUnit.Rows[0]["Pathway"].ToString(); strUnitNames += "<BR>"; } // Remove trailing command if it exists and replace with a full stop if (strUnitNames.Length > 0) { strUnitNames = strUnitNames.Substring(0, strUnitNames.Length - 2); strUnitNames += "."; } // add to the criteria list this.Criteria.Add(ResourceManager.GetString("lblUnits"), strUnitNames); } else { // add to the criteria list this.Criteria.Add(ResourceManager.GetString("lblUnits"), ResourceManager.GetString("lblAny")); } }
/// <summary> /// Get Unit's Details /// </summary> private void GetDetails() { BusinessServices.Unit objUnit; DataTable dtbUnit; int intOrganisationID; //1. Get Unit details objUnit = new BusinessServices.Unit(); dtbUnit = objUnit.GetUnit(this.m_intUnitID); this.txtName.Text = dtbUnit.Rows[0]["Name"].ToString(); this.txtUnitID.Text = this.m_intUnitID.ToString(); if (dtbUnit.Rows[0]["Active"].ToString() == "True") { this.cboStatus.SelectedIndex = 0; } else { this.cboStatus.SelectedIndex = 1; } this.lblPathway.Text = dtbUnit.Rows[0]["Organisation"].ToString() + " > " + dtbUnit.Rows[0]["Pathway"].ToString(); DateTime dteOriginalDateUpdated = (DateTime)dtbUnit.Rows[0]["DateUpdated"]; this.OriginalDateUpdated = DatabaseTool.ToLongDateTimeString(dteOriginalDateUpdated); intOrganisationID = (int)dtbUnit.Rows[0]["OrganisationID"]; //2. Get Sub-Units tree DataSet dstUnits = objUnit.GetUnitsByOrganisation(intOrganisationID, "", "", "", this.m_intUnitID); string strUnits = UnitTreeConvert.ConvertXml(dstUnits); if (strUnits == "") { this.trvSubUnits.Visible = false; this.lblNoSubUnits.Visible = true; } else { this.trvSubUnits.Visible = true; this.lblNoSubUnits.Visible = false; this.trvSubUnits.LoadXml(strUnits); } }
/// <summary> /// Load data the page is first loaded /// </summary> private void LoadData() { BusinessServices.Unit objUnit; DataTable dtbUnit; int intOrganisationID; objUnit = new BusinessServices.Unit(); dtbUnit = objUnit.GetUnit(this.m_intUnitID); this.lblUnitName.Text = dtbUnit.Rows[0]["Pathway"].ToString(); litMessage2.Text = String.Format(ResourceManager.GetString("litMessage"), dtbUnit.Rows[0]["Organisation"].ToString(), "<a href=\"UnitDetails.aspx?UnitID=" + m_intUnitID + "\">" + ResourceManager.GetString("lnkUnitDetails") + "</a>"); intOrganisationID = (int)dtbUnit.Rows[0]["OrganisationID"]; //1.Load Course list that are assigned to this organisation this.GetCourseList(intOrganisationID); if (this.cboCourse.Items.Count > 0) { //2. Lists all modules in the selected course this.GetModuleAccess(); //Show warning message this.btnSave.Attributes.Add("onclick", "javascript:return SaveConfirm();"); } else { this.cboCourse.Visible = false; this.grdModules.Visible = false; this.btnSave.Visible = false; this.lblMessage.Text = ResourceManager.GetString("lblMessage.NoCourseAccess"); //"There is no course access"; this.lblMessage.CssClass = "FeedbackMessage"; } }
/// <summary> /// Load data the page is first loaded /// </summary> private void LoadData() { BusinessServices.Unit objUnit; // Used to gather the unit details DataTable dtbUnit; // Holds the unit details int intOrganisationID; // the organisation id of the unit objUnit = new BusinessServices.Unit(); // Get unit details dtbUnit = objUnit.GetUnit(this.m_intUnitID); this.lblUnitName.Text = dtbUnit.Rows[0]["Pathway"].ToString(); intOrganisationID = (int)dtbUnit.Rows[0]["OrganisationID"]; // Emerging bug 7, 8 DataTable dtLoadOrg; string strLangCode = Request.Cookies["currentCulture"].Value; Bdw.Application.Salt.BusinessServices.Organisation objOrganisation = new Bdw.Application.Salt.BusinessServices.Organisation(); dtLoadOrg = objOrganisation.GetOrganisation(strLangCode, intOrganisationID); this.cboLessonFrequency.SelectedValue = dtLoadOrg.Rows[0]["DefaultLessonFrequency"].ToString(); this.cboQuizFrequency.SelectedValue = dtLoadOrg.Rows[0]["DefaultQuizFrequency"].ToString(); this.txtQuizPassMark.Text = dtLoadOrg.Rows[0]["DefaultQuizPassMark"].ToString(); // Setup date dropdowns with value if (dtLoadOrg.Rows[0]["DefaultLessonCompletionDate"] != System.DBNull.Value) { DateTime defaultLessonCompletionDate = (DateTime)dtLoadOrg.Rows[0]["DefaultLessonCompletionDate"]; cboLCompletionDay.SelectedValue = defaultLessonCompletionDate.Day.ToString(); cboLCompletionMonth.SelectedValue = defaultLessonCompletionDate.Month.ToString(); cboLCompletionYear.SelectedValue = defaultLessonCompletionDate.Year.ToString(); } if (dtLoadOrg.Rows[0]["DefaultQuizCompletionDate"] != System.DBNull.Value) { DateTime defaultQuizCompletionDate = (DateTime)dtLoadOrg.Rows[0]["DefaultQuizCompletionDate"]; cboQCompletionDay.SelectedValue = defaultQuizCompletionDate.Day.ToString(); cboQCompletionMonth.SelectedValue = defaultQuizCompletionDate.Month.ToString(); cboQCompletionYear.SelectedValue = defaultQuizCompletionDate.Year.ToString(); } // emerging end //1.Load Course list that are assigned to this organisation this.GetCourseList(intOrganisationID); //2. Get Organisation Default Compliance Rules this.GetDefaultRules(intOrganisationID); if (this.cboCourse.Items.Count > 0) { //3. Lists all modules in the selected course this.GetModuleRule(); } else { this.cboCourse.Visible = false; this.grdModules.Visible = false; this.btnPopulateAll.Visible = false; this.lblMessage.Text = ResourceManager.GetString("lblMessage.NoCourseAccess"); //"There is no course access."; this.lblMessage.CssClass = "FeedbackMessage"; } }
/// <summary> /// This is the method called when the user elects to add the selected users to the unit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAssign_Click(object sender, System.EventArgs e) { lblError.Text = ""; lblStatus.Text = ""; // Check if user has select a unit if (this.trvToUnitsSelector.GetSelectedValue() == null) { lblError.Visible = true; lblError.Text = ResourceManager.GetString("lblError.Select"); //"You must select a unit to continue."; this.lblError.CssClass = "WarningMessage"; } else { try { int intAdded = 0; // Counter of added users int intUnitID; // Desired Unit ID int intUserID; // User ID User objUser = new User(); // Check a unit has been selected if (trvToUnitsSelector.GetSelectedValue().ToString() != "") { // Get the unit it (its a single select tree) intUnitID = Convert.ToInt32(trvToUnitsSelector.GetSelectedValue()); // Instantiate the unit BusinessServices.Unit objUnit = new BusinessServices.Unit(); DataTable dtbUnit = objUnit.GetUnit(intUnitID); string strUnitName = dtbUnit.Rows[0]["Name"].ToString(); // Update the users on the current page foreach (DataGridItem objItem in this.dgrResults.Items) { // Get the checkbox in the first column CheckBox objCheckbox = (CheckBox)objItem.Cells[0].Controls[1]; if (objCheckbox.Checked) { // Get the user id from the second column which is hidden. intUserID = Int32.Parse(objItem.Cells[1].Text); // Update the actual user. objUser.Update(intUserID, intUnitID, UserContext.UserID, UserContext.UserData.OrgID); objUser.UpdateUserProfilePeriodAccess(intUserID, intUnitID); objUser.UpdateUserPolicyAccess(intUserID, intUnitID); //intAdded++; } } //if there are users from other pages if (this.txtUserIDs.Text.Length > 1) { // Array of user IDs from the txtUserID's field on the page. string[] strUserIDs = this.txtUserIDs.Text.Split(','); // For each user id foreach (string strUserID in strUserIDs) { if (strUserID.Length > 0) { // Update those users as well objUser.Update(Int32.Parse(strUserID), intUnitID, UserContext.UserID, UserContext.UserData.OrgID); intAdded++; } } } // If users have been added if (intAdded > 0) { // Display status message //if (chkSelectAll.Checked) //{ //this.lblStatus.Text=String.Format(ResourceManager.GetString("lblStatus.Assigned"), strUnitName);//"Assigned all users to '" + strUnitName + "'."; //} //else //{ lblStatus.Visible = true; this.lblStatus.Text = String.Format(ResourceManager.GetString("lblStatus.Assigned2"), intAdded.ToString(), strUnitName); //"Assigned " + intAdded.ToString() + " users to '" + strUnitName + "'."; //} this.lblStatus.CssClass = "SuccessMessage"; //this.txtUserIDs.Text=","; this.chkSelectAll.Checked = false; // Reset the record of selected users this.txtAllUserIDs.Text = ""; this.txtUserIDs.Text = ""; StartPagination(); } else { // No users selected this.lblError.Text = ResourceManager.GetString("lblError.SelectUsers"); //"You must select some users to continue."; this.lblError.CssClass = "WarningMessage"; this.lblStatus.Visible = false; } } else { // No Unit selected if (lblError.Text == "") { lblError.Visible = true; lblError.Text = ResourceManager.GetString("lblError.SelectUnit"); //"Please select a unit to assign these users to."; this.lblError.CssClass = "WarningMessage"; this.lblStatus.Visible = false; } else { lblError.Visible = true; lblError.Text = ResourceManager.GetString("lblError.SelectUnit"); //"Please select a unit to assign these users to."; this.lblError.CssClass = "WarningMessage"; this.lblStatus.Visible = false; } } } catch (RecordNotFoundException ex) { lblError.Visible = true; lblError.Text = ex.Message; this.lblError.CssClass = "WarningMessage"; this.lblStatus.Visible = false; } catch (Exception Ex) { // Error occurred, Log it. throw new Exception(Ex.Message); } } }