diff --git a/PROMS/VEPROMS User Interface/frmSI.Designer.cs b/PROMS/VEPROMS User Interface/frmSI.Designer.cs new file mode 100644 index 00000000..97c2de5f --- /dev/null +++ b/PROMS/VEPROMS User Interface/frmSI.Designer.cs @@ -0,0 +1,90 @@ +namespace VEPROMS +{ + partial class frmSI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.panelSI = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // btnOk + // + this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOk.Location = new System.Drawing.Point(12, 222); + this.btnOk.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 23); + this.btnOk.TabIndex = 0; + this.btnOk.Text = "Ok"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(109, 222); + this.btnCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 1; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // panelPSI + // + this.panelSI.AutoScroll = true; + this.panelSI.Location = new System.Drawing.Point(12, 12); + this.panelSI.Name = "panelSI"; + this.panelSI.Size = new System.Drawing.Size(349, 205); + this.panelSI.TabIndex = 2; + // + // frmSI + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.ClientSize = new System.Drawing.Size(373, 257); + this.Controls.Add(this.panelSI); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "frmSI"; + this.Text = "frmSI"; + this.TopMost = true; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Panel panelSI; + } +} \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/frmSI.cs b/PROMS/VEPROMS User Interface/frmSI.cs new file mode 100644 index 00000000..d0f43f0a --- /dev/null +++ b/PROMS/VEPROMS User Interface/frmSI.cs @@ -0,0 +1,197 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using VEPROMS.CSLA.Library; +using Volian.Controls.Library; + +namespace VEPROMS +{ + public partial class frmSI : Form + { + private StepTabRibbon _MyStepTabRibbon; + private Dictionary _DicStepRtb; + private Dictionary _DicCheckBox; + private bool DoFolder = true; + private SI SIDialogDef = null; + private string OrigConfig = null; + private FolderInfo MyFolderInfo = null; + private DocVersionInfo MyDocVersionInfo = null; + public frmSI(SI siDialogDef, string config, bool doFolder, FolderInfo fi, DocVersionInfo dvi) + { + DoFolder = doFolder; + SIDialogDef = siDialogDef; + OrigConfig = config; + if (DoFolder) MyFolderInfo = fi; + else MyDocVersionInfo = dvi; + InitializeComponent(); + _DicStepRtb = new Dictionary(); + _DicCheckBox = new Dictionary(); + InitializeSpecificControls(); + _MyStepTabRibbon = new StepTabRibbon(); + } + + private void InitializeSpecificControls() + { + this.Text = SIDialogDef.Caption; + this.Location = new Point((int)SIDialogDef.x * 2, (int)SIDialogDef.y * 2); + int maxx = 0; + int maxy = 0; + int xB4Scroll = 900; + int yB4Scroll = 630; + this.panelSI.AutoScroll = false; + foreach (SILabel lbl in SIDialogDef.LabelList) + { + Label wlbl = new Label(); + wlbl.Text = lbl.text; + wlbl.Location = new Point((int)lbl.x * 2, (int)lbl.y * 2); + wlbl.AutoSize = true; + //wlbl.Size = new Size((int)lbl.width * 2, (int)lbl.height * 2); + wlbl.Visible = true; + this.panelSI.Controls.Add(wlbl); + maxx = ((int)lbl.x * 2 + (int)lbl.width * 2) > maxx ? ((int)lbl.x * 2 + (int)lbl.width * 2) : maxx; + maxy = ((int)lbl.y * 2 + (int)lbl.height * 2) > maxy ? ((int)lbl.y * 2 + (int)lbl.height * 2) : maxy; + } + FolderConfig folderConfig = DoFolder ? new FolderConfig(OrigConfig) : null; + DocVersionConfig dvConfig = DoFolder ? null : new DocVersionConfig(OrigConfig); + foreach (SIField fld in SIDialogDef.FieldList) + { + if (fld.type.ToLower() == "text") + { + StepRTB tb = new StepRTB(); + tb.Font = tb.FormatFont = new Font("Arial", 8); + string mystr = tb.FontTable; + _DicStepRtb.Add(fld.name, tb); + tb.MyItemInfo = null; // pi as ItemInfo; + tb.FieldToEdit = E_FieldToEdit.PSI; + tb.BorderStyle = BorderStyle.FixedSingle; + tb.Enter += new System.EventHandler(this.FieldStepRTB_Enter); + // see if config has data for this field, i.e. search for the 'name' + string val = DoFolder ? folderConfig.GetValue("SI", fld.name) : dvConfig.GetValue("SI", fld.name); + DisplayText dt = new DisplayText(val, new VE_Font("Arial", 10, E_Style.None, 12), false); + StringBuilder sb = new StringBuilder(); + sb.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset2 Arial;}"); + sb.Append(@"{\f1\fnil\fcharset0 Arial Unicode MS;}}{\colortbl ;\red255\green0\blue0;}"); + sb.Append(@"\viewkind4\uc1\pard\sl-240\slmult0\fs" + (int)(this.Font.SizeInPoints*2) + " " + dt.StartText + @"}"); + tb.Rtf = sb.ToString(); + tb.Location = new Point((int)fld.x * 2, (int)fld.y * 2); + tb.Size = new Size((int)fld.width * 2, (int)fld.height * 2); + tb.Visible = true; + this.panelSI.Controls.Add(tb); + maxx = ((int)fld.x * 2 + (int)fld.width * 2) > maxx ? ((int)fld.x * 2 + (int)fld.width * 2) : maxx; + maxy = ((int)fld.y * 2 + (int)fld.height * 2) > maxy ? ((int)fld.y * 2 + (int)fld.height * 2) : maxy; + } + if (fld.type.ToLower()== "logical") + { + CheckBox cb = new CheckBox(); + _DicCheckBox.Add(fld.name, cb); + cb.Text = fld.text; + cb.Location = new Point((int)fld.x * 2, (int)fld.y * 2); + cb.Visible = true; + cb.Width = (int)fld.width * 2; + string val = DoFolder ? folderConfig.GetValue("SI", fld.name) : dvConfig.GetValue("SI", fld.name); + cb.Checked = val!=null && val!="" && val.ToUpper()[0] == 'Y' ? true : false; + this.panelSI.Controls.Add(cb); + maxx = ((int)fld.x * 2 + (int)fld.width * 2) > maxx ? ((int)fld.x * 2 + (int)fld.width * 2) : maxx; + maxy = ((int)fld.y * 2 + (int)fld.height * 2) > maxy ? ((int)fld.y * 2 + (int)fld.height * 2) : maxy; + } + } + if (maxx > xB4Scroll) + { + maxx = xB4Scroll; + this.panelSI.Width = xB4Scroll; + this.panelSI.AutoScroll = true; + } + else + this.panelSI.Width = maxx + 50; + if (maxy > yB4Scroll) + { + maxy = yB4Scroll; + this.panelSI.Height = yB4Scroll; + this.panelSI.AutoScroll = true; + } + else + this.panelSI.Height = maxy + 50; + if (SIDialogDef.ButtonsOnBottom == null || SIDialogDef.ButtonsOnBottom.ToUpper() == "NO") + { + btnOk.Location = new Point(maxx+70, 30); + btnCancel.Location = new Point(maxx + 70, 60); + } + } + private void FieldStepRTB_Enter(object sender, EventArgs e) + { + // _MyStepTabRibbon.MyStepRTB = (StepRTB)sender; + } + private void btnOk_Click(object sender, EventArgs e) + { + FolderConfig folderConfig = DoFolder ? new FolderConfig(OrigConfig) : null; + DocVersionConfig dvConfig = DoFolder ? null : new DocVersionConfig(OrigConfig); + + // loop through all of the fields (Text & logical) + bool isDirty = false; + foreach (SIField fld in SIDialogDef.FieldList) + { + if (fld.type.ToLower() == "text") + { + StepRTB cur = _DicStepRtb[fld.name]; + string rtf = cur.Rtf; + string newval = DisplayText.StaticStripRtfCommands(rtf); + // compare to original and if different, save in proc config. + string oldval = DoFolder ? folderConfig.GetValue("SI", fld.name) : dvConfig.GetValue("SI", fld.name); + if (oldval != newval) + { + isDirty = true; + if (DoFolder) + folderConfig.SetValue("SI", fld.name, newval); + else + dvConfig.SetValue("SI", fld.name, newval); + } + } + else if (fld.type.ToLower() == "logical") + { + CheckBox cur = _DicCheckBox[fld.name]; + string newval = cur.Checked ? "Y" : "N"; + string oldval = DoFolder ? folderConfig.GetValue("SI", fld.name) : dvConfig.GetValue("SI", fld.name); + if (newval != oldval) + { + isDirty = true; + if (DoFolder) + folderConfig.SetValue("SI", fld.name, newval); + else + dvConfig.SetValue("SI", fld.name, newval); + } + } + } + if (isDirty) // need to pass in folder or docversion for save. + { + if (DoFolder) + { + using (Folder fld = MyFolderInfo.Get()) + { + fld.Config = folderConfig.ToString(); + fld.Save(); + } + } + else + { + using (DocVersion dv = MyDocVersionInfo.Get()) + { + dv.Config = dvConfig.ToString(); + dv.Save(); + } + } + } + DialogResult = DialogResult.OK; + this.Close(); + } + + private void btnCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + this.Close(); + } + } +} \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/frmSI.resx b/PROMS/VEPROMS User Interface/frmSI.resx new file mode 100644 index 00000000..19dc0dd8 --- /dev/null +++ b/PROMS/VEPROMS User Interface/frmSI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index f47eb7be..b3b1f43f 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -240,6 +240,7 @@ namespace VEPROMS VETreeNode tn = VETreeNode.GetFolder(1); tv.Nodes.Add(tn); tv.NodePSI += new vlnTreeViewPSIEvent(tv_NodePSI); + tv.NodeSI += new vlnTreeViewSIEvent(tv_NodeSI); tv.NodeOpenProperty += new vlnTreeViewPropertyEvent(tv_NodeOpenProperty); tv.NodeSelect += new Volian.Controls.Library.vlnTreeViewEvent(tv_NodeSelect); tv.NodeNew += new vlnTreeViewEvent(tv_NodeNew); @@ -347,7 +348,7 @@ namespace VEPROMS if (fi != null) { string msg = string.Empty; - bool ok = MySessionInfo.CanCheckOutItem(fi.FolderID, CheckOutType.Folder, ref msg); + bool ok = MySessionInfo.CanCheckOutItem(fi.FolderID, CheckOutType.Session, ref msg); if (!ok) { if (args.Index == 0) @@ -357,7 +358,7 @@ namespace VEPROMS } else { - int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, CheckOutType.Folder); + int ownerid = MySessionInfo.CheckOutItem(fi.FolderID, CheckOutType.Session); dlgExportImport dlg = new dlgExportImport(args.Index == 0 ? "Export" : "Import", fi); dlg.ShowDialog(this); MySessionInfo.CheckInItem(ownerid); @@ -701,6 +702,35 @@ namespace VEPROMS MySessionInfo.CheckInItem(ownerID); return dr; } + DialogResult tv_NodeSI(object sender, vlnTreeEventArgs args) + { + VETreeNode vNode = (VETreeNode)args.Node; + IVEDrillDownReadOnly veObj = vNode.VEObject; + // see if working draft or folder & get associated 'SI' info from its config. + // For now, do folder. + bool doFolder = true; + FolderInfo myFolder = veObj as FolderInfo; + DocVersionInfo myDV = veObj as DocVersionInfo; ; + if (myFolder == null) doFolder = false; + string message = string.Empty; + if (!MySessionInfo.CanCheckOutItem(doFolder?myFolder.FolderID:myDV.VersionID, doFolder?CheckOutType.Folder:CheckOutType.DocVersion, ref message)) + { + MessageBox.Show(this, message, "Item Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return DialogResult.None; + } + string strConfig = doFolder ? myFolder.Config : myDV.Config; + FormatInfo fi = doFolder ? myFolder.ActiveFormat : myDV.ActiveFormat; + if (fi == null) + { + MessageBox.Show("You must define a format at this level before access of Specific Information"); + return DialogResult.Cancel; + } + int ownerID = MySessionInfo.CheckOutItem(doFolder ? myFolder.FolderID : myDV.VersionID, doFolder ? CheckOutType.Folder : CheckOutType.DocVersion); + frmSI fsi = new frmSI(fi.PlantFormat.FormatData.SI, strConfig, doFolder, myFolder, myDV); + DialogResult dr = fsi.ShowDialog(this); + MySessionInfo.CheckInItem(ownerID); + return dr; + } /// /// Activate tmrTreeView so that the newly created Step recieves focus /// @@ -1818,16 +1848,34 @@ namespace VEPROMS { if (args.FolderConfig != null) { + string message = string.Empty; + if (!MySessionInfo.CanCheckOutItem(args.FolderConfig.MyFolder.FolderID, CheckOutType.Folder, ref message)) + { + MessageBox.Show(this, message, "Folder Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); + this.Cursor = Cursors.Default; + return DialogResult.None; + } + int ownerID = MySessionInfo.CheckOutItem(args.FolderConfig.MyFolder.FolderID, CheckOutType.Folder); frmFolderProperties frmfld = new frmFolderProperties(args.FolderConfig); dr = frmfld.ShowDialog(); if (dr == DialogResult.OK) epProcedures.TitleText = getProcedurePanelHeading();// get the panel heading + MySessionInfo.CheckInItem(ownerID); } else if (args.DocVersionConfig != null) { + string message = string.Empty; + if (!MySessionInfo.CanCheckOutItem(args.DocVersionConfig.MyDocVersion.VersionID, CheckOutType.DocVersion, ref message)) + { + MessageBox.Show(this, message, "Document Version Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); + this.Cursor = Cursors.Default; + return DialogResult.None; + } + int ownerID = MySessionInfo.CheckOutItem(args.DocVersionConfig.MyDocVersion.VersionID, CheckOutType.DocVersion); frmVersionsProperties frmver = new frmVersionsProperties(args.DocVersionConfig); frmver.ProgressBar = bottomProgBar; dr = frmver.ShowDialog(); + MySessionInfo.CheckInItem(ownerID); } else if (args.ProcedureConfig != null) {