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()); if (date < new DateTime(1753,1,1) || date > new DateTime(9999,12,31)) { throw new Exception(); } return date; } catch (Exception e) { return new DateTime(3000, 1, 1); } } } }