private NOTIFICATIONDC FillObject(DataRow row) { NOTIFICATIONDC objNOTIFICATION = null; objNOTIFICATION = new NOTIFICATIONDC(); // objNOTIFICATION.NOTIFICATION_ID = (int)row["NOTIFICATION_ID"]; objNOTIFICATION.EVENT_ID = row["EVENT_ID"] == DBNull.Value ? 0 : (int)row["EVENT_ID"]; objNOTIFICATION.EVENT_TYPE = row["EVENT_TYPE"] == DBNull.Value ? 0 : (int)row["EVENT_TYPE"]; objNOTIFICATION.CREATED_DATE = (DateTime)row["CREATED_DATE"]; objNOTIFICATION.TYPE = (int)row["TYPE"]; objNOTIFICATION.TYPE_NAME = (String)row["TYPE_NAME"]; objNOTIFICATION.TIME_ZONE = row["TIME_ZONE"] == DBNull.Value ? "": (String)row["TIME_ZONE"]; objNOTIFICATION.NOTIFICATION = (String)row["NOTIFICATION"]; objNOTIFICATION.NO_OF_NOTIFICATIONS = (int)row["NO_OF_NOTIFICATIONS"]; objNOTIFICATION.DST_APPLIED_CREATED_DATE = Utility.IsDayTimeSavingEffective((row["CREATED_DATE"] == DBNull.Value ? System.DateTime.Now : (DateTime)row["CREATED_DATE"]), Convert.ToString(row["TIME_ZONE"])); objNOTIFICATION.CREATED_DATE_STRING = row["TIME_ZONE"] == DBNull.Value ? Convert.ToDateTime(row["CREATED_DATE"]).ToString("MM/dd/yyyy HH:mm"):""; return(objNOTIFICATION); }
private NOTIFICATIONDC FillObject(IDataReader reader) { NOTIFICATIONDC objNOTIFICATION = null; if (reader != null && reader.Read()) { objNOTIFICATION = new NOTIFICATIONDC(); objNOTIFICATION.NOTIFICATION_ID = (int)reader["NOTIFICATION_ID"]; objNOTIFICATION.EVENT_ID = (int)reader["EVENT_ID"]; objNOTIFICATION.CREATED_DATE = (DateTime)reader["CREATED_DATE"]; objNOTIFICATION.TYPE = (int)reader["TYPE"]; objNOTIFICATION.TYPE_NAME = (String)reader["TYPE_NAME"]; objNOTIFICATION.NOTIFICATION = (String)reader["NOTIFICATION"]; reader.Close(); reader.Dispose(); } return(objNOTIFICATION); }
private int Update(DBConnection Connection, NOTIFICATIONDC objNOTIFICATION) { int updateCount = 0; StringBuilder sql = new StringBuilder(); sql.Append("proc_NOTIFICATIONSUpdate"); SqlDatabase database = (SqlDatabase)Connection.dataBase; DbCommand cmd = database.GetStoredProcCommand(sql.ToString()); database.AddInParameter(cmd, "p_NOTIFICATION_ID", DbType.Int32, objNOTIFICATION.NOTIFICATION_ID); database.AddInParameter(cmd, "p_EVENT_ID", DbType.Int32, objNOTIFICATION.EVENT_ID); database.AddInParameter(cmd, "p_CREATED_DATE", DbType.DateTime, objNOTIFICATION.CREATED_DATE); database.AddInParameter(cmd, "p_TYPE", DbType.Int32, objNOTIFICATION.TYPE); database.AddInParameter(cmd, "p_NOTIFICATION", SqlDbType.NVarChar, objNOTIFICATION.NOTIFICATION); try { if (Connection.Transaction != null) { updateCount = Connection.dataBase.ExecuteNonQuery(cmd, Connection.Transaction); } else { updateCount = Connection.dataBase.ExecuteNonQuery(cmd); } if (updateCount == 0) { objNOTIFICATION.IsDirty = IsDirty = true; } } catch (Exception exp) { //Utilities.InsertIntoErrorLog("Error: NOTIFICATION UPDATE ", exp.Message + "\r\n" + exp.StackTrace, objNOTIFICATION.CREATED_BY); objNOTIFICATION.SetError(exp); throw exp; } return(updateCount); }
private int Delete(DBConnection Connection, NOTIFICATIONDC objNOTIFICATION) { int deleteCount = 0; StringBuilder sql = new StringBuilder(); sql.Append("proc_NOTIFICATIONSDelete"); DBCommandWarpper dbCommandWrapper = new DBCommandWarpper(Connection.dataBase.GetStoredProcCommand(sql.ToString()), Connection); dbCommandWrapper.AddInParameter("p_NOTIFICATION_ID", DbType.Int32, objNOTIFICATION.NOTIFICATION_ID); if (Connection.Transaction != null) { deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand, Connection.Transaction); } else { deleteCount = Connection.dataBase.ExecuteNonQuery(dbCommandWrapper.DBCommand); } return(deleteCount); }