class CheckData
{
/// <summary>
/// 根据传入的用户注册帐号以及密码判断其数据正确性:
/// 只能是2-6个汉字,或4-12大小写字母数字,或4-10汉字大小写字母数字
/// </summary>
/// <param name="strUserName">用户名</param>
/// <param name="strPassword">密码</param>
/// <returns></returns>
public static bool CheckUser(string strUserName, string strPassword)
{
Regex rx = new Regex("(^[/u4e00-/u9fa5]{2,6}$)|(^[a-zA-Z0-9]{4,12}$)|(^[/u4e00-/u9fa5a-zA-Z0-9]{4,10}$)");
Match ma1 = rx.Match(strUserName);
Match ma2 = rx.Match(strPassword);
bool bo1 = ma1.Success;
bool bo2 = ma2.Success;
if (bo1 == true && bo2 == true)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据传入的编号判断其数据正确性:
/// 只能是1-6个大小写字母或数字
/// </summary>
/// <param name="strCode">编号</param>
/// <returns></returns>
public static bool CheckCode(string strCode)
{
Regex rx = new Regex("(^[a-zA-Z0-9]{1,6}$)");
Match ma1 = rx.Match(strCode);
bool bo1 = ma1.Success;
if (bo1 == true)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据传入的编号及正则式判断其数据正确性
/// </summary>
/// <param name="strCode">编号</param>
/// <param name="rx">正则式</param>
/// <returns></returns>
public static bool CheckCode(string strCode, Regex rx)
{
Match ma1 = rx.Match(strCode);
bool bo1 = ma1.Success;
if (bo1 == true)
{
return true;
}
else
{
return false;
}
}
}