SB 12-Jun-2019, create listView & listFilter
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView
|
||||
{
|
||||
/// <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,102 @@
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sarand.PatientMgr.Core.App;
|
||||
using Sarand.PatientMgr.Win.Forms.App;
|
||||
using Sarand.PatientMgr.Core.Mgr;
|
||||
using Sarand.Core.Security;
|
||||
using Sarand.Core.CodeTypes;
|
||||
using Sarand.Core.UpdateLog;
|
||||
using Sarand.Core.ItemOptions;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView : SacsListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public class Config
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly SpmInternals internals;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
private SpmItemListView() : this(new Config()) { }
|
||||
public SpmItemListView(Config config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
internals = new SpmInternals(SessionProfile != null ? SessionProfile.UserContext : null);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
if (internals != null) internals.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
/// <summary>Flag to indicate initial population</summary>
|
||||
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public virtual bool InitialPopulation { get; protected set; } = true;
|
||||
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public virtual int DisplayRecordsBatchSize { get; } = 32;
|
||||
/// <summary>Total number of items to be displayed (not items already in the list).</summary>
|
||||
[Browsable(false), ReadOnly(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public virtual int ItemTotal { get; protected set; } = 0;
|
||||
|
||||
|
||||
// Session.
|
||||
protected SpmSessionProfile_Win SessionProfile { get; } = SpmGlobals_Win.SessionProfile;
|
||||
protected SpmUserContext UserContext { get { return (SessionProfile != null ? SessionProfile.UserContext : null); } }
|
||||
protected SpmSessionContext SessionContext { get { return (UserContext != null ? UserContext.SessionContext : null); } }
|
||||
|
||||
// Security.
|
||||
protected SpmSecurityProfile SecurityProfile { get { return internals.SecurityProfile; } }
|
||||
|
||||
// Managers.
|
||||
protected SpmAdmissionMgr AdmissionMgr { get { return internals.AdmissionMgr; } }
|
||||
protected SpmDepartmentMgr DepartmentMgr { get { return internals.DepartmentMgr; } }
|
||||
protected SpmInstitutionMgr InstitutionMgr { get { return internals.InstitutionMgr; } }
|
||||
|
||||
// Consoles.
|
||||
protected SaSecurityConsole SecurityConsole { get { return internals.SecurityConsole; } }
|
||||
protected SaCodeTypeConsole CodeTypeConsole { get { return internals.CodeTypeConsole; } }
|
||||
protected SaUpdateLogConsole UpdateLogConsole { get { return internals.UpdateLogConsole; } }
|
||||
protected SaItemOptionConsole ItemOptionConsole { get { return internals.ItemOptionConsole; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
protected void SetConfig(Config config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_Admission
|
||||
{
|
||||
/// <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,400 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Admission : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmAdmission.Params prmAdmission;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Admission() : this(new Config()) { }
|
||||
public SpmItemListView_Admission(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedAdmissionId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmAdmission SelectedAdmission
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return AdmissionMgr.GetAdmissionById(SelectedAdmissionId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitAdmissionList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitAdmissionList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.FacilityId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TemplateId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Seq));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionFromDate));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionFromTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionFromDateTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionToDate));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionToTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AdmissionToDateTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Type));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Type_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.DecisionToReferOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.ReferredOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.BreechOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.DecisionToAdmitOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.PatientId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.PatientNo));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.PatientName));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.PatientSurname));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.PatientForename));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.BirthAge));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.BirthOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Age));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AgeOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.FacilityIdWard));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Ward));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.ProcedureId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.SpecialityCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Procedure));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.ComplexityCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.ProcedureIndication));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.DurationExp));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.DurationAct));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Anaesthetic));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Position));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.SpecialEquipment));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.AttendanceStatusDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.ComfortScore));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeCalled));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeArrived));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeAnaesStart));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeProcStart));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeProcEnd));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeInRecovery));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeInformDest));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.TimeLeave));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelType));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelTypeDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelDate));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelElapsed));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelReBookBy));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelReBookDue));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.CancelCount));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_Type));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_TypeDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_Name));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_TemplateMapType));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_ApplicFrom));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_ApplicTo));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Facility_Notes));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_WeekOfMonth));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_DayOfWeek));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_ConsultantId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_ConsultantCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_SpecialityCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_StartAt));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_FinishAt));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_CategoryDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_TypeDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_Name));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_Group));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_ApplicFrom));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_ApplicTo));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Template_Notes));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_TemplateId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_ConsultantId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_ConsultantCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_SpecialityCode));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_StartAt));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_FinishAt));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_Name));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_Flags));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Session_Notes));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.SessionDfn_Summary));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.SessionDfn_Name));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_PatientNo));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_Surname));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_Forename));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_BirthOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_Age));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Patient_AgeOn));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Role_Consultant_Operating_Code));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Role_Consultant_Referring_Code));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Role_Surgeon_Operating_Code));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Role_Anaesthetist_Operating_Code));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionColumnDfn(SpmAdmission.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmAdmission.Column.FacilityId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmAdmission.Params prmAdmission)
|
||||
{
|
||||
if (prmAdmission == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshAdmissions(SpmAdmission.Params prmAdmission)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmAdmission = prmAdmission;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmAdmission)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)AdmissionMgr.GetAdmissionCount(prmAdmission);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Admission count: " + ItemTotal);
|
||||
dbResultSet = AdmissionMgr.ExecuteAdmissionQuery(columnsQuery, prmAdmission);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshAdmission(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmAdmission.Params prm = new SpmAdmission.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = AdmissionMgr.ExecuteAdmissionQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmAdmission.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = AdmissionMgr.GetAdmissionDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_AdmissionAction
|
||||
{
|
||||
/// <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,315 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_AdmissionAction : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmAdmissionAction.Params prmAdmissionAction;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_AdmissionAction() : this(new Config()) { }
|
||||
public SpmItemListView_AdmissionAction(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedAdmissionActionId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmAdmissionAction SelectedAdmissionAction
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return AdmissionMgr.GetAdmissionActionById(SelectedAdmissionActionId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitAdmissionActionList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitAdmissionActionList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.Type));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.Type_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.Admission_FacilityId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.Admission_TemplateId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionFrom));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionFromDateTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionFromDate));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionFromTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionTo));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionToDate));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionToTime));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionType));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionTypeDesc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionNotes));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionFlags));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionStatus));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.AdmissionStatusInd));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionActionColumnDfn(SpmAdmissionAction.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmAdmissionAction.Column.AdmissionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmAdmissionAction.Params prmAdmissionAction)
|
||||
{
|
||||
if (prmAdmissionAction == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshAdmissionActions(SpmAdmissionAction.Params prmAdmissionAction)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmAdmissionAction = prmAdmissionAction;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmAdmissionAction)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)AdmissionMgr.GetAdmissionActionCount(prmAdmissionAction);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData AdmissionAction count: " + ItemTotal);
|
||||
dbResultSet = AdmissionMgr.ExecuteAdmissionActionQuery(columnsQuery, prmAdmissionAction);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshAdmissionAction(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmAdmissionAction.Params prm = new SpmAdmissionAction.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = AdmissionMgr.ExecuteAdmissionActionQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmAdmissionAction.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = AdmissionMgr.GetAdmissionActionDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_AdmissionData
|
||||
{
|
||||
/// <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,301 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_AdmissionData : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmAdmissionData.Params prmAdmissionData;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_AdmissionData() : this(new Config()) { }
|
||||
public SpmItemListView_AdmissionData(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedAdmissionDataId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmAdmissionData SelectedAdmissionData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return AdmissionMgr.GetAdmissionDataById(SelectedAdmissionDataId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitAdmissionDataList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitAdmissionDataList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionDataColumnDfn(SpmAdmissionData.Column.AdmissionId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionDataColumnDfn(SpmAdmissionData.Column.Type));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionDataColumnDfn(SpmAdmissionData.Column.Type_Desc));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionDataColumnDfn(SpmAdmissionData.Column.AdmissionData));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionDataColumnDfn(SpmAdmissionData.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmAdmissionData.Column.AdmissionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmAdmissionData.Params prmAdmissionData)
|
||||
{
|
||||
if (prmAdmissionData == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshAdmissionDatas(SpmAdmissionData.Params prmAdmissionData)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmAdmissionData = prmAdmissionData;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmAdmissionData)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)AdmissionMgr.GetAdmissionDataCount(prmAdmissionData);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData AdmissionData count: " + ItemTotal);
|
||||
dbResultSet = AdmissionMgr.ExecuteAdmissionDataQuery(columnsQuery, prmAdmissionData);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshAdmissionData(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmAdmissionData.Params prm = new SpmAdmissionData.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = AdmissionMgr.ExecuteAdmissionDataQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmAdmissionData.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = AdmissionMgr.GetAdmissionDataDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_AdmissionRole
|
||||
{
|
||||
/// <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,303 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_AdmissionRole : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmAdmissionRole.Params prmAdmissionRole;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_AdmissionRole() : this(new Config()) { }
|
||||
public SpmItemListView_AdmissionRole(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedAdmissionRoleId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmAdmissionRole SelectedAdmissionRole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return AdmissionMgr.GetAdmissionRoleById(SelectedAdmissionRoleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitAdmissionRoleList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitAdmissionRoleList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.AdmissionId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.Role));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.Category));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.Seq));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.EmployeeRoleId));
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.EmployeeCode));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(AdmissionMgr.GetAdmissionRoleColumnDfn(SpmAdmissionRole.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmAdmissionRole.Column.AdmissionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmAdmissionRole.Params prmAdmissionRole)
|
||||
{
|
||||
if (prmAdmissionRole == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshAdmissionRoles(SpmAdmissionRole.Params prmAdmissionRole)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmAdmissionRole = prmAdmissionRole;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmAdmissionRole)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)AdmissionMgr.GetAdmissionRoleCount(prmAdmissionRole);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData AdmissionRole count: " + ItemTotal);
|
||||
dbResultSet = AdmissionMgr.ExecuteAdmissionRoleQuery(columnsQuery, prmAdmissionRole);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshAdmissionRole(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmAdmissionRole.Params prm = new SpmAdmissionRole.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = AdmissionMgr.ExecuteAdmissionRoleQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmAdmissionRole.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = AdmissionMgr.GetAdmissionRoleDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_Department
|
||||
{
|
||||
/// <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,304 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Department : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmDepartment.Params prmDepartment;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Department() : this(new Config()) { }
|
||||
public SpmItemListView_Department(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedDepartmentId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmDepartment SelectedDepartment
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetDepartmentById(SelectedDepartmentId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitDepartmentList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitDepartmentList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Name));
|
||||
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicatonFrom));
|
||||
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.ApplicationTo));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetDepartmentColumnDfn(SpmDepartment.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmDepartment.Column.Name);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmDepartment.Params prmDepartment)
|
||||
{
|
||||
if (prmDepartment == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshDepartments(SpmDepartment.Params prmDepartment)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmDepartment = prmDepartment;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmDepartment)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetDepartmentCount(prmDepartment);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Department count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteDepartmentQuery(columnsQuery, prmDepartment);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshDepartment(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmDepartment.Params prm = new SpmDepartment.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteDepartmentQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmDepartment.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetDepartmentDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,304 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Employee : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmEmployee.Params prmEmployee;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Employee() : this(new Config()) { }
|
||||
public SpmItemListView_Employee(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedEmployeeId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmEmployee SelectedEmployee
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return InstitutionMgr.GetEmployeeById(SelectedEmployeeId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitEmployeeList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitEmployeeList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.InstitutionId));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.EmployeeNo));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Code));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Initials));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Title));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Forename));
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Surname));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(InstitutionMgr.GetEmployeeColumnDfn(SpmEmployee.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmEmployee.Column.InstitutionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmEmployee.Params prmEmployee)
|
||||
{
|
||||
if (prmEmployee == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshEmployees(SpmEmployee.Params prmEmployee)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmEmployee = prmEmployee;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmEmployee)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)InstitutionMgr.GetEmployeeCount(prmEmployee);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Employee count: " + ItemTotal);
|
||||
dbResultSet = InstitutionMgr.ExecuteEmployeeQuery(columnsQuery, prmEmployee);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshEmployee(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmEmployee.Params prm = new SpmEmployee.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = InstitutionMgr.ExecuteEmployeeQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmEmployee.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = InstitutionMgr.GetEmployeeDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_EmployeeRole : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmEmployeeRole.Params prmEmployeeRole;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_EmployeeRole() : this(new Config()) { }
|
||||
public SpmItemListView_EmployeeRole(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedEmployeeRoleId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmEmployeeRole SelectedEmployeeRole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetEmployeeRoleById(SelectedEmployeeRoleId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitEmployeeRoleList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitEmployeeRoleList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.DepartmentId));
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.EmployeeId));
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.Role));
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.ApplicationFrom));
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.ApplicationTo));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetEmployeeRoleColumnDfn(SpmEmployeeRole.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmEmployeeRole.Column.DepartmentId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmEmployeeRole.Params prmEmployeeRole)
|
||||
{
|
||||
if (prmEmployeeRole == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshEmployeeRoles(SpmEmployeeRole.Params prmEmployeeRole)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmEmployeeRole = prmEmployeeRole;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmEmployeeRole)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetEmployeeRoleCount(prmEmployeeRole);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData EmployeeRole count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteEmployeeRoleQuery(columnsQuery, prmEmployeeRole);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshEmployeeRole(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmEmployeeRole.Params prm = new SpmEmployeeRole.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteEmployeeRoleQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmEmployeeRole.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetEmployeeRoleDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_Facility
|
||||
{
|
||||
/// <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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Facility : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmFacility.Params prmFacility;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Facility() : this(new Config()) { }
|
||||
public SpmItemListView_Facility(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedFacilityId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmFacility SelectedFacility
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetFacilityById(SelectedFacilityId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitFacilityList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitFacilityList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.DepartmentId));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.Type));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.Type_Desc));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.Name));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.SortCode));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityColumnDfn(SpmFacility.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmFacility.Column.DepartmentId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmFacility.Params prmFacility)
|
||||
{
|
||||
if (prmFacility == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshFacilitys(SpmFacility.Params prmFacility)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmFacility = prmFacility;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmFacility)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetFacilityCount(prmFacility);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Facility count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteFacilityQuery(columnsQuery, prmFacility);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshFacility(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmFacility.Params prm = new SpmFacility.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteFacilityQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmFacility.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetFacilityDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_FacilitySession
|
||||
{
|
||||
/// <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,299 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_FacilitySession : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmFacilitySession.Params prmFacilitySession;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_FacilitySession() : this(new Config()) { }
|
||||
public SpmItemListView_FacilitySession(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedFacilitySessionId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmFacilitySession SelectedFacilitySession
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetFacilitySessionById(SelectedFacilitySessionId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitFacilitySessionList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitFacilitySessionList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilitySessionColumnDfn(SpmFacilitySession.Column.Facility_TypeDesc));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilitySessionColumnDfn(SpmFacilitySession.Column.Facility_Name));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilitySessionColumnDfn(SpmFacilitySession.Column.Facility_SortCode));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilitySessionColumnDfn(SpmFacilitySession.Column.Facility_Desc));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilitySessionColumnDfn(SpmFacilitySession.Column.Facility_TemplateMapTypeDesc));
|
||||
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmFacilitySession.Column.Facility_Name);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmFacilitySession.Params prmFacilitySession)
|
||||
{
|
||||
if (prmFacilitySession == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshFacilitySessions(SpmFacilitySession.Params prmFacilitySession)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmFacilitySession = prmFacilitySession;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmFacilitySession)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetFacilitySessionCount(prmFacilitySession);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData FacilitySession count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteFacilitySessionQuery(columnsQuery, prmFacilitySession);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshFacilitySession(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmFacilitySession.Params prm = new SpmFacilitySession.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteFacilitySessionQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmFacilitySession.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetFacilitySessionDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_FacilityTemplate
|
||||
{
|
||||
/// <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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_FacilityTemplate : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmFacilityTemplate.Params prmFacilityTemplate;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_FacilityTemplate() : this(new Config()) { }
|
||||
public SpmItemListView_FacilityTemplate(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedFacilityTemplateId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmFacilityTemplate SelectedFacilityTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetFacilityTemplateById(SelectedFacilityTemplateId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitFacilityTemplateList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitFacilityTemplateList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Category));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Type));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Type_Desc));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Sort));
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Group));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetFacilityTemplateColumnDfn(SpmFacilityTemplate.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmFacilityTemplate.Column.Name);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmFacilityTemplate.Params prmFacilityTemplate)
|
||||
{
|
||||
if (prmFacilityTemplate == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshFacilityTemplates(SpmFacilityTemplate.Params prmFacilityTemplate)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmFacilityTemplate = prmFacilityTemplate;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmFacilityTemplate)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetFacilityTemplateCount(prmFacilityTemplate);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData FacilityTemplate count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteFacilityTemplateQuery(columnsQuery, prmFacilityTemplate);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshFacilityTemplate(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmFacilityTemplate.Params prm = new SpmFacilityTemplate.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteFacilityTemplateQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmFacilityTemplate.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetFacilityTemplateDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Institution : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmInstitution.Params prmInstitution;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Institution() : this(new Config()) { }
|
||||
public SpmItemListView_Institution(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedInstitutionId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmInstitution SelectedInstitution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return InstitutionMgr.GetInstitutionById(SelectedInstitutionId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitInstitutionList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitInstitutionList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(InstitutionMgr.GetInstitutionColumnDfn(SpmInstitution.Column.Name));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(InstitutionMgr.GetInstitutionColumnDfn(SpmInstitution.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmInstitution.Column.Name);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmInstitution.Params prmInstitution)
|
||||
{
|
||||
if (prmInstitution == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshInstitutions(SpmInstitution.Params prmInstitution)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmInstitution = prmInstitution;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmInstitution)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)InstitutionMgr.GetInstitutionCount(prmInstitution);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Institution count: " + ItemTotal);
|
||||
dbResultSet = InstitutionMgr.ExecuteInstitutionQuery(columnsQuery, prmInstitution);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshInstitution(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmInstitution.Params prm = new SpmInstitution.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = InstitutionMgr.ExecuteInstitutionQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmInstitution.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = InstitutionMgr.GetInstitutionDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,300 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Operation : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmOperation.Params prmOperation;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Operation() : this(new Config()) { }
|
||||
public SpmItemListView_Operation(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedOperationId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmOperation SelectedOperation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return InstitutionMgr.GetOperationById(SelectedOperationId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitOperationList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitOperationList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(InstitutionMgr.GetOperationColumnDfn(SpmOperation.Column.InstitutionId));
|
||||
columnsDisplay.Add(InstitutionMgr.GetOperationColumnDfn(SpmOperation.Column.Code));
|
||||
columnsDisplay.Add(InstitutionMgr.GetOperationColumnDfn(SpmOperation.Column.Description));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(InstitutionMgr.GetOperationColumnDfn(SpmOperation.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmOperation.Column.InstitutionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmOperation.Params prmOperation)
|
||||
{
|
||||
if (prmOperation == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshOperations(SpmOperation.Params prmOperation)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmOperation = prmOperation;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmOperation)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)InstitutionMgr.GetOperationCount(prmOperation);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Operation count: " + ItemTotal);
|
||||
dbResultSet = InstitutionMgr.ExecuteOperationQuery(columnsQuery, prmOperation);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshOperation(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmOperation.Params prm = new SpmOperation.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = InstitutionMgr.ExecuteOperationQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmOperation.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = InstitutionMgr.GetOperationDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Patient : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmPatient.Params prmPatient;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Patient() : this(new Config()) { }
|
||||
public SpmItemListView_Patient(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedPatientId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmPatient SelectedPatient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return InstitutionMgr.GetPatientById(SelectedPatientId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitPatientList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitPatientList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.InstitutionId));
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.PatientNo));
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.NhsNumber));
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.Title));
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.Forename));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(InstitutionMgr.GetPatientColumnDfn(SpmPatient.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmPatient.Column.InstitutionId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmPatient.Params prmPatient)
|
||||
{
|
||||
if (prmPatient == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshPatients(SpmPatient.Params prmPatient)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmPatient = prmPatient;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmPatient)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)InstitutionMgr.GetPatientCount(prmPatient);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Patient count: " + ItemTotal);
|
||||
dbResultSet = InstitutionMgr.ExecutePatientQuery(columnsQuery, prmPatient);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshPatient(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmPatient.Params prm = new SpmPatient.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = InstitutionMgr.ExecutePatientQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmPatient.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = InstitutionMgr.GetPatientDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,302 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_Procedure : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmProcedure.Params prmProcedure;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_Procedure() : this(new Config()) { }
|
||||
public SpmItemListView_Procedure(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedProcedureId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmProcedure SelectedProcedure
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetProcedureById(SelectedProcedureId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitProcedureList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitProcedureList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.DepartmentId));
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.OperationId));
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.Description));
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.SpecialityCode));
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.ComplexityCode));
|
||||
|
||||
#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetProcedureColumnDfn(SpmProcedure.Column.Id));
|
||||
#endif
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
SortColumnIdx = GetColumnIdxById((int)SpmProcedure.Column.DepartmentId);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmProcedure.Params prmProcedure)
|
||||
{
|
||||
if (prmProcedure == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshProcedures(SpmProcedure.Params prmProcedure)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmProcedure = prmProcedure;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmProcedure)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetProcedureCount(prmProcedure);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData Procedure count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteProcedureQuery(columnsQuery, prmProcedure);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshProcedure(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmProcedure.Params prm = new SpmProcedure.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteProcedureQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmProcedure.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetProcedureDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
partial class SpmItemListView_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,298 @@
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Dbas.Base;
|
||||
using Sarand.PatientMgr.Core.Bus;
|
||||
using Sarand.Win.Forms.Controls;
|
||||
using Sarand.Win.Forms.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sarand.PatientMgr.Win.Forms.Controls
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class SpmItemListView_TemplateData : SpmItemListView
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Configuration.
|
||||
public enum ListMode
|
||||
{
|
||||
General,
|
||||
}
|
||||
|
||||
public new class Config : SpmItemListView.Config
|
||||
{
|
||||
public ListMode Mode { get; set; } = ListMode.General;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config = new Config();
|
||||
private readonly List<ColumnDfn> columnsDisplay = new List<ColumnDfn>();
|
||||
private readonly List<ColumnDfn> columnsQuery = new List<ColumnDfn>();
|
||||
private Timer timerQueryData = null;
|
||||
private Timer timerDisplayItem = null;
|
||||
private ColumnDfn columnDfnId = null;
|
||||
private DbResultSet dbResultSet = null;
|
||||
private SpmTemplateData.Params prmTemplateData;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SpmItemListView_TemplateData() : this(new Config()) { }
|
||||
public SpmItemListView_TemplateData(Config config) : base(config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
|
||||
/* ToDo Timers function need modifying.
|
||||
timerQueryData = new Timer() { Interval = 250 };
|
||||
timerQueryData.Tick += OnTimerQueryData;
|
||||
timerDisplayItem = new Timer() { Interval = 5 };
|
||||
timerDisplayItem.Tick += OnTimerDisplayItem;*/
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null) components.Dispose();
|
||||
timerQueryData.Dispose();
|
||||
timerDisplayItem.Dispose();
|
||||
ClearResultSet();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
private void ClearResultSet()
|
||||
{
|
||||
if (dbResultSet != null)
|
||||
dbResultSet.Dispose();
|
||||
dbResultSet = null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
[Browsable(false)]
|
||||
public List<ColumnDfn> DisplayColumns { get { return new List<ColumnDfn>(columnsDisplay); } }
|
||||
[Browsable(false)]
|
||||
public SysId SelectedTemplateDataId { get { return SelectedItemId; } }
|
||||
[Browsable(false)]
|
||||
public SpmTemplateData SelectedTemplateData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (SelectedItemCount == 1)
|
||||
return DepartmentMgr.GetTemplateDataById(SelectedTemplateDataId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Configure.
|
||||
public void SetConfig(Config config)
|
||||
{
|
||||
base.SetConfig(config);
|
||||
this.config = config;
|
||||
ConfigureList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Initialisation.
|
||||
protected override void OnCreateControl()
|
||||
{
|
||||
base.OnCreateControl();
|
||||
if (this.IsDesignerHosted()) return;
|
||||
}
|
||||
private void ConfigureList()
|
||||
{
|
||||
if (!this.Created) return;
|
||||
|
||||
InitTemplateDataList(true);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
private void InitTemplateDataList(bool forceInit = false)
|
||||
{
|
||||
// Clear the existing list.
|
||||
if (Columns.Count > 0 && !forceInit) return;
|
||||
Clear();
|
||||
columnsDisplay.Clear();
|
||||
columnsQuery.Clear();
|
||||
|
||||
// Populate list of columns to be displayed.
|
||||
//columnsDisplay.Add(DepartmentMgr.GetTemplateDataColumnDfn(SpmTemplateData.Column.Name));
|
||||
|
||||
/*#if DEBUG
|
||||
columnsDisplay.Add(DepartmentMgr.GetTemplateDataColumnDfn(SpmTemplateData.Column.Id));
|
||||
#endif*/
|
||||
// Populate columns to list view.
|
||||
SetColumns(columnsDisplay);
|
||||
|
||||
// Default sort column.
|
||||
//SortColumnIdx = GetColumnIdxById((int)SpmTemplateData.Column.Name);
|
||||
Refresh();
|
||||
|
||||
// Initialise list of columns to be queries - ensure Id column in list.
|
||||
columnsQuery.Clear();
|
||||
columnsQuery.AddRange(columnsDisplay);
|
||||
if (!columnsQuery.HasId(columnDfnId.Id))
|
||||
columnsQuery.Add(columnDfnId);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P o p u l a t i o n
|
||||
//-------------------------------------------------------------------
|
||||
public bool IsValidFiter(SpmTemplateData.Params prmTemplateData)
|
||||
{
|
||||
if (prmTemplateData == null) return false;
|
||||
return true;
|
||||
}
|
||||
public void RefreshTemplateDatas(SpmTemplateData.Params prmTemplateData)
|
||||
{
|
||||
// Clear timers.
|
||||
/*timerQueryData.Enabled = false;
|
||||
timerDisplayItem.Enabled = false;*/
|
||||
// Item Ids in the 'Initial selection' list are automatically selected on population.
|
||||
// Subsequent refreshes automatically select the current selection by repopulation of the 'Initial selection' list.
|
||||
if (!InitialPopulation)
|
||||
{
|
||||
InitiallySelectedItemIds.Clear();
|
||||
InitiallySelectedItemIds.AddRange(SelectedItemIds);
|
||||
}
|
||||
SelectedIndices.Clear();
|
||||
// Clear previous results.
|
||||
ItemTotal = 0;
|
||||
Items.Clear();
|
||||
// Prepare query.
|
||||
ClearResultSet();
|
||||
this.prmTemplateData = prmTemplateData;
|
||||
// Enable timer.
|
||||
}
|
||||
void OnTimerQueryData(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerQueryData.Enabled = false;
|
||||
QueryData();
|
||||
}
|
||||
private void QueryData()
|
||||
{
|
||||
ClearResultSet();
|
||||
if (!IsValidFiter(prmTemplateData)) return;
|
||||
// Query data.
|
||||
ItemTotal = (int)DepartmentMgr.GetTemplateDataCount(prmTemplateData);
|
||||
if (ItemTotal > 0) Logger.Trace(GetType().Name + ".QueryData TemplateData count: " + ItemTotal);
|
||||
dbResultSet = DepartmentMgr.ExecuteTemplateDataQuery(columnsQuery, prmTemplateData);
|
||||
//timerDisplayItem.Enabled = true;
|
||||
InitialPopulation = false;
|
||||
}
|
||||
public void RefreshTemplateData(SysId affiliateId)
|
||||
{
|
||||
// Parameters to query single item:
|
||||
if (!SysId.IsValid(affiliateId)) return;
|
||||
SpmTemplateData.Params prm = new SpmTemplateData.Params();
|
||||
prm.IncludedIds.Add(affiliateId);
|
||||
|
||||
// Query data.
|
||||
using (DbResultSet dbResultSet = DepartmentMgr.ExecuteTemplateDataQuery(columnsQuery, prm))
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
DisplayItem(dbResultSet.GetRecordValues(), true);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// D i s p l a y I t e m s
|
||||
//-------------------------------------------------------------------
|
||||
private void OnTimerDisplayItem(Object myObject, EventArgs myEventArgs)
|
||||
{
|
||||
//timerDisplayItem.Enabled = false;
|
||||
DisplayNextItems();
|
||||
}
|
||||
private void DisplayNextItems()
|
||||
{
|
||||
if (dbResultSet == null) return;
|
||||
for (int itemCount = 0; itemCount <= Math.Min(64, Math.Max(0, DisplayRecordsBatchSize)); itemCount++)
|
||||
{
|
||||
if (dbResultSet.NextRecord())
|
||||
{
|
||||
DisplayItem(dbResultSet.GetRecordValues());
|
||||
//timerDisplayItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearResultSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisplayItem(NamedValue.Map values, bool highlight = false)
|
||||
{
|
||||
// Item identity.
|
||||
SysId itemId = new SysId(StringUtil.ToInt(values.GetValue(columnDfnId.DataName).ToString()));
|
||||
String itemName = SysId.ToString(itemId);
|
||||
bool addNewItem = false;
|
||||
ListViewItem item = FindItemWithName(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
// New item to be added.
|
||||
item = new ListViewItem();
|
||||
item.Name = itemName;
|
||||
addNewItem = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Clear sub items for existing item.
|
||||
item.SubItems.Clear();
|
||||
item.Name = itemName;
|
||||
}
|
||||
|
||||
// Populate list view item.
|
||||
int columnIdx = -1;
|
||||
foreach (var column in columnsDisplay)
|
||||
{
|
||||
DataValue value = new DataValue();
|
||||
if (column.Id == (int)SpmTemplateData.Column.Pos)
|
||||
{
|
||||
value = new DataValue((Items.Count + 1).ToString() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = DepartmentMgr.GetTemplateDataDataValue(column, values);
|
||||
if (!value.IsValid())
|
||||
value = new DataValue(column.FormatValue(values));
|
||||
}
|
||||
if (++columnIdx == 0)
|
||||
item.Text = value.ToString();
|
||||
else
|
||||
item.SubItems.Add(new ListViewSubItemExtended(column, value));
|
||||
}
|
||||
// Add to list if required (otherwise item has already been updated in list.
|
||||
if (addNewItem)
|
||||
{
|
||||
ListViewItem itemAdded = Items.Add(item);
|
||||
}
|
||||
// Check for selection:
|
||||
if (!highlight && InitiallySelectedItemIds.Contains(itemId))
|
||||
highlight = true;
|
||||
if (highlight)
|
||||
{
|
||||
item.Selected = true;
|
||||
item.Focused = true;
|
||||
EnsureVisible(item.Index);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
//Logger.Debug(GetType().Name + ".OnResize Size: " + Size.ToString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user