81 lines
1.6 KiB
C#
81 lines
1.6 KiB
C#
using System;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FWA_MAIN
|
|
{
|
|
public class Val
|
|
{
|
|
|
|
public static string varchar(TextBox box, int length)
|
|
{
|
|
|
|
if (box.Text.Length <= length)
|
|
{
|
|
return box.Text.Trim();
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
|
|
}
|
|
|
|
public static int IntType(TextBox box)
|
|
{
|
|
|
|
try
|
|
{
|
|
|
|
return int.Parse(box.Text.Trim());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
public static short SmallIntType(TextBox box)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (box.Text.Length > 0)
|
|
{
|
|
if (double.Parse(box.Text) < 65535 && double.Parse(box.Text) >= 0)
|
|
{
|
|
return short.Parse(box.Text.Trim());
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public static DateTime Date(TextBox box)
|
|
{
|
|
try
|
|
{
|
|
|
|
DateTime date = DateTime.Parse(box.Text.Trim());
|
|
|
|
return date;
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return new DateTime(3000, 1, 1);
|
|
}
|
|
}
|
|
}
|
|
} |