PageRenderTime 27ms CodeModel.GetById 24ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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