128 lines
5.1 KiB
C#
128 lines
5.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System.Data;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
class DataPermissionDA
|
|
{
|
|
#region Constructor
|
|
|
|
private DataPermissionDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
internal static void Insert(TransactionContext tc, DataPermission item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO DataPermission(UserID, PayrollTypeID, PermissionType, ReferenceID, CreatedBy, CreatedDate, PermissionStatus)" +
|
|
" VALUES(%n, %n, %n, %n, %n, %D, %n)", item.UserID, item.PayrollTypeID, item.PermissionType,
|
|
item.ReferenceID, item.CreatedBy, item.CreatedDate,item.PermissionStatus);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, DataPermission item)
|
|
{
|
|
//tc.ExecuteNonQuery(
|
|
// "UPDATE Religion SET code=%s, name=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n, nameinbangla=%u" +
|
|
// " WHERE ReligionID=%n", item.Code, item.Name, DataReader.GetNullValue(item.ModifiedBy),
|
|
// DataReader.GetNullValue(item.ModifiedDate), item.Sequence, item.Status, item.NameInBangla, item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|
{
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Religion Where Status=%n Order By SequenceNo", status);
|
|
}
|
|
else
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Religion Order By SequenceNo");
|
|
}
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int ID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Religion WHERE ReligionID=%n", ID);
|
|
}
|
|
|
|
#region
|
|
internal static IDataReader GetUsersByUserType(TransactionContext tc, EnumUserType type)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Users where UserType = %n", type);
|
|
}
|
|
internal static bool hasPermissoin(TransactionContext tc, int userid, int payrolltypeid)
|
|
{
|
|
var datam= tc.ExecuteScalar("SELECT count(*) FROM DataPermission where UserID = %n and PayrollTypeID=%n", userid, payrolltypeid);
|
|
if(datam == DBNull.Value)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
if( Convert.ToInt32( datam) ==0)
|
|
return false;
|
|
else return true;
|
|
}
|
|
}
|
|
#endregion
|
|
internal static void InsertDataPermission(TransactionContext tc, DataPermission item)
|
|
{
|
|
item.CreatedDate = DateTime.Now;
|
|
|
|
|
|
string sql = SQLParser.MakeSQL(@"INSERT INTO DataPermission(UserID, PayrollTypeID, PermissionType, ReferenceID, CreatedBy, CreatedDate, PermissionStatus)
|
|
VALUES(%n, %n, %n, %n, %n, %d, %n)", item.UserID, item.PayrollTypeID, item.PermissionType, item.ReferenceID, item.CreatedBy, item.CreatedDate, item.PermissionStatus );
|
|
|
|
tc.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
|
|
internal static IDataReader GetDataPermission(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM DataPermission");
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, int userid, int payrolltypeid)
|
|
{
|
|
return tc.ExecuteReader(@"select d.*, c.DESCRIPTION referenceName from DataPermission d, CATEGORY c where PermissionType =1
|
|
and d.ReferenceID = c.CATEGORYID and d.userid =%n and d.payrolltypeid =%n
|
|
union
|
|
select d.*, g.DESCRIPTION referenceName from DataPermission d, GRADES g where PermissionType = 2
|
|
and d.ReferenceID = g.GRADEID and d.userid =%n and d.payrolltypeid =%n
|
|
union
|
|
select d.*, dd.DESCRIPTION referenceName from DataPermission d, DEPARTMENT dd where PermissionType = 3
|
|
and d.ReferenceID = dd.DEPARTMENTID and d.userid =%n and d.payrolltypeid =%n
|
|
union
|
|
select d.*, l.DESCRIPTION referenceName from DataPermission d, LOCATION l where PermissionType = 4
|
|
and d.ReferenceID = l.LOCATIONID and d.userid =%n and d.payrolltypeid =%n", userid, payrolltypeid,
|
|
userid, payrolltypeid, userid, payrolltypeid, userid, payrolltypeid);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void Delete(TransactionContext tc, int id)
|
|
{
|
|
|
|
tc.ExecuteNonQuery("DELETE FROM DataPermission WHERE DataPermissionID=%n", id);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |