diff --git a/PROMS/VEPROMS User Interface/frmRODbProperties.cs b/PROMS/VEPROMS User Interface/frmRODbProperties.cs index 56449c3c..87ff2b46 100644 --- a/PROMS/VEPROMS User Interface/frmRODbProperties.cs +++ b/PROMS/VEPROMS User Interface/frmRODbProperties.cs @@ -36,15 +36,52 @@ namespace VEPROMS private void ppBtnOk_Click(object sender, EventArgs e) { - // check for modify - if modify, just save current data, close & return. + // check for modify. If the path to this rodb already exists, we've got to use that + // as the assocation. if it's a new path, i.e. a modify of the rodb record, just save current data. + // Then close & return. if (_origROName !=null && _origFolderPath !=null && (_origROName != ppRTxtName.Text || _origFolderPath != ppTxtPath.Text)) { RODb roDb = RODb.Get(_roDbInfo.RODbID); if (_origROName != ppRTxtName.Text) roDb.ROName = ppRTxtName.Text; - if (_origFolderPath != ppTxtPath.Text) roDb.FolderPath = ppTxtPath.Text; - roDb.Save().Dispose(); - Close(); - return; + if (_origFolderPath != ppTxtPath.Text) + { + // see if an rodb already exists with this pathname. + RODbInfoList roDbList = RODbInfoList.Get(); + foreach (RODbInfo rdi in roDbList) + { + if (ppTxtPath.Text.ToUpper() == rdi.FolderPath.ToUpper()) + { + // get the most recent rofst data for this rodb: + ROFstInfoList roFstList = ROFstInfoList.GetByRODbID(rdi.RODbID); + DateTime dts = new DateTime(1900, 1, 1); + int rofstinfoid = -1; + foreach (ROFstInfo rfi in roFstList) + { + if (rfi.DTS > dts) + { + dts = rfi.DTS; + rofstinfoid = rfi.ROFstID; + } + } + _docVersion.DocVersionAssociations[0].MyROFst = ROFst.Get(rofstinfoid); + _docVersion.Save().Dispose(); + Close(); + return; + } + } + roDb.FolderPath = ppTxtPath.Text; + } + try + { + roDb.Save().Dispose(); + Close(); + return; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return; + } } // this is creating a new rodb. A new rofst record will be created as well & the association set @@ -82,7 +119,7 @@ namespace VEPROMS newroDb.Save().Dispose(); ROFst rofst = ROFstInfo.AddRoFst(newrdi, _docVersion); Close(); - } + } private void frmRODbProperties_Load(object sender, EventArgs e) { ppRTxtName.Text = (_roDbInfo == null) ? null : _roDbInfo.ROName;