Skip to content

Instantly share code, notes, and snippets.

View kwestground's full-sized avatar

Kenny Westermark kwestground

View GitHub Profile
@kwestground
kwestground / StorelocatorGeocodeTask.cs
Last active November 4, 2015 15:29
StorelocatorGeocodeTask
using Geocoding.Google;
using Nop.Core.Data;
using Nop.Services.Configuration;
using Nop.Services.Logging;
using Nop.Services.Tasks;
using SevenSpikes.Nop.Plugins.StoreLocator.Domain.Shops;
using System;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
@kwestground
kwestground / ImportShopWidget.cshtml
Created November 4, 2015 15:38
Store Locator: Excel Import
<!-- Widget: admin_header_before -->
<script type="text/javascript">
$(function () {
var importButton = $('<a href="#" class="k-button">Import</a>').click(function (e) {
e.preventDefault();
var window = $("#importexcel-window");
if (!window.data("kendoWindow")) {
window.kendoWindow({
modal: true,
@kwestground
kwestground / SboItemExtensions.cs
Created November 5, 2015 15:17
SboItemExtensions
using SAPbouiCOM;
using System.Globalization;
using System.Text.RegularExpressions;
namespace SboHelpers
{
public static class SboItemExtensions
{
public static MoneyField GetMoney(this EditText editText)
{
CREATE FUNCTION SBODateTimeToSQLDateTime
(
@Date datetime, @Time smallint
)
RETURNS datetime
AS
BEGIN
DECLARE
@Hour smallint = CAST(SUBSTRING(CAST(@Time as varchar(4)), 1, 2) AS smallint),
@Minute smallint = CAST(SUBSTRING(CAST(@Time as varchar(4)), 3, 2) AS smallint)
@kwestground
kwestground / PrintCrystalReportFromEmbededResource.cs
Last active February 26, 2016 11:00
Print Crystal Report from Embeded Resource with Customer Query
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using ITCO.SboAddon.Framework;
namespace MyAddon
{
SELECT
CAST(SUBSTRING(RIGHT('0'+ CAST([Time] AS varchar), 6), 1, 2) + ':' +
SUBSTRING(RIGHT('0'+ CAST([Time] AS varchar), 6), 3, 2) + ':' +
SUBSTRING(RIGHT('0'+ CAST([Time] AS varchar), 6), 5, 2) AS time)
FROM [USR5]
ORDER BY [Time]
@kwestground
kwestground / SyncHelper.cs
Created August 4, 2016 12:23
Syncronize entities helper class for nopCommerce
using System.Collections.Generic;
using System.Linq;
using Nop.Core;
using Nop.Core.Data;
using Nop.Core.Domain.Common;
using Nop.Core.Infrastructure;
using Nop.Services.Common;
namespace Nop.Plugin.MyPlugin
{
@kwestground
kwestground / PermissionRecord.cs
Last active October 26, 2016 12:50
PermissionRecord validation attribute for NopCommerce
namespace Nop.Web.Framework.Controllers
{
using System;
using System.Web.Mvc;
using Core.Domain.Security;
using Core.Infrastructure;
using Services.Security;
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple=true)]
public class PermissionRecordValidation : FilterAttribute, IAuthorizationFilter
DECLARE @Now date = GETDATE()
SELECT
@Now AS [Today],
DATEADD(MONTH, DATEDIFF(MONTH,0,@Now)-0, 0) AS [Current_From],
DATEADD(DAY,-1,DATEADD(MONTH, DATEDIFF(MONTH,0,@Now)+1,0)) AS [Current_To],
DATEADD(MONTH, DATEDIFF(MONTH,0,@Now)-1, 0) AS [LastMonth_From],
DATEADD(DAY,-1,DATEADD(MONTH, DATEDIFF(MONTH,0,@Now)+0,0)) AS [LastMonth_To],
DATEADD(MONTH, DATEDIFF(MONTH,0,@Now)-2, 0) AS [LastMonth2_From],
@kwestground
kwestground / TypeConverter.cs
Last active December 22, 2016 12:47
TypeConverter
using System;
using System.ComponentModel;
using System.Globalization;
public static class TypeConverter
{
public static T To<T>(this object value)
{
return (T)To(value, typeof(T));
}