TS - Bus objects updated + Service classes and forms added

This commit is contained in:
Thomas Savine
2020-03-23 09:12:33 +00:00
parent 114aa49535
commit 7edbd07575
55 changed files with 8312 additions and 372 deletions
@@ -0,0 +1,124 @@
namespace Sarand.PatientMgr.Win.Forms.Maint
{
partial class SpmForm_Institution
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonOk = new Sarand.Win.Forms.Controls.SacsButton();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabControl = new System.Windows.Forms.TabControl();
this.buttonCancel = new Sarand.Win.Forms.Controls.SacsButton();
this.groupBoxProperties = new Sarand.Win.Forms.Controls.SacsGroupBox();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(411, 441);
this.buttonOk.Margin = new System.Windows.Forms.Padding(4);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(100, 28);
this.buttonOk.TabIndex = 6;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 25);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(600, 197);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 25);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(600, 68);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// tabControl
//
this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(12, 208);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(608, 226);
this.tabControl.TabIndex = 5;
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(519, 441);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(100, 28);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// groupBoxProperties
//
this.groupBoxProperties.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBoxProperties.BorderColour = System.Drawing.Color.Gray;
this.groupBoxProperties.Location = new System.Drawing.Point(12, 12);
this.groupBoxProperties.Name = "groupBoxProperties";
this.groupBoxProperties.Size = new System.Drawing.Size(608, 190);
this.groupBoxProperties.TabIndex = 4;
this.groupBoxProperties.TabStop = false;
this.groupBoxProperties.Text = "Properties";
//
// SpmForm_Institution
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(632, 482);
this.ControlBox = false;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.groupBoxProperties);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(650, 500);
this.Name = "SpmForm_Institution";
this.ShowIcon = false;
this.Text = "Update Institution";
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Sarand.Win.Forms.Controls.SacsButton buttonOk;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabControl tabControl;
private Sarand.Win.Forms.Controls.SacsButton buttonCancel;
private Sarand.Win.Forms.Controls.SacsGroupBox groupBoxProperties;
}
}
@@ -0,0 +1,162 @@
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Core.Bus;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.Win.Forms.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Sarand.PatientMgr.Win.Forms.Maint
{
//=======================================================================
public partial class SpmForm_Institution : SpmForm_Item
{
//-------------------------------------------------------------------
// Configuration.
public new class Config : SpmForm_Item.Config
{
public SpmInstitution InstitutionToUpdate { internal get; set; } = null;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
//-------------------------------------------------------------------
// Construction.
public SpmForm_Institution() : this(new Config()) { }
public SpmForm_Institution(Config config) : base(config)
{
this.config = config;
if (SpmGlobals.System != null)
{
}
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
[Browsable(false)]
protected override String DefaultMessageTitle { get { return "Institution"; } }
//-------------------------------------------------------------------
// S h o w D i a l o g
//-------------------------------------------------------------------
public new DialogResult ShowDialog()
{
return base.ShowDialog();
}
// Validate configuration to ensure that form can be opened correctly.
private bool ValidateConfiguration()
{
return true;
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Complete dialog initialisation.
PositionControls();
AcceptChanges();
SetControlActivity();
}
//-------------------------------------------------------------------
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
// Initial focus.
}
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
// PopulateToControls.
private void PopulateToControls(SpmInstitution.Data data)
{
// Populate item properties to controls.
AcceptChanges();
}
//-------------------------------------------------------------------
// Validate properties.
public bool IsDataValid(SpmInstitution.Data data)
{
return true;
}
//-------------------------------------------------------------------
// PopulateFromControls.
private void PopulateFromControls(SpmInstitution.Data data)
{
}
//-------------------------------------------------------------------
// UpdatedAssociated Data.
public bool UpdateAssociatedData()
{
return true;
}
//-------------------------------------------------------------------
// C l o s e F o r m
//-------------------------------------------------------------------
private void buttonOk_Click(object sender, EventArgs e)
{
}
private void buttonCancel_Click(object sender, EventArgs e)
{
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity()
{
SetControlsReadOnly();
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
if (ReadOnly) return true;
return false;
}
protected override void SetControlsReadOnly()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls()
{
}
//-------------------------------------------------------------------
// F o r m E v e n t s
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,186 @@
namespace Sarand.PatientMgr.Win.Forms.Panels
{
partial class SpmPanel_Employees
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listFilterEmployee = new Sarand.PatientMgr.Win.Forms.Filters.SpmItemListFilter_Employee();
this.listViewEmployee = new Sarand.PatientMgr.Win.Forms.Controls.SpmItemListView_Employee();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.buttonRemove = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// listFilterEmployee
//
this.listFilterEmployee.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listFilterEmployee.Location = new System.Drawing.Point(0, 2);
this.listFilterEmployee.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.listFilterEmployee.Name = "listFilterEmployee";
this.listFilterEmployee.Size = new System.Drawing.Size(400, 30);
this.listFilterEmployee.TabIndex = 0;
this.listFilterEmployee.FilterChanged += new System.EventHandler(this.listFilterEmployee_FilterChanged);
//
// listViewEmployee
//
this.listViewEmployee.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewEmployee.FullRowSelect = true;
this.listViewEmployee.HideSelection = false;
this.listViewEmployee.Location = new System.Drawing.Point(0, 37);
this.listViewEmployee.Margin = new System.Windows.Forms.Padding(2);
this.listViewEmployee.Name = "listViewEmployee";
this.listViewEmployee.OwnerDraw = true;
this.listViewEmployee.Size = new System.Drawing.Size(317, 155);
this.listViewEmployee.TabIndex = 1;
this.listViewEmployee.UseCompatibleStateImageBehavior = false;
this.listViewEmployee.ItemCountChanged += new System.EventHandler<Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs>(this.listViewEmployee_ItemCountChanged);
this.listViewEmployee.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewEmployee_ColumnClick);
this.listViewEmployee.SelectedIndexChanged += new System.EventHandler(this.listViewEmployee_SelectedIndexChanged);
this.listViewEmployee.DoubleClick += new System.EventHandler(this.listViewEmployee_DoubleClick);
this.listViewEmployee.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listViewEmployee_MouseUp);
//
// tabControl
//
this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(2, 196);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(398, 154);
this.tabControl.TabIndex = 6;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(390, 128);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(390, 128);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// buttonRemove
//
this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRemove.Location = new System.Drawing.Point(322, 95);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(75, 23);
this.buttonRemove.TabIndex = 15;
this.buttonRemove.Text = "Remove";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
//
// buttonUpdate
//
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUpdate.Location = new System.Drawing.Point(322, 66);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreate.Location = new System.Drawing.Point(322, 37);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.TabIndex = 13;
this.buttonCreate.Text = "Create";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(322, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(322, 139);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 15;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// SpmPanel_Employees
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRemove);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.listViewEmployee);
this.Controls.Add(this.listFilterEmployee);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(400, 350);
this.Name = "SpmPanel_Employees";
this.Size = new System.Drawing.Size(400, 350);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Filters.SpmItemListFilter_Employee listFilterEmployee;
private Controls.SpmItemListView_Employee listViewEmployee;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Button buttonRemove;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOk;
}
}
@@ -0,0 +1,604 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.TabPages;
using Sarand.PatientMgr.Win.Forms.Filters;
using Sarand.PatientMgr.Win.Forms.Base;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_Employees : SpmPanel_Items
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelMode
{
Search,
Maintain,
}
public new class Config : SpmPanel_Items.Config
{
public Config (PanelMode mode)
{
Mode = mode;
// Defaults based on mode.
DisplayFilter = false; // Mode == PanelMode.Maintain || Mode == PanelMode.Search;
DisplayTabs = Mode == PanelMode.Maintain;
DisplayActionButtons = Mode == PanelMode.Maintain;
DisplayNavigationButtons = Mode == PanelMode.Search;
}
public PanelMode Mode { get; } = PanelMode.Maintain;
public SpmForm SearchForm { get; set; }
// Display options.
public bool DisplayFilter { get; set; } = false;
public bool DisplayContextMenu { get; set; } = true;
public bool DisplayActionButtons { get; set; } = false;
public bool DisplayNavigationButtons { get; set; } = false;
public bool DisplayTabs { get; set; } = false;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config(PanelMode.Search);
private readonly List<SpmTabPage_Employee> tabPages = new List<SpmTabPage_Employee>();
//-------------------------------------------------------------------
// Construction.
private SpmPanel_Employees () : this(new Config(PanelMode.Search)) { }
public SpmPanel_Employees (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected override String DefaultMessageTitle { get { return "Employee"; } }
public override int ItemTotal { get { return listViewEmployee.ItemTotal; } }
public override int ItemCount { get { return listViewEmployee.ItemCount; } }
public override int SelectedItemCount { get { return listViewEmployee.SelectedItemCount; } }
public SysId SelectedItemId { get { return listViewEmployee.SelectedItemId; } }
public List<SysId> SelectedItemIds { get { return listViewEmployee.SelectedItemIds; } }
public SpmEmployee SelectedEmployee { get { return listViewEmployee.SelectedEmployee; } }
//-------------------------------------------------------------------
// Configure.
public void SetConfig (Config config)
{
base.SetConfig(config);
this.config = config;
ConfigurePanel();
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
ConfigurePanel();
}
private void ConfigurePanel ()
{
if (!Created || this.IsDesignerHosted()) return;
// Configure filter.
if (config.DisplayFilter)
{
SpmItemListFilter_Employee.Config configFilter = new SpmItemListFilter_Employee.Config();
configFilter.Internals = Internals;
listFilterEmployee.SetConfig(configFilter);
}
listFilterEmployee.Visible = config.DisplayFilter;
// Configure list.
SpmItemListView_Employee.Config configList = new SpmItemListView_Employee.Config();
configList.Internals = Internals;
configList.Mode = SpmItemListView_Employee.ListMode.General;
listViewEmployee.SetConfig(configList);
// Tabs.
tabControl.TabPages.Clear();
tabControl.Visible = config.DisplayTabs;
RefreshTabs();
// Configure buttons.
buttonCreate.Visible = config.DisplayActionButtons && SecurityProfile.Admin.CanManageConfig();
buttonUpdate.Visible = config.DisplayActionButtons;
buttonRemove.Visible = config.DisplayActionButtons && buttonCreate.Visible;
buttonOk.Visible = config.DisplayNavigationButtons && config.Mode == PanelMode.Search;
buttonCancel.Visible = config.DisplayNavigationButtons;
// Complete form initialisation.
RefreshDataItems();
SetControlActivity();
PositionControls();
}
//-------------------------------------------------------------------
// Initialise tabs.
private void InitTabs ()
{
String fn = GetType().Name + ".InitTabs";
tabControl.TabPages.Clear();
tabPages.Clear();
if (!config.DisplayTabs)
{
tabPages.Clear();
tabControl.TabPages.Clear();
tabControl.Visible = false;
return;
}
// Selected Employee.
SpmEmployee employee = SelectedEmployee;
// Updates.
List<SpmTabPage_Employee.PanelType> panelTypes_Updates = new List<SpmTabPage_Employee.PanelType>();
panelTypes_Updates.Add(SpmTabPage_Employee.PanelType.Updates);
if (panelTypes_Updates.Count > 0)
{
SpmTabPage_Employee.Config configTabPage = new SpmTabPage_Employee.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Updates);
SpmTabPage_Employee tabPage = new SpmTabPage_Employee(configTabPage) { Text = "Updates" };
tabPages.Add(tabPage);
}
// Populate tab pages.
tabControl.Visible = tabPages.Count > 0;
foreach (var tabPage in tabPages)
tabControl.TabPages.Add(tabPage);
}
//-------------------------------------------------------------------
// P a n e l I n t e r f a c e
//-------------------------------------------------------------------
private String previouslySelectedTabPageText = "";
private void RefreshTabs ()
{
if (tabControl.SelectedTab != null)
previouslySelectedTabPageText = tabControl.SelectedTab.Text;
// Reinitialise tabs whenever the selection changes in case the set of tab pages displayed needs to be changed.
InitTabs();
// Select previous tab page if still present.
if (!StringUtil.IsEmpty(previouslySelectedTabPageText))
{
foreach (TabPage tabPage in tabControl.TabPages)
{
if (tabPage.Text.Equals(previouslySelectedTabPageText))
{
tabControl.SelectTab(tabPage);
break;
}
}
}
RefreshTabPages();
SetControlActivity();
PositionControls();
}
private void RefreshTabPages ()
{
// Selected Employee - populated when needed.
SpmEmployee employee = null;
// Refresh tabs.
if (tabControl.Visible)
{
if (employee == null) employee = SelectedEmployee;
SpmEmployee.Data employeeData = employee != null ? employee.GetData() : new SpmEmployee.Data();
tabPages.PopulateToControls(employeeData);
}
}
//-------------------------------------------------------------------
// F i l t e r
//-------------------------------------------------------------------
public bool ParamsAreValid (SpmEmployee.Params prmEmployee)
{
return true;
}
public SpmEmployee.Params GetParams ()
{
SpmEmployee.Params prmEmployee = new SpmEmployee.Params();
// Sort columns.
prmEmployee.SortColumns.AddRange(listViewEmployee.GetSortColumns());
return prmEmployee;
}
//-------------------------------------------------------------------
// A c t i o n s
//-------------------------------------------------------------------
// Refresh.
public override void RefreshDataItems ()
{
SpmEmployee.Params prmEmployee = GetParams();
if (!ParamsAreValid(prmEmployee)) prmEmployee = null;
listViewEmployee.RefreshEmployees(prmEmployee);
}
public override void RefreshDataItem (SysId id)
{
listViewEmployee.RefreshEmployee(id);
}
public override void RemoveDataItem (SysId id)
{
listViewEmployee.RemoveItemById(id);
}
//-------------------------------------------------------------------
// Create item.
public override bool CanCreateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void CreateItem ()
{
if (!CanCreateItem()) return;
if (config.Mode == PanelMode.Search) return;
// Create new Employee.
SpmForm_Employee.Config configEmployee = new SpmForm_Employee.Config();
using (var form = new SpmForm_Employee(configEmployee))
{
if (form.ShowDialog() == DialogResult.OK)
{
RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.DataItemType.Employee, form.NewItemId);
}
}
}
//-------------------------------------------------------------------
// View/Update item.
public override bool CanViewItem ()
{
return true;
}
public override bool CanUpdateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void UpdateItem (bool updateItem = true)
{
if (config.Mode == PanelMode.Search) return;
SpmEmployee employee = SelectedEmployee;
if (SelectedItemCount != 1) return;
if (!CanUpdateItem() && !CanViewItem()) return;
if (!CanUpdateItem()) updateItem = false;
if (employee == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve selected item");
return;
}
SpmForm_Employee.Config configEmployee = new SpmForm_Employee.Config();
configEmployee.EmployeeToUpdate = employee;
configEmployee.ReadOnly = (config.ReadOnly || !updateItem);
using (SpmForm_Employee formEmployee = new SpmForm_Employee(configEmployee))
{
// Perform the update.
if (formEmployee.ShowDialog() == DialogResult.OK)
{
// Employee has been updated.
RefreshDataItem(employee.Id);
listViewEmployee.RefreshEmployee(employee.Id);
InvokeItemUpdatedEvent(Spm.DataItemType.Employee, employee.Id);
}
}
}
//-------------------------------------------------------------------
// Delete item.
public override bool CanDeleteItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void DeleteItem ()
{
if (!CanDeleteItem()) return;
if (config.Mode == PanelMode.Search) return;
if (SelectedItemCount != 1) return;
SpmEmployee employee = SelectedEmployee;
if (employee == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve item for deletion.");
return;
}
if (!InstitutionMgr.EmployeeCanBeDeleted(employee))
{
MessageConsole.ShowMessageError("Unable to remove employee - " + InstitutionMgr.ErrorStateMessage + ".");
return;
}
if (MessageConsole.ShowMessageConfirm("Are you sure that this employee should be removed from the system?"))
{
if (InstitutionMgr.DeleteEmployee(employee, DbUpdateInfo))
{
int selectIdx = listViewEmployee.SelectedIndex;
listViewEmployee.RemoveItemById(employee.Id.ToString());
if (selectIdx >= listViewEmployee.ItemCount - 1) selectIdx--;
listViewEmployee.SelectedIndices.Clear();
listViewEmployee.SelectedIndices.Add(selectIdx);
}
else MessageConsole.ShowMessageError("Failed to remove employee - " + InstitutionMgr.ErrorStateMessage + ".");
}
}
//-------------------------------------------------------------------
// Import data.
public override bool CanImportData ()
{
return false;
}
public override void ImportData ()
{
if (!CanImportData()) return;
}
//-------------------------------------------------------------------
// Export data.
public override bool CanExportData ()
{
return false;
}
public override void ExportData ()
{
}
//-------------------------------------------------------------------
// C o n t e x t M e n u
//-------------------------------------------------------------------
private SpmContextMenuStrip contextMenuStrip = new SpmContextMenuStrip();
private void RefreshContextMenu ()
{
contextMenuStrip.Name = "Employee";
contextMenuStrip.Items.Clear();
if (CanCreateItem())
contextMenuStrip.Items.Add("Create", null, CreateItem);
if (SysId.IsValid(listViewEmployee.SelectedItemId))
{
SpmEmployee employee = SelectedEmployee;
if (employee != null)
{
if (CanUpdateItem() || CanDeleteItem())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
contextMenuStrip.Items.Add(CanUpdateItem() ? "Update" : "View", null, UpdateItem);
if (CanDeleteItem())
contextMenuStrip.Items.Add("Remove", null, DeleteItem);
}
}
}
if (CanExportData() || CanImportData())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
if (CanImportData())
contextMenuStrip.Items.Add("Import", null, ImportData);
if (CanExportData())
contextMenuStrip.Items.Add("Export", null, ExportData);
}
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
bool itemSelected = SysId.IsValid(SelectedItemId);
listViewEmployee.Enabled = Enabled;
buttonCreate.Enabled = Enabled;
buttonUpdate.Enabled = Enabled && itemSelected;
buttonRemove.Enabled = Enabled && itemSelected;
buttonOk.Enabled = Enabled;
buttonCancel.Enabled = Enabled;
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls ()
{
if (this.IsDesignerHosted() || !Created) return;
Rectangle clientRect = ClientRectangle;
//---------------------------------------------------------------
// Filter panel.
if (listFilterEmployee.Visible)
{
listFilterEmployee.PositionAtTopLeftOf(this);
listFilterEmployee.SetFullWidthOf(this);
listFilterEmployee.ResizeToBottomControl();
listViewEmployee.PositionBelow(listFilterEmployee);
}
else
{
listViewEmployee.PositionAtTopLeftOf(this);
}
//---------------------------------------------------------------
// List view.
int buttonLeft = clientRect.Width - buttonCreate.Width - buttonCreate.Margin.Right - Padding.Right;
listViewEmployee.Left = listViewEmployee.Margin.Left;
listViewEmployee.Width = buttonLeft - buttonCreate.Margin.Left - listViewEmployee.Left - listViewEmployee.Margin.Right;
if (!(buttonCreate.Visible || buttonUpdate.Visible || buttonRemove.Visible || buttonOk.Visible || buttonCancel.Visible))
listViewEmployee.Width = clientRect.Width - Padding.Right - listViewEmployee.Left - listViewEmployee.Margin.Right;
//---------------------------------------------------------------
// Tab control.
if (tabControl.Visible)
{
tabControl.Left = listViewEmployee.Left;
tabControl.Width = clientRect.Width - (tabControl.Left * 2);
listViewEmployee.Height = (int)((clientRect.Height - listViewEmployee.Top) * 0.40);
tabControl.Top = listViewEmployee.Bottom + listViewEmployee.Margin.Bottom + tabControl.Margin.Top;
tabControl.Height = clientRect.Height - tabControl.Top - tabControl.Margin.Bottom - Padding.Bottom;
}
else
{
listViewEmployee.Height = clientRect.Height - listViewEmployee.Top - listViewEmployee.Margin.Bottom - Padding.Bottom;
}
//---------------------------------------------------------------
// Create button.
int buttonTop = listViewEmployee.Top + listViewEmployee.HeaderHeight;
buttonCreate.Top = buttonTop;
buttonCreate.Left = buttonLeft;
if (buttonCreate.Visible)
buttonTop += buttonCreate.Height + buttonCreate.Margin.Bottom;
// Update button.
buttonUpdate.Top = buttonTop;
buttonUpdate.Left = buttonLeft;
if (buttonUpdate.Visible)
buttonTop += buttonUpdate.Height + buttonUpdate.Margin.Bottom;
// Remove button.
buttonRemove.Top = buttonTop;
buttonRemove.Left = buttonLeft;
if (buttonRemove.Visible)
buttonTop += buttonRemove.Height + buttonRemove.Margin.Bottom;
//---------------------------------------------------------------
// Navigation buttons.
// Cancel button.
buttonCancel.Top = clientRect.Bottom - Padding.Bottom - buttonCancel.Margin.Bottom - buttonCancel.Height;
buttonCancel.Left = buttonLeft;
// OK button.
buttonOk.Top = buttonCancel.Top - buttonOk.Height - buttonCancel.Padding.Top - buttonCancel.Margin.Bottom;
buttonOk.Left = buttonLeft;
if (buttonOk.Visible)
buttonTop += buttonOk.Height + buttonOk.Margin.Bottom;
//---------------------------------------------------------------
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
// Filter.
private void listFilterEmployee_FilterChanged (object sender, EventArgs e)
{
RefreshDataItems();
SetControlActivity();
}
//-------------------------------------------------------------------
// Item list.
private void listViewEmployee_ColumnClick (object sender, ColumnClickEventArgs e)
{
RefreshDataItems();
}
private void listViewEmployee_ItemCountChanged (object sender, Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs e)
{
InvokeItemCountChangedEvent(e);
}
private void listViewEmployee_SelectedIndexChanged (object sender, EventArgs e)
{
RefreshTabs();
InvokeItemSelectionChangedEvent(e);
SetControlActivity();
}
private void listViewEmployee_DoubleClick (object sender, EventArgs e)
{
if (config.Mode == PanelMode.Search)
{
//if (config.SearchForm != null) config.SearchForm.OnOK();
}
else
UpdateItem();
SetControlActivity();
}
private void listViewEmployee_MouseUp (object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
// Refresh the context menu and display at pointer position.
RefreshContextMenu();
contextMenuStrip.Show(listViewEmployee, new Point(e.X, e.Y), ToolStripDropDownDirection.Default);
break;
}
SetControlActivity();
}
//-------------------------------------------------------------------
// Actions.
private void buttonCreate_Click (object sender, EventArgs e)
{
CreateItem();
SetControlActivity();
}
private void buttonUpdate_Click (object sender, EventArgs e)
{
UpdateItem();
SetControlActivity();
}
private void buttonRemove_Click (object sender, EventArgs e)
{
DeleteItem();
SetControlActivity();
}
private void buttonOk_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnOK();
return;
}
SetControlActivity();
}
private void buttonCancel_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnCancel();
return;
}
SetControlActivity();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,186 @@
namespace Sarand.PatientMgr.Win.Forms.Panels
{
partial class SpmPanel_Institutions
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
this.listFilterInstitution = new Sarand.PatientMgr.Win.Forms.Filters.SpmItemListFilter_Institution();
this.listViewInstitution = new Sarand.PatientMgr.Win.Forms.Controls.SpmItemListView_Institution();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.buttonRemove = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// listFilterInstitution
//
this.listFilterInstitution.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listFilterInstitution.Location = new System.Drawing.Point(0, 2);
this.listFilterInstitution.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.listFilterInstitution.Name = "listFilterInstitution";
this.listFilterInstitution.Size = new System.Drawing.Size(400, 30);
this.listFilterInstitution.TabIndex = 0;
this.listFilterInstitution.FilterChanged += new System.EventHandler(this.listFilterInstitution_FilterChanged);
//
// listViewInstitution
//
this.listViewInstitution.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewInstitution.FullRowSelect = true;
this.listViewInstitution.HideSelection = false;
this.listViewInstitution.Location = new System.Drawing.Point(0, 37);
this.listViewInstitution.Margin = new System.Windows.Forms.Padding(2);
this.listViewInstitution.Name = "listViewInstitution";
this.listViewInstitution.OwnerDraw = true;
this.listViewInstitution.Size = new System.Drawing.Size(317, 155);
this.listViewInstitution.TabIndex = 1;
this.listViewInstitution.UseCompatibleStateImageBehavior = false;
this.listViewInstitution.ItemCountChanged += new System.EventHandler<Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs>(this.listViewInstitution_ItemCountChanged);
this.listViewInstitution.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewInstitution_ColumnClick);
this.listViewInstitution.SelectedIndexChanged += new System.EventHandler(this.listViewInstitution_SelectedIndexChanged);
this.listViewInstitution.DoubleClick += new System.EventHandler(this.listViewInstitution_DoubleClick);
this.listViewInstitution.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listViewInstitution_MouseUp);
//
// tabControl
//
this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(2, 196);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(398, 154);
this.tabControl.TabIndex = 6;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(390, 128);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(390, 128);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// buttonRemove
//
this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRemove.Location = new System.Drawing.Point(322, 95);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(75, 23);
this.buttonRemove.TabIndex = 15;
this.buttonRemove.Text = "Remove";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
//
// buttonUpdate
//
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUpdate.Location = new System.Drawing.Point(322, 66);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreate.Location = new System.Drawing.Point(322, 37);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.TabIndex = 13;
this.buttonCreate.Text = "Create";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(322, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(322, 139);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 15;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// SpmPanel_Institutions
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRemove);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.listViewInstitution);
this.Controls.Add(this.listFilterInstitution);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(400, 350);
this.Name = "SpmPanel_Institutions";
this.Size = new System.Drawing.Size(400, 350);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Filters.SpmItemListFilter_Institution listFilterInstitution;
private Controls.SpmItemListView_Institution listViewInstitution;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Button buttonRemove;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOk;
}
}
@@ -0,0 +1,604 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.TabPages;
using Sarand.PatientMgr.Win.Forms.Filters;
using Sarand.PatientMgr.Win.Forms.Base;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_Institutions : SpmPanel_Items
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelMode
{
Search,
Maintain,
}
public new class Config : SpmPanel_Items.Config
{
public Config (PanelMode mode)
{
Mode = mode;
// Defaults based on mode.
DisplayFilter = false; // Mode == PanelMode.Maintain || Mode == PanelMode.Search;
DisplayTabs = Mode == PanelMode.Maintain;
DisplayActionButtons = Mode == PanelMode.Maintain;
DisplayNavigationButtons = Mode == PanelMode.Search;
}
public PanelMode Mode { get; } = PanelMode.Maintain;
public SpmForm SearchForm { get; set; }
// Display options.
public bool DisplayFilter { get; set; } = false;
public bool DisplayContextMenu { get; set; } = true;
public bool DisplayActionButtons { get; set; } = false;
public bool DisplayNavigationButtons { get; set; } = false;
public bool DisplayTabs { get; set; } = false;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config(PanelMode.Search);
private readonly List<SpmTabPage_Institution> tabPages = new List<SpmTabPage_Institution>();
//-------------------------------------------------------------------
// Construction.
private SpmPanel_Institutions () : this(new Config(PanelMode.Search)) { }
public SpmPanel_Institutions (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected override String DefaultMessageTitle { get { return "Institution"; } }
public override int ItemTotal { get { return listViewInstitution.ItemTotal; } }
public override int ItemCount { get { return listViewInstitution.ItemCount; } }
public override int SelectedItemCount { get { return listViewInstitution.SelectedItemCount; } }
public SysId SelectedItemId { get { return listViewInstitution.SelectedItemId; } }
public List<SysId> SelectedItemIds { get { return listViewInstitution.SelectedItemIds; } }
public SpmInstitution SelectedInstitution { get { return listViewInstitution.SelectedInstitution; } }
//-------------------------------------------------------------------
// Configure.
public void SetConfig (Config config)
{
base.SetConfig(config);
this.config = config;
ConfigurePanel();
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
ConfigurePanel();
}
private void ConfigurePanel ()
{
if (!Created || this.IsDesignerHosted()) return;
// Configure filter.
if (config.DisplayFilter)
{
SpmItemListFilter_Institution.Config configFilter = new SpmItemListFilter_Institution.Config();
configFilter.Internals = Internals;
listFilterInstitution.SetConfig(configFilter);
}
listFilterInstitution.Visible = config.DisplayFilter;
// Configure list.
SpmItemListView_Institution.Config configList = new SpmItemListView_Institution.Config();
configList.Internals = Internals;
configList.Mode = SpmItemListView_Institution.ListMode.General;
listViewInstitution.SetConfig(configList);
// Tabs.
tabControl.TabPages.Clear();
tabControl.Visible = config.DisplayTabs;
RefreshTabs();
// Configure buttons.
buttonCreate.Visible = config.DisplayActionButtons && SecurityProfile.Admin.CanManageConfig();
buttonUpdate.Visible = config.DisplayActionButtons;
buttonRemove.Visible = config.DisplayActionButtons && buttonCreate.Visible;
buttonOk.Visible = config.DisplayNavigationButtons && config.Mode == PanelMode.Search;
buttonCancel.Visible = config.DisplayNavigationButtons;
// Complete form initialisation.
RefreshDataItems();
SetControlActivity();
PositionControls();
}
//-------------------------------------------------------------------
// Initialise tabs.
private void InitTabs ()
{
String fn = GetType().Name + ".InitTabs";
tabControl.TabPages.Clear();
tabPages.Clear();
if (!config.DisplayTabs)
{
tabPages.Clear();
tabControl.TabPages.Clear();
tabControl.Visible = false;
return;
}
// Selected Institution.
SpmInstitution institution = SelectedInstitution;
// Updates.
List<SpmTabPage_Institution.PanelType> panelTypes_Updates = new List<SpmTabPage_Institution.PanelType>();
panelTypes_Updates.Add(SpmTabPage_Institution.PanelType.Updates);
if (panelTypes_Updates.Count > 0)
{
SpmTabPage_Institution.Config configTabPage = new SpmTabPage_Institution.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Updates);
SpmTabPage_Institution tabPage = new SpmTabPage_Institution(configTabPage) { Text = "Updates" };
tabPages.Add(tabPage);
}
// Populate tab pages.
tabControl.Visible = tabPages.Count > 0;
foreach (var tabPage in tabPages)
tabControl.TabPages.Add(tabPage);
}
//-------------------------------------------------------------------
// P a n e l I n t e r f a c e
//-------------------------------------------------------------------
private String previouslySelectedTabPageText = "";
private void RefreshTabs ()
{
if (tabControl.SelectedTab != null)
previouslySelectedTabPageText = tabControl.SelectedTab.Text;
// Reinitialise tabs whenever the selection changes in case the set of tab pages displayed needs to be changed.
InitTabs();
// Select previous tab page if still present.
if (!StringUtil.IsEmpty(previouslySelectedTabPageText))
{
foreach (TabPage tabPage in tabControl.TabPages)
{
if (tabPage.Text.Equals(previouslySelectedTabPageText))
{
tabControl.SelectTab(tabPage);
break;
}
}
}
RefreshTabPages();
SetControlActivity();
PositionControls();
}
private void RefreshTabPages ()
{
// Selected Institution - populated when needed.
SpmInstitution institution = null;
// Refresh tabs.
if (tabControl.Visible)
{
if (institution == null) institution = SelectedInstitution;
SpmInstitution.Data institutionData = institution != null ? institution.GetData() : new SpmInstitution.Data();
tabPages.PopulateToControls(institutionData);
}
}
//-------------------------------------------------------------------
// F i l t e r
//-------------------------------------------------------------------
public bool ParamsAreValid (SpmInstitution.Params prmInstitution)
{
return true;
}
public SpmInstitution.Params GetParams ()
{
SpmInstitution.Params prmInstitution = new SpmInstitution.Params();
// Sort columns.
prmInstitution.SortColumns.AddRange(listViewInstitution.GetSortColumns());
return prmInstitution;
}
//-------------------------------------------------------------------
// A c t i o n s
//-------------------------------------------------------------------
// Refresh.
public override void RefreshDataItems ()
{
SpmInstitution.Params prmInstitution = GetParams();
if (!ParamsAreValid(prmInstitution)) prmInstitution = null;
listViewInstitution.RefreshInstitutions(prmInstitution);
}
public override void RefreshDataItem (SysId id)
{
listViewInstitution.RefreshInstitution(id);
}
public override void RemoveDataItem (SysId id)
{
listViewInstitution.RemoveItemById(id);
}
//-------------------------------------------------------------------
// Create item.
public override bool CanCreateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void CreateItem ()
{
if (!CanCreateItem()) return;
if (config.Mode == PanelMode.Search) return;
// Create new Institution.
SpmForm_Institution.Config configInstitution = new SpmForm_Institution.Config();
using (var form = new SpmForm_Institution(configInstitution))
{
if (form.ShowDialog() == DialogResult.OK)
{
RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.DataItemType.Institution, form.NewItemId);
}
}
}
//-------------------------------------------------------------------
// View/Update item.
public override bool CanViewItem ()
{
return true;
}
public override bool CanUpdateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void UpdateItem (bool updateItem = true)
{
if (config.Mode == PanelMode.Search) return;
SpmInstitution institution = SelectedInstitution;
if (SelectedItemCount != 1) return;
if (!CanUpdateItem() && !CanViewItem()) return;
if (!CanUpdateItem()) updateItem = false;
if (institution == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve selected item");
return;
}
SpmForm_Institution.Config configInstitution = new SpmForm_Institution.Config();
configInstitution.InstitutionToUpdate = institution;
configInstitution.ReadOnly = (config.ReadOnly || !updateItem);
using (SpmForm_Institution formInstitution = new SpmForm_Institution(configInstitution))
{
// Perform the update.
if (formInstitution.ShowDialog() == DialogResult.OK)
{
// Institution has been updated.
RefreshDataItem(institution.Id);
listViewInstitution.RefreshInstitution(institution.Id);
InvokeItemUpdatedEvent(Spm.DataItemType.Institution, institution.Id);
}
}
}
//-------------------------------------------------------------------
// Delete item.
public override bool CanDeleteItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void DeleteItem ()
{
if (!CanDeleteItem()) return;
if (config.Mode == PanelMode.Search) return;
if (SelectedItemCount != 1) return;
SpmInstitution institution = SelectedInstitution;
if (institution == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve item for deletion.");
return;
}
if (!InstitutionMgr.InstitutionCanBeDeleted(institution))
{
MessageConsole.ShowMessageError("Unable to remove institution - " + InstitutionMgr.ErrorStateMessage + ".");
return;
}
if (MessageConsole.ShowMessageConfirm("Are you sure that this institution should be removed from the system?"))
{
if (InstitutionMgr.DeleteInstitution(institution, DbUpdateInfo))
{
int selectIdx = listViewInstitution.SelectedIndex;
listViewInstitution.RemoveItemById(institution.Id.ToString());
if (selectIdx >= listViewInstitution.ItemCount - 1) selectIdx--;
listViewInstitution.SelectedIndices.Clear();
listViewInstitution.SelectedIndices.Add(selectIdx);
}
else MessageConsole.ShowMessageError("Failed to remove institution - " + InstitutionMgr.ErrorStateMessage + ".");
}
}
//-------------------------------------------------------------------
// Import data.
public override bool CanImportData ()
{
return false;
}
public override void ImportData ()
{
if (!CanImportData()) return;
}
//-------------------------------------------------------------------
// Export data.
public override bool CanExportData ()
{
return false;
}
public override void ExportData ()
{
}
//-------------------------------------------------------------------
// C o n t e x t M e n u
//-------------------------------------------------------------------
private SpmContextMenuStrip contextMenuStrip = new SpmContextMenuStrip();
private void RefreshContextMenu ()
{
contextMenuStrip.Name = "Institution";
contextMenuStrip.Items.Clear();
if (CanCreateItem())
contextMenuStrip.Items.Add("Create", null, CreateItem);
if (SysId.IsValid(listViewInstitution.SelectedItemId))
{
SpmInstitution institution = SelectedInstitution;
if (institution != null)
{
if (CanUpdateItem() || CanDeleteItem())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
contextMenuStrip.Items.Add(CanUpdateItem() ? "Update" : "View", null, UpdateItem);
if (CanDeleteItem())
contextMenuStrip.Items.Add("Remove", null, DeleteItem);
}
}
}
if (CanExportData() || CanImportData())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
if (CanImportData())
contextMenuStrip.Items.Add("Import", null, ImportData);
if (CanExportData())
contextMenuStrip.Items.Add("Export", null, ExportData);
}
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
bool itemSelected = SysId.IsValid(SelectedItemId);
listViewInstitution.Enabled = Enabled;
buttonCreate.Enabled = Enabled;
buttonUpdate.Enabled = Enabled && itemSelected;
buttonRemove.Enabled = Enabled && itemSelected;
buttonOk.Enabled = Enabled;
buttonCancel.Enabled = Enabled;
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls ()
{
if (this.IsDesignerHosted() || !Created) return;
Rectangle clientRect = ClientRectangle;
//---------------------------------------------------------------
// Filter panel.
if (listFilterInstitution.Visible)
{
listFilterInstitution.PositionAtTopLeftOf(this);
listFilterInstitution.SetFullWidthOf(this);
listFilterInstitution.ResizeToBottomControl();
listViewInstitution.PositionBelow(listFilterInstitution);
}
else
{
listViewInstitution.PositionAtTopLeftOf(this);
}
//---------------------------------------------------------------
// List view.
int buttonLeft = clientRect.Width - buttonCreate.Width - buttonCreate.Margin.Right - Padding.Right;
listViewInstitution.Left = listViewInstitution.Margin.Left;
listViewInstitution.Width = buttonLeft - buttonCreate.Margin.Left - listViewInstitution.Left - listViewInstitution.Margin.Right;
if (!(buttonCreate.Visible || buttonUpdate.Visible || buttonRemove.Visible || buttonOk.Visible || buttonCancel.Visible))
listViewInstitution.Width = clientRect.Width - Padding.Right - listViewInstitution.Left - listViewInstitution.Margin.Right;
//---------------------------------------------------------------
// Tab control.
if (tabControl.Visible)
{
tabControl.Left = listViewInstitution.Left;
tabControl.Width = clientRect.Width - (tabControl.Left * 2);
listViewInstitution.Height = (int)((clientRect.Height - listViewInstitution.Top) * 0.40);
tabControl.Top = listViewInstitution.Bottom + listViewInstitution.Margin.Bottom + tabControl.Margin.Top;
tabControl.Height = clientRect.Height - tabControl.Top - tabControl.Margin.Bottom - Padding.Bottom;
}
else
{
listViewInstitution.Height = clientRect.Height - listViewInstitution.Top - listViewInstitution.Margin.Bottom - Padding.Bottom;
}
//---------------------------------------------------------------
// Create button.
int buttonTop = listViewInstitution.Top + listViewInstitution.HeaderHeight;
buttonCreate.Top = buttonTop;
buttonCreate.Left = buttonLeft;
if (buttonCreate.Visible)
buttonTop += buttonCreate.Height + buttonCreate.Margin.Bottom;
// Update button.
buttonUpdate.Top = buttonTop;
buttonUpdate.Left = buttonLeft;
if (buttonUpdate.Visible)
buttonTop += buttonUpdate.Height + buttonUpdate.Margin.Bottom;
// Remove button.
buttonRemove.Top = buttonTop;
buttonRemove.Left = buttonLeft;
if (buttonRemove.Visible)
buttonTop += buttonRemove.Height + buttonRemove.Margin.Bottom;
//---------------------------------------------------------------
// Navigation buttons.
// Cancel button.
buttonCancel.Top = clientRect.Bottom - Padding.Bottom - buttonCancel.Margin.Bottom - buttonCancel.Height;
buttonCancel.Left = buttonLeft;
// OK button.
buttonOk.Top = buttonCancel.Top - buttonOk.Height - buttonCancel.Padding.Top - buttonCancel.Margin.Bottom;
buttonOk.Left = buttonLeft;
if (buttonOk.Visible)
buttonTop += buttonOk.Height + buttonOk.Margin.Bottom;
//---------------------------------------------------------------
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
// Filter.
private void listFilterInstitution_FilterChanged (object sender, EventArgs e)
{
RefreshDataItems();
SetControlActivity();
}
//-------------------------------------------------------------------
// Item list.
private void listViewInstitution_ColumnClick (object sender, ColumnClickEventArgs e)
{
RefreshDataItems();
}
private void listViewInstitution_ItemCountChanged (object sender, Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs e)
{
InvokeItemCountChangedEvent(e);
}
private void listViewInstitution_SelectedIndexChanged (object sender, EventArgs e)
{
RefreshTabs();
InvokeItemSelectionChangedEvent(e);
SetControlActivity();
}
private void listViewInstitution_DoubleClick (object sender, EventArgs e)
{
if (config.Mode == PanelMode.Search)
{
//if (config.SearchForm != null) config.SearchForm.OnOK();
}
else
UpdateItem();
SetControlActivity();
}
private void listViewInstitution_MouseUp (object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
// Refresh the context menu and display at pointer position.
RefreshContextMenu();
contextMenuStrip.Show(listViewInstitution, new Point(e.X, e.Y), ToolStripDropDownDirection.Default);
break;
}
SetControlActivity();
}
//-------------------------------------------------------------------
// Actions.
private void buttonCreate_Click (object sender, EventArgs e)
{
CreateItem();
SetControlActivity();
}
private void buttonUpdate_Click (object sender, EventArgs e)
{
UpdateItem();
SetControlActivity();
}
private void buttonRemove_Click (object sender, EventArgs e)
{
DeleteItem();
SetControlActivity();
}
private void buttonOk_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnOK();
return;
}
SetControlActivity();
}
private void buttonCancel_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnCancel();
return;
}
SetControlActivity();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,186 @@
namespace Sarand.PatientMgr.Win.Forms.Panels
{
partial class SpmPanel_Operations
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listFilterOperation = new Sarand.PatientMgr.Win.Forms.Filters.SpmItemListFilter_Operation();
this.listViewOperation = new Sarand.PatientMgr.Win.Forms.Controls.SpmItemListView_Operation();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.buttonRemove = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// listFilterOperation
//
this.listFilterOperation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listFilterOperation.Location = new System.Drawing.Point(0, 2);
this.listFilterOperation.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.listFilterOperation.Name = "listFilterOperation";
this.listFilterOperation.Size = new System.Drawing.Size(400, 30);
this.listFilterOperation.TabIndex = 0;
this.listFilterOperation.FilterChanged += new System.EventHandler(this.listFilterOperation_FilterChanged);
//
// listViewOperation
//
this.listViewOperation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewOperation.FullRowSelect = true;
this.listViewOperation.HideSelection = false;
this.listViewOperation.Location = new System.Drawing.Point(0, 37);
this.listViewOperation.Margin = new System.Windows.Forms.Padding(2);
this.listViewOperation.Name = "listViewOperation";
this.listViewOperation.OwnerDraw = true;
this.listViewOperation.Size = new System.Drawing.Size(317, 155);
this.listViewOperation.TabIndex = 1;
this.listViewOperation.UseCompatibleStateImageBehavior = false;
this.listViewOperation.ItemCountChanged += new System.EventHandler<Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs>(this.listViewOperation_ItemCountChanged);
this.listViewOperation.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewOperation_ColumnClick);
this.listViewOperation.SelectedIndexChanged += new System.EventHandler(this.listViewOperation_SelectedIndexChanged);
this.listViewOperation.DoubleClick += new System.EventHandler(this.listViewOperation_DoubleClick);
this.listViewOperation.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listViewOperation_MouseUp);
//
// tabControl
//
this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(2, 196);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(398, 154);
this.tabControl.TabIndex = 6;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(390, 128);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(390, 128);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// buttonRemove
//
this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRemove.Location = new System.Drawing.Point(322, 95);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(75, 23);
this.buttonRemove.TabIndex = 15;
this.buttonRemove.Text = "Remove";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
//
// buttonUpdate
//
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUpdate.Location = new System.Drawing.Point(322, 66);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreate.Location = new System.Drawing.Point(322, 37);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.TabIndex = 13;
this.buttonCreate.Text = "Create";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(322, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(322, 139);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 15;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// SpmPanel_Operations
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRemove);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.listViewOperation);
this.Controls.Add(this.listFilterOperation);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(400, 350);
this.Name = "SpmPanel_Operations";
this.Size = new System.Drawing.Size(400, 350);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Filters.SpmItemListFilter_Operation listFilterOperation;
private Controls.SpmItemListView_Operation listViewOperation;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Button buttonRemove;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOk;
}
}
@@ -0,0 +1,604 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.TabPages;
using Sarand.PatientMgr.Win.Forms.Filters;
using Sarand.PatientMgr.Win.Forms.Base;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_Operations : SpmPanel_Items
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelMode
{
Search,
Maintain,
}
public new class Config : SpmPanel_Items.Config
{
public Config (PanelMode mode)
{
Mode = mode;
// Defaults based on mode.
DisplayFilter = false; // Mode == PanelMode.Maintain || Mode == PanelMode.Search;
DisplayTabs = Mode == PanelMode.Maintain;
DisplayActionButtons = Mode == PanelMode.Maintain;
DisplayNavigationButtons = Mode == PanelMode.Search;
}
public PanelMode Mode { get; } = PanelMode.Maintain;
public SpmForm SearchForm { get; set; }
// Display options.
public bool DisplayFilter { get; set; } = false;
public bool DisplayContextMenu { get; set; } = true;
public bool DisplayActionButtons { get; set; } = false;
public bool DisplayNavigationButtons { get; set; } = false;
public bool DisplayTabs { get; set; } = false;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config(PanelMode.Search);
private readonly List<SpmTabPage_Operation> tabPages = new List<SpmTabPage_Operation>();
//-------------------------------------------------------------------
// Construction.
private SpmPanel_Operations () : this(new Config(PanelMode.Search)) { }
public SpmPanel_Operations (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected override String DefaultMessageTitle { get { return "Operation"; } }
public override int ItemTotal { get { return listViewOperation.ItemTotal; } }
public override int ItemCount { get { return listViewOperation.ItemCount; } }
public override int SelectedItemCount { get { return listViewOperation.SelectedItemCount; } }
public SysId SelectedItemId { get { return listViewOperation.SelectedItemId; } }
public List<SysId> SelectedItemIds { get { return listViewOperation.SelectedItemIds; } }
public SpmOperation SelectedOperation { get { return listViewOperation.SelectedOperation; } }
//-------------------------------------------------------------------
// Configure.
public void SetConfig (Config config)
{
base.SetConfig(config);
this.config = config;
ConfigurePanel();
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
ConfigurePanel();
}
private void ConfigurePanel ()
{
if (!Created || this.IsDesignerHosted()) return;
// Configure filter.
if (config.DisplayFilter)
{
SpmItemListFilter_Operation.Config configFilter = new SpmItemListFilter_Operation.Config();
configFilter.Internals = Internals;
listFilterOperation.SetConfig(configFilter);
}
listFilterOperation.Visible = config.DisplayFilter;
// Configure list.
SpmItemListView_Operation.Config configList = new SpmItemListView_Operation.Config();
configList.Internals = Internals;
configList.Mode = SpmItemListView_Operation.ListMode.General;
listViewOperation.SetConfig(configList);
// Tabs.
tabControl.TabPages.Clear();
tabControl.Visible = config.DisplayTabs;
RefreshTabs();
// Configure buttons.
buttonCreate.Visible = config.DisplayActionButtons && SecurityProfile.Admin.CanManageConfig();
buttonUpdate.Visible = config.DisplayActionButtons;
buttonRemove.Visible = config.DisplayActionButtons && buttonCreate.Visible;
buttonOk.Visible = config.DisplayNavigationButtons && config.Mode == PanelMode.Search;
buttonCancel.Visible = config.DisplayNavigationButtons;
// Complete form initialisation.
RefreshDataItems();
SetControlActivity();
PositionControls();
}
//-------------------------------------------------------------------
// Initialise tabs.
private void InitTabs ()
{
String fn = GetType().Name + ".InitTabs";
tabControl.TabPages.Clear();
tabPages.Clear();
if (!config.DisplayTabs)
{
tabPages.Clear();
tabControl.TabPages.Clear();
tabControl.Visible = false;
return;
}
// Selected Operation.
SpmOperation operation = SelectedOperation;
// Updates.
List<SpmTabPage_Operation.PanelType> panelTypes_Updates = new List<SpmTabPage_Operation.PanelType>();
panelTypes_Updates.Add(SpmTabPage_Operation.PanelType.Updates);
if (panelTypes_Updates.Count > 0)
{
SpmTabPage_Operation.Config configTabPage = new SpmTabPage_Operation.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Updates);
SpmTabPage_Operation tabPage = new SpmTabPage_Operation(configTabPage) { Text = "Updates" };
tabPages.Add(tabPage);
}
// Populate tab pages.
tabControl.Visible = tabPages.Count > 0;
foreach (var tabPage in tabPages)
tabControl.TabPages.Add(tabPage);
}
//-------------------------------------------------------------------
// P a n e l I n t e r f a c e
//-------------------------------------------------------------------
private String previouslySelectedTabPageText = "";
private void RefreshTabs ()
{
if (tabControl.SelectedTab != null)
previouslySelectedTabPageText = tabControl.SelectedTab.Text;
// Reinitialise tabs whenever the selection changes in case the set of tab pages displayed needs to be changed.
InitTabs();
// Select previous tab page if still present.
if (!StringUtil.IsEmpty(previouslySelectedTabPageText))
{
foreach (TabPage tabPage in tabControl.TabPages)
{
if (tabPage.Text.Equals(previouslySelectedTabPageText))
{
tabControl.SelectTab(tabPage);
break;
}
}
}
RefreshTabPages();
SetControlActivity();
PositionControls();
}
private void RefreshTabPages ()
{
// Selected Operation - populated when needed.
SpmOperation operation = null;
// Refresh tabs.
if (tabControl.Visible)
{
if (operation == null) operation = SelectedOperation;
SpmOperation.Data operationData = operation != null ? operation.GetData() : new SpmOperation.Data();
tabPages.PopulateToControls(operationData);
}
}
//-------------------------------------------------------------------
// F i l t e r
//-------------------------------------------------------------------
public bool ParamsAreValid (SpmOperation.Params prmOperation)
{
return true;
}
public SpmOperation.Params GetParams ()
{
SpmOperation.Params prmOperation = new SpmOperation.Params();
// Sort columns.
prmOperation.SortColumns.AddRange(listViewOperation.GetSortColumns());
return prmOperation;
}
//-------------------------------------------------------------------
// A c t i o n s
//-------------------------------------------------------------------
// Refresh.
public override void RefreshDataItems ()
{
SpmOperation.Params prmOperation = GetParams();
if (!ParamsAreValid(prmOperation)) prmOperation = null;
listViewOperation.RefreshOperations(prmOperation);
}
public override void RefreshDataItem (SysId id)
{
listViewOperation.RefreshOperation(id);
}
public override void RemoveDataItem (SysId id)
{
listViewOperation.RemoveItemById(id);
}
//-------------------------------------------------------------------
// Create item.
public override bool CanCreateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void CreateItem ()
{
if (!CanCreateItem()) return;
if (config.Mode == PanelMode.Search) return;
// Create new Operation.
SpmForm_Operation.Config configOperation = new SpmForm_Operation.Config();
using (var form = new SpmForm_Operation(configOperation))
{
if (form.ShowDialog() == DialogResult.OK)
{
RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.DataItemType.Operation, form.NewItemId);
}
}
}
//-------------------------------------------------------------------
// View/Update item.
public override bool CanViewItem ()
{
return true;
}
public override bool CanUpdateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void UpdateItem (bool updateItem = true)
{
if (config.Mode == PanelMode.Search) return;
SpmOperation operation = SelectedOperation;
if (SelectedItemCount != 1) return;
if (!CanUpdateItem() && !CanViewItem()) return;
if (!CanUpdateItem()) updateItem = false;
if (operation == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve selected item");
return;
}
SpmForm_Operation.Config configOperation = new SpmForm_Operation.Config();
configOperation.OperationToUpdate = operation;
configOperation.ReadOnly = (config.ReadOnly || !updateItem);
using (SpmForm_Operation formOperation = new SpmForm_Operation(configOperation))
{
// Perform the update.
if (formOperation.ShowDialog() == DialogResult.OK)
{
// Operation has been updated.
RefreshDataItem(operation.Id);
listViewOperation.RefreshOperation(operation.Id);
InvokeItemUpdatedEvent(Spm.DataItemType.Operation, operation.Id);
}
}
}
//-------------------------------------------------------------------
// Delete item.
public override bool CanDeleteItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void DeleteItem ()
{
if (!CanDeleteItem()) return;
if (config.Mode == PanelMode.Search) return;
if (SelectedItemCount != 1) return;
SpmOperation operation = SelectedOperation;
if (operation == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve item for deletion.");
return;
}
if (!InstitutionMgr.OperationCanBeDeleted(operation))
{
MessageConsole.ShowMessageError("Unable to remove operation - " + InstitutionMgr.ErrorStateMessage + ".");
return;
}
if (MessageConsole.ShowMessageConfirm("Are you sure that this operation should be removed from the system?"))
{
if (InstitutionMgr.DeleteOperation(operation, DbUpdateInfo))
{
int selectIdx = listViewOperation.SelectedIndex;
listViewOperation.RemoveItemById(operation.Id.ToString());
if (selectIdx >= listViewOperation.ItemCount - 1) selectIdx--;
listViewOperation.SelectedIndices.Clear();
listViewOperation.SelectedIndices.Add(selectIdx);
}
else MessageConsole.ShowMessageError("Failed to remove operation - " + InstitutionMgr.ErrorStateMessage + ".");
}
}
//-------------------------------------------------------------------
// Import data.
public override bool CanImportData ()
{
return false;
}
public override void ImportData ()
{
if (!CanImportData()) return;
}
//-------------------------------------------------------------------
// Export data.
public override bool CanExportData ()
{
return false;
}
public override void ExportData ()
{
}
//-------------------------------------------------------------------
// C o n t e x t M e n u
//-------------------------------------------------------------------
private SpmContextMenuStrip contextMenuStrip = new SpmContextMenuStrip();
private void RefreshContextMenu ()
{
contextMenuStrip.Name = "Operation";
contextMenuStrip.Items.Clear();
if (CanCreateItem())
contextMenuStrip.Items.Add("Create", null, CreateItem);
if (SysId.IsValid(listViewOperation.SelectedItemId))
{
SpmOperation operation = SelectedOperation;
if (operation != null)
{
if (CanUpdateItem() || CanDeleteItem())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
contextMenuStrip.Items.Add(CanUpdateItem() ? "Update" : "View", null, UpdateItem);
if (CanDeleteItem())
contextMenuStrip.Items.Add("Remove", null, DeleteItem);
}
}
}
if (CanExportData() || CanImportData())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
if (CanImportData())
contextMenuStrip.Items.Add("Import", null, ImportData);
if (CanExportData())
contextMenuStrip.Items.Add("Export", null, ExportData);
}
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
bool itemSelected = SysId.IsValid(SelectedItemId);
listViewOperation.Enabled = Enabled;
buttonCreate.Enabled = Enabled;
buttonUpdate.Enabled = Enabled && itemSelected;
buttonRemove.Enabled = Enabled && itemSelected;
buttonOk.Enabled = Enabled;
buttonCancel.Enabled = Enabled;
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls ()
{
if (this.IsDesignerHosted() || !Created) return;
Rectangle clientRect = ClientRectangle;
//---------------------------------------------------------------
// Filter panel.
if (listFilterOperation.Visible)
{
listFilterOperation.PositionAtTopLeftOf(this);
listFilterOperation.SetFullWidthOf(this);
listFilterOperation.ResizeToBottomControl();
listViewOperation.PositionBelow(listFilterOperation);
}
else
{
listViewOperation.PositionAtTopLeftOf(this);
}
//---------------------------------------------------------------
// List view.
int buttonLeft = clientRect.Width - buttonCreate.Width - buttonCreate.Margin.Right - Padding.Right;
listViewOperation.Left = listViewOperation.Margin.Left;
listViewOperation.Width = buttonLeft - buttonCreate.Margin.Left - listViewOperation.Left - listViewOperation.Margin.Right;
if (!(buttonCreate.Visible || buttonUpdate.Visible || buttonRemove.Visible || buttonOk.Visible || buttonCancel.Visible))
listViewOperation.Width = clientRect.Width - Padding.Right - listViewOperation.Left - listViewOperation.Margin.Right;
//---------------------------------------------------------------
// Tab control.
if (tabControl.Visible)
{
tabControl.Left = listViewOperation.Left;
tabControl.Width = clientRect.Width - (tabControl.Left * 2);
listViewOperation.Height = (int)((clientRect.Height - listViewOperation.Top) * 0.40);
tabControl.Top = listViewOperation.Bottom + listViewOperation.Margin.Bottom + tabControl.Margin.Top;
tabControl.Height = clientRect.Height - tabControl.Top - tabControl.Margin.Bottom - Padding.Bottom;
}
else
{
listViewOperation.Height = clientRect.Height - listViewOperation.Top - listViewOperation.Margin.Bottom - Padding.Bottom;
}
//---------------------------------------------------------------
// Create button.
int buttonTop = listViewOperation.Top + listViewOperation.HeaderHeight;
buttonCreate.Top = buttonTop;
buttonCreate.Left = buttonLeft;
if (buttonCreate.Visible)
buttonTop += buttonCreate.Height + buttonCreate.Margin.Bottom;
// Update button.
buttonUpdate.Top = buttonTop;
buttonUpdate.Left = buttonLeft;
if (buttonUpdate.Visible)
buttonTop += buttonUpdate.Height + buttonUpdate.Margin.Bottom;
// Remove button.
buttonRemove.Top = buttonTop;
buttonRemove.Left = buttonLeft;
if (buttonRemove.Visible)
buttonTop += buttonRemove.Height + buttonRemove.Margin.Bottom;
//---------------------------------------------------------------
// Navigation buttons.
// Cancel button.
buttonCancel.Top = clientRect.Bottom - Padding.Bottom - buttonCancel.Margin.Bottom - buttonCancel.Height;
buttonCancel.Left = buttonLeft;
// OK button.
buttonOk.Top = buttonCancel.Top - buttonOk.Height - buttonCancel.Padding.Top - buttonCancel.Margin.Bottom;
buttonOk.Left = buttonLeft;
if (buttonOk.Visible)
buttonTop += buttonOk.Height + buttonOk.Margin.Bottom;
//---------------------------------------------------------------
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
// Filter.
private void listFilterOperation_FilterChanged (object sender, EventArgs e)
{
RefreshDataItems();
SetControlActivity();
}
//-------------------------------------------------------------------
// Item list.
private void listViewOperation_ColumnClick (object sender, ColumnClickEventArgs e)
{
RefreshDataItems();
}
private void listViewOperation_ItemCountChanged (object sender, Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs e)
{
InvokeItemCountChangedEvent(e);
}
private void listViewOperation_SelectedIndexChanged (object sender, EventArgs e)
{
RefreshTabs();
InvokeItemSelectionChangedEvent(e);
SetControlActivity();
}
private void listViewOperation_DoubleClick (object sender, EventArgs e)
{
if (config.Mode == PanelMode.Search)
{
//if (config.SearchForm != null) config.SearchForm.OnOK();
}
else
UpdateItem();
SetControlActivity();
}
private void listViewOperation_MouseUp (object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
// Refresh the context menu and display at pointer position.
RefreshContextMenu();
contextMenuStrip.Show(listViewOperation, new Point(e.X, e.Y), ToolStripDropDownDirection.Default);
break;
}
SetControlActivity();
}
//-------------------------------------------------------------------
// Actions.
private void buttonCreate_Click (object sender, EventArgs e)
{
CreateItem();
SetControlActivity();
}
private void buttonUpdate_Click (object sender, EventArgs e)
{
UpdateItem();
SetControlActivity();
}
private void buttonRemove_Click (object sender, EventArgs e)
{
DeleteItem();
SetControlActivity();
}
private void buttonOk_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnOK();
return;
}
SetControlActivity();
}
private void buttonCancel_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnCancel();
return;
}
SetControlActivity();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,186 @@
namespace Sarand.PatientMgr.Win.Forms.Panels
{
partial class SpmPanel_Patients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listFilterPatient = new Sarand.PatientMgr.Win.Forms.Filters.SpmItemListFilter_Patient();
this.listViewPatient = new Sarand.PatientMgr.Win.Forms.Controls.SpmItemListView_Patient();
this.tabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.buttonRemove = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.tabControl.SuspendLayout();
this.SuspendLayout();
//
// listFilterPatient
//
this.listFilterPatient.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listFilterPatient.Location = new System.Drawing.Point(0, 2);
this.listFilterPatient.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.listFilterPatient.Name = "listFilterPatient";
this.listFilterPatient.Size = new System.Drawing.Size(400, 30);
this.listFilterPatient.TabIndex = 0;
this.listFilterPatient.FilterChanged += new System.EventHandler(this.listFilterPatient_FilterChanged);
//
// listViewPatient
//
this.listViewPatient.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listViewPatient.FullRowSelect = true;
this.listViewPatient.HideSelection = false;
this.listViewPatient.Location = new System.Drawing.Point(0, 37);
this.listViewPatient.Margin = new System.Windows.Forms.Padding(2);
this.listViewPatient.Name = "listViewPatient";
this.listViewPatient.OwnerDraw = true;
this.listViewPatient.Size = new System.Drawing.Size(317, 155);
this.listViewPatient.TabIndex = 1;
this.listViewPatient.UseCompatibleStateImageBehavior = false;
this.listViewPatient.ItemCountChanged += new System.EventHandler<Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs>(this.listViewPatient_ItemCountChanged);
this.listViewPatient.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewPatient_ColumnClick);
this.listViewPatient.SelectedIndexChanged += new System.EventHandler(this.listViewPatient_SelectedIndexChanged);
this.listViewPatient.DoubleClick += new System.EventHandler(this.listViewPatient_DoubleClick);
this.listViewPatient.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listViewPatient_MouseUp);
//
// tabControl
//
this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl.Controls.Add(this.tabPage1);
this.tabControl.Controls.Add(this.tabPage2);
this.tabControl.Location = new System.Drawing.Point(2, 196);
this.tabControl.Margin = new System.Windows.Forms.Padding(2);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(398, 154);
this.tabControl.TabIndex = 6;
//
// tabPage1
//
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(390, 128);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(390, 128);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
// buttonRemove
//
this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonRemove.Location = new System.Drawing.Point(322, 95);
this.buttonRemove.Name = "buttonRemove";
this.buttonRemove.Size = new System.Drawing.Size(75, 23);
this.buttonRemove.TabIndex = 15;
this.buttonRemove.Text = "Remove";
this.buttonRemove.UseVisualStyleBackColor = true;
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
//
// buttonUpdate
//
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonUpdate.Location = new System.Drawing.Point(322, 66);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(75, 23);
this.buttonUpdate.TabIndex = 14;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreate.Location = new System.Drawing.Point(322, 37);
this.buttonCreate.Name = "buttonCreate";
this.buttonCreate.Size = new System.Drawing.Size(75, 23);
this.buttonCreate.TabIndex = 13;
this.buttonCreate.Text = "Create";
this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(322, 168);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOk
//
this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOk.Location = new System.Drawing.Point(322, 139);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 15;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
//
// SpmPanel_Patients
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonRemove);
this.Controls.Add(this.buttonUpdate);
this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.tabControl);
this.Controls.Add(this.listViewPatient);
this.Controls.Add(this.listFilterPatient);
this.Margin = new System.Windows.Forms.Padding(2);
this.MinimumSize = new System.Drawing.Size(400, 350);
this.Name = "SpmPanel_Patients";
this.Size = new System.Drawing.Size(400, 350);
this.tabControl.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Filters.SpmItemListFilter_Patient listFilterPatient;
private Controls.SpmItemListView_Patient listViewPatient;
private System.Windows.Forms.TabControl tabControl;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.Button buttonRemove;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.Button buttonCreate;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOk;
}
}
@@ -0,0 +1,604 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Core.Bus;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.TabPages;
using Sarand.PatientMgr.Win.Forms.Filters;
using Sarand.PatientMgr.Win.Forms.Base;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_Patients : SpmPanel_Items
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelMode
{
Search,
Maintain,
}
public new class Config : SpmPanel_Items.Config
{
public Config (PanelMode mode)
{
Mode = mode;
// Defaults based on mode.
DisplayFilter = false; // Mode == PanelMode.Maintain || Mode == PanelMode.Search;
DisplayTabs = Mode == PanelMode.Maintain;
DisplayActionButtons = Mode == PanelMode.Maintain;
DisplayNavigationButtons = Mode == PanelMode.Search;
}
public PanelMode Mode { get; } = PanelMode.Maintain;
public SpmForm SearchForm { get; set; }
// Display options.
public bool DisplayFilter { get; set; } = false;
public bool DisplayContextMenu { get; set; } = true;
public bool DisplayActionButtons { get; set; } = false;
public bool DisplayNavigationButtons { get; set; } = false;
public bool DisplayTabs { get; set; } = false;
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config(PanelMode.Search);
private readonly List<SpmTabPage_Patient> tabPages = new List<SpmTabPage_Patient>();
//-------------------------------------------------------------------
// Construction.
private SpmPanel_Patients () : this(new Config(PanelMode.Search)) { }
public SpmPanel_Patients (Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
protected override String DefaultMessageTitle { get { return "Patient"; } }
public override int ItemTotal { get { return listViewPatient.ItemTotal; } }
public override int ItemCount { get { return listViewPatient.ItemCount; } }
public override int SelectedItemCount { get { return listViewPatient.SelectedItemCount; } }
public SysId SelectedItemId { get { return listViewPatient.SelectedItemId; } }
public List<SysId> SelectedItemIds { get { return listViewPatient.SelectedItemIds; } }
public SpmPatient SelectedPatient { get { return listViewPatient.SelectedPatient; } }
//-------------------------------------------------------------------
// Configure.
public void SetConfig (Config config)
{
base.SetConfig(config);
this.config = config;
ConfigurePanel();
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
ConfigurePanel();
}
private void ConfigurePanel ()
{
if (!Created || this.IsDesignerHosted()) return;
// Configure filter.
if (config.DisplayFilter)
{
SpmItemListFilter_Patient.Config configFilter = new SpmItemListFilter_Patient.Config();
configFilter.Internals = Internals;
listFilterPatient.SetConfig(configFilter);
}
listFilterPatient.Visible = config.DisplayFilter;
// Configure list.
SpmItemListView_Patient.Config configList = new SpmItemListView_Patient.Config();
configList.Internals = Internals;
configList.Mode = SpmItemListView_Patient.ListMode.General;
listViewPatient.SetConfig(configList);
// Tabs.
tabControl.TabPages.Clear();
tabControl.Visible = config.DisplayTabs;
RefreshTabs();
// Configure buttons.
buttonCreate.Visible = config.DisplayActionButtons && SecurityProfile.Admin.CanManageConfig();
buttonUpdate.Visible = config.DisplayActionButtons;
buttonRemove.Visible = config.DisplayActionButtons && buttonCreate.Visible;
buttonOk.Visible = config.DisplayNavigationButtons && config.Mode == PanelMode.Search;
buttonCancel.Visible = config.DisplayNavigationButtons;
// Complete form initialisation.
RefreshDataItems();
SetControlActivity();
PositionControls();
}
//-------------------------------------------------------------------
// Initialise tabs.
private void InitTabs ()
{
String fn = GetType().Name + ".InitTabs";
tabControl.TabPages.Clear();
tabPages.Clear();
if (!config.DisplayTabs)
{
tabPages.Clear();
tabControl.TabPages.Clear();
tabControl.Visible = false;
return;
}
// Selected Patient.
SpmPatient patient = SelectedPatient;
// Updates.
List<SpmTabPage_Patient.PanelType> panelTypes_Updates = new List<SpmTabPage_Patient.PanelType>();
panelTypes_Updates.Add(SpmTabPage_Patient.PanelType.Updates);
if (panelTypes_Updates.Count > 0)
{
SpmTabPage_Patient.Config configTabPage = new SpmTabPage_Patient.Config();
configTabPage.Internals = Internals;
configTabPage.ReadOnly = ReadOnly;
configTabPage.PanelTypes.AddRange(panelTypes_Updates);
SpmTabPage_Patient tabPage = new SpmTabPage_Patient(configTabPage) { Text = "Updates" };
tabPages.Add(tabPage);
}
// Populate tab pages.
tabControl.Visible = tabPages.Count > 0;
foreach (var tabPage in tabPages)
tabControl.TabPages.Add(tabPage);
}
//-------------------------------------------------------------------
// P a n e l I n t e r f a c e
//-------------------------------------------------------------------
private String previouslySelectedTabPageText = "";
private void RefreshTabs ()
{
if (tabControl.SelectedTab != null)
previouslySelectedTabPageText = tabControl.SelectedTab.Text;
// Reinitialise tabs whenever the selection changes in case the set of tab pages displayed needs to be changed.
InitTabs();
// Select previous tab page if still present.
if (!StringUtil.IsEmpty(previouslySelectedTabPageText))
{
foreach (TabPage tabPage in tabControl.TabPages)
{
if (tabPage.Text.Equals(previouslySelectedTabPageText))
{
tabControl.SelectTab(tabPage);
break;
}
}
}
RefreshTabPages();
SetControlActivity();
PositionControls();
}
private void RefreshTabPages ()
{
// Selected Patient - populated when needed.
SpmPatient patient = null;
// Refresh tabs.
if (tabControl.Visible)
{
if (patient == null) patient = SelectedPatient;
SpmPatient.Data patientData = patient != null ? patient.GetData() : new SpmPatient.Data();
tabPages.PopulateToControls(patientData);
}
}
//-------------------------------------------------------------------
// F i l t e r
//-------------------------------------------------------------------
public bool ParamsAreValid (SpmPatient.Params prmPatient)
{
return true;
}
public SpmPatient.Params GetParams ()
{
SpmPatient.Params prmPatient = new SpmPatient.Params();
// Sort columns.
prmPatient.SortColumns.AddRange(listViewPatient.GetSortColumns());
return prmPatient;
}
//-------------------------------------------------------------------
// A c t i o n s
//-------------------------------------------------------------------
// Refresh.
public override void RefreshDataItems ()
{
SpmPatient.Params prmPatient = GetParams();
if (!ParamsAreValid(prmPatient)) prmPatient = null;
listViewPatient.RefreshPatients(prmPatient);
}
public override void RefreshDataItem (SysId id)
{
listViewPatient.RefreshPatient(id);
}
public override void RemoveDataItem (SysId id)
{
listViewPatient.RemoveItemById(id);
}
//-------------------------------------------------------------------
// Create item.
public override bool CanCreateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void CreateItem ()
{
if (!CanCreateItem()) return;
if (config.Mode == PanelMode.Search) return;
// Create new Patient.
SpmForm_Patient.Config configPatient = new SpmForm_Patient.Config();
using (var form = new SpmForm_Patient(configPatient))
{
if (form.ShowDialog() == DialogResult.OK)
{
RefreshDataItem(form.NewItemId);
InvokeItemCreatedEvent(Spm.DataItemType.Patient, form.NewItemId);
}
}
}
//-------------------------------------------------------------------
// View/Update item.
public override bool CanViewItem ()
{
return true;
}
public override bool CanUpdateItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void UpdateItem (bool updateItem = true)
{
if (config.Mode == PanelMode.Search) return;
SpmPatient patient = SelectedPatient;
if (SelectedItemCount != 1) return;
if (!CanUpdateItem() && !CanViewItem()) return;
if (!CanUpdateItem()) updateItem = false;
if (patient == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve selected item");
return;
}
SpmForm_Patient.Config configPatient = new SpmForm_Patient.Config();
configPatient.PatientToUpdate = patient;
configPatient.ReadOnly = (config.ReadOnly || !updateItem);
using (SpmForm_Patient formPatient = new SpmForm_Patient(configPatient))
{
// Perform the update.
if (formPatient.ShowDialog() == DialogResult.OK)
{
// Patient has been updated.
RefreshDataItem(patient.Id);
listViewPatient.RefreshPatient(patient.Id);
InvokeItemUpdatedEvent(Spm.DataItemType.Patient, patient.Id);
}
}
}
//-------------------------------------------------------------------
// Delete item.
public override bool CanDeleteItem ()
{
if (ReadOnly) return false;
if (!SecurityProfile.Admin.CanManageConfig()) return false;
return true;
}
public override void DeleteItem ()
{
if (!CanDeleteItem()) return;
if (config.Mode == PanelMode.Search) return;
if (SelectedItemCount != 1) return;
SpmPatient patient = SelectedPatient;
if (patient == null)
{
MessageConsole.ShowMessageWarning("Failed to retrieve item for deletion.");
return;
}
if (!InstitutionMgr.PatientCanBeDeleted(patient))
{
MessageConsole.ShowMessageError("Unable to remove patient - " + InstitutionMgr.ErrorStateMessage + ".");
return;
}
if (MessageConsole.ShowMessageConfirm("Are you sure that this patient should be removed from the system?"))
{
if (InstitutionMgr.DeletePatient(patient, DbUpdateInfo))
{
int selectIdx = listViewPatient.SelectedIndex;
listViewPatient.RemoveItemById(patient.Id.ToString());
if (selectIdx >= listViewPatient.ItemCount - 1) selectIdx--;
listViewPatient.SelectedIndices.Clear();
listViewPatient.SelectedIndices.Add(selectIdx);
}
else MessageConsole.ShowMessageError("Failed to remove patient - " + InstitutionMgr.ErrorStateMessage + ".");
}
}
//-------------------------------------------------------------------
// Import data.
public override bool CanImportData ()
{
return false;
}
public override void ImportData ()
{
if (!CanImportData()) return;
}
//-------------------------------------------------------------------
// Export data.
public override bool CanExportData ()
{
return false;
}
public override void ExportData ()
{
}
//-------------------------------------------------------------------
// C o n t e x t M e n u
//-------------------------------------------------------------------
private SpmContextMenuStrip contextMenuStrip = new SpmContextMenuStrip();
private void RefreshContextMenu ()
{
contextMenuStrip.Name = "Patient";
contextMenuStrip.Items.Clear();
if (CanCreateItem())
contextMenuStrip.Items.Add("Create", null, CreateItem);
if (SysId.IsValid(listViewPatient.SelectedItemId))
{
SpmPatient patient = SelectedPatient;
if (patient != null)
{
if (CanUpdateItem() || CanDeleteItem())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
contextMenuStrip.Items.Add(CanUpdateItem() ? "Update" : "View", null, UpdateItem);
if (CanDeleteItem())
contextMenuStrip.Items.Add("Remove", null, DeleteItem);
}
}
}
if (CanExportData() || CanImportData())
{
if (contextMenuStrip.Items.Count > 0)
contextMenuStrip.Items.Add(new ToolStripSeparator());
if (CanImportData())
contextMenuStrip.Items.Add("Import", null, ImportData);
if (CanExportData())
contextMenuStrip.Items.Add("Export", null, ExportData);
}
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
bool itemSelected = SysId.IsValid(SelectedItemId);
listViewPatient.Enabled = Enabled;
buttonCreate.Enabled = Enabled;
buttonUpdate.Enabled = Enabled && itemSelected;
buttonRemove.Enabled = Enabled && itemSelected;
buttonOk.Enabled = Enabled;
buttonCancel.Enabled = Enabled;
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
// P o s i t i o n C o n t r o l s
//-------------------------------------------------------------------
protected override void PositionControls ()
{
if (this.IsDesignerHosted() || !Created) return;
Rectangle clientRect = ClientRectangle;
//---------------------------------------------------------------
// Filter panel.
if (listFilterPatient.Visible)
{
listFilterPatient.PositionAtTopLeftOf(this);
listFilterPatient.SetFullWidthOf(this);
listFilterPatient.ResizeToBottomControl();
listViewPatient.PositionBelow(listFilterPatient);
}
else
{
listViewPatient.PositionAtTopLeftOf(this);
}
//---------------------------------------------------------------
// List view.
int buttonLeft = clientRect.Width - buttonCreate.Width - buttonCreate.Margin.Right - Padding.Right;
listViewPatient.Left = listViewPatient.Margin.Left;
listViewPatient.Width = buttonLeft - buttonCreate.Margin.Left - listViewPatient.Left - listViewPatient.Margin.Right;
if (!(buttonCreate.Visible || buttonUpdate.Visible || buttonRemove.Visible || buttonOk.Visible || buttonCancel.Visible))
listViewPatient.Width = clientRect.Width - Padding.Right - listViewPatient.Left - listViewPatient.Margin.Right;
//---------------------------------------------------------------
// Tab control.
if (tabControl.Visible)
{
tabControl.Left = listViewPatient.Left;
tabControl.Width = clientRect.Width - (tabControl.Left * 2);
listViewPatient.Height = (int)((clientRect.Height - listViewPatient.Top) * 0.40);
tabControl.Top = listViewPatient.Bottom + listViewPatient.Margin.Bottom + tabControl.Margin.Top;
tabControl.Height = clientRect.Height - tabControl.Top - tabControl.Margin.Bottom - Padding.Bottom;
}
else
{
listViewPatient.Height = clientRect.Height - listViewPatient.Top - listViewPatient.Margin.Bottom - Padding.Bottom;
}
//---------------------------------------------------------------
// Create button.
int buttonTop = listViewPatient.Top + listViewPatient.HeaderHeight;
buttonCreate.Top = buttonTop;
buttonCreate.Left = buttonLeft;
if (buttonCreate.Visible)
buttonTop += buttonCreate.Height + buttonCreate.Margin.Bottom;
// Update button.
buttonUpdate.Top = buttonTop;
buttonUpdate.Left = buttonLeft;
if (buttonUpdate.Visible)
buttonTop += buttonUpdate.Height + buttonUpdate.Margin.Bottom;
// Remove button.
buttonRemove.Top = buttonTop;
buttonRemove.Left = buttonLeft;
if (buttonRemove.Visible)
buttonTop += buttonRemove.Height + buttonRemove.Margin.Bottom;
//---------------------------------------------------------------
// Navigation buttons.
// Cancel button.
buttonCancel.Top = clientRect.Bottom - Padding.Bottom - buttonCancel.Margin.Bottom - buttonCancel.Height;
buttonCancel.Left = buttonLeft;
// OK button.
buttonOk.Top = buttonCancel.Top - buttonOk.Height - buttonCancel.Padding.Top - buttonCancel.Margin.Bottom;
buttonOk.Left = buttonLeft;
if (buttonOk.Visible)
buttonTop += buttonOk.Height + buttonOk.Margin.Bottom;
//---------------------------------------------------------------
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
// Filter.
private void listFilterPatient_FilterChanged (object sender, EventArgs e)
{
RefreshDataItems();
SetControlActivity();
}
//-------------------------------------------------------------------
// Item list.
private void listViewPatient_ColumnClick (object sender, ColumnClickEventArgs e)
{
RefreshDataItems();
}
private void listViewPatient_ItemCountChanged (object sender, Sarand.Win.Forms.Controls.SacsListView.ItemCountChangedEventArgs e)
{
InvokeItemCountChangedEvent(e);
}
private void listViewPatient_SelectedIndexChanged (object sender, EventArgs e)
{
RefreshTabs();
InvokeItemSelectionChangedEvent(e);
SetControlActivity();
}
private void listViewPatient_DoubleClick (object sender, EventArgs e)
{
if (config.Mode == PanelMode.Search)
{
//if (config.SearchForm != null) config.SearchForm.OnOK();
}
else
UpdateItem();
SetControlActivity();
}
private void listViewPatient_MouseUp (object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
// Refresh the context menu and display at pointer position.
RefreshContextMenu();
contextMenuStrip.Show(listViewPatient, new Point(e.X, e.Y), ToolStripDropDownDirection.Default);
break;
}
SetControlActivity();
}
//-------------------------------------------------------------------
// Actions.
private void buttonCreate_Click (object sender, EventArgs e)
{
CreateItem();
SetControlActivity();
}
private void buttonUpdate_Click (object sender, EventArgs e)
{
UpdateItem();
SetControlActivity();
}
private void buttonRemove_Click (object sender, EventArgs e)
{
DeleteItem();
SetControlActivity();
}
private void buttonOk_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnOK();
return;
}
SetControlActivity();
}
private void buttonCancel_Click (object sender, EventArgs e)
{
if (config.SearchForm != null)
{
//config.SearchForm.OnCancel();
return;
}
SetControlActivity();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Employee
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Employee : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Employee form hosting the tab control.</summary>
public SpmForm_Employee EmployeeForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Employee(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmEmployee.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Employee, data.Id);
}
public bool IsDataValid(SpmEmployee.Data data)
{
return true;
}
public void PopulateFromControls(SpmEmployee.Data data)
{
}
public bool UpdateAssociatedData(SpmEmployee.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_EmployeeList
{
public static void PopulateToControls (this List<SpmTabPage_Employee> tabPages, SpmEmployee.Data data)
{
foreach (SpmTabPage_Employee tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Employee> tabPages, SpmEmployee.Data data)
{
foreach (SpmTabPage_Employee tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_EmployeeRole
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_EmployeeRole : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>EmployeeRole form hosting the tab control.</summary>
public SpmForm_EmployeeRole EmployeeRoleForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_EmployeeRole(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmEmployeeRole.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.EmployeeRole, data.Id);
}
public bool IsDataValid(SpmEmployeeRole.Data data)
{
return true;
}
public void PopulateFromControls(SpmEmployeeRole.Data data)
{
}
public bool UpdateAssociatedData(SpmEmployeeRole.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_EmployeeRoleList
{
public static void PopulateToControls (this List<SpmTabPage_EmployeeRole> tabPages, SpmEmployeeRole.Data data)
{
foreach (SpmTabPage_EmployeeRole tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_EmployeeRole> tabPages, SpmEmployeeRole.Data data)
{
foreach (SpmTabPage_EmployeeRole tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Institution
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Institution : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Institution form hosting the tab control.</summary>
public SpmForm_Institution InstitutionForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Institution(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmInstitution.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Institution, data.Id);
}
public bool IsDataValid(SpmInstitution.Data data)
{
return true;
}
public void PopulateFromControls(SpmInstitution.Data data)
{
}
public bool UpdateAssociatedData(SpmInstitution.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_InstitutionList
{
public static void PopulateToControls (this List<SpmTabPage_Institution> tabPages, SpmInstitution.Data data)
{
foreach (SpmTabPage_Institution tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Institution> tabPages, SpmInstitution.Data data)
{
foreach (SpmTabPage_Institution tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Operation
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Operation : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Operation form hosting the tab control.</summary>
public SpmForm_Operation OperationForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Operation(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmOperation.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Operation, data.Id);
}
public bool IsDataValid(SpmOperation.Data data)
{
return true;
}
public void PopulateFromControls(SpmOperation.Data data)
{
}
public bool UpdateAssociatedData(SpmOperation.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_OperationList
{
public static void PopulateToControls (this List<SpmTabPage_Operation> tabPages, SpmOperation.Data data)
{
foreach (SpmTabPage_Operation tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Operation> tabPages, SpmOperation.Data data)
{
foreach (SpmTabPage_Operation tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Patient
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Patient : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Patient form hosting the tab control.</summary>
public SpmForm_Patient PatientForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Patient(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmPatient.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Patient, data.Id);
}
public bool IsDataValid(SpmPatient.Data data)
{
return true;
}
public void PopulateFromControls(SpmPatient.Data data)
{
}
public bool UpdateAssociatedData(SpmPatient.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_PatientList
{
public static void PopulateToControls (this List<SpmTabPage_Patient> tabPages, SpmPatient.Data data)
{
foreach (SpmTabPage_Patient tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Patient> tabPages, SpmPatient.Data data)
{
foreach (SpmTabPage_Patient tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_Procedure
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_Procedure : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>Procedure form hosting the tab control.</summary>
public SpmForm_Procedure ProcedureForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_Procedure(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmProcedure.Data data)
{
if (panelUpdates != null)
panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.Procedure, data.Id);
}
public bool IsDataValid(SpmProcedure.Data data)
{
return true;
}
public void PopulateFromControls(SpmProcedure.Data data)
{
}
public bool UpdateAssociatedData(SpmProcedure.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_ProcedureList
{
public static void PopulateToControls (this List<SpmTabPage_Procedure> tabPages, SpmProcedure.Data data)
{
foreach (SpmTabPage_Procedure tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_Procedure> tabPages, SpmProcedure.Data data)
{
foreach (SpmTabPage_Procedure tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}
@@ -0,0 +1,23 @@
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
partial class SpmTabPage_TemplateData
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
@@ -0,0 +1,194 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.PatientMgr.Win.Forms.Base;
using Sarand.PatientMgr.Core.Bus;
using Sarand.Core.Base;
using Sarand.PatientMgr.Win.Forms.Panels;
using Sarand.Win.Forms.UpdateLog;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.Maint;
using Sarand.PatientMgr.Core.App;
using Sarand.Core.Bus;
using Sarand.Win.Forms.Utils;
namespace Sarand.PatientMgr.Win.Forms.TabPages
{
//=======================================================================
public partial class SpmTabPage_TemplateData : SpmTabPage
{
//-------------------------------------------------------------------
// Configuration.
public enum PanelType
{
Unknown = 0,
Updates,
}
public new class Config : SpmTabPage.Config
{
/// <summary>TemplateData form hosting the tab control.</summary>
//public SpmForm_TemplateData TemplateDataForm { get; set; } = null;
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get; } = new List<PanelType>();
/// <summary>Number of panels on this tab page.</summary>
public override int PanelCount { get { return PanelTypes.Count; } }
}
//-------------------------------------------------------------------
// Data members.
private Config config = new Config();
private SaPanel_UpdateLog panelUpdates = null;
//-------------------------------------------------------------------
// Construction.
public SpmTabPage_TemplateData(Config config) : base(config)
{
this.config = config;
InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// Properties.
/// <summary>Panels to display on this tab page.</summary>
public List<PanelType> PanelTypes { get { return config.PanelTypes; } }
//-------------------------------------------------------------------
// Initialisation.
protected override void OnCreateControl()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
// Configure page.
// Initial panels.
List<SacsPanel> panels = new List<SacsPanel>();
foreach (var panelType in config.PanelTypes)
{
SacsPanel panel = null;
switch (panelType)
{
case PanelType.Updates:
{
SaPanel_UpdateLog.Config configUpdateLog = new SaPanel_UpdateLog.Config();
configUpdateLog.UpdateLogConsole = UpdateLogConsole;
panelUpdates = new SaPanel_UpdateLog();
panelUpdates.SetConfig(configUpdateLog);
panel = panelUpdates;
panel.SizeChanged += Panel_Resize;
break;
}
}
if (panel != null)
panels.Add(panel);
else Logger.Warn(GetType().Name + ".OnCreateControl Panel type not supported: " + panelType.ToString());
}
AddPanelsToPage(panels);
// Complete panel initialisation.
SetControlsReadOnly();
SetControlActivity();
}
//-------------------------------------------------------------------
// P a g e I n t e r f a c e
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls(SpmTemplateData.Data data)
{
//if (panelUpdates != null)
//panelUpdates.ItemId = new ItemId((short)Spm.DataItemType.TemplateData, data.Id);
}
public bool IsDataValid(SpmTemplateData.Data data)
{
return true;
}
public void PopulateFromControls(SpmTemplateData.Data data)
{
}
public bool UpdateAssociatedData(SpmTemplateData.Data data)
{
return true;
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected void SetControlActivity()
{
if (panelUpdates != null)
panelUpdates.Enabled = Enabled;
}
public bool IsFieldReadOnly(SpmDbDfn.ColumnIdx col)
{
return false;
}
protected void SetControlsReadOnly()
{
return;
}
//-------------------------------------------------------------------
// P a n e l E v e n t s
//-------------------------------------------------------------------
private void panel_ItemCreated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemCreatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemUpdated(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemUpdatedEvent((short)e.ItemType, e.ItemId);
}
private void panel_ItemDeleted(object sender, SpmPanel_Items.ItemModifiedEventArgs e)
{
InvokeItemDeletedEvent((short)e.ItemType, e.ItemId);
}
//-------------------------------------------------------------------
// P a n e l S i z e a n d P o s i t i o n
//-------------------------------------------------------------------
protected override void PositionControls()
{
base.PositionControls();
Rectangle clientRect = ClientRectangle;
}
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmTabPage_TemplateDataList
{
public static void PopulateToControls (this List<SpmTabPage_TemplateData> tabPages, SpmTemplateData.Data data)
{
foreach (SpmTabPage_TemplateData tabPage in tabPages)
tabPage.PopulateToControls(data);
}
public static void PopulateFromControls (this List<SpmTabPage_TemplateData> tabPages, SpmTemplateData.Data data)
{
foreach (SpmTabPage_TemplateData tabPage in tabPages)
tabPage.PopulateFromControls(data);
}
}
//=======================================================================
}