Esempio n. 1
0
        public void OnSaveRequest(SaveEvent e)
        {
            //2. Set the lesson name as the default new file name
            if (e.IsSaveAs || this.thisXDocument.IsNew)
            {
                //IXMLDOMNode node = this.thisXDocument.DOM.selectSingleNode("//ContentType");
                this.thisXDocument.UI.SetSaveAsDialogFileName("phrases");
            }

            e.IsCancelled = e.PerformSaveOperation();

            // Write the code to be run after saving here.

            e.ReturnStatus = true;
        }
Esempio n. 2
0
        public void OnSaveRequest(SaveEvent e)
        {
            //1. Validation
            //Most of  validations are completed by the validation rule in design mode
            //a. Validate the SubmitAnswers button
            //1)There is one SubmitAnswers button on the active pages
            //2)There is only one SubmitAnswers button on the active pages
            //3)That page must be the last page
            IXMLDOMNodeList endQuizPages = this.thisXDocument.DOM.selectNodes("//Complete/Page[@IsActive='true' and .//SubmitAnswers]");

            //1) no SubmitAnswers control
            if (endQuizPages.length == 0)
            {
                this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nThere is no SubmitAnswers control, this control must be on the last active page.\n");
                e.ReturnStatus = true;
                return;
            }
            //2) More that 1 SubmitAnswers control
            else if (endQuizPages.length > 1)
            {
                this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nSubmitAnswers control is on more than one active pages, this control can only be on the last active page.\n");
                e.ReturnStatus = true;
                return;
            }
            //One SubmitAnswers control
            else
            {
                IXMLDOMNode endControlPage = endQuizPages[0];
                //3) Is this page the last active page?
                IXMLDOMNodeList followingSiblingPages = endControlPage.selectNodes("following-sibling::Page[@IsActive='true']");
                if (followingSiblingPages.length > 0)
                {
                    this.thisXDocument.UI.Alert("This form contains the following validation errors:\n\nSubmitAnswers control is on other active page, this control can only be on the last active page.\n");
                    e.ReturnStatus = true;
                    return;
                }
            }

            //2. Set the quiz ID as the default new file name
            if (e.IsSaveAs || this.thisXDocument.IsNew)
            {
                IXMLDOMNode node = this.thisXDocument.DOM.selectSingleNode("//Summary/@ID");
                this.thisXDocument.UI.SetSaveAsDialogFileName(node.text);
            }

            //3. If the form is modified, set the last modified data
            if (!this.thisXDocument.IsNew)
            {
                IXMLDOMNode lastModifiedBy   = this.thisXDocument.DOM.selectSingleNode("//Summary/LastModifiedBy");
                IXMLDOMNode lastModifiedDate = this.thisXDocument.DOM.selectSingleNode("//Summary/LastModifiedDate");

                lastModifiedBy.text = System.Environment.UserName;

                //Determine whether the xsi:nil attribute is set for this
                //element. If so, remove the xsi:nil attributes so that
                //the value can be set.
                if (lastModifiedDate.attributes.getNamedItem("xsi:nil") != null)
                {
                    lastModifiedDate.attributes.removeNamedItem("xsi:nil");
                }
                lastModifiedDate.text = DateTime.Now.ToString("s");
            }


            e.IsCancelled = e.PerformSaveOperation();

            // Write the code to be run after saving here.
            e.ReturnStatus = true;
        }