270 lines
16 KiB
C#
270 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
using HRM.BO.Basic;
|
|
using Microsoft.Data.SqlClient;
|
|
using Org.BouncyCastle.Utilities.Collections;
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
namespace HRM.DA.DA.Basic
|
|
{
|
|
internal class HrNotificationDA
|
|
{
|
|
internal static IDataReader GetAll(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("select * from HrNotification");
|
|
}
|
|
internal static IDataReader GetAllNew(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader(@"SELECT hrNotificationId, EntryDate, NotificationText,
|
|
NotificationTextDetail, PublishDate, PublishEndDate, ShowAsNewDays,
|
|
NotificationType, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate,
|
|
TotalNewDays, NotificationUrl, IsSendToAll, Status, OriginalFileName, FileType
|
|
FROM HrNotification");
|
|
}
|
|
internal static IDataReader GetAllNew(TransactionContext tc, int payrolltypeID)
|
|
{
|
|
return tc.ExecuteReader(@"SELECT hrNotificationId, EntryDate, NotificationText,
|
|
NotificationTextDetail, PublishDate, PublishEndDate, ShowAsNewDays,
|
|
NotificationType, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate,
|
|
TotalNewDays, NotificationUrl, IsSendToAll, Status, OriginalFileName, FileType
|
|
FROM HrNotification where payrolltypeID = %n", payrolltypeID);
|
|
}
|
|
// Every HR notification one employee can see: same audience rule as the ESS
|
|
// "Company Updates" feed (WFMovementTranDA.NotificationItemsESS - payroll type,
|
|
// then send-to-all or targeted at this employee), but without its TOP 15 /
|
|
// last-30-days window.
|
|
internal static IDataReader GetForEmployee(TransactionContext tc, int payrolltypeID, int employeeID)
|
|
{
|
|
return tc.ExecuteReader(@"SELECT HN.hrNotificationId, HN.EntryDate, HN.NotificationText,
|
|
HN.NotificationTextDetail, HN.PublishDate, HN.PublishEndDate, HN.ShowAsNewDays,
|
|
HN.NotificationType, HN.CreatedBy, HN.CreatedDate, HN.ModifiedBy, HN.ModifiedDate,
|
|
HN.TotalNewDays, HN.NotificationUrl, HN.IsSendToAll, HN.Status, HN.OriginalFileName, HN.FileType
|
|
FROM HrNotification HN
|
|
WHERE HN.PayrolltypeID = %n
|
|
AND (HN.IsSendToAll = 1
|
|
OR EXISTS (SELECT 1 FROM HrNotificationEmployees HNE
|
|
WHERE HNE.HrNotificationID = HN.HrNotificationID
|
|
AND HNE.EmployeeID = %n))
|
|
ORDER BY HN.PublishDate DESC", payrolltypeID, employeeID);
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("select * from HrNotification where hrNotificationId = %n", id);
|
|
}
|
|
internal static IDataReader GetHrNotificationEmployees(TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("select * from HrNotificationEmployees where hrNotificationId = %n", id);
|
|
}
|
|
internal static IDataReader GetHrNotificationEmployeeWithDetails(TransactionContext tc, int id)
|
|
{
|
|
return tc.ExecuteReader("select HrNotificationEmployeeID, HrNotificationID, hr.EmployeeID, e.EmployeeNo, e.Name, d.DESCRIPTION as Department, ds.NAME as Designation, NotificationType from HrNotificationEmployees hr join EMPLOYEE e on hr.EmployeeID = e.EMPLOYEEID join DEPARTMENT d on e.DEPARTMENTID = d.DEPARTMENTID join DESIGNATION ds on e.DESIGNATIONID = ds.DESIGNATIONID where hrNotificationId = %n", id);
|
|
}
|
|
internal static void Insert(TransactionContext tc, HrNotification item)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"INSERT INTO dbo.HrNotification
|
|
(hrNotificationId,EntryDate,NotificationText,NotificationTextDetail,
|
|
PublishDate,PublishEndDate,ShowAsNewDays,NotificationType,CreatedBy,CreatedDate,TotalNewDays,NotificationUrl, IsSendToAll, Status)
|
|
VALUES (%n,%d,%s,%s,%d,%d,%n,%n,%n,%d,%n,%s, %b, %n)", item.ID, item.EntryDate, item.NotificationText, item.NotificationTextDetail, item.PublishDate, item.PublishEndDate, item.ShowAsNewDays, item.NotificationType, item.CreatedBy, item.CreatedDate, item.TotalNewDays, item.NotificationUrl, item.IsSendToAll, (int)item.Status);
|
|
tc.ExecuteDataTable(sql);
|
|
}
|
|
internal static void InsertWithAttachment(TransactionContext tc, HrNotification item)
|
|
{
|
|
string strQuery = @"INSERT INTO dbo.HrNotification
|
|
(hrNotificationId, EntryDate, NotificationText, NotificationTextDetail,
|
|
PublishDate, PublishEndDate, ShowAsNewDays, NotificationType,
|
|
CreatedBy, CreatedDate, TotalNewDays, NotificationUrl,
|
|
IsSendToAll, Status, PayrolltypeID, FileData, OriginalFileName, FileType)
|
|
VALUES (@hrNotificationId, @EntryDate, @NotificationText, @NotificationTextDetail,
|
|
@PublishDate, @PublishEndDate, @ShowAsNewDays, @NotificationType,
|
|
@CreatedBy, @CreatedDate, @TotalNewDays, @NotificationUrl,
|
|
@IsSendToAll, @Status, @PayrolltypeID, @FileData, @OriginalFileName, @FileType)";
|
|
|
|
SqlCommand cmd = new SqlCommand(strQuery, (SqlConnection)tc.Connection);
|
|
cmd.Transaction = (SqlTransaction)tc.Transaction;
|
|
|
|
cmd.Parameters.Add("@hrNotificationId", SqlDbType.Int).Value = item.ID;
|
|
cmd.Parameters.Add("@EntryDate", SqlDbType.DateTime).Value = item.EntryDate;
|
|
cmd.Parameters.Add("@NotificationText", SqlDbType.VarChar).Value = item.NotificationText;
|
|
cmd.Parameters.Add("@NotificationTextDetail", SqlDbType.VarChar).Value = item.NotificationTextDetail ?? (object)DBNull.Value;
|
|
cmd.Parameters.Add("@PublishDate", SqlDbType.DateTime).Value = item.PublishDate;
|
|
cmd.Parameters.Add("@PublishEndDate", SqlDbType.DateTime).Value = (object)item.PublishEndDate ?? DBNull.Value;
|
|
cmd.Parameters.Add("@ShowAsNewDays", SqlDbType.Bit).Value = item.ShowAsNewDays;
|
|
cmd.Parameters.Add("@NotificationType", SqlDbType.Int).Value = (int)item.NotificationType;
|
|
cmd.Parameters.Add("@CreatedBy", SqlDbType.Int).Value = item.CreatedBy;
|
|
cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = item.CreatedDate;
|
|
cmd.Parameters.Add("@TotalNewDays", SqlDbType.Int).Value = item.TotalNewDays;
|
|
cmd.Parameters.Add("@NotificationUrl", SqlDbType.VarChar).Value = item.NotificationUrl ?? (object)DBNull.Value;
|
|
cmd.Parameters.Add("@IsSendToAll", SqlDbType.Bit).Value = item.IsSendToAll;
|
|
cmd.Parameters.Add("@Status", SqlDbType.Int).Value = (int)item.Status;
|
|
cmd.Parameters.Add("@PayrolltypeID", SqlDbType.Int).Value = item.PayrollTypeID;
|
|
|
|
// File columns
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = (object)item.FileAsByteArray ?? DBNull.Value;
|
|
cmd.Parameters.Add("@OriginalFileName", SqlDbType.VarChar).Value = (object)item.OriginalFileName ?? DBNull.Value;
|
|
cmd.Parameters.Add("@FileType", SqlDbType.Int).Value = (object)item.FileType ?? DBNull.Value;
|
|
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
|
|
internal static void UpdateWithAttachment(TransactionContext tc, HrNotification item)
|
|
{
|
|
string strQuery = @"UPDATE dbo.HrNotification SET
|
|
EntryDate = @EntryDate,
|
|
NotificationText = @NotificationText,
|
|
NotificationTextDetail = @NotificationTextDetail,
|
|
PublishDate = @PublishDate,
|
|
PublishEndDate = @PublishEndDate,
|
|
ShowAsNewDays = @ShowAsNewDays,
|
|
NotificationType = @NotificationType,
|
|
ModifiedBy = @ModifiedBy,
|
|
ModifiedDate = @ModifiedDate,
|
|
TotalNewDays = @TotalNewDays,
|
|
NotificationUrl = @NotificationUrl,
|
|
IsSendToAll = @IsSendToAll,
|
|
Status = @Status,
|
|
FileData = ISNULL(@FileData, FileData),
|
|
OriginalFileName = ISNULL(@OriginalFileName, OriginalFileName),
|
|
FileType = ISNULL(@FileType, FileType)
|
|
WHERE hrNotificationId = @hrNotificationId";
|
|
|
|
SqlCommand cmd = new SqlCommand(strQuery, (SqlConnection)tc.Connection);
|
|
cmd.Transaction = (SqlTransaction)tc.Transaction;
|
|
|
|
cmd.Parameters.Add("@EntryDate", SqlDbType.DateTime).Value = item.EntryDate;
|
|
cmd.Parameters.Add("@NotificationText", SqlDbType.VarChar).Value = item.NotificationText;
|
|
cmd.Parameters.Add("@NotificationTextDetail", SqlDbType.VarChar).Value = item.NotificationTextDetail ?? (object)DBNull.Value;
|
|
cmd.Parameters.Add("@PublishDate", SqlDbType.DateTime).Value = item.PublishDate;
|
|
cmd.Parameters.Add("@PublishEndDate", SqlDbType.DateTime).Value = (object)item.PublishEndDate ?? DBNull.Value;
|
|
cmd.Parameters.Add("@ShowAsNewDays", SqlDbType.Bit).Value = item.ShowAsNewDays;
|
|
cmd.Parameters.Add("@NotificationType", SqlDbType.Int).Value = (int)item.NotificationType;
|
|
cmd.Parameters.Add("@ModifiedBy", SqlDbType.Int).Value = item.ModifiedBy;
|
|
cmd.Parameters.Add("@ModifiedDate", SqlDbType.DateTime).Value = item.ModifiedDate;
|
|
cmd.Parameters.Add("@TotalNewDays", SqlDbType.Int).Value = item.TotalNewDays;
|
|
cmd.Parameters.Add("@NotificationUrl", SqlDbType.VarChar).Value = item.NotificationUrl ?? (object)DBNull.Value;
|
|
cmd.Parameters.Add("@IsSendToAll", SqlDbType.Bit).Value = item.IsSendToAll;
|
|
cmd.Parameters.Add("@Status", SqlDbType.Int).Value = (int)item.Status;
|
|
cmd.Parameters.Add("@hrNotificationId", SqlDbType.Int).Value = item.ID;
|
|
|
|
// File columns
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = (object)item.FileAsByteArray ?? DBNull.Value;
|
|
cmd.Parameters.Add("@OriginalFileName", SqlDbType.VarChar).Value = (object)item.OriginalFileName ?? DBNull.Value;
|
|
cmd.Parameters.Add("@FileType", SqlDbType.Int).Value = (object)item.FileType ?? DBNull.Value;
|
|
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
|
|
internal static void Insert(TransactionContext tc, HrNotificationEmployee oEmp)
|
|
{
|
|
string sql = SQLParser.MakeSQL(@"INSERT INTO dbo.HrNotificationEmployees (HrNotificationEmployeeID, HrNotificationID, EmployeeID, NotificationType)
|
|
VALUES (%n, %n, %n, %n)", oEmp.ID, oEmp.HrNotificationId, oEmp.EmployeeId, (int)oEmp.NotificationType);
|
|
tc.ExecuteDataTable(sql);
|
|
}
|
|
internal static void Update(TransactionContext tc, HrNotification item)
|
|
{
|
|
tc.ExecuteNonQuery(@"UPDATE dbo.HrNotification
|
|
SET
|
|
EntryDate = %d,
|
|
NotificationText = %s,
|
|
NotificationTextDetail = %s,
|
|
PublishDate = %d,
|
|
PublishEndDate = %d,
|
|
ShowAsNewDays = %n,
|
|
NotificationType = %n,
|
|
CreatedBy = %n,
|
|
CreatedDate = %d,
|
|
ModifiedBy = %n,
|
|
ModifiedDate = %d,
|
|
TotalNewDays = %n,
|
|
NotificationUrl = %s,
|
|
IsSendToAll = %b,
|
|
Status = %n
|
|
WHERE hrNotificationId = %n", item.EntryDate,
|
|
item.NotificationText, item.NotificationTextDetail,
|
|
item.PublishDate, item.PublishEndDate, item.ShowAsNewDays,
|
|
item.NotificationType, item.CreatedBy, item.CreatedDate,
|
|
item.ModifiedBy, item.ModifiedDate, item.TotalNewDays,
|
|
item.NotificationUrl, item.IsSendToAll, item.Status, item.ID);
|
|
}
|
|
internal static void Delete(TransactionContext tc, int id)
|
|
{
|
|
tc.ExecuteNonQuery(@"Delete from HrNotification where hrNotificationId = %n", id);
|
|
tc.ExecuteNonQuery(@"Delete from HrNotificationEmployees where hrNotificationId = %n", id);
|
|
}
|
|
internal static void DeleteChild(TransactionContext tc, int id)
|
|
{
|
|
tc.ExecuteNonQuery(@"Delete from HrNotificationEmployees where hrNotificationId = %n", id);
|
|
}
|
|
public static void UploadHallOfFame(TransactionContext tc, HallOfFame item)
|
|
{
|
|
string strQuery = @"insert into HallOfFame(Code, Tittle, Description, FileName, FileData, EmployeeID, EmployeeNo, EmployeeName, DepartmentName, DesignationName)
|
|
values (@Code, @Tittle, @Description, @FileName, @FileData, @EmployeeID, @EmployeeNo, @EmployeeName, @DepartmentName, @DesignationName)";
|
|
|
|
SqlCommand cmd = new SqlCommand(strQuery, (SqlConnection)tc.Connection);
|
|
|
|
cmd.Parameters.Add("@Code", SqlDbType.VarChar).Value = item.Code;
|
|
cmd.Parameters.Add("@Tittle", SqlDbType.VarChar).Value = item.Tittle;
|
|
cmd.Parameters.Add("@Description", SqlDbType.VarChar).Value = item.Description;
|
|
cmd.Parameters.Add("@FileName", SqlDbType.VarChar).Value = item.FileName;
|
|
cmd.Parameters.Add("@FileData", SqlDbType.VarBinary).Value = item.FileData;
|
|
cmd.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = item.EmployeeID;
|
|
cmd.Parameters.Add("@EmployeeNo", SqlDbType.VarChar).Value = item.EmployeeNo;
|
|
cmd.Parameters.Add("@EmployeeName", SqlDbType.VarChar).Value = item.EmployeeName;
|
|
cmd.Parameters.Add("@DepartmentName", SqlDbType.VarChar).Value = item.DepartmentName;
|
|
cmd.Parameters.Add("@DesignationName", SqlDbType.VarChar).Value = item.DesignationName;
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
public static DataTable GetHallOfFame(TransactionContext tc)
|
|
{
|
|
string sql =SQLParser.MakeSQL("select * from HallOfFame");
|
|
return tc.ExecuteDataTable(sql);
|
|
}
|
|
public static void DeleteHallOfFame(TransactionContext tc, int Id)
|
|
{
|
|
string sql = SQLParser.MakeSQL("delete from HallOfFame where HallOfFameID = %n", Id);
|
|
tc.ExecuteScalar(sql);
|
|
}
|
|
public static void SaveLegalTracking(TransactionContext tc, int legalTrackingID, string name, string shortDescription, string detailDescription, string nextAction, string nextActionDescription, DateTime fromDate, DateTime toDate, DateTime nextNotificationDate, int currentUserId)
|
|
{
|
|
if (legalTrackingID == 0)
|
|
{
|
|
string sql = SQLParser.MakeSQL("INSERT INTO LegalTracking ( Name, " +
|
|
"ShortDescription, DetailDescription, FromDate, " +
|
|
"ToDate, NextNotificationDate, NextAction, NextActionDescription, CreatedBy, CreatedDate) " +
|
|
"VALUES (%s, %s, %s, %d, %d, %d, %s, %s, %n, %d) ", name, shortDescription, detailDescription, fromDate, toDate, nextNotificationDate, nextAction, nextActionDescription, currentUserId, DateTime.Now);
|
|
tc.ExecuteScalar(sql);
|
|
|
|
}
|
|
else
|
|
{
|
|
string sql = SQLParser.MakeSQL("UPDATE LegalTracking " +
|
|
"SET " +
|
|
"Name = %s, ShortDescription = %s, DetailDescription = %s, " +
|
|
"FromDate = %d, ToDate = %d, NextNotificationDate = %d, NextAction = %s, NextActionDescription = %s, " +
|
|
"ModifiedBy = %n, " +
|
|
"ModifiedDate =%d " +
|
|
"WHERE " +
|
|
"LegalTrackingID = %n", name, shortDescription, detailDescription, fromDate, toDate, nextNotificationDate, nextAction, nextActionDescription, currentUserId, DateTime.Now, legalTrackingID);
|
|
tc.ExecuteScalar(sql);
|
|
}
|
|
|
|
}
|
|
public static DataTable GetLegalTracking(TransactionContext tc)
|
|
{
|
|
string sql = SQLParser.MakeSQL("select * from LegalTracking");
|
|
return tc.ExecuteDataTable(sql);
|
|
}
|
|
public static void DeleteLegalTracking(TransactionContext tc, int Id)
|
|
{
|
|
string sql = SQLParser.MakeSQL("delete from LegalTracking where LegalTrackingID = %n", Id);
|
|
tc.ExecuteScalar(sql);
|
|
}
|
|
}
|
|
}
|