Resolved conflicts

This commit is contained in:
2021-01-04 18:15:45 +00:00
39 changed files with 6792 additions and 2 deletions
@@ -0,0 +1,71 @@
using Sarand.Core.Base;
using Sarand.Core.Data;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.PatientMgr.Core.Data
{
//=======================================================================
public static class SpmWindowsServiceCrypter
{
//-------------------------------------------------------------------
// Data members.
/// <summary>
/// Encryption is shared between Windows Service app and mobile
/// </summary>
private static readonly String requestDataKey = "<Sarand>~{PatientMgr}#[WindowsService]&/DataCryption/*|RequestData|";
private static readonly String responseDataKey = "{Sarand}+(PatientMgr)%\\WindowsService/=<DataCryption>@:Response:";
//-------------------------------------------------------------------
// R e q u e s t D a t a
//-------------------------------------------------------------------
/// <summary>Encrypt request data</summary>
public static String EncryptRequestData (String value)
{
try
{
return SacsAesIvCrypter.Encrypt(value, requestDataKey);
}
catch (Exception exc) { Logger.Debug("EncryptRequestData " + exc.GetType().Name + ": " + exc.Message); }
return value;
}
/// <summary>Decrypt request data</summary>
public static String DecryptRequestData (String value)
{
try
{
return SacsAesIvCrypter.Decrypt(value, requestDataKey);
}
catch (Exception exc) { Logger.Debug("DecryptRequestData " + exc.GetType().Name + ": " + exc.Message); }
return value;
}
//-------------------------------------------------------------------
// R e s p o n s e D a t a
//-------------------------------------------------------------------
/// <summary>Encrypt response data</summary>
public static String EncryptResponseData (String value)
{
try
{
return SacsAesIvCrypter.Encrypt(value, responseDataKey);
}
catch (Exception exc) { Logger.Debug("EncryptResponseData " + exc.GetType().Name + ": " + exc.Message); }
return value;
}
/// <summary>Decrypt response data</summary>
public static String DecryptResponseData (String value)
{
try
{
return SacsAesIvCrypter.Decrypt(value, responseDataKey);
}
catch (Exception exc) { Logger.Debug("DecryptResponseData " + exc.GetType().Name + ": " + exc.Message); }
return value;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,432 @@
using Sarand.Core.App;
using Sarand.Core.Base;
using Sarand.Core.Data;
using Sarand.Core.Net;
using Sarand.Core.Tasks;
using Sarand.Core.Xml;
using Sarand.PatientMgr.Core.Data;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
// Patient Web Service Client
// Make requests to PatientMgr Web Service hosted by Windows Service application.
//-----------------------------------------------------------------------
// Threading:
// Ref. https://blog.xamarin.com/getting-started-with-async-await/
//=======================================================================
public class SpmWebServiceClient
{
//-------------------------------------------------------------------
// Definitions.
public class RequestData : SacsTaskData
{
/// <summary>
/// Web Service Request data.
/// <para>Cancellation token can optionally be supplied if available higher up the chain.</para>
/// </summary>
public RequestData (SpmWebServiceInstanceDefinition instanceDefinition, CancellationToken? cancellationToken = null) :
base(cancellationToken)
{
InstanceDefinition = instanceDefinition;
}
public SpmWebServiceInstanceDefinition InstanceDefinition { get; }
public String Data { get; set; } = "";
}
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceClient ()
{
}
//-------------------------------------------------------------------
// Properties.
//-------------------------------------------------------------------
// I s A l i v e
//-------------------------------------------------------------------
public async Task<bool> RequestIsAlive (SpmWebServiceInstanceDefinition instanceDefinition)
{
String fn = GetType().Name + ".IsAlive";
try
{
RequestData requestData = new RequestData(instanceDefinition);
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
if (serviceResponse.ResponseData.EqualsCI(SpmWebServiceDfn.IsAliveResponse))
return true;
}
catch (Exception exc) { Logger.Warn(fn + " " + exc.GetLogMessage()); }
return false;
}
//-------------------------------------------------------------------
// I t e m C o u n t R e q u e s t
//-------------------------------------------------------------------
public class ItemCountResponseData : SpmWebServiceResponse
{
public ItemCountResponseData (SpmWebServiceResponse serviceResponse) : base(serviceResponse) { }
public long ItemCount { get; set; }
}
public async Task<ItemCountResponseData> RequestItemCount (SpmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemCount";
if (SacsSystem.DebugMode && configRequest.RequestType != SpmWebServiceRequest.RequestType.Count) Debugger.Break();
// Service Request.
SpmWebServiceRequest serviceRequestData = new SpmWebServiceRequest(configRequest);
serviceRequestData.Filters.AddRange(filters);
// Configure Web Service and make Request.
RequestData requestData = new RequestData(configRequest.Context.InstanceDefinition, taskData.CancellationToken) { Debug = taskData.Debug };
requestData.Data = serviceRequestData.GenerateRequestData();
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
ItemCountResponseData responseData = new ItemCountResponseData(serviceResponse);
bool itemCountFound = false;
// Interpret response.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
{
foreach (XElement responseChildElement in serviceResponse.ResponseElement.Elements())
{
if (responseChildElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Data))
{
foreach (XElement dataElement in responseChildElement.Elements())
{
if (dataElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Count))
{
itemCountFound = true;
responseData.ItemCount = StringUtil.ToLong(dataElement.Value);
break;
}
if (taskData.IsCancellationRequested) break;
}
}
if (itemCountFound || taskData.IsCancellationRequested) break;
}
}
if (!itemCountFound) responseData.ErrorStateMessage = "Incomplete item count";
if (taskData.IsCancellationRequested) responseData.TaskCancelled = true;
return responseData;
}
//-------------------------------------------------------------------
// Q u e r y L i s t R e q u e s t
//-------------------------------------------------------------------
public class QueryListResponseData : SpmWebServiceResponse
{
public QueryListResponseData (SpmWebServiceResponse serviceResponse) : base(serviceResponse) { }
public List<SpmWebServiceItemData> Items { get; } = new List<SpmWebServiceItemData>();
public int Count { get; set; }
public int Total { get; set; }
public uint PageNo { get; set; }
public ushort PageLength { get; set; }
}
public async Task<QueryListResponseData> RequestQueryList (SpmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, List<string> columns, List<String> sortColumns, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemList";
if (SacsSystem.DebugMode && configRequest.RequestType != SpmWebServiceRequest.RequestType.QueryList) Debugger.Break();
// Service Request.
SpmWebServiceRequest serviceRequestData = new SpmWebServiceRequest(configRequest);
serviceRequestData.Filters.AddRange(filters);
serviceRequestData.Columns.AddRange(columns);
if (sortColumns != null) serviceRequestData.SortColumns.AddRange(sortColumns);
// Configure Web Service and make Request.
RequestData requestData = new RequestData(configRequest.Context.InstanceDefinition, taskData.CancellationToken) { Debug = taskData.Debug };
requestData.Data = serviceRequestData.GenerateRequestData();
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
QueryListResponseData responseData = new QueryListResponseData(serviceResponse);
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) Logger.Debug(fn + " Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
// Interpret response.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
{
foreach (XElement responseChildElement in serviceResponse.ResponseElement.Elements())
{
if (responseChildElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Data))
{
foreach (XElement dataElement in responseChildElement.Elements())
{
if (dataElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.List))
{
// Paging info.
// <List Count="8" Total="196527" PageNo="1" PageLength="8">
responseData.Count = StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Count));
responseData.Total = StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Total));
responseData.PageNo = (uint)StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.PageNo));
responseData.PageLength = (ushort)StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.PageLength));
// Extract items.
foreach (XElement listElement in dataElement.Elements())
{
taskData.ThrowIfCancellationRequested();
if (listElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Item))
{
SpmWebServiceItemData itemData = new SpmWebServiceItemData("");
List<String> fields = SacsCsvHandler.ParseCsvRecord(listElement.Value);
for (int fieldIdx = 0; fieldIdx < fields.Count && fieldIdx < columns.Count; fieldIdx++)
{
String column = columns[fieldIdx];
String field = fields[fieldIdx];
itemData.AddValue(column, field);
}
responseData.Items.Add(itemData);
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) responseData.TaskCancelled = true;
return responseData;
}
//-------------------------------------------------------------------
// I t e m L i s t R e q u e s t
//-------------------------------------------------------------------
public class ItemListResponseData : SpmWebServiceResponse
{
public ItemListResponseData (SpmWebServiceResponse serviceResponse) : base(serviceResponse) { }
public List<SpmWebServiceItemData> Items { get; } = new List<SpmWebServiceItemData>();
public int Count { get; set; }
public int Total { get; set; }
public uint PageNo { get; set; }
public ushort PageLength { get; set; }
}
public async Task<ItemListResponseData> RequestItemList (SpmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, List<String> sortColumns, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemList";
if (SacsSystem.DebugMode && configRequest.RequestType != SpmWebServiceRequest.RequestType.ItemList) Debugger.Break();
// Service Request.
SpmWebServiceRequest serviceRequestData = new SpmWebServiceRequest(configRequest);
serviceRequestData.Filters.AddRange(filters);
if (sortColumns != null) serviceRequestData.SortColumns.AddRange(sortColumns);
// Configure Web Service and make Request.
RequestData requestData = new RequestData(configRequest.Context.InstanceDefinition, taskData.CancellationToken) { Debug = taskData.Debug };
requestData.Data = serviceRequestData.GenerateRequestData();
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
ItemListResponseData responseData = new ItemListResponseData(serviceResponse);
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) Logger.Debug(fn + " Response:\n\n" + responseData.ResponseElement.FormatXml() + "\n");
// Interpret response.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
{
foreach (XElement responseChildElement in serviceResponse.ResponseElement.Elements())
{
if (responseChildElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Data))
{
foreach (XElement dataElement in responseChildElement.Elements())
{
if (dataElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.List))
{
// Paging info.
// <List Count="8" Total="196527" PageNo="1" PageLength="8">
responseData.Count = StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Count));
responseData.Total = StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Total));
responseData.PageNo = (uint)StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.PageNo));
responseData.PageLength = (ushort)StringUtil.ToInt(dataElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.PageLength));
// Extract items.
foreach (XElement listElement in dataElement.Elements())
{
taskData.ThrowIfCancellationRequested();
if (listElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Item))
responseData.Items.Add(ExtractItemData(listElement, taskData));
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) responseData.TaskCancelled = true;
return responseData;
}
//-------------------------------------------------------------------
// I t e m D a t a R e q u e s t
//-------------------------------------------------------------------
public class ItemDataResponseData : SpmWebServiceResponse
{
public ItemDataResponseData (SpmWebServiceResponse serviceResponse) : base(serviceResponse) { }
public XElement DataElement => (ResponseElement?.GetFirstChildElement(SpmWebServiceDfn.ElementName.Data) ?? null);
public XElement ItemElement => (DataElement?.GetFirstChildElement(SpmWebServiceDfn.ElementName.Item) ?? null);
public SpmWebServiceItemData Item { get; set; }
}
public async Task<ItemDataResponseData> RequestItemData (SpmWebServiceRequest.Config configRequest, Dictionary<String, String> filters, SacsTaskData taskData)
{
String fn = GetType().Name + ".GetItemData";
if (SacsSystem.DebugMode && configRequest.RequestType != SpmWebServiceRequest.RequestType.Item) Debugger.Break();
// Service Request.
SpmWebServiceRequest serviceRequestData = new SpmWebServiceRequest(configRequest);
serviceRequestData.Filters.AddRange(filters);
// Configure Web Service and make Request.
RequestData requestData = new RequestData(configRequest.Context.InstanceDefinition, taskData.CancellationToken) { Debug = taskData.Debug };
requestData.Data = serviceRequestData.GenerateRequestData();
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
ItemDataResponseData responseData = new ItemDataResponseData(serviceResponse);
//if (SacsSystem.DebugMode && responseData.ResponseElement != null) Logger.Debug("Response:\n\n" + responseData.ResponseElement.FormatXml()+"\n");
// Extract item properties.
if (serviceResponse.ResponseElement != null && !taskData.IsCancellationRequested)
{
foreach (XElement responseChildElement in serviceResponse.ResponseElement.Elements())
{
requestData.ThrowIfCancellationRequested();
if (responseChildElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Data))
{
foreach (XElement dataElement in responseChildElement.Elements())
{
requestData.ThrowIfCancellationRequested();
if (dataElement.Name.LocalName.EqualsCI(SpmWebServiceDfn.ElementName.Item))
responseData.Item = ExtractItemData(dataElement, taskData);
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) responseData.TaskCancelled = true;
return responseData;
}
//-------------------------------------------------------------------
// E x t r a c t I t e m
//-------------------------------------------------------------------
private SpmWebServiceItemData ExtractItemData (XElement itemElement, SacsTaskData taskData)
{
SpmWebServiceItemData itemData = new SpmWebServiceItemData(itemElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.ItemType));
foreach (XElement itemDataElement in itemElement.Elements())
{
if (!itemDataElement.HasElements)
{
// No child elements - treat as item property.
itemData.AddValue(itemDataElement.Name.LocalName, itemDataElement.Value);
}
else if (itemDataElement.Name.LocalName.Length > 4 && itemDataElement.Name.LocalName.EndsWithCI("List"))
{
// Data elements has children and is a list of child items.
String childItemType = itemDataElement.Name.LocalName;
if (!itemData.ChildItems.ContainsKey(childItemType))
itemData.ChildItems[childItemType] = new List<SpmWebServiceItemData>();
foreach (XElement childItemElement in itemDataElement.Elements())
{
itemData.ChildItems[childItemType].Add(ExtractItemData(childItemElement, taskData));
if (taskData.IsCancellationRequested) break;
}
}
if (taskData.IsCancellationRequested) break;
}
return itemData;
}
//-------------------------------------------------------------------
// S t o r e I t e m R e q u e s t
//-------------------------------------------------------------------
public class StoreItemResponseData : SpmWebServiceResponse
{
public StoreItemResponseData (SpmWebServiceResponse serviceResponse) : base(serviceResponse) { }
public XElement DataElement => (ResponseElement?.GetFirstChildElement("Item") ?? null);
}
public async Task<StoreItemResponseData> StoreItem (SpmWebServiceRequest.Config configRequest, XElement itemElement, SacsTaskData taskData)
{
String fn = GetType().Name + ".StoreItem";
if (SacsSystem.DebugMode && configRequest.RequestType != SpmWebServiceRequest.RequestType.Store) Debugger.Break();
// Service Request.
SpmWebServiceRequest serviceRequestData = new SpmWebServiceRequest(configRequest);
serviceRequestData.ItemElement = itemElement;
// Configure Web Service and make Request.
RequestData requestData = new RequestData(configRequest.Context.InstanceDefinition, taskData.CancellationToken) { Debug = taskData.Debug };
requestData.Data = serviceRequestData.GenerateRequestData();
SpmWebServiceResponse serviceResponse = await DoWebServiceRequest(requestData);
// Return result.
return new StoreItemResponseData(serviceResponse);
}
//-------------------------------------------------------------------
// W e b S e r v i c e R e q u e s t
//-------------------------------------------------------------------
/// <summary>
/// Execute the web service request.
/// <para>Request data is encrypted and response data is decrypted automatically.</para>
/// </summary>
public async Task<SpmWebServiceResponse> DoWebServiceRequest (RequestData requestData)
{
String fn = GetType().Name + ".DoWebServiceRequest";
SpmWebServiceResponse serviceResponse = null;
// Throw canceled exception if task has been cancelled - invoke at regular intervals.
requestData.ThrowIfCancellationRequested();
// Log request.
if (SacsSystem.DebugMode) Logger.Debug(fn + " Request URL:" + requestData.InstanceDefinition.URL);
if (requestData.Debug)
{
if (requestData.Data.Length < 512)
Logger.Debug(fn + " Request:\n\t" + requestData.Data);
else Logger.Debug(fn + " Request length:" + requestData.Data.Length);
}
// Configure the request.
SacsHttpRequestData httpRequestData = new SacsHttpRequestData(requestData.CancellationToken)
{
Url = requestData.InstanceDefinition.URL,
TimeoutSecs = 1,
PostData = SpmWindowsServiceCrypter.EncryptRequestData(requestData.Data)
};
// Make the request.
DateTime started = DateTime.Now;
requestData.InstanceDefinition.LastRequestAt = started;
SacsHttpResponseData httpResponseData = await SacsHttpClient.DoRequest(httpRequestData);
// Construct the response.
SpmWebServiceResponse.Config serviceResponseConfig = new SpmWebServiceResponse.Config()
{
RequestStarted = started,
RequestCompleted = DateTime.Now,
HttpResponseData = httpResponseData
};
serviceResponse = new SpmWebServiceResponse(serviceResponseConfig);
// Note if request was successful.
if (httpResponseData.Success)
requestData.InstanceDefinition.LastSuccessfulRequestAt = serviceResponseConfig.RequestCompleted;
// Log response.
if (requestData.Debug)
{
if (serviceResponse.ResponseData.Length < 1024)
Logger.Debug(fn + " Response: " + serviceResponse.ResponseData);
else Logger.Debug(fn + " Response size: " + serviceResponse.ResponseData.Length);
}
return serviceResponse;
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public static class SpmWebServiceDfn
{
//-------------------------------------------------------------------
// Web Service XML element names.
public class ElementNameData
{
// Common.
public String Data { get; } = "Data";
public String List { get; } = "List";
public String Item { get; } = "Item";
public String Filter { get; } = "Filter";
public String Property { get; } = "Property";
public String Columns { get; } = "Columns";
public String SortColumns { get; } = "SortColumns";
public String SortColumn { get; } = "SortColumn";
// Request.
public String Config { get; } = "Config";
public String Context { get; } = "Context";
public String Site { get; } = "Site";
public String Host { get; } = "Host";
public String User { get; } = "User";
public String Email { get; } = "Email";
public String AffiliateIdOrganisation { get; } = "AffiliateIdOrganisation";
public String Debug { get; } = "Debug";
// Response.
public String SpmResponse { get; } = "SpmResponse";
public String Status { get; } = "Status";
public String Messages { get; } = "Messages";
public String Message { get; } = "Message";
public String Count { get; } = "Count";
// Item.
public String Id { get; } = "Id";
public String Code { get; } = "Code";
public String Notes { get; } = "Notes";
public String Flags { get; } = "Flags";
public String CreatedOn { get; } = "CreatedOn";
public String UpdatedOn { get; } = "UpdatedOn";
}
public static ElementNameData ElementName { get; } = new ElementNameData();
//-------------------------------------------------------------------
// Web Service XML attribute names.
public class AttributeNameData
{
// Common.
public String ItemType { get; } = "ItemType";
public String Name { get; } = "Name";
public String Value { get; } = "Value";
public String Code { get; } = "Code";
public String Debug { get; } = "Debug";
// Messages.
public String Context { get; } = "Context";
public String Level { get; } = "Level";
// Item list.
public String Total { get; } = "Total";
public String Count { get; } = "Count";
public String PageNo { get; } = "PageNo";
public String PageLength { get; } = "PageLength";
}
public static AttributeNameData AttributeName { get; } = new AttributeNameData();
//-------------------------------------------------------------------
// Properties.
public static String IsAliveResponse { get; } = "Hello";
public static String StatusSuccess { get; } = "OK";
public static String StatusFatal { get; } = "Fatal";
public static String StatusError { get; } = "Error";
public static String StatusWarning { get; } = "Warning";
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,37 @@
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public class SpmWebServiceInstanceDefinition
{
//-------------------------------------------------------------------
// Definitions.
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceInstanceDefinition (String caption, String url)
{
Caption = caption;
URL = url;
}
//-------------------------------------------------------------------
// Properties.
public String Caption { get; }
public String URL { get; }
public DateTime LastRequestAt { get; set; }
public DateTime LastSuccessfulRequestAt { get; set; }
public bool Valid { get { return (!StringUtil.IsEmpty(URL)); } }
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,129 @@
using Sarand.Core.Base;
using Sarand.Core.Bus;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public class SpmWebServiceItemData
{
//-------------------------------------------------------------------
// Data members.
private readonly Dictionary<String, String> values = new Dictionary<String, String>();
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceItemData (String itemType)
{
ItemType = itemType;
}
// Copy construction.
public SpmWebServiceItemData (SpmWebServiceItemData itemData)
{
values.AddRange(itemData.values);
}
//-------------------------------------------------------------------
// Properties.
public String ItemType { get; }
/// <summary>
/// Child items.
/// <para>Dictionary key identifies type of item.</para>
/// </summary>
public Dictionary<String, List<SpmWebServiceItemData>> ChildItems { get; } = new Dictionary<string, List<SpmWebServiceItemData>>();
//-------------------------------------------------------------------
// Population.
public void AddValue (String name, String value)
{
values[name] = value;
}
//-------------------------------------------------------------------
// Value exists.
public bool HasValue<T> (T name)
{
return HasValue(name.ToString());
}
public bool HasValue (string name)
{
return values.ContainsKey(name);
}
//-------------------------------------------------------------------
// String value.
public String GetValue<T> (T name)
{
return GetValue(name.ToString());
}
public String GetValue (string name)
{
return values.GetValue(name, "");
}
//-------------------------------------------------------------------
// SysId value.
public SysId GetIdValue<T> (T name)
{
return GetIdValue(name.ToString());
}
public SysId GetIdValue (string name)
{
return new SysId(StringUtil.ToInt(GetValue(name)));
}
//-------------------------------------------------------------------
// Bool value.
public bool GetBoolValue<T> (T name)
{
return GetBoolValue(name.ToString());
}
public bool GetBoolValue (string name)
{
return StringUtil.ToBool(GetValue(name));
}
// Int value.
public int GetIntValue<T> (T name)
{
return GetIntValue(name.ToString());
}
public int GetIntValue (string name)
{
return StringUtil.ToInt(GetValue(name));
}
// Decimal value.
public decimal GetDecimalValue<T> (T name)
{
return GetDecimalValue(name.ToString());
}
public decimal GetDecimalValue (string name)
{
return StringUtil.ToDecimal(GetValue(name));
}
//-------------------------------------------------------------------
// Date value.
public DateTime GetDateValue<T> (T name)
{
return GetDateValue(name.ToString());
}
public DateTime GetDateValue (string name)
{
return DateUtil.ParseXmlDate(GetValue(name));
}
// DateTime value.
public DateTime GetDateTimeValue<T> (T name)
{
return GetDateTimeValue(name.ToString());
}
public DateTime GetDateTimeValue (string name)
{
return DateUtil.ParseXmlDateTime(GetValue(name));
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,46 @@
using Sarand.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public class SpmWebServiceMessage
{
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceMessage (String context, String code, String message, SaMessageLevel level = SaMessageLevel.Info)
{
Level = level;
Context = context;
Code = code;
Message = message;
}
//-------------------------------------------------------------------
// Properties.
public SaMessageLevel Level { get; }
public string Context { get; }
public string Code { get; }
public string Message { get; }
//-------------------------------------------------------------------
}
//=======================================================================
public static class SpmWebServiceMessageList
{
public static bool HasMessagesOfLevel (this IEnumerable<SpmWebServiceMessage> messages, SaMessageLevel level)
{
return messages.Any(msg => msg.Level == level);
}
public static List<SpmWebServiceMessage> GetMessagesOfLevel (this IEnumerable<SpmWebServiceMessage> messages, SaMessageLevel level)
{
return messages.Where(msg => msg.Level == level).ToList();
}
}
//=======================================================================
}
@@ -0,0 +1,219 @@
using Sarand.Core.Base;
using Sarand.Core.Xml;
using Sarand.PatientMgr.Core.App;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
using Sarand.Core.Bus;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public class SpmWebServiceRequest
{
//-------------------------------------------------------------------
// Definitions.
public enum RequestType
{
Unknown,
IsAlive,
/// <summary>Item count</summary>
Count,
/// <summary>Query list - specific columns, compressed (csv etc) response data</summary>
QueryList,
/// <summary>Item list - full xml for each item with optional associated items.</summary>
ItemList,
/// <summary>Single Item with optional associated items.</summary>
Item,
/// <summary>Validate item properties without update.</summary>
Validate,
/// <summary>Validate properties and store (insert/update) item.</summary>
Store,
/// <summary>Delete item.</summary>
Delete,
/// <summary>List - as per Query List</summary>
[Obsolete("Deprecated. Use QueryList instead.", true)]
List,
/// <summary>Single Item with optional associated items.</summary>
[Obsolete("Deprecated. Use Item instead.", true)]
Data,
}
public enum DataType
{
Unknown,
// Security.
UserProfile,
// Reference data.
CodeType,
Code,
// Admission.
Admission,
AdmissionAction,
AdmissionData,
AdmissionRole,
// Department.
Department,
EmployeeRole,
Facility,
FacilitySession,
FacilityTemplate,
Procedure,
TemplateData,
// Institution.
Employee,
Institution,
Operation,
Patient
}
//-------------------------------------------------------------------
/// <summary>
/// Sort column identified by column name with ascending flag.
/// </summary>
public class SortColumnData
{
public SortColumnData (String columnName, bool ascending)
{
ColumnName = columnName;
Ascending = ascending;
}
public String ColumnName { get; }
public bool Ascending { get; }
}
//-------------------------------------------------------------------
// Configuration.
public class Config
{
public bool SoapEnvelope { get; set; }
public String SoapPrefix { get; set; }
public DataType DataType { get; set; }
public RequestType RequestType { get; set; }
public class ContextProperties
{
public SpmWebServiceInstanceDefinition InstanceDefinition { get; set; }
public String Url { get; set; }
public String User { get; set; }
public String Email { get; set; }
public SysId AffiliateIdOrganisation { get; set; }
public bool Commit { get; set; }
public bool Debug { get; set; }
}
public ContextProperties Context { get; } = new ContextProperties();
}
//-------------------------------------------------------------------
// Data members.
private readonly Config config;
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceRequest (Config config)
{
this.config = config;
}
//-------------------------------------------------------------------
// Properties.
public Dictionary<String, String> Filters { get; } = new Dictionary<String, String>();
public List<String> Columns { get; } = new List<String>();
public List<String> SortColumns { get; } = new List<String>();
public XElement ItemElement { get; set; }
//-------------------------------------------------------------------
// D a t a G e n e r a t i o n
//-------------------------------------------------------------------
public String GetRequestName ()
{
if (config.RequestType == RequestType.IsAlive) return "";
String requestName = "";
if (config.DataType > 0)
requestName += config.DataType.ToString();
if (config.RequestType > 0)
requestName += config.RequestType.ToString();
return requestName + "Request";
}
public String GenerateRequestData (bool formatted = false)
{
if (config.RequestType == RequestType.IsAlive) return "";
// Request document.
XDocument requestDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
// Request root.
XElement requestElement = null;
if (config.SoapEnvelope)
{
XElement envelopeElement = null;
XElement headerElement = null;
XElement bodyElement = null;
if (!StringUtil.IsEmpty(config.SoapPrefix))
{
XNamespace soapNamespace = SacsSoapUtils.GetSoapNamespace(SoapNamespaceType.Soap_1_1);
envelopeElement = requestDoc.AppendElement(soapNamespace, SacsSoapUtils.GetElementName(SoapElementType.Envelope));
envelopeElement.SetAttributeValue(XNamespace.Xmlns + config.SoapPrefix, soapNamespace);
headerElement = envelopeElement.AppendElement(soapNamespace, SacsSoapUtils.GetElementName(SoapElementType.Header));
bodyElement = envelopeElement.AppendElement(soapNamespace, SacsSoapUtils.GetElementName(SoapElementType.Body));
}
else
{
// No namespace.
envelopeElement = requestDoc.AppendElement(SacsSoapUtils.GetElementName(SoapElementType.Envelope));
headerElement = envelopeElement.AppendElement(SacsSoapUtils.GetElementName(SoapElementType.Header));
bodyElement = envelopeElement.AppendElement(SacsSoapUtils.GetElementName(SoapElementType.Body));
}
requestElement = bodyElement.AppendElement(GetRequestName());
}
else
{
// Otherwise add the request directly to the document.
requestElement = requestDoc.AppendElement(GetRequestName());
}
// Config.
XElement configElement = requestElement.AppendElement("Config");
// Context.
XElement contextElement = configElement.AppendElement("Context");
if (!StringUtil.IsEmpty(config.Context.User)) contextElement.AppendElement("User", config.Context.User);
if (!StringUtil.IsEmpty(config.Context.Email)) contextElement.AppendElement("Email", config.Context.Email);
if (SysId.IsValid(config.Context.AffiliateIdOrganisation)) contextElement.AppendElement("AffiliateIdOrganisation", SysId.ToString(config.Context.AffiliateIdOrganisation));
if (config.Context.Commit) contextElement.AppendElement("Commit", "1");
if (config.Context.Debug) contextElement.AppendElement("Debug", "1");
// Filter.
if (Filters.Count > 0)
{
XElement filterElement = configElement.AppendElement("Filter");
foreach (String name in Filters.Keys)
filterElement.AppendElement(name, Filters[name]);
}
// Columns.
if (Columns.Count > 0)
{
XElement columnsElement = configElement.AppendElement("Columns", Columns.Concat(",", "", ""));
}
// Sort columns.
if (SortColumns.Count > 0)
{
XElement sortColumnsElement = configElement.AppendElement("SortColumns", SortColumns.Concat(",", "", ""));
}
// Item.
if (ItemElement != null)
{
XElement dataElement = requestElement.AppendElement("Data");
dataElement.AppendElement(ItemElement);
}
if (formatted)
return requestDoc.FormatXml();
return requestDoc.GetXml();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,126 @@
using Sarand.Core.App;
using Sarand.Core.Base;
using Sarand.Core.Net;
using Sarand.Core.Xml;
using Sarand.PatientMgr.Core.Data;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Sarand.PatientMgr.Core.WebService
{
//=======================================================================
public class SpmWebServiceResponse
{
//-------------------------------------------------------------------
// Definitions.
//-------------------------------------------------------------------
// Configuration.
public class Config
{
public DateTime RequestStarted { get; set; } = DateTime.Now;
public DateTime RequestCompleted { get; set; }
public SacsHttpResponseData HttpResponseData { get; set; }
}
//-------------------------------------------------------------------
// Data members.
protected readonly Config config;
//-------------------------------------------------------------------
// Construction.
public SpmWebServiceResponse (Config config)
{
this.config = config;
ResponseData = SpmWindowsServiceCrypter.DecryptResponseData(config.HttpResponseData.Data);
try
{
// Identify the response element in the xml data.
ResponseDoc = XDocument.Parse(ResponseData, LoadOptions.None);
XElement rootElement = ResponseDoc.Root;
if (rootElement.Name.LocalName.EndsWithCI("Response"))
ResponseElement = rootElement;
else if (rootElement.Name.LocalName.EqualsCI(SacsSoapUtils.GetElementName(SoapElementType.Envelope)))
{
SoapEnvelope = true;
SoapPrefix = rootElement.GetNamespacePrefix();
foreach (XElement soapElement in rootElement.Elements())
{
if (soapElement.Name.LocalName.EqualsCI(SacsSoapUtils.GetElementName(SoapElementType.Body)))
{
foreach (XElement bodyElement in soapElement.Elements())
{
if (bodyElement.Name.LocalName.EndsWithCI("Response"))
{
ResponseElement = bodyElement;
}
}
}
}
}
if (ResponseElement != null)
{
// Extract status code.
XElement statusElement = ResponseElement.GetFirstChildElement(SpmWebServiceDfn.ElementName.Status);
if (statusElement != null)
{
StatusCode = statusElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Code);
// Extract messages.
XElement messagesElement = statusElement.GetFirstChildElement(SpmWebServiceDfn.ElementName.Messages);
if (messagesElement != null)
{
foreach (XElement messageElement in messagesElement.GetChildElements(SpmWebServiceDfn.ElementName.Message))
{
String context = messageElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Context);
String code = messageElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Code);
SaMessageLevel level = SacsSystem.GetMessageLevelFromCode(messageElement.GetAttributeValue(SpmWebServiceDfn.AttributeName.Level));
SpmWebServiceMessage message = new SpmWebServiceMessage(context, code, messageElement.Value, level);
Messages.Add(message);
}
}
}
}
}
catch (Exception) { }
}
public SpmWebServiceResponse (SpmWebServiceResponse serviceResponse)
{
// Copied from another service reponse - don't re-intrepert properties.
this.config = serviceResponse.config;
// Structure.
SoapEnvelope = serviceResponse.SoapEnvelope;
SoapPrefix = serviceResponse.SoapPrefix;
// Response.
ResponseData = serviceResponse.ResponseData;
ResponseDoc = serviceResponse.ResponseDoc;
ResponseElement = serviceResponse.ResponseElement;
// Status.
StatusCode = serviceResponse.StatusCode;
Messages = serviceResponse.Messages;
}
//-------------------------------------------------------------------
// Properties.
public DateTime RequestStarted { get { return config.RequestStarted; } }
public DateTime RequestCompleted { get { return config.RequestCompleted; } }
public SacsHttpResponseData HttpResponseData { get { return config.HttpResponseData; } }
// Structure.
public bool SoapEnvelope { get; }
public String SoapPrefix { get; } = "";
// Response.
public String ResponseData { get; }
public XDocument ResponseDoc { get; }
public XElement ResponseElement { get; }
// Status.
public bool TaskCancelled { get; set; }
public String StatusCode { get; } = "";
public List<SpmWebServiceMessage> Messages { get; } = new List<SpmWebServiceMessage>();
public String ErrorStateMessage { get; set; }
//-------------------------------------------------------------------
}
//=======================================================================
}
-2
View File
@@ -23,9 +23,7 @@
<ItemGroup>
<Folder Include="Core\Consoles\" />
<Folder Include="Core\Data\" />
<Folder Include="Core\UpdateLog\" />
<Folder Include="Core\WebService\" />
</ItemGroup>
<ItemGroup>
+87
View File
@@ -285,6 +285,12 @@
<Compile Include="Win\Forms\Base\SpmPanel.Designer.cs">
<DependentUpon>SpmPanel.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Maint\SpmForm_Institution.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Win\Forms\Maint\SpmForm_Institution.Designer.cs">
<DependentUpon>SpmForm_Institution.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Maint\SpmForm_Admission.cs">
<SubType>Form</SubType>
</Compile>
@@ -387,6 +393,30 @@
<Compile Include="Win\Forms\Maint\SpmForm_Department.Designer.cs">
<DependentUpon>SpmForm_Department.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Patients.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Patients.Designer.cs">
<DependentUpon>SpmPanel_Patients.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Operations.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Operations.Designer.cs">
<DependentUpon>SpmPanel_Operations.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Institutions.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Institutions.Designer.cs">
<DependentUpon>SpmPanel_Institutions.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Employees.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Employees.Designer.cs">
<DependentUpon>SpmPanel_Employees.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\Panels\SpmPanel_Departments.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -435,6 +465,48 @@
<Compile Include="Win\Forms\Panels\SpmPanel_UpdateStamp.Designer.cs">
<DependentUpon>SpmPanel_UpdateStamp.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_EmployeeRole.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_EmployeeRole.Designer.cs">
<DependentUpon>SpmTabPage_EmployeeRole.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_TemplateData.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_TemplateData.Designer.cs">
<DependentUpon>SpmTabPage_TemplateData.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Operation.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Operation.Designer.cs">
<DependentUpon>SpmTabPage_Operation.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Patient.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Patient.Designer.cs">
<DependentUpon>SpmTabPage_Patient.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Procedure.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Procedure.Designer.cs">
<DependentUpon>SpmTabPage_Procedure.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Institution.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Institution.Designer.cs">
<DependentUpon>SpmTabPage_Institution.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Employee.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Employee.Designer.cs">
<DependentUpon>SpmTabPage_Employee.cs</DependentUpon>
</Compile>
<Compile Include="Win\Forms\TabPages\SpmTabPage_Admission.cs">
<SubType>Component</SubType>
</Compile>
@@ -551,6 +623,9 @@
<EmbeddedResource Include="Win\Forms\Filters\SpmItemListFilter_Admission.resx">
<DependentUpon>SpmItemListFilter_Admission.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Maint\SpmForm_Institution.resx">
<DependentUpon>SpmForm_Institution.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Maint\SpmForm_Admission.resx">
<DependentUpon>SpmForm_Admission.cs</DependentUpon>
</EmbeddedResource>
@@ -596,6 +671,18 @@
<EmbeddedResource Include="Win\Forms\Maint\SpmForm_Department.resx">
<DependentUpon>SpmForm_Department.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Patients.resx">
<DependentUpon>SpmPanel_Patients.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Operations.resx">
<DependentUpon>SpmPanel_Operations.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Institutions.resx">
<DependentUpon>SpmPanel_Institutions.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Employees.resx">
<DependentUpon>SpmPanel_Employees.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Win\Forms\Panels\SpmPanel_Departments.resx">
<DependentUpon>SpmPanel_Departments.cs</DependentUpon>
</EmbeddedResource>
@@ -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);
}
}
//=======================================================================
}