/App_Code/Control/ZaytonaClasses/Utility.cs

http://github.com/gmhawash/SSR · C# · 47 lines · 38 code · 6 blank · 3 comment · 7 complexity · 4c3f2f6c71a58e79e18fd6cdaf48bae3 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using TrackerTableAdapters;
  6. /// <summary>
  7. /// Summary description for Utility
  8. /// </summary>
  9. public class Utility
  10. {
  11. public static string TrimString(object stringtotrim)
  12. {
  13. if (!(stringtotrim is string) || String.IsNullOrEmpty(stringtotrim as String))
  14. return null;
  15. else {
  16. string totrim = stringtotrim as String;
  17. return (totrim.Length > 25) ? totrim.Substring(0, 24) + " <span style='color:red;'>...more.</span>" : totrim;
  18. }
  19. }
  20. public static string IsNew(object CreatedOn)
  21. {
  22. if ((CreatedOn is DateTime)) {
  23. DateTime cdate = (DateTime) CreatedOn;
  24. if (cdate.ToBinary() == 0L || DateTime.Now < cdate.AddMinutes (20))
  25. return @"<span style='color:red;'>New</span>";
  26. }
  27. return "";
  28. }
  29. public static Guid? StatusId(string status)
  30. {
  31. TicketsBLL bll = new TicketsBLL();
  32. StatusesTableAdapter ta = new StatusesTableAdapter();
  33. Guid? id = ta.GetId(status);
  34. return id;
  35. }
  36. public static bool IsAssigned(object id)
  37. {
  38. TicketsUsersTableAdapter trta = new TicketsUsersTableAdapter();
  39. return (int)trta.spIsAssigned((Guid)id) > 0;
  40. }
  41. }