using System; using System.Collections.Generic; using System.Text.RegularExpressions; namespace SSWMS.Common { public class StringUtils { public static string GetCurrentTime() { return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } public static string GetExpireDay(int iDays) { return DateTime.Now.AddDays(0 - iDays).ToString("yyyy-MM-dd HH:mm:ss"); } public static string GetCurrentDay() { return DateTime.Now.ToString("yyyy-MM-dd"); } public static string GetNextDay() { return DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); } public static bool StockBarcodeValidate(string sStockBarcode) { //return Regex.IsMatch(sStockBarcode, @"^[T|H][0-9]{5}$"); return Regex.IsMatch(sStockBarcode, @"^[0-9|A-Z|a-z]{20}$"); } public static bool StockBarcodeValidateStock(string sStockBarcode) { return Regex.IsMatch(sStockBarcode, @"^T[0-9]{5}$"); } public static bool StockBarcodeValidateCage(string sStockBarcode) { //return Regex.IsMatch(sStockBarcode, @"^H[0-9]{5}$"); return false; } public static string GetParenthesesValue(string str) { return Regex.Match(str, @"\((.+)\)").Groups[1].Value; } private static Dictionary DicCHSString = new Dictionary() { }; private static Dictionary DicENString = new Dictionary() { }; public static string GetLangString(string sKey, string sLang = "Default") { return (sLang == "en-US" ? DicENString : DicCHSString)[sKey]; } } }