using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
using System.IO;
|
using System.Windows.Forms;
|
using System.Drawing;
|
using System.Xml;
|
using System.Xml.XPath;
|
using HotelPms.Share.Util;
|
using HotelPms.Share.Windows.Component;
|
using HotelPms.Share.Windows.GraphicsApi;
|
|
namespace HotelPms.Share.Windows.Util
|
{
|
[Flags()]
|
public enum numInputType
|
{
|
None = 0x1, //ÁÉȵ
|
Num = 0x2, //
|
Alpha_S = 0x4, //At@xbg¬
|
Alpha_C = 0x8, //At@xbgå
|
Kana = 0x10, //Ji
|
Half = 0x20, //¼p
|
Full = 0x40, //Sp
|
Num_FieldClear = 0x80, //üÍÅå
´¦½çNA
|
Plus_FieldClear = 0x100,//"+"L[ÅNA
|
Space = 0x200, //ó
|
Colon = 0x400, //":"ðÂ\
|
Subtract = 0x800, //"-"
|
DotSendKeys = 0x1000, //"."¨"000"Æ·é
|
Dot = 0x2000, //"."
|
Slash = 0x4000, //"/"
|
Comma = 0x8000, //"," J}
|
|
Alpha = Alpha_S | Alpha_C,//At@xbg¬+At@xbgå
|
NumAlpha = Num | Alpha | Space,//{At@xbg{ó
|
ANK = NumAlpha | Kana, //{At@xbg{ó{Ji
|
TIME = Num | Colon, //Ôp "12:30"
|
}
|
|
[Flags()]
|
public enum numShowStyle
|
{
|
None = 0x1, //ÁÉȵ
|
ZeroPad = 0x2, //
¢¾Á½ç"0"ðªÉÇÁ
|
ThousandSeparator = 0x4,//àzÌ3
²ÆÌ"," á1,000,000
|
ShowList = 0x8, //ENDL[ÅêIðæÊª è
|
}
|
|
public class InputCtrl
|
{
|
public static string Chr_SqlKinshi = "'";
|
public static string Chr_Num = "0123456789";
|
public static string Chr_Alpha_S = "abcdefghijklmnopqrstuvwxyz ";
|
public static string Chr_Alpha_C = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
|
public static string Chr_Kana = "¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß ";
|
public static string Chr_Alpha = Chr_Alpha_S + Chr_Alpha_C;
|
public static string Chr_NumAlpha = Chr_Num + Chr_Alpha;
|
public static string Chr_ANK = Chr_NumAlpha + Chr_Kana;
|
|
///¡ IsNotInOwnStr
|
///@yT@vzFY¶ñÍe¶ñÌÉÜÜêÄÈ¢©
|
///@yø@zFhsValue@@@@õ¶ñ
|
///@@@@@@@hsOwnString@@e¶ñ@@
|
///@yßèlzFBoolean
|
public static bool IsNotInOwnStr(string hsValue, string hsOwnString)
|
{
|
try
|
{
|
for (int i = 0; i <= hsValue.Length - 1; i++)
|
{
|
if (hsOwnString.IndexOf(hsValue[i]) != -1)
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
|
///¡ IsInOwnStr
|
///@yT@vzFY¶ñÍe¶ñÌÉÜÜêÄÜ·©
|
///@yø@zFhsValue@@@@õ¶ñ
|
///@@@@@@@hsOwnString@@e¶ñ@@@
|
///@yßèlzFBoolean
|
public static bool IsInOwnStr(string hsValue, string hsOwnString)
|
{
|
try
|
{
|
for (int i = 0; i <= hsValue.Length - 1; i++)
|
{
|
if (hsOwnString.IndexOf(hsValue[i]) == -1)
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
public static bool IsCorrectValue(CTextBox textBox)
|
{
|
return IsCorrectValue(textBox, true);
|
}
|
|
///¡ IsCorrectValue
|
///@yT@vzF`FbN
|
///@yø@zF
|
///@yßèlzFobject
|
public static bool IsCorrectValue(CTextBox textBox, bool showErrMsg)
|
{
|
string wsChkStr = "";
|
numInputType wlErrFlg = 0;
|
int wiLen;
|
try
|
{
|
string text = (GetShowStyle(textBox) & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator ? textBox.Text.Replace(",", string.Empty) : textBox.Text;
|
|
System.Text.Encoding enc = System.Text.Encoding.Default;
|
wiLen = enc.GetBytes(text).Length;
|
|
numInputType inputType = GetInputType(textBox);
|
|
//¼p`FbN
|
if ((inputType & numInputType.Half) == numInputType.Half && wiLen != text.Length)
|
{
|
if (showErrMsg) { MessageBox.Show(null, "¼pü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK); }
|
return false;
|
}
|
|
//Sp`FbN
|
if ((inputType & numInputType.Full) == numInputType.Full && wiLen != 2 * text.Length)
|
{
|
if (showErrMsg) { MessageBox.Show(null, "Spü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK); }
|
return false;
|
}
|
|
//
|
if ((inputType & numInputType.Num) == numInputType.Num)
|
{
|
wsChkStr = wsChkStr + Chr_Num;
|
wlErrFlg = wlErrFlg | numInputType.Num;
|
}
|
|
//.
|
if ((inputType & numInputType.Dot) == numInputType.Dot)
|
{
|
wsChkStr = wsChkStr + ".";
|
wlErrFlg = wlErrFlg | numInputType.Dot;
|
}
|
|
//[/]
|
if ((inputType & numInputType.Slash) == numInputType.Slash)
|
{
|
wsChkStr = wsChkStr + "/";
|
wlErrFlg = wlErrFlg | numInputType.Slash;
|
}
|
|
//Space
|
if ((inputType & numInputType.Space) == numInputType.Space)
|
{
|
wsChkStr = wsChkStr + " ";
|
wlErrFlg = wlErrFlg | numInputType.Space;
|
}
|
|
//-
|
if ((inputType & numInputType.Subtract) == numInputType.Subtract)
|
{
|
wsChkStr = wsChkStr + "-";
|
wlErrFlg = wlErrFlg | numInputType.Subtract;
|
}
|
|
//:
|
if ((inputType & numInputType.Colon) == numInputType.Colon)
|
{
|
wsChkStr = wsChkStr + ":";
|
wlErrFlg = wlErrFlg | numInputType.Colon;
|
}
|
|
//,
|
if ((inputType & numInputType.Comma) == numInputType.Comma)
|
{
|
wsChkStr = wsChkStr + ",";
|
wlErrFlg = wlErrFlg | numInputType.Colon;
|
}
|
|
//¬p
|
if ((inputType & numInputType.Alpha_C) == numInputType.Alpha_C)
|
{
|
wsChkStr = wsChkStr + Chr_Alpha_C;
|
wlErrFlg = wlErrFlg | numInputType.Alpha_C;
|
}
|
|
//åp
|
if ((inputType & numInputType.Alpha_S) == numInputType.Alpha_S)
|
{
|
wsChkStr = wsChkStr + Chr_Alpha_S;
|
wlErrFlg = wlErrFlg | numInputType.Alpha_S;
|
}
|
|
//Ji
|
if ((inputType & numInputType.Kana) == numInputType.Kana)
|
{
|
wsChkStr = wsChkStr + Chr_Kana;
|
wlErrFlg = wlErrFlg | numInputType.Kana;
|
}
|
if (wsChkStr != "")
|
{
|
if (IsInOwnStr(text, wsChkStr) == false)
|
{
|
if (!showErrMsg) { return false; }
|
if (wlErrFlg == numInputType.Num)
|
{
|
MessageBox.Show(null, "ðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK);
|
}
|
else if (wlErrFlg == numInputType.Kana)
|
{
|
MessageBox.Show(null, "¼pJiðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK);
|
}
|
else if (wlErrFlg == numInputType.Alpha_S)
|
{
|
MessageBox.Show(null, "¬p¶ðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK);
|
}
|
else if (wlErrFlg == numInputType.Alpha_C)
|
{
|
MessageBox.Show(null, "åp¶ðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK);
|
}
|
else
|
{
|
MessageBox.Show(null, "³µ¢lðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK);
|
}
|
return false;
|
}
|
}
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
|
///¡ IsOutOfRange
|
///@yT@vzF`FbN
|
///@yø@zF
|
///@yßèlzFbool
|
public static bool IsOutOfRange(string hsValue, string hsRange)
|
{
|
try
|
{
|
string[] wsRange;
|
if (hsRange[0] == "'"[0])
|
{
|
|
if (hsRange.IndexOf("'" + hsValue + "'") == -1)
|
{
|
return true;
|
}
|
}
|
else
|
{
|
wsRange = hsRange.Split(new char[] { ',' });
|
wsRange[0] = wsRange[0].Substring(1);
|
wsRange[1] = wsRange[1].Substring(0, wsRange[1].Length - 1);
|
if (hsRange[0] == '[')
|
{
|
if (Convert.ToDouble(hsValue) < Convert.ToDouble(wsRange[0]))
|
{
|
return true;
|
}
|
}
|
else if (hsRange[0] == '(')
|
{
|
if (Convert.ToDouble(hsValue) <= Convert.ToDouble(wsRange[0]))
|
{
|
return true;
|
}
|
}
|
if (hsRange[hsRange.Length - 1] == ']')
|
{
|
if (Convert.ToDouble(hsValue) > Convert.ToDouble(wsRange[1]))
|
{
|
return true;
|
}
|
}
|
else if (hsRange[hsRange.Length - 1] == ')')
|
{
|
if (Convert.ToDouble(hsValue) >= Convert.ToDouble(wsRange[1]))
|
{
|
return true;
|
}
|
}
|
}
|
|
return false;
|
}
|
catch
|
{
|
return true;
|
}
|
}
|
|
public static bool IsCorrectText(CTextBox textbox)
|
{
|
return IsCorrectText(textbox, true, false);
|
}
|
|
public static bool IsCorrectText(CTextBox textbox, bool showErrMsg)
|
{
|
return IsCorrectText(textbox, showErrMsg, false);
|
}
|
|
public static bool IsCorrectText(CTextBox textbox, bool showErrMsg, bool ignoteNull)
|
{
|
if (!textbox.Visible) { return true; }
|
|
if (IsCorrectInput(textbox, showErrMsg, ignoteNull))
|
{
|
if (textbox.Text.Length > 0)
|
{
|
if ((GetShowStyle(textbox) & numShowStyle.ZeroPad) == numShowStyle.ZeroPad)
|
{
|
textbox.Text = textbox.Text.PadLeft(textbox.MaxLength, '0');
|
}
|
}
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public static bool IsCorrectInput(CTextBox textbox)
|
{
|
return IsCorrectInput(textbox, true, false);
|
}
|
|
///¡ IsCorrectInput
|
///@yT@vzF`FbN
|
///@yø@zF
|
///@yßèlzFbool
|
public static bool IsCorrectInput(CTextBox textbox, bool showErrMsg , bool ignoteNull)
|
{
|
try
|
{
|
if (textbox.IsChkData == false)
|
{
|
return true;
|
}
|
|
if ("".Equals(textbox.Text.Trim()))
|
{
|
if (ignoteNull){return true;}
|
|
if (textbox.NotNull)
|
{
|
if (showErrMsg) { MessageBox.Show("àeðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
|
return false;
|
}
|
else
|
{
|
return true;
|
}
|
}
|
if (!IsCorrectValue(textbox, showErrMsg))
|
{
|
return false;
|
}
|
//System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");
|
//if (enc.GetBytes(hsValue).Length > hoCtrTag.MaxKeta)
|
//{
|
// if (showErrMsg) { MessageBox.Show(null, hoCtrTag.MaxKeta.ToString() + "
ÈàÅü͵ľ³¢B", MessageBoxButtons.OK); }
|
// return false;
|
//}
|
if (textbox.IsDate)
|
{
|
if (CConvert.IsDate(CConvert.ToInt(textbox.Text).ToString().PadLeft(8,'0')))
|
{
|
if (showErrMsg) { MessageBox.Show("útðü͵ľ³¢B", "üÍ`FbN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
|
return false;
|
}
|
}
|
if (textbox.In_Range != "")
|
{
|
if (IsOutOfRange(textbox.Text, textbox.In_Range))
|
{
|
if (showErrMsg) { MessageBox.Show("üÍÍÍÈOÅ·B", "üÍ`FbN", MessageBoxButtons.OK, MessageBoxIcon.Information); }
|
return false;
|
}
|
}
|
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
///¡ SetNextFocus
|
///@yT@vzFJ\Ú®
|
///@yø@zF
|
///@yßèlzFbool
|
public static bool SetNextFocus(System.Windows.Forms.KeyEventArgs e)
|
{
|
try
|
{
|
System.Windows.Forms.Keys KeyCode = e.KeyCode;
|
if (KeyCode == Keys.Return)
|
{
|
SendKeys.Send("{TAB}");
|
}
|
else if (KeyCode == Keys.Escape)
|
{
|
SendKeys.Send("+{TAB}");
|
}
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
public static numShowStyle GetShowStyle(CTextBox curField)
|
{
|
string[] wsItems = null;
|
if (curField.ShowStyle.Length == 0)
|
{
|
return numShowStyle.None;
|
}
|
else
|
{
|
wsItems = curField.ShowStyle.Split(new char[] { ',' });
|
numShowStyle ret = (numShowStyle)CConvert.ToInt(wsItems[0]);
|
for (int i = 1; i <= wsItems.Length - 1; i++)
|
{
|
ret = ret | (numShowStyle)CConvert.ToInt(wsItems[i]);
|
}
|
return ret;
|
}
|
}
|
|
public static numInputType GetInputType(CTextBox curField)
|
{
|
string[] wsItems = null;
|
if (curField.InputType.Length == 0)
|
{
|
return numInputType.None;
|
}
|
else
|
{
|
wsItems = curField.InputType.Split(new char[] { ',' });
|
numInputType ret = (numInputType)CConvert.ToInt(wsItems[0]);
|
for (int i = 1; i <= wsItems.Length - 1; i++)
|
{
|
ret = ret | (numInputType)CConvert.ToInt(wsItems[i]);
|
}
|
return ret;
|
}
|
}
|
|
public static void TextEnter(CTextBox hoTextBox)
|
{
|
numShowStyle style = GetShowStyle(hoTextBox);
|
if ((style & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator)
|
{
|
hoTextBox.Text = hoTextBox.Text.Replace(",", string.Empty);
|
}
|
|
if (!hoTextBox.PanelExEnabled)
|
{
|
if ((style & numShowStyle.ShowList) == numShowStyle.ShowList)
|
{
|
hoTextBox.BackColor = Color.Pink;
|
}
|
else
|
{
|
hoTextBox.BackColor = Color.LightSteelBlue;
|
}
|
}
|
}
|
|
public static void TextLeave(CTextBox hoTextBox)
|
{
|
numShowStyle style = GetShowStyle(hoTextBox);
|
if ((style & numShowStyle.ThousandSeparator) == numShowStyle.ThousandSeparator)
|
{
|
hoTextBox.Text = string.Format("{0:#,0}", CConvert.ToDecimal(hoTextBox.Text));
|
}
|
if (!hoTextBox.PanelExEnabled) { hoTextBox.BackColor = hoTextBox.ReadOnly ? ColorType.Control : Color.White; }
|
}
|
|
public static bool TextKeyPress(TextBox hoTextBox, ref char hKeyAscii, int hlMaxKeta, numInputType hlInputType)
|
{
|
try
|
{
|
if (hlInputType == numInputType.None)
|
{
|
return true;
|
}
|
|
if (hKeyAscii == 8)
|
{
|
return true;
|
}
|
else if (hKeyAscii == "'"[0])
|
{
|
hKeyAscii = (char)0;
|
return false;
|
}
|
else if (hKeyAscii == 13)
|
{
|
//hKeyAscii = (char)0;
|
return false;
|
}
|
else if (hKeyAscii == '+')
|
{
|
//if ((hlInputType & numInputType.Plus_FieldClear) == numInputType.Plus_FieldClear)
|
//{
|
// hoTextBox.Text = "";
|
// hKeyAscii = (char)0;
|
// return false;
|
//}
|
}
|
|
if ((hlInputType & numInputType.Num_FieldClear) == numInputType.Num_FieldClear)
|
{
|
if (hoTextBox.Text.Length >= hlMaxKeta)
|
{
|
hoTextBox.Text = "";
|
//ºÌ`FbNÉs
|
}
|
}
|
|
if ((hlInputType & numInputType.Num) == numInputType.Num)
|
{
|
if ('0' <= hKeyAscii && hKeyAscii <= '9')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Dot) == numInputType.Dot)
|
{
|
if (hKeyAscii == '.')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Slash) == numInputType.Slash)
|
{
|
if (hKeyAscii == '/')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Colon) == numInputType.Colon)
|
{
|
if (hKeyAscii == ':')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Subtract) == numInputType.Subtract)
|
{
|
if (hKeyAscii == '-')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Comma) == numInputType.Comma)
|
{
|
if (hKeyAscii == ',')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.DotSendKeys) == numInputType.DotSendKeys)
|
{
|
if (hKeyAscii == '.')
|
{
|
SendKeys.Send("000");
|
hKeyAscii = (char)0;
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Space) == numInputType.Space)
|
{
|
if (hKeyAscii == ' ')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Alpha_C) == numInputType.Alpha_C)
|
{
|
if ('A' <= hKeyAscii && hKeyAscii <= 'Z')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Alpha_S) == numInputType.Alpha_S)
|
{
|
if ('a' <= hKeyAscii && hKeyAscii <= 'z')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Kana) == numInputType.Kana)
|
{
|
if ('¦' <= hKeyAscii && hKeyAscii <= 'ß')
|
{
|
return true;
|
}
|
}
|
|
if ((hlInputType & numInputType.Half) == numInputType.Half)
|
{
|
if (hKeyAscii >= 0 && hKeyAscii <= 255)
|
{
|
return true;
|
}
|
}
|
if ((hlInputType & numInputType.Full) == numInputType.Full)
|
{
|
if (hKeyAscii < 0 || hKeyAscii > 255)
|
{
|
return true;
|
}
|
}
|
|
hKeyAscii = (char)0;
|
return false;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
|
public static void TextBoxEnter(object sender)
|
{
|
TextBox txtField = (TextBox)sender;
|
txtField.BackColor = Color.Pink;
|
}
|
|
public static void TextBoxLeave(object sender)
|
{
|
TextBox txtField = (TextBox)sender;
|
txtField.BackColor = Color.White;
|
}
|
|
public static void TextBoxKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e,int maxKeta,numInputType inputType)
|
{
|
TextBox txtField = (TextBox)sender;
|
char KeyAscii = e.KeyChar;
|
TextKeyPress(txtField, ref KeyAscii, maxKeta, inputType);
|
if (KeyAscii == (char)0)
|
{
|
e.Handled = true;
|
}
|
}
|
|
///¡ GetFormXml
|
///@yT@vzF¼½ÃÑWÌwlkðÇÞ
|
///@yø@zF(IN) hsConfigXml String ̧²ÙÊß½
|
///@yßèlzFȵ
|
public static Dictionary<string, InputItem> GetFormXml(object hvConfigXml)
|
{
|
Dictionary<string, InputItem> woParentHash = new Dictionary<string, InputItem>();
|
XmlDocument doc = new XmlDocument();
|
string wsName;
|
string wsValue;
|
string wsCtrKey;
|
InputItem woCtrTag;
|
try
|
{
|
if (hvConfigXml == null)
|
{
|
return null;
|
}
|
if (hvConfigXml is Stream)
|
{
|
doc.Load(((Stream)(hvConfigXml)));
|
}
|
else
|
{
|
doc.Load(((string)(hvConfigXml)));
|
}
|
XmlNode rootnode = doc.DocumentElement;
|
foreach (XmlNode child in rootnode.ChildNodes)
|
{
|
if (child.NodeType == XmlNodeType.Element && child.Name == "control")
|
{
|
wsCtrKey = child.Attributes["CtrName"].Value;
|
if (wsCtrKey.Length == 0)
|
{
|
return null;
|
}
|
woCtrTag = new InputItem();
|
foreach (XmlAttribute child1 in child.Attributes)
|
{
|
wsName = child1.Name;
|
wsValue = child1.Value;
|
//Debug.WriteLine(wsName + " : " + wsValue);
|
if (wsName.Equals("InputType"))
|
{
|
string[] wsItems = null;
|
wsItems = wsValue.Split(new char[] { ','});
|
for (int i = 0; i <= wsItems.Length - 1; i++)
|
{
|
woCtrTag.InputType = woCtrTag.InputType | (numInputType)CConvert.ToInt(wsItems[i]);
|
}
|
}
|
else if (wsName.Equals("ShowStyle"))
|
{
|
string[] wsItems = null;
|
wsItems = wsValue.Split(new char[] { ',' });
|
for (int i = 0; i <= wsItems.Length - 1; i++)
|
{
|
woCtrTag.ShowStyle = woCtrTag.ShowStyle | (numShowStyle)CConvert.ToInt(wsItems[i]);
|
}
|
}
|
else if (wsName.Equals("ImeMode"))
|
{
|
woCtrTag.ImeMode = (ImeMode)CConvert.ToInt(wsValue);
|
}
|
else
|
{
|
CConvert.CallByName(woCtrTag, wsName, CallType.Let, new object[] { wsValue });
|
}
|
}
|
woParentHash.Add(wsCtrKey, woCtrTag);
|
}
|
}
|
return woParentHash;
|
}
|
catch
|
{
|
return woParentHash;
|
}
|
}
|
|
public static bool IsNaturalNumber(String strNumber)
|
{
|
Regex objNotNaturalPattern = new Regex("[^0-9]");
|
Regex objNaturalPattern = new Regex("0*[1-9][0-9]*");
|
return !objNotNaturalPattern.IsMatch(strNumber) &&
|
objNaturalPattern.IsMatch(strNumber);
|
}
|
|
public static bool IsInteger(String strNumber)
|
{
|
Regex objNotIntPattern = new Regex("[^0-9-]");
|
Regex objIntPattern = new Regex("^-[0-9]+$|^[0-9]+$");
|
return !objNotIntPattern.IsMatch(strNumber) && objIntPattern.IsMatch(strNumber);
|
}
|
|
public static bool IsPositiveNumber(String strNumber)
|
{
|
Regex objNotPositivePattern = new Regex("[^0-9.]");
|
Regex objPositivePattern = new Regex("^[.][0-9]+$|[0-9]*[.]*[0-9]+$");
|
Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
|
return !objNotPositivePattern.IsMatch(strNumber) &&
|
objPositivePattern.IsMatch(strNumber) &&
|
!objTwoDotPattern.IsMatch(strNumber);
|
}
|
|
public static bool IsNumber(String strNumber)
|
{
|
Regex objNotNumberPattern = new Regex("[^0-9.-]");
|
Regex objTwoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
|
Regex objTwoMinusPattern = new Regex("[0-9]*[-][0-9]*[-][0-9]*");
|
String strValidRealPattern = "^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$";
|
String strValidIntegerPattern = "^([-]|[0-9])[0-9]*$";
|
Regex objNumberPattern = new Regex("(" + strValidRealPattern + ")|(" + strValidIntegerPattern + ")");
|
return !objNotNumberPattern.IsMatch(strNumber) &&
|
!objTwoDotPattern.IsMatch(strNumber) &&
|
!objTwoMinusPattern.IsMatch(strNumber) &&
|
objNumberPattern.IsMatch(strNumber);
|
}
|
|
public static bool IsAlpha(String strToCheck)
|
{
|
Regex objAlphaPattern = new Regex("[^a-zA-Z]");
|
return !objAlphaPattern.IsMatch(strToCheck);
|
}
|
|
public static bool IsAlphaNumeric(String strToCheck)
|
{
|
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
|
return !objAlphaNumericPattern.IsMatch(strToCheck);
|
}
|
|
public static bool IsHalfKana(String strToCheck)
|
{
|
Regex objNotPattern = new Regex("[^¦-ß]");
|
Regex objPattern = new Regex("^[¦-ß]+$");
|
return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
|
}
|
|
public static bool IsLargAlpha(String strToCheck)
|
{
|
Regex objNotPattern = new Regex("[^A-Z]");
|
Regex objPattern = new Regex("^[A-Z]+$");
|
return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
|
}
|
|
public static bool IsSmallAlpha(String strToCheck)
|
{
|
Regex objNotPattern = new Regex("[^a-z]");
|
Regex objPattern = new Regex("^[a-z]+$");
|
return !objNotPattern.IsMatch(strToCheck) && objPattern.IsMatch(strToCheck);
|
}
|
|
/// <summary>
|
/// SĩǤ©
|
/// </summary>
|
/// <param name="strNumber"></param>
|
/// <returns></returns>
|
public static bool IsWholeNumber(String strNumber)
|
{
|
Regex objNotPattern = new Regex("[^0-9]");
|
Regex objPattern = new Regex("^[0-9]+$");
|
return !objNotPattern.IsMatch(strNumber) && objPattern.IsMatch(strNumber);
|
}
|
|
/// <summary>
|
/// SQLÌSMALLDateTimeÌ`FbN
|
/// </summary>
|
/// <param name="value"></param>
|
/// <returns></returns>
|
public static bool IsCorrectSmallDateTime(string value)
|
{
|
//1900-01-01 ` 2079-06-06
|
try
|
{
|
DateTime date = CConvert.ToDateTime(value);
|
if (date.Date.CompareTo(CConvert.ToDateTime("1900/01/01").Date) < 0) { return false; }
|
if (date.CompareTo(CConvert.ToDateTime("2079/06/05 23:59:59")) > 0) { return false; }
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
}
|
}
|