This commit is contained in:
109
PROMS/VEPROMS User Interface/frmRODbProperties.cs
Normal file
109
PROMS/VEPROMS User Interface/frmRODbProperties.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace VEPROMS
|
||||
{
|
||||
public partial class frmRODbProperties : Form
|
||||
{
|
||||
private RODbInfo _roDbInfo;
|
||||
private string _origROName;
|
||||
private string _origFolderPath;
|
||||
private DocVersion _docVersion;
|
||||
public frmRODbProperties(DocVersion docVersion, RODbInfo roDbInfo)
|
||||
{
|
||||
_roDbInfo = roDbInfo;
|
||||
_docVersion = docVersion;
|
||||
InitializeComponent();
|
||||
_origROName = (_roDbInfo == null) ? null : _roDbInfo.ROName;
|
||||
_origFolderPath = (_roDbInfo == null) ? null : _roDbInfo.FolderPath;
|
||||
}
|
||||
|
||||
private void ppBtnFldrDlg_Click(object sender, EventArgs e)
|
||||
{
|
||||
FolderBrowserDialog dlgROFolder = new FolderBrowserDialog();
|
||||
if (dlgROFolder.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ppTxtPath.Text = dlgROFolder.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void ppBtnOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
// check for modify - if modify, just save current data, 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;
|
||||
}
|
||||
|
||||
// this is creating a new rodb. A new rofst record will be created as well & the association set
|
||||
// check for unique name/path first
|
||||
RODbInfoList allrodbinfo = RODbInfoList.Get();
|
||||
foreach (RODbInfo rdi in allrodbinfo)
|
||||
{
|
||||
if (ppRTxtName.Text == rdi.ROName || ppTxtPath.Text == rdi.FolderPath)
|
||||
{
|
||||
MessageBox.Show("Name and/or folder path are not unique, create unique names.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ppRTxtName.Text == null || ppRTxtName.Text == "")
|
||||
{
|
||||
MessageBox.Show("You must enter a Name.");
|
||||
return;
|
||||
}
|
||||
if (ppTxtPath.Text == null || ppTxtPath.Text == "")
|
||||
{
|
||||
MessageBox.Show("You must enter a Path.");
|
||||
return;
|
||||
}
|
||||
|
||||
// check for an ro.fst existing in the selected path. If it is valid, create an rodb, rofst
|
||||
// and an association to its docversion.
|
||||
string rofstPath = ppTxtPath.Text + @"\ro.fst";
|
||||
if (!File.Exists(rofstPath))
|
||||
{
|
||||
MessageBox.Show("No existing ro.fst in path " + ppTxtPath.Text + ". Check for invalid path");
|
||||
return;
|
||||
}
|
||||
RODb newroDb = RODb.MakeRODb(ppRTxtName.Text, ppTxtPath.Text, "cstring", null);
|
||||
RODbInfo newrdi = RODbInfo.Get(newroDb.RODbID);
|
||||
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;
|
||||
ppTxtPath.Text = (_roDbInfo == null) ? null : _roDbInfo.FolderPath;
|
||||
RODbConfig cfg = (_roDbInfo == null) ? new RODbConfig() : new RODbConfig(_roDbInfo);
|
||||
// Note that the Graphic Extension data is shown in a non-editable text box here because
|
||||
// the data is either retrieved from the roapp.ini - and if there can only be editted from
|
||||
// the file system. Otherwise it is derived from the top node - and changed from folder
|
||||
// properties on the top node. And lastly, it is the code default.
|
||||
ppTxtExt.Text = cfg.GetDefaultGraphicExtension();
|
||||
ppLblGraphicFileExtLoc.Text = (cfg == null) ? null : cfg.GetDefaultGraphicExtensionLocation();
|
||||
if (_roDbInfo == null)
|
||||
{
|
||||
string newFolderPath = null;
|
||||
FolderBrowserDialog dlgROFolder = new FolderBrowserDialog();
|
||||
if (dlgROFolder.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
newFolderPath = dlgROFolder.SelectedPath;
|
||||
}
|
||||
ppTxtPath.Text = newFolderPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user