138 lines
5.0 KiB
C#
138 lines
5.0 KiB
C#
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;
|
|
using System.Windows.Forms;
|
|
using Sarand.Core.Dbas.Base;
|
|
|
|
namespace Sarand.PatientMgr.Win.Forms.Controls
|
|
{
|
|
//=======================================================================
|
|
public partial class SpmItemListView : SacsListView
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Configuration.
|
|
public class Config
|
|
{
|
|
/// <summary>Pass Internals via Config to share cached data.</summary>
|
|
public SpmInternals Internals { get; set; } = null;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private Config config = new Config();
|
|
private SpmInternals internals = null;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
private SpmItemListView() : this(new Config()) { }
|
|
public SpmItemListView(Config config)
|
|
{
|
|
this.config = config;
|
|
InitializeComponent();
|
|
}
|
|
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); } }
|
|
protected SpmInternals Internals
|
|
{
|
|
get
|
|
{
|
|
if (config.Internals != null) return config.Internals;
|
|
if (internals == null) internals = new SpmInternals(UserContext);
|
|
return internals;
|
|
}
|
|
}
|
|
// Security.
|
|
public SpmSecurityProfile SecurityProfile { get { return Internals.SecurityProfile; } }
|
|
// Managers.
|
|
public SpmInstitutionMgr InstitutionMgr { get { return Internals.InstitutionMgr; } }
|
|
public SpmDepartmentMgr DepartmentMgr { get { return Internals.DepartmentMgr; } }
|
|
public SpmAdmissionMgr AdmissionMgr { get { return Internals.AdmissionMgr; } }
|
|
// Consoles.
|
|
public SaSecurityConsole SecurityConsole { get { return Internals.SecurityConsole; } }
|
|
public SaCodeTypeConsole CodeTypeConsole { get { return Internals.CodeTypeConsole; } }
|
|
public SaUpdateLogConsole UpdateLogConsole { get { return Internals.UpdateLogConsole; } }
|
|
public 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;
|
|
|
|
// List View configuration.
|
|
View = View.Details;
|
|
FullRowSelect = true;
|
|
HideSelection = false;
|
|
MultiSelect = false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
protected override void OnHandleDestroyed (EventArgs e)
|
|
{
|
|
//CancelListRefresh();
|
|
Clear();
|
|
base.OnHandleDestroyed(e);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// R e f r e s h L i s t
|
|
//-------------------------------------------------------------------
|
|
/// <summary>Close and dispose the result set, if not null.</summary>
|
|
protected void ClearResultSet (ref DbResultSet dbResultSet)
|
|
{
|
|
if (dbResultSet == null) return;
|
|
// Copy the ResultSet reference so that the original can be nulled before closing/disposing.
|
|
DbResultSet dbResultSet_Local = dbResultSet;
|
|
dbResultSet = null;
|
|
dbResultSet_Local.Close();
|
|
dbResultSet_Local.Dispose();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|