using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { //internal class NotificationDA //{ // #region Get // internal static IDataReader Get(TransactionContext tc, int id) // { // return tc.ExecuteReader("SELECT * FROM Notification where NotificationID=%n",id); // } // internal static IDataReader Get(TransactionContext tc) // { // return tc.ExecuteReader("SELECT * FROM Notification"); // } // internal static IDataReader GetByDateRange(TransactionContext tc, DateTime startDate, DateTime endDate) // { // String sql = SQLParser.MakeSQL(@"SELECT * FROM Notification n // WHERE n.NotificationID IN // ( // SELECT dt.NotificationID FROM // (SELECT MAX(nr.SendDate) SendDate,nr.NotificationID FROM NotificationRule nr // GROUP BY nr.NotificationID) dt // WHERE dt.SendDate BETWEEN %d AND %d // UNION // SELECT dt.NotificationID FROM // (SELECT MIN(nr.SendDate) SendDate,nr.NotificationID FROM NotificationRule nr // GROUP BY nr.NotificationID) dt // WHERE dt.SendDate BETWEEN %d AND %d // )", startDate, endDate, startDate, endDate); // return tc.ExecuteReader(sql); // } // public static IDataReader Get(TransactionContext tc, EnumNotificationStatus status) // { // return tc.ExecuteReader("SELECT * FROM Notification WHERE Status=%n",(int)status); // } // internal static IDataReader GetParticipants(TransactionContext tc, int id) // { // return tc.ExecuteReader("SELECT * FROM NotificationParticipant where NotificationID=%n",id); // } // internal static IDataReader GetNotificationRules(TransactionContext tc, int id) // { // return tc.ExecuteReader("SELECT * FROM NotificationRule where NotificationID=%n ORDER BY BatchNo", id); // } // internal static DateTime GetMinDateByID(TransactionContext tc, int iD) // { // string sql = // SQLParser.MakeSQL("SELECT MIN(nr.SendDate) FROM NotificationRule nr WHERE nr.NotificationID = %n", iD); // DateTime sendDate = (DateTime)tc.ExecuteScalar(sql); // return sendDate; // } // #endregion // #region Delete // internal static void Delete(TransactionContext tc, int id) // { // tc.ExecuteNonQuery("DELETE FROM Notification WHERE NotificationID=%n", id); // } // internal static void DeleteParticipants(TransactionContext tc, int id) // { // tc.ExecuteNonQuery("DELETE FROM NotificationParticipant WHERE NotificationID=%n", id); // } // internal static void DeleteNotificationRules(TransactionContext tc, int id) // { // tc.ExecuteNonQuery("DELETE FROM NotificationRule WHERE NotificationID=%n", id); // } // #endregion // #region Insert // internal static void Insert(TransactionContext tc, Notification item) // { // string sql = SQLParser.MakeSQL("INSERT INTO Notification(NotificationID, TagOutputID,ObjectID,OptionalObjectID, Subject, Body, Attachment, Footer,Type,IsMailNf,IsSMSNf,IsWebNf,Status)" + // " VALUES(%n,%n,%n,%n,%s, %s, %s, %s,%n,%b,%b,%b,%n)", item.ID, DataReader.GetNullValue(item.TagOutputID), DataReader.GetNullValue(item.ObjectID), DataReader.GetNullValue(item.OptionalObjectID), item.Subject, item.Body, item.Attachment, item.Footer, (int)item.Type, item.IsMailNf, item.IsSMSNf, item.IsWebNf, (int)item.Status); // tc.ExecuteNonQuery(sql); // } // internal static void InsertNotificationRule(TransactionContext tc, NotificationRule item) // { // string sql = // SQLParser.MakeSQL( // "INSERT INTO NotificationRule(NotificationRuleID,BatchNo,NotificationID,PerticipantID,PerticipantType,SendDate, ExtendedBody, Remarks, AllowWrite,SMSSendStatus,WebSendStatus,EmailSendStatus)" + // " VALUES(%n,%n,%n,%n,%n,%d, %s, %s, %b,%n,%n,%n)", item.ID, item.BatchNo, item.NotificationID, // item.PerticipantID, (int)item.PerticipantType, item.SendDate, item.ExtendedBody, item.Remarks, item.AllowWrite, (int)item.SMSSendStatus, (int)item.WebSendStatus, (int)item.EmailSendStatus); // tc.ExecuteNonQuery(sql); // } // #endregion // #region Update // internal static void Update(TransactionContext tc, Notification item) // { // string sql = // SQLParser.MakeSQL( // "UPDATE Notification SET TagOutputID=%n,ObjectID=%n,OptionalObjectID=%n, Subject=%s, Body=%s, Attachment=%s, Footer=%s,Type=%n,IsMailNf=%b,IsSMSNf=%b,IsWebNf=%b,Status=%n" + // " WHERE NotificationID=%n", DataReader.GetNullValue(item.TagOutputID), DataReader.GetNullValue(item.ObjectID), DataReader.GetNullValue(item.OptionalObjectID), item.Subject, // item.Body, item.Attachment, item.Footer, (int)item.Type, item.IsMailNf, item.IsSMSNf, item.IsWebNf, // (int)item.Status, item.ID); // tc.ExecuteNonQuery(sql); // } // public static void UpdateNotficationRule(TransactionContext tc, NotificationRule item) // { // string sql = // SQLParser.MakeSQL( // "UPDATE NotificationRule SET BatchNo=%n,NotificationID=%n,PerticipantID=%n,PerticipantType=%n,SendDate=%d, ExtendedBody=%s, Remarks=%s, AllowWrite=%b,SMSSendStatus=%n,WebSendStatus=%n,EmailSendStatus=%n " + // "Where NotificationRuleID=%n", item.BatchNo, item.NotificationID, // item.PerticipantID, (int)item.PerticipantType, item.SendDate, item.ExtendedBody, item.Remarks, item.AllowWrite, (int)item.SMSSendStatus, (int)item.WebSendStatus, (int)item.EmailSendStatus, item.ID); // tc.ExecuteNonQuery(sql); // } // #endregion // internal static void InsertReply(TransactionContext tc, NotificationParticipant oParticipant) // { // string sql = SQLParser.MakeSQL("INSERT INTO NotificationParticipant(NotificationParticipantID,NotificationID,EmployeeID,Comments, SentTime, Authorized,Locked, ProcessButton,UndoButton,ApproveButton)" + // " VALUES(%n,%n,%n,%s,%D,%b,%b,%b,%b,%b)",oParticipant.ID,oParticipant.NotificationID,oParticipant.EmployeeID,oParticipant.Comments,oParticipant.SentTime,true, true,false,false,false); // tc.ExecuteNonQuery(sql); // } //} }