Exemple #1
0
        }         // AddOrganisation

        /// <summary>
        /// Updates the organisation details.
        /// </summary>
        private void UpdateOrganisation()
        {
            try
            {
                DateTime defaultLessonCompletionDate = DateTime.Parse("1/1/1900");
                DateTime defaultQuizCompletionDate   = DateTime.Parse("1/1/1900");
                DateTime defaultOriginalDateUpdated  = DateTime.Parse("1/1/1990");
                if (!ValidateOrganisation(ref defaultLessonCompletionDate, ref defaultQuizCompletionDate))
                {
                    return;
                }


                string   strLogoName           = this.GetOrganisationLogo();
                DateTime dtOriginalDateUpdated = DateTime.Parse(this.OriginalDateUpdated);

                string strOrganisationNotes;
                strOrganisationNotes = BusinessServices.HTMLSanitizer.Sanitize(this.txtOrganisationNotes.Text);
                strOrganisationNotes = Server.HtmlEncode(strOrganisationNotes);

                long lngDiskSpace;
                if (this.txtDiskSpace.Text.Trim() != "")
                {
                    lngDiskSpace = long.Parse(this.txtDiskSpace.Text);
                    lngDiskSpace = lngDiskSpace * (1024 * 1024);                     //Convert to  bytes
                }
                else
                {
                    lngDiskSpace = 0;
                }
                string strLangCode = Request.Cookies["currentCulture"].Value;
                Bdw.Application.Salt.BusinessServices.Organisation objOrganisation = new Bdw.Application.Salt.BusinessServices.Organisation();

                objOrganisation.UpdateOrganisation(strLangCode, UserContext.UserData.OrgID, this.txtOrganisationName.Text, strOrganisationNotes,
                                                   strLogoName,
                                                   this.cboDefaultLessonFrequency.SelectedValue == null?System.Data.SqlTypes.SqlInt32.Null:Int32.Parse(this.cboDefaultLessonFrequency.SelectedValue),
                                                   this.cboDefaultLessonFrequency.SelectedValue == null?System.Data.SqlTypes.SqlInt32.Null:Int32.Parse(this.cboDefaultQuizFrequency.SelectedValue),
                                                   this.txtDefaultQuizPassMark.Text == ""?System.Data.SqlTypes.SqlInt32.Null:Int32.Parse(this.txtDefaultQuizPassMark.Text),
                                                   defaultLessonCompletionDate,
                                                   defaultQuizCompletionDate,
                                                   UserContext.UserData.UserType == UserType.SaltAdmin?this.chkAdvancedReporting.Checked:System.Data.SqlTypes.SqlBoolean.Null,
                                                   UserContext.UserID,
                                                   dtOriginalDateUpdated,
                                                   this.txtCPDReportName.Text,
                                                   lngDiskSpace,
                                                   System.Data.SqlTypes.SqlBoolean.Parse(this.ckbIncludeLogo.Checked.ToString()),
                                                   System.Data.SqlTypes.SqlBoolean.Parse(this.chkActivatePassword.Checked.ToString()),
                                                   this.listTimeZone.SelectedItem.ToString(),
                                                   chkBxShowLastPassDate.Checked,
                                                   chkDisablePasswordField.Checked,
                                                   chkurlrequest.Checked,
                                                   chkuserCPDEvent.Checked,
                                                   chkEbookNotification.Checked
                                                   );

                //7. Save the Organisation Logo
                this.SaveOrganisationLogo(strLogoName);

                if (this.txtClassificationName.Text != "")
                {
                    if (this.ClassificationTypeID == 0)
                    {
                        //4. Save the ClassificationName
                        Classification objClassification = new Classification();
                        objClassification.AddClassificationType(this.txtClassificationName.Text, UserContext.UserData.OrgID);
                    }
                    else
                    {
                        //8. Update the ClassificationType name.
                        Classification objClassification = new Classification();
                        objClassification.UpdateClassificationType(this.txtClassificationName.Text, this.ClassificationTypeID, UserContext.UserData.OrgID);
                    }
                }

                if (ckbOverrideUnitLF.Checked)
                {
                    BusinessServices.Unit.OverrideLessonCompliance(UserContext.UserData.OrgID, defaultLessonCompletionDate, Int32.Parse(this.cboDefaultLessonFrequency.SelectedValue));
                }

                if (ckbOverrideUnitQF.Checked)
                {
                    BusinessServices.Unit.OverrideQuizCompliance(UserContext.UserData.OrgID, defaultQuizCompletionDate, Int32.Parse(this.cboDefaultQuizFrequency.SelectedValue));
                }

                //9. Reload the page
                //Response.Redirect("OrganisationDetails.aspx");
                this.lblMessage.Text     = ResourceManager.GetString("lblMessage.Saved");//"The Organisation's Details have been updated successfully";
                this.lblMessage.CssClass = "SuccessMessage";

                //10. Refresh the UI
                this.LoadData();
                this.SetPageState();
            }
            catch (UniqueViolationException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (ParameterException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (PermissionDeniedException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (IntegrityViolationException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }         // UpdateOrganisation
Exemple #2
0
        /// <summary>
        /// Add the new organisation details to the database.
        /// </summary>
        private void AddOrganisation()
        {
            try
            {
                //2. Add the new organisation.
                string strLogoName = this.GetOrganisationLogo();

                BusinessServices.Organisation objOrganisation = new BusinessServices.Organisation();

                string strOrganisationNotes;
                strOrganisationNotes = BusinessServices.HTMLSanitizer.Sanitize(this.txtOrganisationNotes.Text);
                strOrganisationNotes = Server.HtmlEncode(strOrganisationNotes);

                DateTime defaultLessonCompletionDate = DateTime.Parse("1/1/1900");
                DateTime defaultQuizCompletionDate   = DateTime.Parse("1/1/1900");

                // if  txtCPDReportName and/or txtDiskSpace visible then parse values otherwise parse Null
                string strCPDReportName;
                if (this.txtCPDReportName.Visible)
                {
                    strCPDReportName = this.txtCPDReportName.Text;
                }
                else
                {
                    strCPDReportName = "";
                }

                long lngDiskSpace;
                if (this.txtDiskSpace.Text.Trim() != "")
                {
                    lngDiskSpace = long.Parse(this.txtDiskSpace.Text);
                    lngDiskSpace = lngDiskSpace * (1024 ^ 2);                   //Convert to  bytes
                }
                else
                {
                    lngDiskSpace = 0;
                }
                if (!ValidateOrganisation(ref defaultLessonCompletionDate, ref defaultQuizCompletionDate))
                {
                    return;
                }


                int intOrganisationID = objOrganisation.AddOrganisation(this.txtOrganisationName.Text, strOrganisationNotes, strLogoName,
                                                                        Int32.Parse(this.cboDefaultLessonFrequency.SelectedValue),
                                                                        Int32.Parse(this.cboDefaultQuizFrequency.SelectedValue),
                                                                        Int32.Parse(this.txtDefaultQuizPassMark.Text),
                                                                        defaultLessonCompletionDate,
                                                                        defaultQuizCompletionDate,
                                                                        this.chkAdvancedReporting.Checked,
                                                                        UserContext.UserID,
                                                                        strCPDReportName,
                                                                        lngDiskSpace,
                                                                        this.ckbIncludeLogo.Checked,
                                                                        this.chkActivatePassword.Checked,
                                                                        this.listTimeZone.SelectedItem.ToString(),
                                                                        chkBxShowLastPassDate.Checked,
                                                                        chkDisablePasswordField.Checked,
                                                                        chkurlrequest.Checked,
                                                                        chkuserCPDEvent.Checked,
                                                                        chkEbookNotification.Checked);

                //3. Save the Organisation Logo
                this.SaveOrganisationLogo(strLogoName);

                //4. Save the ClassificationName
                if (this.txtClassificationName.Text != "")
                {
                    Classification objClassification = new Classification();
                    objClassification.AddClassificationType(this.txtClassificationName.Text, intOrganisationID);
                }

                // re select the organisation
                WebSecurity.SelectOrganisation(intOrganisationID);

                Response.Redirect("OrganisationDetails.aspx?adsx=true");
            }
            catch (UniqueViolationException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (ParameterException ex)
            {
                throw ex;
            }
            catch (PermissionDeniedException ex)
            {
                this.lblMessage.Text     = ex.Message;
                this.lblMessage.CssClass = "WarningMessage";
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }         // AddOrganisation