Files

131 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sarand.Win.Forms.Controls;
using Sarand.PatientMgr.Win.Forms.App;
using Sarand.Core.Bus;
using Sarand.Core.Security;
using Sarand.Win.Forms.Utils;
using Sarand.Core.Base;
using Sarand.PatientMgr.Core.App;
namespace Sarand.PatientMgr.Win.Forms.Panels
{
//=======================================================================
public partial class SpmPanel_UpdateStamp : SacsUserControl
{
//-------------------------------------------------------------------
// Data members.
private SpmSessionProfile_Win sessionProfile = null;
private SacsHierarchyItem.Data itemData = null;
private SaSecurityConsole securityConsole;
//-------------------------------------------------------------------
// Construction.
public SpmPanel_UpdateStamp ()
{
if (SpmGlobals.System != null)
{
sessionProfile = SpmGlobals_Win.SessionProfile;
securityConsole = SpmGlobals.Application.GetSecurityConsole(sessionProfile.SessionContext);
}
InitializeComponent();
}
protected override void Dispose (bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
//-------------------------------------------------------------------
// I n i t i a l i s a t i o n
//-------------------------------------------------------------------
protected override void OnCreateControl ()
{
base.OnCreateControl();
if (this.IsDesignerHosted()) return;
BorderStyle = BorderStyle.None;
RefreshDisplay();
}
//-------------------------------------------------------------------
// Properties.
public SacsHierarchyItem.Data ItemData
{
set
{
if (itemData == value) return;
itemData = value;
RefreshDisplay();
}
}
//-------------------------------------------------------------------
// Refresh display.
private void RefreshDisplay ()
{
List<String> body = new List<String>();
if (itemData != null)
{
// Users.
string createUser = (securityConsole != null ? securityConsole.GetNameForItemId(itemData.CreateStamp.By) : "");
string updateUser = (securityConsole != null ? securityConsole.GetNameForItemId(itemData.UpdateStamp.By) : "");
// Display update stamp.
body.Add("<div><span class='label'>Created:</span> <span class='value'>" + DateUtil.Format(itemData.CreateStamp.On, "d-MMM-yyyy HH:mm") + (!StringUtil.IsEmpty(createUser) ? " by " + createUser : "") + "</div>");
body.Add("<div><span class='label'>Updated:</span> <span class='value'>" + DateUtil.Format(itemData.UpdateStamp.On, "d-MMM-yyyy HH:mm") + (!StringUtil.IsEmpty(updateUser) ? " by " + updateUser : "") + "</div>");
}
else
{
body.Add("<div><span class='label'>Created:</span> <span class='value'>" + DateUtil.Format(DateTime.Now, "d-MMM-yyyy HH:mm") + "</span></div>");
}
if (htmlPanel.DocumentPopulated && htmlPanel.Document != null && htmlPanel.Document.Body != null && false)
{
htmlPanel.SetDocumentBody(body.Concat("\n"));
}
else
{
List<String> html = new List<String>();
html.Add("<html><head>" + GetStyle() + "</html><body>");
html.AddRange(body);
html.Add("</body></html>");
htmlPanel.SetDocumentHtml(html.Concat("\n"));
htmlPanel.DocumentPopulated = true;
}
}
private String GetStyle ()
{
List<String> style = new List<String>();
style.Add("<style>");
style.Add("body{margin:0;padding:4px;font-family:arial;font-size:10px;background-color:#F0F0F0;border:1px solid #D0D0D0;overflow:hidden;}");
style.Add(".label{color:#606060;font-weight:bold;}");
style.Add("</style>");
return style.Concat("\n");
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
}
protected override void SetControlsReadOnly ()
{
}
//-------------------------------------------------------------------
}
//=======================================================================
}