Update underlying data field when related object is updated.

If the selected Library Document is out-of-range throw a specific error
Don't fail if the user clicks on open space in the BookMark list
Added property to provide a right margin (RTBMargin) between the RichTextBox and the StepItem
This commit is contained in:
Rich
2010-12-16 20:42:44 +00:00
parent abd26062f6
commit 10f06a5e9c
42 changed files with 147 additions and 69 deletions

View File

@@ -445,40 +445,40 @@ namespace VEPROMS
{
ProcessButtonClick(tiLibDoc, btnLibDocs);
}
private void ppBtnCvrtToLibDoc_Click(object sender, EventArgs e)
{
private void ppBtnCvrtToLibDoc_Click(object sender, EventArgs e)
{
// Double Check that this is not a step section, if so just return.
if (_isStepSection) 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.
if (ppBtnCvrtToLibDoc.Text.IndexOf("Non") > 0) // convert to a 'non' library.
{
ItemInfo ii = ItemInfo.Get(_SectionConfig.MySection.ItemID);
DocumentInfo doclibinfo = ii.MyContent.MyEntry.MyDocument;
// 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.
if (ppBtnCvrtToLibDoc.Text.IndexOf("Non") > 0) // convert to a 'non' library.
{
ItemInfo ii = ItemInfo.Get(_SectionConfig.MySection.ItemID);
DocumentInfo doclibinfo = ii.MyContent.MyEntry.MyDocument;
// if just one usage (this one), then just convert this to a non-library document. If there are more
// than one usage, make a copy so that the rest of the usages still point to the library document.
if (doclibinfo.DocumentEntryCount == 1)
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = null;
else
{
// make new document with 'no' libtitle - use libtitle for the doc title. Then link this
// to the item...
Document doc = Document.MakeDocument(null, doclibinfo.DocContent,doclibinfo.DocAscii,doclibinfo.Config,doclibinfo.DocPdf);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc;
}
ppCmbxLibDoc.Items.Clear();
ppCmbxLibDoc.WatermarkEnabled = true;
ppBtnCvrtToLibDoc.Text = "Convert this to a Library Document";
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 just one usage (this one), then just convert this to a non-library document. If there are more
// than one usage, make a copy so that the rest of the usages still point to the library document.
if (doclibinfo.DocumentEntryCount == 1)
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = null;
else
{
// make new document with 'no' libtitle - use libtitle for the doc title. Then link this
// to the item...
Document doc = Document.MakeDocument(null, doclibinfo.DocContent, doclibinfo.DocAscii, doclibinfo.Config, doclibinfo.DocPdf);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc;
}
ppCmbxLibDoc.Items.Clear();
ppCmbxLibDoc.WatermarkEnabled = true;
ppBtnCvrtToLibDoc.Text = "Convert this to a Library Document";
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)));
return;
}
// If current section is not a library document, it is either a new section or the user selected the
}
// 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)
{
else if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null)
{
// if nothing was selected, give message & return
if (ppCmbxLibDoc.SelectedIndex == -1)
{
@@ -495,57 +495,57 @@ namespace VEPROMS
break;
}
}
if (docid==-1)return;
if (docid == -1) return;
using (Document dc = Document.Get(docid))
{
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = dc;
}
}
else
else
// if converting to library document, just put 'text' into the 'LibTitle' property (that's what flags
// it to be a library document.
// it to be a library document.
{
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = _SectionConfig.MySection.MyContent.Text;
// Save now so that it shows up in the library document list in the ppcmbxlibdoc (combo box
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle = _SectionConfig.MySection.MyContent.Text;
// 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();
_SectionConfig.MySection.MyContent.MyEntry.MyDocument.Save();
ppCmbxLibDocFill();
ppCmbxLibDoc.Enabled = false;
}
ppCmbxLibDoc.Enabled = false;
}
ppBtnCvrtToLibDoc.Text = "Convert this Section To A Non-Library Document";
lblLibraryDocument.Text = "Library Document";
superTooltip1.SetSuperTooltip(this.ppBtnCvrtToLibDoc, new DevComponents.DotNetBar.SuperTooltipInfo("Convert To Non-Library Document", "", "This button will convert the current section from a library document to a non-library document",
null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, false, new System.Drawing.Size(250, 76)));
}
}
private void ppCmbxLibDoc_SelectedIndexChanged(object sender, EventArgs e)
{
if (_Initializing) return;
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 == 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 != null && !(_SectionConfig.MySection.MyContent.MyEntry.MyDocument.LibTitle != ""))
{
// 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 != null && !(_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 to this section. Do you want to continue?", "Link", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_DocumentToDelete = _SectionConfig.MySection.MyContent.MyEntry.MyDocument;
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
if (ppCmbxLibDoc.SelectedIndex > -1)
{
if (MessageBox.Show("Linking to this library document will cause loss of data to this section. Do you want to continue?", "Link", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
_DocumentToDelete = _SectionConfig.MySection.MyContent.MyEntry.MyDocument;
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
ppBtnCvrtToLibDoc.Enabled = true;
}
else
{
ppCmbxLibDoc.SelectedIndex = -1;
}
else
{
ppCmbxLibDoc.SelectedIndex = -1;
ppBtnCvrtToLibDoc.Enabled = false;
}
}
}
}
}
}
//else if (_SectionConfig.MySection.MyContent.MyEntry.MyDocument == null)
//{
// // was creating a new document & selected to connect it to a libdoc
@@ -553,12 +553,19 @@ namespace VEPROMS
//}
else
{
// it already is a library document, just change usages...
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
ppBtnCvrtToLibDoc.Enabled = true;
}
}
// it already is a library document, just change usages...
DocumentInfoList LibDocList = DocumentInfoList.GetLibraries(true);
if (ppCmbxLibDoc.SelectedIndex >= 0 && ppCmbxLibDoc.SelectedIndex < LibDocList.Count)
{
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = Document.Get(LibDocList[ppCmbxLibDoc.SelectedIndex].DocID);
ppBtnCvrtToLibDoc.Enabled = true;
}
else
{
throw new Exception(string.Format("Index Out Of Range Index = {0}, Count = {1}", ppCmbxLibDoc.SelectedIndex, LibDocList.Count));
}
}
}
#endregion
#region View Settings tab