126 lines
5.3 KiB
C#
126 lines
5.3 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Sarand.Core.App;
|
|
using Sarand.Core.Base;
|
|
using Sarand.Core.Bus;
|
|
using Sarand.Core.Dbas.Base;
|
|
using Sarand.PatientMgr.Core.App;
|
|
using Sarand.PatientMgr.Core.Bus;
|
|
|
|
namespace Sarand.PatientMgr.Core.Mgr
|
|
{
|
|
//=======================================================================
|
|
partial class SpmInstitutionMgr
|
|
{
|
|
//*******************************************************************
|
|
// E m p l o y e e
|
|
//*******************************************************************
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Retrieve individual employee.
|
|
//-------------------------------------------------------------------
|
|
// Exist employee.
|
|
public abstract bool EmployeeExistsById(SysId id);
|
|
//-------------------------------------------------------------------
|
|
// Get employee.
|
|
public abstract SpmEmployee GetEmployee(SpmEmployee.Params prm);
|
|
public abstract SpmEmployee GetEmployeeById(SysId id);
|
|
//-------------------------------------------------------------------
|
|
// Create employee.
|
|
public abstract SpmEmployee CreateEmployee(SysId id, SysId institutionId);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Validate employee data.
|
|
public bool IsValidEmployee(SpmEmployee employee)
|
|
{
|
|
ClearErrorState();
|
|
if (employee == null) return SetErrorState(ErrorMessage.ItemNotSpecified);
|
|
return IsValidEmployeeData(employee.GetData(), new SpmEmployee.ErrField());
|
|
}
|
|
public virtual bool IsValidEmployeeData(SpmEmployee.Data data, SpmEmployee.ErrField errField)
|
|
{
|
|
ClearErrorState();
|
|
// Employee properties.
|
|
if (errField.EmployeeNo != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.EmployeeNo, "EmployeeNo", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_EmployeeNo), true))
|
|
{
|
|
errField.EmployeeNo = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Code != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Code, "Code", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Code), true))
|
|
{
|
|
errField.Code = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Title != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Title, "Title", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Title), true))
|
|
{
|
|
errField.Title = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Initials != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Initials, "Initials", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Initials), true))
|
|
{
|
|
errField.Initials = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Forename != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Forename, "Forename", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Forename), true))
|
|
{
|
|
errField.Forename = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Surname != SacsHierarchyItem.ValidValue.Ignore && !IsValidValue(data.Surname, "Surname", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Surname), true))
|
|
{
|
|
errField.Surname = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
|
|
// Common properties.
|
|
if (!IsValidValue(data.Notes, "notes", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Notes)))
|
|
{
|
|
errField.Notes = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (errField.Status != SacsHierarchyItem.ValidValue.Ignore)
|
|
{
|
|
if (!IsValidValue(SacsSystem.GetStatusCode(data.Status), "status", (long)SpmDbDfn.GetColTextLen(SpmDbDfn.ColumnIdx.SwmEmployee_Status), true, true))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return false;
|
|
}
|
|
if (!SpmEmployee.EmployeeStatuses.Contains(data.Status))
|
|
{
|
|
errField.Status = SacsHierarchyItem.ValidValue.Invalid;
|
|
return SetErrorState(ErrorMessage.InvalidStatus);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Employee database interface.
|
|
public abstract bool InsertEmployee(SpmEmployee employee, DbUpdateInfo dbUpdateInfo);
|
|
public abstract bool UpdateEmployee(SpmEmployee employee, DbUpdateInfo dbUpdateInfo);
|
|
public virtual bool EmployeeCanBeDeleted(SpmEmployee employee)
|
|
{
|
|
ClearErrorState();
|
|
return true;
|
|
}
|
|
public abstract bool DeleteEmployee(SpmEmployee employee, DbUpdateInfo dbUpdateInfo);
|
|
|
|
//-------------------------------------------------------------------
|
|
// Employee list.
|
|
public abstract ColumnDfn GetEmployeeColumnDfn(SpmEmployee.Column columnId, String caption = "", int width = 0);
|
|
public abstract List<String> GetEmployeeQueryFilter(SpmEmployee.Params prm);
|
|
public abstract long GetEmployeeCount(SpmEmployee.Params prm);
|
|
public abstract List<SpmEmployee> GetEmployeeList(SpmEmployee.Params prm);
|
|
public abstract DbResultSet ExecuteEmployeeQuery(List<ColumnDfn> columns, SpmEmployee.Params prm);
|
|
public abstract DataValue GetEmployeeDataValue(ColumnDfn column, NamedValue.Map values);
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|