This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sorts array elements in ascending order numerically. | |
function CompareForSort(first, second) | |
{ | |
if (first == second) | |
return 0; | |
if (first < second) | |
return -1; | |
else | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Executes a function by simply providing a namespace | |
* @param {string} functionName A namespace such as '_n.Roles.Order.SetOrderNotes' | |
* @param {obj} context The Initial object context to start from, such as window | |
* @return Returns back the result of whatever the function returns | |
*/ | |
function executeFunctionByName(functionName, context /*, args */) { | |
var args = Array.prototype.slice.call(arguments).splice(2); | |
var namespaces = functionName.split("."); | |
var func = namespaces.pop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Grid(string FirstName, string LastName) | |
{ | |
GridHelper.Filters filter = new GridHelper.Filters("FirstName", "LastName"); | |
var _page =(!String.IsNullOrEmpty(HttpContext.Request.QueryString["page"])) ? Convert.ToInt32(HttpContext.Request.QueryString["page"]) : 1; | |
var _contacts = from c in testDB.Contacts | |
join ac in testDB.Account_Contact on c.ID equals ac.ContactID | |
where ac.AccountID == 725 | |
select c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExpressionBuilder | |
{ | |
// Define some of our default filtering options | |
private static MethodInfo containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); | |
private static MethodInfo startsWithMethod = typeof(string).GetMethod("StartsWith", new[] { typeof(string) }); | |
private static MethodInfo endsWithMethod = typeof(string).GetMethod("EndsWith", new[] { typeof(string) }); | |
public static Expression<Func<T, bool>> GetExpression<T>(List<GridHelper.Filter> filters) | |
{ | |
// No filters passed in #KickIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define our Methods | |
private static MethodInfo containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) }); | |
private static MethodInfo startsWithMethod = typeof(string).GetMethod("StartsWith", new[] { typeof(string) }); | |
private static MethodInfo endsWithMethod = typeof(string).GetMethod("EndsWith", new[] { typeof(string) }) | |
// How to use (Invoke) our Method | |
containsMethod.Invoke("FirstName", new object[]{"First"}); // returns true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void SetKey<T>(T obj, TempDataDictionary _tempData) | |
{ | |
System.Type type = typeof(T); | |
// Get our Foreign Key that we want to maintain | |
String foreignKey = _tempData["ForeignKey"].ToString(); | |
// If we do not have a Foreign Key, we do not need to set a property | |
if (String.IsNullOrEmpty(foreignKey)) | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #Regex Regular Expression to match HTML Element structure containing any | |
// text beginning/ending with whitespace in Sublime Text 2 | |
<div class="editor-label">(\s*)(.*?)(\s*)</div> | |
// Matches follwing HTML structure | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.GlobalCustomer) | |
</div> | |
<div class="editor-label">@Html.LabelFor(model => model.GlobalCustomer)</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CSVImportGetHeaders() | |
{ | |
// Get our CSV file from upload | |
var file = document.getElementById('CSVUpload').files[0] | |
// Instantiate a new FileReader | |
var reader = new FileReader(); | |
// Read our file to an ArrayBuffer | |
reader.readAsArrayBuffer(file); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Regex \[(.*?)\] | |
// Result [BinLocation] [nvarchar] | |
[BinLocation] [nvarchar](20) NOT NULL, | |
// RegEx \[([^\[]+)$ | |
// \[ matches [ | |
// [^\/[]+] Matches last occurence of [ | |
// $ matches end of line | |
// Result [nvarchar](20) NOT NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with cte | |
as( | |
select ID, AccountID, ItemTypeID, SourceChannelID, ntile(3) over(order by id) as tile_nr from [Item].[Item] where AccountID = 730 | |
) | |
update [item].[item] | |
set SourceChannelID = cte.tile_nr | |
from [item].[item] ii | |
inner join cte on ii.ID = cte.ID | |
where ii.AccountID = 730 |