Skip to content

Instantly share code, notes, and snippets.

@hasokeric
Created February 19, 2020 14:02
Show Gist options
  • Save hasokeric/f5ca5a5f9fd52a9b7f8d10c82966aea6 to your computer and use it in GitHub Desktop.
Save hasokeric/f5ca5a5f9fd52a9b7f8d10c82966aea6 to your computer and use it in GitHub Desktop.
Regex Match
if (!string.IsNullOrEmpty(id))
{
int counter = 0;
string sPartNum = id + "-";
bool recSelected;
//string whereClause = "[PartList].[PartNum] = (SELECT TOP 1 [PartNum] FROM [Erp].[Part] WHERE [Part].[Company] = [PartList].[Company] AND [Part].[PartNum] LIKE '" + sPartNum + "%' and 12345=12345 ORDER BY [PartNum] DESC)";
string whereClause = "PartNum LIKE '" + sPartNum + "%' BY CreatedOn DESC";
//nextSeq.ToString().PadLeft(5, '0');
// Current company only
DataSet ds = SearchFunctions.listLookup(this.oTrans, "PartAdapter", out recSelected, false, whereClause, false);
if (recSelected) {
//DataRow x = ds.Tables[0].Rows[0]["PartNum"];
int nextSeq = Convert.ToInt32(System.Text.RegularExpressions.Regex.Match(ds.Tables[0].Rows[0]["PartNum"].ToString(), @"\d+").ToString().PadLeft(5, '0')) + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment