diff --git a/PROMS/VEPROMS User Interface/frmSectionProperties.cs b/PROMS/VEPROMS User Interface/frmSectionProperties.cs index 9155bc3e..45e45252 100644 --- a/PROMS/VEPROMS User Interface/frmSectionProperties.cs +++ b/PROMS/VEPROMS User Interface/frmSectionProperties.cs @@ -139,7 +139,7 @@ namespace VEPROMS { _Initializing = true; bool isLib = false; - if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument!=null && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != null) && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "")) isLib = true; + if (_SectionConfig.MySection.MyContent.MyEntry!=null && _SectionConfig.MySection.MyContent.MyEntry.MyDocument!=null && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != null) && (_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "")) isLib = true; if (isLib) { ppBtnCvrtToLibDoc.Text = "Convert this Section To A Non-Library Document"; @@ -149,19 +149,26 @@ namespace VEPROMS } else { - ppBtnCvrtToLibDoc.Text = "Convert this to a Library Document"; + ppBtnCvrtToLibDoc.Text = _SectionConfig.MySection.MyContent.MyEntry.MyDocument == null ? "Select Library Document" : "Convert this to a Library Document"; lblLibraryDocument.Text = "Select Library Document to Link"; - superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" + + if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument==null) + superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Select Library Document button", "", "This button will attach the current section to a library document, allowing it t" + + "o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76))); + else + superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" + "o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76))); } DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true); + int selindx = -1; + ppCmbxLibDoc.Items.Clear(); for (int i = 0; i < LibDocList.Count; i++) { ppCmbxLibDoc.Items.Add(LibDocList[i].DocumentTitle); // see if this lib doc should be the selected index? - if (isLib && (LibDocList[i].DocID == _SectionConfig.MySection.MyContent.MyEntry.MyDocument.DocID)) ppCmbxLibDoc.SelectedIndex = i; + if (isLib && (LibDocList[i].DocID == _SectionConfig.MySection.MyContent.MyEntry.MyDocument.DocID)) selindx = i; } + if (selindx>-1) ppCmbxLibDoc.SelectedIndex = selindx; _Initializing = false; } @@ -234,12 +241,8 @@ namespace VEPROMS } ppCmbxStyleSectionType.DataSource = locDocStyles; ppCmbxStyleSectionType.SelectedIndex = selindx; - //if (_SectionConfig.SectionType < pf.DocStyles.DocStyleList.Count) - //{ - // //Volian.Controls.Library.vlnStackTrace.ShowStack("Before - SelectedValue {0} SectionType {1}", ppCmbxStyleSectionType.SelectedValue, _SectionConfig.SectionType); - // ppCmbxStyleSectionType.SelectedValue = (int)_SectionConfig.SectionType; - // //Volian.Controls.Library.vlnStackTrace.ShowStack("After - SelectedValue {0} SectionType {1}", ppCmbxStyleSectionType.SelectedValue, _SectionConfig.SectionType); - //} + + if (!cbIsStepSection.Checked) ppCmbxLibDocFill(); _Initializing = myInit; } @@ -288,6 +291,8 @@ namespace VEPROMS } private void ppBtnCvrtToLibDoc_Click(object sender, EventArgs e) { + // Double Check that this is not a step section, if so just return. + if (cbIsStepSection.Checked) return; // If current section is library document, user selected to convert to non-library document. If // this is the case, data from lib doc must be copied to new document and the section must point // to id. @@ -313,16 +318,41 @@ namespace VEPROMS superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Library Document button", "", "This button will convert the current section to a library document, allowing it t" + "o be shared with other procedures.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76))); } - // If current section is not a library document, the user selected the button to convert it to a - // library document, to do this, just put 'text' into the 'LibTitle' property (that's what flags - // it to be a library document. - else + // If current section is not a library document, it is either a new section or the user selected the + // button to convert it to a library document. Check for this, if new, just attach to document. + else if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null) { + // if nothing was selected, give message & return + if (ppCmbxLibDoc.SelectedIndex == -1) + { + MessageBox.Show("Must select a library document"); + return; + } + int docid = -1; + DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true); + for (int i = 0; i < LibDocList.Count; i++) + { + if (LibDocList[i].LibTitle == (string)ppCmbxLibDoc.Items[ppCmbxLibDoc.SelectedIndex]) + { + docid = LibDocList[i].DocID; + break; + } + } + if (docid==-1)return; + using (Document dc = Document.Get(docid)) + { + _SectionConfig.MySection.MyContent.MyEntry.MyDocument = dc; + } + } + else + // if converting to library document, just put 'text' into the 'LibTitle' property (that's what flags + // it to be a library document. + { _SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = _SectionConfig.MySection.MyContent.Text; - // TODO: Kbr/Rhm - CSLA was not saving document (libtitle change) on higher level save. Delete following - // line after this is fixed. + // Save now so that it shows up in the library document list in the ppcmbxlibdoc (combo box + // listing lib docs that is regenerated in ppCmbxLibDocFill) _SectionConfig.MySection.MyContent.MyEntry.MyDocument.Save(); - // ppCmbxLibDocFill(); + ppCmbxLibDocFill(); ppCmbxLibDoc.Enabled = false; } } @@ -330,10 +360,14 @@ namespace VEPROMS private void ppCmbxLibDoc_SelectedIndexChanged(object sender, EventArgs e) { if (_Initializing) return; + + // first check if this is a 'new' section - if so, then just return. + if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null) return; // see if this was NOT a library document. If it is not a library document, ask the user if // it should be linked, thus losing the original text/data. if (!(_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != "")) { + _SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.New(); if (ppCmbxLibDoc.SelectedIndex > -1) { if (MessageBox.Show("Linking to this library document will cause loss of data. Do you want to continue?", "Link", MessageBoxButtons.YesNo) == DialogResult.Yes) diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index cbef2230..38c052c6 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -141,7 +141,6 @@ namespace VEPROMS private MostRecentItemList _MyBookMarks; private void SetupBookMarks() { - // TODO: load previously set bookmarks lbxBookMarks.SelectedValueChanged += new EventHandler(lbxBookMarks_SelectedValueChanged); RefreshBookMarkData(); btnPrevPos.Enabled = false; @@ -990,10 +989,9 @@ namespace VEPROMS if (SelectedStepTabPanel == null) return; displayRO.MyROFST = SelectedROFst; displayRO.MyRTB = SelectedStepTabPanel.MyStepPanel.SelectedStepItem.MyStepRTB; - displayRO.CurROLink = args.MyLinkText.RoUsageid; // TODO: this is wrong - use for now. + displayRO.CurROLink = args.MyLinkText.MyRoUsageInfo; displayRO.Mydvi = SelectedDVI; displayRO.ProgressBar = bottomProgBar; - displayRO.CurROLink = args.MyLinkText.RoUsageid; // this is wrong - use for now. } #endregion #region VButton_New