2385 lines
97 KiB
C#
2385 lines
97 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using GZTW.AyaNova.BLL;
|
|
using CSLA.Security;
|
|
using System.Threading;
|
|
using System.Text;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using System.Globalization;
|
|
|
|
namespace AyaNovaMBI
|
|
{
|
|
public class util
|
|
{
|
|
/// <summary>
|
|
/// Get the current user record
|
|
/// </summary>
|
|
public static User CurrentUser
|
|
{
|
|
get
|
|
{
|
|
return User.GetItem((((BusinessPrincipal)Thread.CurrentPrincipal).ID));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the current user record
|
|
/// </summary>
|
|
public static Guid CurrentUserID
|
|
{
|
|
get
|
|
{
|
|
|
|
return (((BusinessPrincipal)Thread.CurrentPrincipal).ID);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Global settings (cached)
|
|
/// </summary>
|
|
public static GZTW.AyaNova.BLL.Global GlobalSettings
|
|
{
|
|
get
|
|
{
|
|
if (mglobal != null)
|
|
return mglobal;
|
|
|
|
if (HttpContext.Current.Cache["GlobalSettings"] == null)
|
|
{
|
|
HttpContext.Current.Cache.Insert("GlobalSettings", GZTW.AyaNova.BLL.Global.GetItem(),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
}
|
|
|
|
mglobal = (GZTW.AyaNova.BLL.Global)HttpContext.Current.Cache["GlobalSettings"];
|
|
return mglobal;
|
|
}
|
|
}
|
|
private static GZTW.AyaNova.BLL.Global mglobal = null;
|
|
|
|
|
|
#region Get localized text strings from cache
|
|
|
|
/// <summary>
|
|
/// Get the localized text from a passed in localizedTextTable fetched
|
|
/// earlier (for performance when doing multiple items at once)
|
|
/// </summary>
|
|
/// <param name="Key"></param>
|
|
/// <param name="ltt"></param>
|
|
/// <returns></returns>
|
|
static public string LocaleText(string Key, LocalizedTextTable ltt)
|
|
{
|
|
if (mt(Key)) return "";
|
|
return ltt.GetLocalizedText(Key).Replace("&", "");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the localized text based on the current users language
|
|
/// from the web app cache
|
|
///
|
|
/// If the cache doesn't contain a localizedtexttable object for the language
|
|
/// requested, populate it first
|
|
///
|
|
/// (caches for 30 minutes from last access)
|
|
/// </summary>
|
|
/// <param name="Key"></param>
|
|
/// <returns></returns>
|
|
static public string LocaleText(string Key)
|
|
{
|
|
if (mt(Key)) return "";
|
|
return LocaleTextTable.GetLocalizedText(Key).Replace("&", "");
|
|
}
|
|
|
|
//private static LocalizedTextTable mlt = null;
|
|
static public LocalizedTextTable LocaleTextTable
|
|
{
|
|
get
|
|
{
|
|
|
|
//If it's in the private member then use that
|
|
|
|
//BUGBUG: this will cause a problem if WBI is used for multiple locales
|
|
//because the static localizedtexttable will be populated once
|
|
//at app startup and first login, then remain forever afterward until wbi is restarted
|
|
//However this does perform much better
|
|
//What to do...?
|
|
//Probably should add a switch for multilingual sites
|
|
//if (mlt != null)
|
|
// return mlt;
|
|
|
|
//try and get it from the cache first
|
|
|
|
if (mt(((BusinessPrincipal)Thread.CurrentPrincipal).Language)) return null;
|
|
string language = ((BusinessPrincipal)Thread.CurrentPrincipal).Language;
|
|
|
|
LocalizedTextTable l = (LocalizedTextTable)HttpContext.Current.Cache["LT_" + language];
|
|
|
|
if (l == null)
|
|
{
|
|
//Not in cache so load it into cache
|
|
|
|
l = LocalizedTextTable.Load(language);
|
|
HttpContext.Current.Cache.Insert("LT_" + language, l,
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
|
|
|
|
}
|
|
|
|
//mlt = l;
|
|
return l;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Localize control and children
|
|
|
|
//Override added after initial design to take the place
|
|
//of the new localize method that takes a localizedtexttable as a parameter
|
|
//for performance
|
|
static public void Localize(System.Web.UI.Control TheControl)
|
|
{
|
|
//prefetch the localized text table
|
|
LocalizedTextTable ltt = LocaleTextTable;
|
|
Localize(TheControl, ltt);
|
|
}
|
|
/// <summary>
|
|
/// iterate through the controls on the passed in control and localize them
|
|
/// and it as necessary
|
|
/// </summary>
|
|
/// <param name="p"></param>
|
|
static public void Localize(System.Web.UI.Control TheControl, LocalizedTextTable ltt)
|
|
{
|
|
switch (TheControl.GetType().ToString())
|
|
{
|
|
//Ignore these:
|
|
case "System.Web.UI.LiteralControl":
|
|
case "System.Web.UI.WebControls.ImageButton":
|
|
case "System.Web.UI.WebControls.Image":
|
|
|
|
break;
|
|
case "System.Web.UI.WebControls.Label":
|
|
{
|
|
Label c = (Label)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.CheckBox":
|
|
{
|
|
CheckBox c = (CheckBox)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.Button":
|
|
{
|
|
Button c = (Button)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.LinkButton":
|
|
{
|
|
LinkButton c = (LinkButton)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
|
|
case "System.Web.UI.WebControls.HyperLink":
|
|
{
|
|
HyperLink c = (HyperLink)TheControl;
|
|
if (c.Text.StartsWith("LT:"))
|
|
c.Text = LocaleText(c.Text.Replace("LT:", ""), ltt);
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "System.Web.UI.Page":
|
|
//case "ASP.masterpage_master":
|
|
{
|
|
//Localize the page title if required
|
|
Page p = (Page)TheControl;
|
|
if (p.Title.StartsWith("LT:"))
|
|
p.Title = LocaleText(p.Title.Replace("LT:", ""), ltt);
|
|
|
|
}
|
|
break;
|
|
|
|
|
|
default:
|
|
{
|
|
;
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
//Now localize any child controls if contained in it
|
|
foreach (Control c in TheControl.Controls)
|
|
{
|
|
Localize(c, ltt);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion page
|
|
|
|
#region converters and time savers
|
|
public static string StringWebify(string input)
|
|
{
|
|
if (mt(input)) return "";
|
|
return input.Replace("\r\n", "<br/>")
|
|
.Replace("\r", "<br/>")
|
|
.Replace("\n", "<br/>");
|
|
|
|
}
|
|
|
|
public static string DTObjectToShortString(object o)
|
|
{
|
|
if (o == null || !(o is DateTime))
|
|
return "";
|
|
DateTime dt = (DateTime)o;
|
|
if (dt.ToShortDateString() == DateTime.Today.ToShortDateString())
|
|
return dt.ToShortTimeString();//today so no date required
|
|
else
|
|
return ((DateTime)o).ToShortDateString() + " " +((DateTime)o).ToShortTimeString();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// typing saver
|
|
/// </summary>
|
|
/// <param name="s"></param>
|
|
/// <returns></returns>
|
|
public static bool mt(string s)
|
|
{
|
|
return string.IsNullOrEmpty(s);
|
|
}
|
|
|
|
public static bool mt(object o)
|
|
{
|
|
if (null == o) return true;
|
|
return mt(o.ToString());
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Read only page fillers
|
|
|
|
#region Add line
|
|
public static void AddLine(StringBuilder sb, string localekey, object o)
|
|
{
|
|
AddLine(sb, localekey, o,"");
|
|
}
|
|
public static void AddLine(StringBuilder sb, string localekey, object o, string sURL)
|
|
{
|
|
string display = "";
|
|
if (o == null) return;
|
|
|
|
if (o is DateTime)
|
|
display = DTObjectToShortString(o);
|
|
else if (o is GridNameValueCellItem)
|
|
{
|
|
GridNameValueCellItem nv = (GridNameValueCellItem)o;
|
|
if (nv.Value == Guid.Empty)
|
|
return;
|
|
//Add link here maybe?
|
|
|
|
display = nv.Display;
|
|
}
|
|
else
|
|
display = o.ToString();
|
|
|
|
if (mt(display)) return;
|
|
if (mt(sURL))
|
|
{
|
|
sb.Append(LocaleText(localekey));
|
|
sb.Append(": ");
|
|
sb.Append(display);
|
|
sb.Append("<br/>");
|
|
}
|
|
else
|
|
{
|
|
//use provided url for link on display text
|
|
sb.Append(LocaleText(localekey));
|
|
sb.Append(": ");
|
|
sb.Append("<a href=\"");
|
|
sb.Append(sURL);
|
|
sb.Append("\">");
|
|
sb.Append(display);
|
|
sb.Append("</a><br/>");
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Object to ro page
|
|
/// <summary>
|
|
/// Generate content for a readonly view
|
|
/// of an AyaNova object
|
|
/// </summary>
|
|
/// <param name="req">Request from ro page containing object type and id</param>
|
|
/// <param name="pagedata">data to be placed in literal on ro page</param>
|
|
/// <param name="titledata">title to be set on ro page</param>
|
|
public static void GetRoPageFromRequest(System.Web.SessionState.HttpSessionState sess, HttpRequest req, ref string pagedata, ref string titledata)
|
|
{
|
|
Guid id = GetIDFromRequest(req);
|
|
string cmd = GetCMDFromRequest(req);
|
|
if (!mt(cmd))
|
|
{
|
|
switch (cmd)
|
|
{
|
|
case "mru":
|
|
{
|
|
titledata = LocaleText("UI.Menu.MRU");
|
|
pagedata = PageFormat(MRUData(),"mru");
|
|
return;
|
|
}
|
|
case "memos":
|
|
{
|
|
titledata = LocaleText("Memo.Label.List");
|
|
pagedata = PageFormat(MemoListData(true), "memos");
|
|
return;
|
|
}
|
|
case "allmemos":
|
|
{
|
|
titledata = LocaleText("Memo.Label.List");
|
|
pagedata = PageFormat(MemoListData(false), "allmemos");
|
|
return;
|
|
}
|
|
case "labors":
|
|
{
|
|
titledata = LocaleText("WorkorderItem.Label.Labors");
|
|
pagedata = PageFormat(LaborListData(id, sess), "");
|
|
return;
|
|
}
|
|
default:
|
|
{
|
|
titledata = "Unknown command";
|
|
pagedata = PageFormat("Unknown command: " + cmd);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
RootObjectTypes otype = GetObjectTypeFromRequest(req);
|
|
if (id == Guid.Empty || otype == RootObjectTypes.Nothing)
|
|
{
|
|
pagedata = PageFormat("<span class=\"clerror\">Unable to retrieve object</span>");
|
|
titledata = "Object not found";
|
|
return;
|
|
}
|
|
|
|
switch (otype)
|
|
{
|
|
case RootObjectTypes.Client:
|
|
{
|
|
titledata = LocaleText("O.Client");
|
|
pagedata = PageFormat(ClientData(Client.GetItem(id)));
|
|
|
|
return;
|
|
}
|
|
|
|
//case RootObjectTypes.Workorder:
|
|
// {
|
|
// titledata = LocaleText("O.Workorder");
|
|
// pagedata = PageFormat(GetWorkorderHeaderDisplay(id,Guid.Empty));
|
|
|
|
// return;
|
|
// }
|
|
//case RootObjectTypes.WorkorderItem:
|
|
// {
|
|
// Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItem, id);
|
|
// if (w == null) return;
|
|
// titledata = LocaleText("O.WorkorderItem");
|
|
// pagedata = PageFormat(GetWorkorderHeaderDisplay(w.ID,id) + GetWorkorderItemDisplay(id));
|
|
|
|
// return;
|
|
// }
|
|
case RootObjectTypes.WorkorderItemScheduledUser:
|
|
{
|
|
WorkorderServiceScheduledUserList.WorkorderServiceScheduledUserListInfo i;
|
|
try
|
|
{
|
|
i = WorkorderServiceScheduledUserList.GetListForSingleItem(id)[0];
|
|
}
|
|
catch
|
|
{
|
|
throw new ApplicationException("Workorder item scheduled user ID is not valid, WorkorderServiceScheduledUserListInfo could not be retrieved");
|
|
}
|
|
titledata = LocaleText("O.WorkorderItemScheduledUser");
|
|
//Display workorder bottom up with scheduser and link to convert to labor at top
|
|
//then item
|
|
//then workorder header itself.
|
|
|
|
pagedata = PageFormat(GetWorkorderItemScheduledUserDisplay(i)+GetWorkorderItemDisplay(i.LT_WorkorderItem_Label_ID)+GetWorkorderHeaderDisplay(i.LT_Workorder_Label_ID) );
|
|
return;
|
|
}
|
|
case RootObjectTypes.ScheduleMarker:
|
|
{
|
|
titledata = LocaleText("O.ScheduleMarker");
|
|
pagedata = PageFormat(GetScheduleMarkerDisplay(id));
|
|
return;
|
|
}
|
|
case RootObjectTypes.Unit:
|
|
{
|
|
titledata = LocaleText("O.Unit");
|
|
pagedata = PageFormat(UnitData(GZTW.AyaNova.BLL.Unit.GetItem(id)));
|
|
return;
|
|
}
|
|
case RootObjectTypes.Memo:
|
|
{
|
|
titledata = LocaleText("O.Memo");
|
|
pagedata = PageFormat(GetMemoDisplay(id));
|
|
return;
|
|
}
|
|
default:
|
|
{
|
|
titledata = "STUB";
|
|
pagedata = PageFormat("<span class=\"clerror\">There is currently no viewer for " + otype.ToString() + " objects</span>");
|
|
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
#endregion object to ro page
|
|
|
|
#region Memo
|
|
static public string GetMemoDisplay(Guid id)
|
|
{
|
|
MemoFetcher m = MemoFetcher.GetItem(id, CurrentUser.DefaultLanguage);
|
|
if (m == null) return "";
|
|
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"sectsubhead\">");
|
|
s.Append(StringWebify(m.ShortHeader));
|
|
s.Append("</span>");
|
|
|
|
s.Append(StringWebify(m.Message));
|
|
|
|
|
|
if (AyaBizUtils.Right("Object.Memo") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
s.Append("<br/><a href=\"memoedit.aspx?id=");
|
|
s.Append(m.ID.ToString());
|
|
s.Append("\">");
|
|
s.Append(LocaleText("Memo.Label.Command.Reply") /*+ " / " + LocaleText("Memo.Label.Command.Forward")*/);//reply only for now
|
|
s.Append("</a>");
|
|
|
|
}
|
|
|
|
|
|
//UI.Command.Delete
|
|
//No delete in initial release
|
|
|
|
//Since the user is about to view it, flag it as viewed
|
|
if (m.Viewed == false)
|
|
{
|
|
Memo.FlagMessageRead(m.ID);
|
|
}
|
|
//s.Append("<br/>");
|
|
|
|
|
|
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion Memo
|
|
|
|
#region Memo list
|
|
public static string MemoListData(bool bNewOnly)
|
|
{
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("Memo.Label.List"));
|
|
s.Append("</span>");
|
|
MemoList ml = MemoList.GetList("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> " +
|
|
"<GRIDCRITERIA> <COLUMNITEM CM=\"aMemo.aCreated\" " +
|
|
"UI=\"LT_Memo_Label_Sent\" PIN=\"0\" WIDTH=\"191\" SORT=\"DESC\" " +
|
|
"/> <COLUMNITEM CM=\"aMemo.aReplied\" UI=\"LT_Memo_Label_Replied\" " +
|
|
"PIN=\"0\" WIDTH=\"86\" /> <COLUMNITEM " +
|
|
"CM=\"aUser.aLastName\" UI=\"LT_Memo_Label_FromID\" " +
|
|
"PIN=\"0\" WIDTH=\"74\" /> <COLUMNITEM CM=\"aMemo.aSubject\" " +
|
|
"UI=\"LT_Memo_Label_Subject\" PIN=\"0\" WIDTH=\"201\" " +
|
|
"/> <COLUMNITEM CM=\"grid\" UI=\"LT_Memo_Label_Sent_Relative\" " +
|
|
"PIN=\"0\" WIDTH=\"105\" /> </GRIDCRITERIA>");
|
|
|
|
|
|
s.Append("<ol>");
|
|
foreach (MemoList.MemoListInfo i in ml)
|
|
{
|
|
if (i.LT_Memo_Label_Viewed && bNewOnly) continue;
|
|
|
|
s.Append("<li>");
|
|
s.Append(util.GetRoLink("", i.ID, RootObjectTypes.Memo, i.LT_Memo_Label_FromID.Display + " " + i.LT_Memo_Label_Subject.Display + " " + DTObjectToShortString(i.LT_Memo_Label_Sent)));
|
|
s.Append("</li>");
|
|
}
|
|
s.Append("</ol>");
|
|
|
|
if (AyaBizUtils.Right("Object.Memo") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
s.Append("<br/><a href=\"memoedit.aspx?id="); //no id means new memo
|
|
s.Append(AyaBizUtils.NewObjectGuid.ToString());
|
|
s.Append("\">");
|
|
s.Append(LocaleText("UI.Toolbar.New"));
|
|
s.Append("</a>");
|
|
}
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion memo list
|
|
|
|
#region MRU
|
|
public static string MRUData()
|
|
{
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("UI.Menu.MRU"));
|
|
s.Append("</span>");
|
|
|
|
int n = 1;
|
|
s.Append("<ol>");
|
|
foreach (DataRowView r in AyaBizUtils.MRU.MRU)
|
|
{
|
|
TypeAndID tid = (TypeAndID)r["TID"];
|
|
//if (tid.RootObjectType != RootObjectTypes.Vendor &&
|
|
// tid.RootObjectType != RootObjectTypes.Workorder &&
|
|
// tid.RootObjectType != RootObjectTypes.WorkorderQuote &&
|
|
// tid.RootObjectType != RootObjectTypes.WorkorderPreventiveMaintenance &&
|
|
// tid.RootObjectType != RootObjectTypes.WorkorderServiceTemplate &&
|
|
// tid.RootObjectType != RootObjectTypes.WorkorderQuoteTemplate &&
|
|
// tid.RootObjectType != RootObjectTypes.WorkorderPreventiveMaintenanceTemplate)
|
|
//Case 809 - makes more sense to just check if it's a type supported by the GetRoPageFromRequest method above
|
|
//than to check what it isn't because there are far more things that are not supported and new stuff might be added in future
|
|
if(tid.RootObjectType == RootObjectTypes.Client ||
|
|
tid.RootObjectType == RootObjectTypes.WorkorderItemScheduledUser ||
|
|
tid.RootObjectType == RootObjectTypes.ScheduleMarker ||
|
|
tid.RootObjectType == RootObjectTypes.Unit ||
|
|
tid.RootObjectType == RootObjectTypes.Workorder ||
|
|
tid.RootObjectType == RootObjectTypes.Memo
|
|
|
|
)
|
|
{
|
|
if (tid.RootObjectType != RootObjectTypes.Workorder)
|
|
{
|
|
s.Append("<li>");
|
|
s.Append(util.GetRoLink(n.ToString(), tid.ID, tid.RootObjectType, r["Description"].ToString()));
|
|
n++;
|
|
s.Append("</li>");
|
|
}
|
|
else
|
|
{
|
|
//case 809, special workorder processing
|
|
//iterate scheduled user items, if match current user then list
|
|
System.Text.StringBuilder ss = new StringBuilder();
|
|
try
|
|
{
|
|
Workorder w = Workorder.GetItemNoMRU(tid.ID);
|
|
foreach (WorkorderItem i in w.WorkorderItems)
|
|
{
|
|
foreach (WorkorderItemScheduledUser su in i.ScheduledUsers)
|
|
{
|
|
if (su.UserID == CurrentUserID)
|
|
{
|
|
ss.Length = 0;
|
|
ss.Append(w.WorkorderService.ServiceNumber.ToString());
|
|
ss.Append(" ");
|
|
ss.Append(NameFetcher.GetItem(new TypeAndID(RootObjectTypes.Client, w.ClientID)).RecordName);
|
|
ss.Append(" ");
|
|
ss.Append(DTObjectToShortString(su.StartDate));
|
|
ss.Append(" - ");
|
|
ss.Append(DTObjectToShortString(su.StopDate));
|
|
|
|
s.Append("<li>");
|
|
s.Append(util.GetRoLink(n.ToString(), su.ID, RootObjectTypes.WorkorderItemScheduledUser, ss.ToString()));
|
|
n++;
|
|
s.Append("</li>");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{//do nothing
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
s.Append("</ol>");
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region Client name and address webbie style
|
|
/// <summary>
|
|
/// build a mobile xhtml friendly name and address
|
|
/// </summary>
|
|
/// <param name="c"></param>
|
|
/// <returns></returns>
|
|
public static string ClientData(Client c)
|
|
{
|
|
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(c.Name);
|
|
s.Append("</span>");
|
|
|
|
//No editing clients in initial release or maybe ever
|
|
//if (AyaBizUtils.Right("Object.Client") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// s.Append(" <a href=\"clientedit.aspx?id=");
|
|
// s.Append(c.ID.ToString());
|
|
// s.Append("\">");
|
|
// s.Append(LocaleText("UI.Command.Edit"));
|
|
// s.Append("</a>");
|
|
|
|
//}
|
|
|
|
s.Append("<br/>");
|
|
|
|
if(!mt(c.Contact))
|
|
s.Append(c.Contact);
|
|
|
|
// <a href="tel:+12065450210">+1 206 545-0210</a>
|
|
s.Append("<div>");
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Phone1") + ": <a href=\"tel:" + c.Phone1 + "\">", c.Phone1, "</a><br/>"));
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Phone2") + ": <a href=\"tel:" + c.Phone2 + "\">", c.Phone2, "</a><br/>"));
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Phone3") + ": <a href=\"tel:" + c.Phone3 + "\">", c.Phone3, "</a><br/>"));
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Phone4") + ": <a href=\"tel:" + c.Phone4 + "\">", c.Phone4, "</a><br/>"));
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Phone5") + ": <a href=\"tel:" + c.Phone5 + "\">", c.Phone5, "</a><br/>"));
|
|
s.Append(AyaBizUtils.SS(LocaleText("Client.Label.Email") + ": <a href=\"mailto:" + c.Email + "\">", c.Email, "</a><br/>"));
|
|
s.Append("</div>");
|
|
|
|
s.Append("<div>");
|
|
s.Append(StringWebify(c.GoToAddress.FullAddress));
|
|
s.Append("</div>");
|
|
|
|
if (c.TechNotes != "")
|
|
{
|
|
s.Append("<div>");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("Client.Label.TechNotes"));
|
|
s.Append("</span>");
|
|
s.Append(":<br/>");
|
|
s.Append(StringWebify(c.TechNotes));
|
|
s.Append("</div>");
|
|
}
|
|
|
|
if (c.ContractInEffect)
|
|
{
|
|
s.Append("<div>");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("O.Contract"));
|
|
s.Append("</span>");
|
|
s.Append(":<br/>");
|
|
s.Append(c.ContractName);
|
|
s.Append("</div>");
|
|
}
|
|
return s.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region Unit
|
|
/// <summary>
|
|
/// build a mobile xhtml friendly read only unit display page
|
|
/// </summary>
|
|
/// <param name="c"></param>
|
|
/// <returns></returns>
|
|
public static string UnitData(GZTW.AyaNova.BLL.Unit c)
|
|
{
|
|
|
|
UnitList.UnitListInfo ul = UnitList.GetListForSingleItem(c.ID)[0];
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(UnitNameFetcher.GetUnitNameFromUnitID(c.ID));
|
|
s.Append("</span>");
|
|
|
|
//No editing of units in MBI initial release
|
|
//if (AyaBizUtils.Right("Object.Unit") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// s.Append(" <a href=\"Unitedit.aspx?id=");
|
|
// s.Append(c.ID.ToString());
|
|
// s.Append("\">");
|
|
// s.Append(LocaleText("UI.Command.Edit"));
|
|
// s.Append("</a>");
|
|
|
|
//}
|
|
|
|
s.Append("<br/>");
|
|
|
|
AddLine(s, "Unit.Label.Serial", c.Serial);
|
|
AddLine(s, "O.UnitModel", ul.LT_O_UnitModel);
|
|
s.Append(GetRoLink("", ul.LT_O_Client));
|
|
s.Append("<br/>");
|
|
|
|
string sDate = "";
|
|
if (c.WarrantyExpiryDateResolved != null)
|
|
sDate = ((DateTime)c.WarrantyExpiryDateResolved).ToShortDateString();
|
|
switch (c.WarrantyStatusResolved)
|
|
{
|
|
case WarrantyStatus.None:
|
|
s.Append(LocaleText("Unit.Label.UI.NotWarrantiedDisplay"));
|
|
break;
|
|
case WarrantyStatus.Expired:
|
|
s.Append(string.Format
|
|
(
|
|
LocaleText("Unit.Label.UI.WarrantyExpiredDisplay"),
|
|
sDate
|
|
));
|
|
break;
|
|
case WarrantyStatus.Active:
|
|
char[] tr = {'\r','\n',' '};
|
|
|
|
s.Append(StringWebify(string.Format
|
|
(
|
|
LocaleText("Unit.Label.UI.WarrantiedDisplay").Replace("\r\n\r\n","\r\n"),
|
|
sDate,
|
|
c.WarrantyTermsResolved
|
|
)));
|
|
break;
|
|
}
|
|
|
|
s.Append("<br/>");
|
|
s.Append(StringWebify(c.History));
|
|
|
|
if (ul.LT_Unit_Label_Metered)
|
|
{
|
|
AddLine(s,"Unit.Label.LastMeter",ul.LT_Unit_Label_LastMeter);
|
|
|
|
}
|
|
|
|
|
|
if (ul.LT_Client_Label_UsesBanking)
|
|
{
|
|
if (ul.LT_ServiceBank_Label_CurrencyBalance != 0)
|
|
{
|
|
AddLine(s,"ServiceBank.Label.CurrencyBalance",ul.LT_ServiceBank_Label_CurrencyBalance.ToString("c"));
|
|
}
|
|
|
|
if (ul.LT_ServiceBank_Label_HoursBalance != 0)
|
|
{
|
|
AddLine(s,"ServiceBank.Label.HoursBalance",ul.LT_ServiceBank_Label_HoursBalance.ToString());
|
|
}
|
|
|
|
if (ul.LT_ServiceBank_Label_IncidentsBalance != 0)
|
|
{
|
|
AddLine(s,"ServiceBank.Label.IncidentsBalance",ul.LT_ServiceBank_Label_IncidentsBalance.ToString());
|
|
}
|
|
}
|
|
|
|
if (c.UnitHasOwnAddress)
|
|
{
|
|
s.Append("<div>");
|
|
s.Append(StringWebify(c.GoToAddress.FullAddress));
|
|
s.Append("</div>");
|
|
|
|
}
|
|
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region Schedulemarker
|
|
static public string GetScheduleMarkerDisplay(Guid id)
|
|
{
|
|
ScheduleMarker sm = ScheduleMarker.GetItem(id);
|
|
if (sm == null) return "";
|
|
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(sm.Name);
|
|
s.Append("</span>");
|
|
|
|
//No editing of schedule markers in initial release or maybe ever
|
|
//if (AyaBizUtils.Right("Object.ScheduleMarker") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// s.Append(" <a href=\"smedit.aspx?id=");
|
|
// s.Append(sm.ID.ToString());
|
|
// s.Append("\">");
|
|
// s.Append(LocaleText("UI.Command.Edit"));
|
|
// s.Append("</a>");
|
|
|
|
//}
|
|
|
|
s.Append("<br/>");
|
|
|
|
s.Append(DTObjectToShortString(sm.StartDate));
|
|
s.Append(" - ");
|
|
s.Append(DTObjectToShortString(sm.StopDate));
|
|
s.Append("<br/>");
|
|
|
|
if (sm.FollowID != Guid.Empty)
|
|
{
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("ScheduleMarker.Label.FollowUp"));
|
|
s.Append("</span><br/>");
|
|
s.Append(NameFetcher.GetItem(new TypeAndID(sm.FollowType, sm.FollowID)).RecordName);
|
|
s.Append("<br/>");
|
|
}
|
|
|
|
|
|
s.Append(StringWebify(sm.Notes));
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion schedulemarker
|
|
|
|
#region Workorder display helpers
|
|
|
|
#region Workorder header
|
|
/// <summary>
|
|
/// Returns an xhtml formatted workorder header snippet
|
|
/// </summary>
|
|
/// <param name="WorkorderID"></param>
|
|
/// <returns></returns>
|
|
public static string GetWorkorderHeaderDisplay(Guid WorkorderID)
|
|
{
|
|
WorkorderServiceList w = WorkorderServiceList.GetListForSingleItem(WorkorderID);
|
|
if (w.Count == 0) return "Workorder not found";
|
|
|
|
WorkorderServiceList.WorkorderServiceListInfo i = w[0];
|
|
StringBuilder s = new StringBuilder();
|
|
s.Append("<div>");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("O.Workorder"));
|
|
s.Append(": ");
|
|
s.Append(i.LT_O_Workorder.Display);
|
|
s.Append("</span>");
|
|
//No editing of workorder head fields in initial release or maybe ever
|
|
//If any particulars are absolutely required can be worked into a special form for just that item
|
|
//i.e. status or something
|
|
//if (!i.LT_Workorder_Label_Closed && AyaBizUtils.Right("Object.xWorkorder") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// s.Append(" <a href=\"woedit.aspx?id=");
|
|
// s.Append(i.LT_O_Workorder.Value.ToString());
|
|
// s.Append("\">");
|
|
// s.Append(LocaleText("UI.Command.Edit"));
|
|
// s.Append("</a>");
|
|
|
|
//}
|
|
s.Append("<br/>");
|
|
|
|
s.Append(GetRoLink("",i.LT_O_Client));
|
|
|
|
s.Append("<br/>");
|
|
|
|
AddLine(s, "O.WorkorderStatus", i.LT_O_WorkorderStatus);
|
|
AddLine(s, "Workorder.Label.Summary",i.LT_Workorder_Label_Summary);
|
|
AddLine(s, "Workorder.Label.CustomerContactName", i.LT_Workorder_Label_CustomerContactName);
|
|
AddLine(s, "Workorder.Label.CustomerReferenceNumber", i.LT_Workorder_Label_CustomerReferenceNumber);
|
|
AddLine(s, "Workorder.Label.InternalReferenceNumber", i.LT_Workorder_Label_InternalReferenceNumber);
|
|
//case 987
|
|
AddLine(s, "Workorder.Label.Onsite", i.LT_Workorder_Label_Onsite);
|
|
// AddLine(s, "Workorder.Label.Closed", i.LT_Workorder_Label_Closed);
|
|
// AddLine(s, "O.Project", i.LT_O_Project);
|
|
// AddLine(s, "O.WorkorderCategory", i.LT_O_WorkorderCategory);
|
|
// AddLine(s, "WorkorderService.Label.InvoiceNumber", i.LT_WorkorderService_Label_InvoiceNumber);
|
|
AddLine(s, "WorkorderService.Label.ServiceDate", i.LT_WorkorderService_Label_ServiceDate);
|
|
AddLine(s, "WorkorderService.Label.CloseByDate", i.LT_WorkorderService_Label_CloseByDate);
|
|
|
|
//case 1346
|
|
//Signature link here
|
|
|
|
s.Append(" <a href=\"sign.aspx?sigwo=" + WorkorderID.ToString() + "\">");
|
|
s.Append(util.LocaleText("Workorder.Label.Sign"));
|
|
s.Append("</a>");
|
|
|
|
s.Append("</div>");
|
|
|
|
//Workorder wo = Workorder.GetItem(i.LT_O_Workorder.Value);
|
|
////if there is only one wo item and we're told to ignore it here then
|
|
////no need to list it redundantly so bail early
|
|
//if (IgnoreWorkorderItemID != Guid.Empty && wo.WorkorderItems.Count == 1)
|
|
// return s.ToString();
|
|
|
|
//s.Append("</div>");
|
|
////Append workorder items that aren't ignored
|
|
//s.Append("<span class=\"sectsubhead\">");
|
|
//s.Append(LocaleText("Workorder.Label.WorkorderItems"));
|
|
//s.Append("</span><br/>");
|
|
//foreach (WorkorderItem wi in wo.WorkorderItems)
|
|
//{
|
|
// if (wi.ID == IgnoreWorkorderItemID) continue;
|
|
|
|
// s.Append(util.GetRoLink("", wi.ID, RootObjectTypes.WorkorderItem, mt(wi.Summary)?"---":wi.Summary));
|
|
//}
|
|
|
|
|
|
//s.Append("</div><br/>");
|
|
return s.ToString();
|
|
|
|
}
|
|
#endregion workorder header
|
|
|
|
#region Workorder Item
|
|
/// <summary>
|
|
/// Returns an xhtml formatted workorder item snippet
|
|
/// </summary>
|
|
/// <param name="WorkorderID"></param>
|
|
/// <returns></returns>
|
|
public static string GetWorkorderItemDisplay(Guid WorkorderItemID)
|
|
{
|
|
return GetWorkorderItemDisplay(WorkorderServiceItemList.GetListForSingleItem(WorkorderItemID)[0]);
|
|
}
|
|
public static string GetWorkorderItemDisplay(WorkorderServiceItemList.WorkorderServiceItemListInfo i)
|
|
{
|
|
Workorder w = Workorder.GetItem(i.LT_O_Workorder.Value);
|
|
WorkorderItem wi=w.WorkorderItems[i.LT_WorkorderItem_Label_ID];
|
|
StringBuilder s = new StringBuilder();
|
|
|
|
s.Append("<div>");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("O.WorkorderItem"));
|
|
s.Append("</span>");
|
|
//if (!w.Closed && AyaBizUtils.Right("Object.xWorkorder") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// //s.Append(" <a href=\"woitemedit.aspx?id=");
|
|
// //s.Append(i.LT_WorkorderItem_Label_ID.ToString());
|
|
// //s.Append("\">");
|
|
// //s.Append(LocaleText("UI.Command.Edit"));
|
|
// //s.Append("</a>");
|
|
|
|
//}
|
|
s.Append("<br/>");
|
|
|
|
|
|
AddLine(s,"WorkorderItem.Label.Summary",i.LT_WorkorderItem_Label_Summary);
|
|
AddLine(s,"WorkorderItem.Label.TechNotes",StringWebify(wi.TechNotes));
|
|
AddLine(s,"WorkorderItem.Label.TypeID",i.LT_WorkorderItem_Label_TypeID);
|
|
|
|
if(w.IsEditable && w.IsWorkorderItemEditable)//case 1903
|
|
AddLine(s, "WorkorderItem.Label.WorkorderStatusID", i.LT_WorkorderItem_Label_WorkorderStatusID, "status.aspx?id=" + i.LT_WorkorderItem_Label_ID.ToString());
|
|
else
|
|
AddLine(s, "WorkorderItem.Label.WorkorderStatusID", i.LT_WorkorderItem_Label_WorkorderStatusID);
|
|
|
|
|
|
AddLine(s,"WorkorderItem.Label.PriorityID",i.LT_WorkorderItem_Label_PriorityID);
|
|
AddLine(s,"WorkorderItem.Label.RequestDate",i.LT_WorkorderItem_Label_RequestDate);
|
|
|
|
//case 903
|
|
if(i.LT_Unit_Label_Serial.Value!=Guid.Empty)
|
|
AddLine(s, "Unit.Label.Serial", i.LT_Unit_Label_Serial);
|
|
|
|
s.Append("</div>");
|
|
|
|
//labor
|
|
//case 1903
|
|
if (AyaBizUtils.Right("Object.WorkorderItemLabor") > (int)SecurityLevelTypes.NoAccess)
|
|
{
|
|
s.Append(" <a href=\"ro.aspx?cmd=labors&id=" + i.LT_WorkorderItem_Label_ID.ToString() + "\">");
|
|
// s.Append("| "); ADD THIS BACK LATER WHEN MORE SUB ITEM HL's
|
|
s.Append(util.LocaleText("WorkorderItem.Label.Labors"));
|
|
s.Append("</a>");
|
|
}
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion workorder item
|
|
|
|
#region Workorder Item scheduled user
|
|
/// <summary>
|
|
/// Returns an xhtml formatted workorder item sched user snippet
|
|
/// </summary>
|
|
/// <param name="WorkorderID"></param>
|
|
/// <returns></returns>
|
|
public static string GetWorkorderItemScheduledUserDisplay(Guid WorkorderItemScheduledUserID)
|
|
{
|
|
return GetWorkorderItemScheduledUserDisplay(WorkorderServiceScheduledUserList.GetListForSingleItem(WorkorderItemScheduledUserID)[0]);
|
|
}
|
|
public static string GetWorkorderItemScheduledUserDisplay(WorkorderServiceScheduledUserList.WorkorderServiceScheduledUserListInfo i)
|
|
{
|
|
Workorder w = Workorder.GetItem(i.LT_O_Workorder.Value);
|
|
WorkorderItem wi = w.WorkorderItems[i.LT_WorkorderItem_Label_ID];
|
|
|
|
StringBuilder s = new StringBuilder();
|
|
|
|
s.Append("<div>");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("O.WorkorderItemScheduledUser"));
|
|
s.Append("</span>");
|
|
s.Append("<br/>");
|
|
//convert to labor link
|
|
if (w.IsEditable && w.IsWorkorderItemEditable && AyaBizUtils.Right("Object.WorkorderItemLabor") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
s.Append(" <a href=\"sched2labor.aspx?id=" + i.LT_WorkorderItemScheduledUser_Label_ID.ToString() + "\">");
|
|
s.Append(util.LocaleText("Workorder.Label.Command.ConvertScheduledUserToLabor"));
|
|
s.Append("</a>");
|
|
}
|
|
//if (!w.Closed && AyaBizUtils.Right("Object.xWorkorder") > (int)SecurityLevelTypes.ReadOnly)
|
|
//{
|
|
// //s.Append(" <a href=\"woitemedit.aspx?id=");
|
|
// //s.Append(i.LT_WorkorderItem_Label_ID.ToString());
|
|
// //s.Append("\">");
|
|
// //s.Append(LocaleText("UI.Command.Edit"));
|
|
// //s.Append("</a>");
|
|
|
|
//}
|
|
s.Append("<br/>");
|
|
|
|
|
|
AddLine(s, "WorkorderItemScheduledUser.Label.StartDate", i.LT_WorkorderItemScheduledUser_Label_StartDate);
|
|
AddLine(s, "WorkorderItemScheduledUser.Label.StopDate", i.LT_WorkorderItemScheduledUser_Label_StopDate);
|
|
AddLine(s, "WorkorderItemScheduledUser.Label.EstimatedQuantity", i.LT_WorkorderItemScheduledUser_Label_EstimatedQuantity.ToString("g29"));
|
|
AddLine(s, "WorkorderItemScheduledUser.Label.ServiceRateID", i.LT_WorkorderItemScheduledUser_Label_ServiceRateID);
|
|
|
|
|
|
s.Append("</div>");
|
|
|
|
|
|
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion workorder item scheduled user
|
|
|
|
#region Workorder item labor list
|
|
public static string LaborListData(Guid WorkorderItemID, System.Web.SessionState.HttpSessionState sess)
|
|
{
|
|
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
|
Workorder w = Workorder.GetWorkorderByRelative(RootObjectTypes.WorkorderItem, WorkorderItemID);
|
|
WorkorderItem wi = w.WorkorderItems[WorkorderItemID];
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(LocaleText("WorkorderItem.Label.Labors"));
|
|
s.Append("</span>");
|
|
|
|
Guid userid = CurrentUserID;
|
|
|
|
s.Append("<ol>");
|
|
foreach (WorkorderItemLabor i in wi.Labors)
|
|
{
|
|
if (i.UserID != userid)
|
|
continue;
|
|
|
|
s.Append("<li>");
|
|
s.Append("<a href=\"labor.aspx?id=");
|
|
s.Append(i.ID.ToString());
|
|
s.Append("\">");
|
|
s.Append(mt(i.ServiceDetails)?"---":i.ServiceDetails);
|
|
s.Append("</a>");
|
|
s.Append("</li>");
|
|
}
|
|
s.Append("</ol>");
|
|
|
|
//case 1622
|
|
//if (!w.Closed && !w.ServiceCompleted && AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly)
|
|
//update case 1903, previous check not correct
|
|
if (w.IsEditable && w.IsWorkorderItemEditable && AyaBizUtils.Right("Object.WorkorderItemLabor") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
s.Append(" <a href=\"cmd.aspx?cmd=newlabor&id=");
|
|
s.Append(wi.ID.ToString());
|
|
s.Append("\">");
|
|
s.Append(LocaleText("UI.Toolbar.New"));
|
|
s.Append("</a>");
|
|
s.Append("<br/>");
|
|
}
|
|
|
|
if (sess["ret"] != null)
|
|
{
|
|
s.Append("<br/><a href=\"");
|
|
s.Append((string)sess["ret"]);
|
|
s.Append("\">");
|
|
s.Append("<<<");
|
|
s.Append("</a>");
|
|
}
|
|
|
|
return s.ToString();
|
|
}
|
|
#endregion workorder item labor list
|
|
|
|
#endregion workorder display helpers
|
|
|
|
#region Form helpers & common menu
|
|
|
|
/// <summary>
|
|
/// formats page with standard header and footer menus
|
|
/// </summary>
|
|
/// <param name="content"></param>
|
|
/// <param name="ignore"></param>
|
|
/// <returns></returns>
|
|
public static string PageFormat(string content, string ignore)
|
|
{
|
|
string s = PageMenu(ignore);
|
|
return s + "<hr/>" + content + "<hr/>" + s;
|
|
}
|
|
|
|
public static string PageFormat(string content)
|
|
{
|
|
return PageFormat(content, "");
|
|
}
|
|
/// <summary>
|
|
/// Standard page footer
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string PageMenu( string ignore)
|
|
{
|
|
//Back to main
|
|
System.Text.StringBuilder s = new StringBuilder();
|
|
|
|
//schedule
|
|
if (ignore != "schedule")
|
|
{
|
|
s.Append(" <a accesskey=\"1\" href=\"schedule.aspx\">");
|
|
s.Append(util.LocaleText("UI.Go.Schedule"));
|
|
s.Append("</a>");
|
|
}
|
|
|
|
//memos
|
|
if (ignore != "memos")
|
|
{
|
|
s.Append(" <a href=\"ro.aspx?cmd=memos\">");
|
|
s.Append("| ");
|
|
s.Append(util.LocaleText("Memo.Label.List"));
|
|
s.Append("</a>");
|
|
}
|
|
//memos
|
|
if (ignore == "memos")
|
|
{
|
|
s.Append(" <a href=\"ro.aspx?cmd=allmemos\">");
|
|
s.Append("| ");
|
|
s.Append("<span class=\"secthead\">");
|
|
s.Append(util.LocaleText("Memo.Label.List") + " " + util.LocaleText("UI.Grid.RowFilterDropDownAllItem"));
|
|
s.Append("</span>");
|
|
s.Append("</a>");
|
|
}
|
|
|
|
//MRU
|
|
if (ignore != "mru")
|
|
{
|
|
s.Append(" <a href=\"ro.aspx?cmd=mru\">");
|
|
s.Append("| ");
|
|
s.Append(util.LocaleText("UI.Menu.MRU"));
|
|
s.Append("</a>");
|
|
}
|
|
|
|
s.Append(" |");
|
|
|
|
|
|
|
|
return s.ToString();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Get's the string command in a request
|
|
/// if it's a command rather than opening a specific object
|
|
/// (i.e. "mru" etc)
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public static string GetCMDFromRequest(HttpRequest request)
|
|
{
|
|
return request.QueryString["cmd"];
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Get's the id in a request as a Guid
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public static Guid GetIDFromRequest(HttpRequest request)
|
|
{
|
|
string idstring = request.QueryString["id"];
|
|
Guid oID = Guid.Empty;
|
|
if (!mt(idstring))
|
|
return new Guid(idstring);
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get's the id in a request as a Guid
|
|
/// using the named variable name
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public static Guid GetIDFromRequest(HttpRequest request, string vname)
|
|
{
|
|
string idstring = request.QueryString[vname];
|
|
Guid oID = Guid.Empty;
|
|
if (!mt(idstring))
|
|
return new Guid(idstring);
|
|
else
|
|
return Guid.Empty;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Parses the request objects uri and
|
|
/// builds a return to url
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public static string GetReturnToUrlFromRequest(HttpRequest request)
|
|
{
|
|
string t = request.Url.ToString();
|
|
int n = t.LastIndexOf("/") + 1;
|
|
return t.Substring(n);
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// redirect to the return to page in the session, or if that's empty
|
|
/// then redirect to the url specified or if that's emtpy do nothing
|
|
/// </summary>
|
|
public static void Redirect(System.Web.SessionState.HttpSessionState sess, HttpResponse resp, string tourl)
|
|
{
|
|
if (sess["ret"] != null)
|
|
{
|
|
resp.Redirect((string)sess["ret"]);
|
|
return;
|
|
}
|
|
|
|
if (!mt(tourl))
|
|
resp.Redirect(tourl);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Get's the object type in a request
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
public static RootObjectTypes GetObjectTypeFromRequest(HttpRequest request)
|
|
{
|
|
string objectstring = request.QueryString["o"];
|
|
int n=0;
|
|
if(!int.TryParse(objectstring,out n))
|
|
return RootObjectTypes.Nothing;
|
|
return (RootObjectTypes)n;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Format and return an ahref link to a read only view of an object
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="ro"></param>
|
|
/// <returns></returns>
|
|
public static string GetRoLink(string accesskey,Guid id, RootObjectTypes ro,string display)
|
|
{
|
|
if(mt(accesskey) || accesskey.Length>1)
|
|
return "<a href=\"ro.aspx?id=" + id.ToString() + "&o=" + (int)ro + "\">" + HttpUtility.HtmlEncode(display) + "</a> ";//case 1331
|
|
else
|
|
return "<a accesskey=\"" + accesskey + "\" href=\"ro.aspx?id=" + id.ToString() + "&o=" + (int)ro + "\">" + HttpUtility.HtmlEncode(display) + "</a> ";
|
|
|
|
}
|
|
|
|
public static string GetRoLink(string accesskey, GridNameValueCellItem nv)
|
|
{
|
|
return GetRoLink(accesskey, nv.Value, nv.RootObjectType, nv.Display);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Provides a link to the status page where the remote user can
|
|
/// quickly change the status of the workorder item in question
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <param name="display"></param>
|
|
/// <returns></returns>
|
|
public static string GetWOItemStatusLink(Guid WorkorderItemID)
|
|
{
|
|
Workorder w = Workorder.GetWorkorderByRelativeNoMRU(RootObjectTypes.WorkorderItem, WorkorderItemID);
|
|
if (!w.IsEditable || !w.IsWorkorderItemEditable) return ""; //case 1903
|
|
string display = "";
|
|
WorkorderServiceItemList wsil=WorkorderServiceItemList.GetListForSingleItem(WorkorderItemID);
|
|
if (wsil.Count > 0)
|
|
{
|
|
display = wsil[0].LT_WorkorderItem_Label_WorkorderStatusID.Display;
|
|
}
|
|
if (mt(display))
|
|
{
|
|
display = LocaleText("WorkorderItem.Label.WorkorderStatusID");
|
|
|
|
}
|
|
//make a link to the status page
|
|
return "<a href=\"status.aspx?id=" + WorkorderItemID.ToString() + "\">" + HttpUtility.HtmlEncode(display) + "</a><br/>";//case 1885
|
|
}
|
|
#endregion
|
|
|
|
#endregion read only page fillers
|
|
|
|
|
|
#region Diagnostics
|
|
public static string VistorDiagInfo(HttpRequest r)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
HttpBrowserCapabilities bc = r.Browser;
|
|
sb.Append("AGENT = " + r.UserAgent + "\r\n");
|
|
sb.Append("From = " + r.UrlReferrer + "\r\n");
|
|
sb.Append("Host = " + r.UserHostName + " " + r.UserHostAddress + "\r\n");
|
|
sb.Append("Type = " + bc.Type + "\r\n");
|
|
sb.Append("Name = " + bc.Browser + "\r\n");
|
|
sb.Append("Version = " + bc.Version + "\r\n");
|
|
sb.Append("Major Version = " + bc.MajorVersion + "\r\n");
|
|
sb.Append("Minor Version = " + bc.MinorVersion + "\r\n");
|
|
sb.Append("Platform = " + bc.Platform + "\r\n");
|
|
sb.Append("IsMobile = " + bc.IsMobileDevice + "\r\n");
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
#endregion diagnostics
|
|
|
|
#region List retrievers for combo boxes and value lists in grid
|
|
|
|
#region NonBizLists
|
|
|
|
|
|
|
|
public static string GetNonBizName(string EnumListName, int i)
|
|
{
|
|
DataView dv = GetDataNonBiz(EnumListName);
|
|
|
|
foreach (DataRowView dr in dv)
|
|
{
|
|
if (int.Parse(dr["Value"].ToString()) == i)
|
|
return dr["Display"].ToString();
|
|
}
|
|
return " ";
|
|
}
|
|
public static DataView GetDataNonBiz(string EnumListName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Display");
|
|
dt.Columns.Add("Value");
|
|
|
|
|
|
switch (EnumListName)
|
|
{
|
|
case "QuoteStatus":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Awarded, LocaleText("WorkorderQuoteStatusTypes.Label.Awarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.InProgress, LocaleText("WorkorderQuoteStatusTypes.Label.InProgress"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded, LocaleText("WorkorderQuoteStatusTypes.Label.NotAwarded"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.Submitted, LocaleText("WorkorderQuoteStatusTypes.Label.Submitted"));
|
|
|
|
//case 1556
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.New, LocaleText("WorkorderQuoteStatusTypes.Label.New"));
|
|
AddNVRow(dt, (int)WorkorderQuoteStatusTypes.NotAwarded2, LocaleText("WorkorderQuoteStatusTypes.Label.NotAwarded2"));
|
|
|
|
}
|
|
break;
|
|
case "ClientServiceRequestStatus":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Accepted, LocaleText("ClientServiceRequestStatus.Accepted"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Declined, LocaleText("ClientServiceRequestStatus.Declined"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Open, LocaleText("ClientServiceRequestStatus.Open"));
|
|
AddNVRow(dt, (int)ClientServiceRequestStatus.Closed, LocaleText("ClientServiceRequestStatus.Closed"));
|
|
|
|
}
|
|
break;
|
|
case "ClientServiceRequestPriority":
|
|
{
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.NotUrgent, LocaleText("ClientServiceRequestPriority.NotUrgent"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.ASAP, LocaleText("ClientServiceRequestPriority.ASAP"));
|
|
AddNVRow(dt, (int)ClientServiceRequestPriority.Emergency, LocaleText("ClientServiceRequestPriority.Emergency"));
|
|
|
|
}
|
|
break;
|
|
case "UnitsOfTime":
|
|
{
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Minutes, LocaleText("UI.Label.TimeSpan.Minutes"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Hours, LocaleText("UI.Label.TimeSpan.Hours"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Days, LocaleText("UI.Label.TimeSpan.Days"));
|
|
//Weeks are not supported because the concept of Week is very "weak" globally :)
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Months, LocaleText("UI.Label.TimeSpan.Months"));
|
|
AddNVRow(dt, (int)AyaUnitsOfTime.Years, LocaleText("UI.Label.TimeSpan.Years"));
|
|
|
|
}
|
|
break;
|
|
case "DaysOfWeek":
|
|
{
|
|
AddNVRow(dt, (int)AyaDayOfWeek.AnyDayOfWeek, LocaleText("UI.Label.Day.Any"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Monday, LocaleText("UI.Label.Day.Monday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Tuesday, LocaleText("UI.Label.Day.Tuesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Wednesday, LocaleText("UI.Label.Day.Wednesday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Thursday, LocaleText("UI.Label.Day.Thursday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Friday, LocaleText("UI.Label.Day.Friday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Saturday, LocaleText("UI.Label.Day.Saturday"));
|
|
AddNVRow(dt, (int)AyaDayOfWeek.Sunday, LocaleText("UI.Label.Day.Sunday"));
|
|
|
|
}
|
|
break;
|
|
case "VendorTypes":
|
|
{
|
|
AddNVRow(dt, -1, "-");//Case 344
|
|
AddNVRow(dt, (int)VendorTypes.Manufacturer, LocaleText("Vendor.Label.VendorType.Manufacturer"));
|
|
AddNVRow(dt, (int)VendorTypes.Shipper, LocaleText("Vendor.Label.VendorType.Shipper"));
|
|
AddNVRow(dt, (int)VendorTypes.SubContractor, LocaleText("Vendor.Label.VendorType.SubContractor"));
|
|
AddNVRow(dt, (int)VendorTypes.ThirdPartyRepair, LocaleText("Vendor.Label.VendorType.ThirdPartyRepair"));
|
|
AddNVRow(dt, (int)VendorTypes.Wholesaler, LocaleText("Vendor.Label.VendorType.Wholesaler"));
|
|
|
|
}
|
|
break;
|
|
case "PurchaseOrderStatus":
|
|
{
|
|
AddNVRow(dt, -1, "-");//Case 344
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedFullReceived, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedFullReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedNoneReceived, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedNoneReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.ClosedPartialReceived, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.ClosedPartialReceived"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenNotYetOrdered, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenNotYetOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenOrdered, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenOrdered"));
|
|
AddNVRow(dt, (int)PurchaseOrderStatus.OpenPartialReceived, LocaleText("PurchaseOrder.Label.PurchaseOrderStatus.OpenPartialReceived"));
|
|
|
|
|
|
}
|
|
break;
|
|
case "WorkorderItemTaskCompletionType":
|
|
{
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Complete, LocaleText("WorkorderItemTask.Label.CompletionType.Complete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.Incomplete, LocaleText("WorkorderItemTask.Label.CompletionType.Incomplete"));
|
|
AddNVRow(dt, (int)WorkorderItemTaskCompletionTypes.NotApplicable, LocaleText("WorkorderItemTask.Label.CompletionType.NotApplicable"));
|
|
|
|
}
|
|
break;
|
|
|
|
case "ContactPhoneTypes":
|
|
{
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Unset, "-");//Case 344
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Business, LocaleText("ContactPhone.Label.ContactPhoneType.Business"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Mobile, LocaleText("ContactPhone.Label.ContactPhoneType.Mobile"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Fax, LocaleText("ContactPhone.Label.ContactPhoneType.Fax"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Pager, LocaleText("ContactPhone.Label.ContactPhoneType.Pager"));
|
|
AddNVRow(dt, (int)ContactPhoneTypes.Home, LocaleText("ContactPhone.Label.ContactPhoneType.Home"));
|
|
}
|
|
break;
|
|
|
|
case "UserTypes":
|
|
{
|
|
AddNVRow(dt, (int)UserTypes.Administrator, LocaleText("UserTypes.Label.Administrator"));
|
|
AddNVRow(dt, (int)UserTypes.Schedulable, LocaleText("UserTypes.Label.Schedulable"));
|
|
AddNVRow(dt, (int)UserTypes.NonSchedulable, LocaleText("UserTypes.Label.NonSchedulable"));
|
|
AddNVRow(dt, (int)UserTypes.Client, LocaleText("UserTypes.Label.Client"));
|
|
AddNVRow(dt, (int)UserTypes.HeadOffice, LocaleText("UserTypes.Label.HeadOffice"));
|
|
AddNVRow(dt, (int)UserTypes.Utility, LocaleText("UserTypes.Label.UTILITY"));
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
//Case 513
|
|
case "LoanItemRates":
|
|
{
|
|
AddNVRow(dt, (int)LoanItemRates.None, LocaleText("LoanItem.Label.RateNone"));
|
|
AddNVRow(dt, (int)LoanItemRates.Hours, LocaleText("LoanItem.Label.RateHour"));
|
|
AddNVRow(dt, (int)LoanItemRates.HalfDays, LocaleText("LoanItem.Label.RateHalfDay"));
|
|
AddNVRow(dt, (int)LoanItemRates.Days, LocaleText("LoanItem.Label.RateDay"));
|
|
AddNVRow(dt, (int)LoanItemRates.Weeks, LocaleText("LoanItem.Label.RateWeek"));
|
|
AddNVRow(dt, (int)LoanItemRates.Months, LocaleText("LoanItem.Label.RateMonth"));
|
|
AddNVRow(dt, (int)LoanItemRates.Years, LocaleText("LoanItem.Label.RateYear"));
|
|
}
|
|
break;
|
|
|
|
}
|
|
dt.DefaultView.Sort = "Display";
|
|
return dt.DefaultView;
|
|
}
|
|
#endregion nonbizlists
|
|
|
|
#region BizList
|
|
/// <summary>
|
|
/// overload for original method without ID2
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <returns></returns>
|
|
public static DataView GetDataBiz(string PickList, Guid SelectedID, bool ActiveOnly, Guid ID1, List<Guid> SelectedIDList, bool Regional)
|
|
{
|
|
return GetDataBiz(PickList, SelectedID, ActiveOnly, ID1, Guid.Empty, SelectedIDList, Regional);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="PickList"></param>
|
|
/// <param name="SelectedID"></param>
|
|
/// <param name="ActiveOnly"></param>
|
|
/// <param name="ID1"></param>
|
|
/// <param name="SelectedIDList"></param>
|
|
/// <returns></returns>
|
|
public static DataView GetDataBiz(string PickList, Guid SelectedID, bool ActiveOnly, Guid ID1, Guid ID2, List<Guid> SelectedIDList, bool Regional)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt.Columns.Add("Display");
|
|
dt.Columns.Add("Value", typeof(Guid));
|
|
dt.Columns.Add("Color", typeof(int));
|
|
//add an initial blank row for Guid.empty
|
|
DataRow drBlank = dt.NewRow();
|
|
drBlank["Display"] = "-";//Case 344
|
|
drBlank["Value"] = Guid.Empty;
|
|
dt.Rows.Add(drBlank);
|
|
|
|
switch (PickList)
|
|
{
|
|
|
|
case "UserPickListScheduleable":
|
|
{
|
|
#region
|
|
ScheduleableUserNameDisplayFormats fmt = GlobalSettings.DefaultScheduleableUserNameDisplayFormat;
|
|
UserListScheduleable UList = UserListScheduleable.GetList();
|
|
|
|
foreach (UserListScheduleable.UserListScheduleableInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name(fmt);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name(fmt);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "UserPickList":
|
|
{
|
|
#region
|
|
UserPickList UList = UserPickList.GetList(Regional);
|
|
|
|
foreach (UserPickList.UserPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "UserPickListStaffOnly":
|
|
{//used for quote prepared by combo
|
|
#region
|
|
UserPickList UList = UserPickList.GetList(Regional);
|
|
|
|
foreach (UserPickList.UserPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active && ui.Type != UserTypes.Utility && ui.Type != UserTypes.Client && ui.Type != UserTypes.HeadOffice)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
else if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "ScheduleableUserGroupPickList":
|
|
{
|
|
#region
|
|
ScheduleableUserGroupPickList UList = ScheduleableUserGroupPickList.GetList();
|
|
|
|
foreach (ScheduleableUserGroupPickList.ScheduleableUserGroupPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "ClientUnitList":
|
|
{
|
|
#region
|
|
UnitPickList UList = UnitPickList.GetListByClient(ID1);
|
|
GZTW.AyaNova.BLL.Global g = GlobalSettings;
|
|
|
|
foreach (UnitPickList.UnitPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
else if (SelectedIDList != null)
|
|
{
|
|
|
|
//is the current, inactive item selected in the workorder in any woitem?
|
|
foreach (Guid id in SelectedIDList)
|
|
{
|
|
if (id == ui.ID)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Now manually add items that are selected on the workorder but have changed owners and
|
|
//wouldn't have been picked up in the above
|
|
if (SelectedIDList != null)
|
|
{
|
|
foreach (Guid id in SelectedIDList)
|
|
{
|
|
if (!UList.Contains(id))
|
|
{
|
|
//manually add it, it's selected on the wo, but
|
|
//it's not in the client unit pick list
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + UnitNameFetcher.GetUnitNameFromUnitID(id) + " [" + GZTW.AyaNova.BLL.Unit.GetOwnerNameForUnit(id) + "]";
|
|
dr["Value"] = id;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PriorityPickList":
|
|
{
|
|
#region
|
|
PriorityPickList UList = PriorityPickList.GetList();
|
|
|
|
foreach (PriorityPickList.PriorityPickListInfo ui in UList)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dr["Color"] = ui.Color;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "TaxCodeList":
|
|
{
|
|
#region
|
|
TaxCodeList UList = TaxCodeList.GetList();
|
|
|
|
foreach (TaxCodeList.TaxCodeListInfo ui in UList)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "LaborRateList":
|
|
{
|
|
#region
|
|
//ID1 contains a contract ID or guid.empty if no contract
|
|
//SelectedIDList contains an arraylist of selected ID's or is null
|
|
RatePickList rates;
|
|
if (ID1 == Guid.Empty)
|
|
rates = RatePickList.GetList(true);
|
|
else
|
|
rates = RatePickList.GetListWithContract(ID1);
|
|
|
|
foreach (RatePickList.RatePickListInfo ui in rates)
|
|
{
|
|
if (ui.RateType != RateTypes.Service) continue;
|
|
|
|
//Case 186
|
|
//Selectable and active are same thing with no contract
|
|
//with a contract then selectable is active and then if contract rates only is
|
|
//set accordingly
|
|
if (/*ui.Active*/ui.Selectable == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
//Case 186 currently there are no calls to this list that are not activeonly
|
|
//so just removed it since it would conflict with contract rates
|
|
System.Diagnostics.Debug.Assert(ActiveOnly, "Util::GetDataBiz - LaborRateList called with !ActiveOnly");
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "TravelRateList":
|
|
{
|
|
#region
|
|
//ID1 contains a contract ID or guid.empty if no contract
|
|
//SelectedIDList contains an arraylist of selected ID's or is null
|
|
RatePickList rates;
|
|
if (ID1 == Guid.Empty)
|
|
rates = RatePickList.GetList(true);
|
|
else
|
|
rates = RatePickList.GetListWithContract(ID1);
|
|
|
|
foreach (RatePickList.RatePickListInfo ui in rates)
|
|
{
|
|
if (ui.RateType != RateTypes.Travel) continue;
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartPickList":
|
|
{
|
|
#region
|
|
PartPickList UList = PartPickList.GetAllParts();
|
|
GZTW.AyaNova.BLL.Global g = GlobalSettings;
|
|
foreach (PartPickList.PartPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.DisplayName(g.DefaultPartDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.DisplayName(g.DefaultPartDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartWarehousePickList":
|
|
{
|
|
#region
|
|
//Case 640
|
|
PartWarehousePickList UList = PartWarehousePickList.GetActiveOnlyListWithExceptions(SelectedIDList);
|
|
|
|
foreach (PartWarehousePickList.PartWarehousePickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartSerialPickList":
|
|
{
|
|
#region
|
|
//ID1 contains part ID and ID2 contains warehouse ID (optional)
|
|
PartSerialPickList serialz;
|
|
serialz = PartSerialPickList.GetList(ID1, ID2);
|
|
|
|
|
|
foreach (PartSerialPickList.PartSerialPickListInfo ui in serialz)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.SerialNumber;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "PartSerialPickListForWorkorder":
|
|
{
|
|
#region
|
|
//special version to ensure no sn's appear in the list that are
|
|
//already selected on this workorder
|
|
PartSerialPickList serialz;
|
|
serialz = PartSerialPickList.GetList(ID1, ID2);
|
|
|
|
|
|
foreach (PartSerialPickList.PartSerialPickListInfo ui in serialz)
|
|
{
|
|
//Ensure that we're only adding serials that are not
|
|
//already selected on teh workorder
|
|
if (!SelectedIDList.Contains(ui.ID))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.SerialNumber;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "LoanItemPickList":
|
|
{
|
|
#region
|
|
LoanItemPickList UList = LoanItemPickList.GetList(true);
|
|
|
|
foreach (LoanItemPickList.LoanItemPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name + " " + ui.Serial;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name + " " + ui.Serial;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "UnitList":
|
|
{
|
|
#region
|
|
UnitPickList UList = UnitPickList.GetListOfAll();
|
|
GZTW.AyaNova.BLL.Global g = GlobalSettings;
|
|
|
|
foreach (UnitPickList.UnitPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.UnitName(g.DefaultUnitNameDisplayFormat);
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
|
|
case "UnitModelList":
|
|
{
|
|
#region
|
|
UnitModelPickList UList = UnitModelPickList.GetList();
|
|
|
|
foreach (UnitModelPickList.UnitModelPickListInfo ui in UList)
|
|
{
|
|
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID || !ActiveOnly))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "Vendors:Shipper":
|
|
{
|
|
#region
|
|
VendorPickList UList = VendorPickList.GetList(VendorTypes.Shipper);
|
|
|
|
foreach (VendorPickList.VendorPickListInfo ui in UList)
|
|
{
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "Vendors:NonShipper":
|
|
{
|
|
#region
|
|
VendorPickList UList = VendorPickList.GetList();
|
|
|
|
foreach (VendorPickList.VendorPickListInfo ui in UList)
|
|
{
|
|
if (ui.VendorType != VendorTypes.Shipper)
|
|
{
|
|
if (ui.Active)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
if (ui.ID == SelectedID || !ActiveOnly)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
//fogbugz case 11
|
|
case "WorkorderStatusList":
|
|
{
|
|
#region
|
|
WorkorderStatusPickList statuses = WorkorderStatusPickList.GetList();
|
|
|
|
|
|
foreach (WorkorderStatusPickList.WorkorderStatusPickListInfo ui in statuses)
|
|
{
|
|
|
|
if (ui.Active == true)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
else
|
|
{
|
|
|
|
if ((SelectedIDList != null && SelectedIDList.Contains(ui.ID))
|
|
|| (ui.ID == SelectedID /*|| !ActiveOnly*/))
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + ui.Name;
|
|
dr["Value"] = ui.ID;
|
|
dt.Rows.Add(dr);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
default://generic list PickList contains biz object name
|
|
{
|
|
#region
|
|
GenericNVList l = GenericNVList.GetList("a" + PickList, "aID", "aName", true, ActiveOnly, Regional);
|
|
|
|
//ensure that non-active record
|
|
//still appears in list
|
|
bool bSelectedRecordIsInList = false;
|
|
|
|
|
|
foreach (DictionaryEntry d in l.BindableList)
|
|
{
|
|
|
|
Guid gValue = new Guid(d.Key.ToString());
|
|
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = d.Value.ToString();
|
|
dr["Value"] = gValue;
|
|
dt.Rows.Add(dr);
|
|
|
|
if (gValue == SelectedID)
|
|
bSelectedRecordIsInList = true;
|
|
|
|
}
|
|
|
|
if (ActiveOnly && SelectedID != Guid.Empty && !bSelectedRecordIsInList)
|
|
{
|
|
//retrieve manually non-active item
|
|
try
|
|
{
|
|
NameFetcher nf = NameFetcher.GetItem(PickList, "Name", SelectedID);
|
|
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = "*" + nf.RecordName;
|
|
dr["Value"] = SelectedID;
|
|
dt.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
}
|
|
|
|
dt.DefaultView.Sort = "Display";
|
|
return dt.DefaultView;
|
|
}
|
|
#endregion BizList
|
|
|
|
static private void AddNVRow(DataTable dt, object value, object display)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["Display"] = display.ToString();
|
|
dr["Value"] = value;
|
|
dt.Rows.Add(dr);
|
|
|
|
}
|
|
|
|
|
|
#endregion List retrievers
|
|
|
|
|
|
#region Parsers
|
|
|
|
public static Guid ParseGuid(object s)
|
|
{
|
|
if (!GuidSelected(s))
|
|
return Guid.Empty;
|
|
return new Guid(s.ToString());
|
|
|
|
}
|
|
|
|
public static decimal ParseDecimal(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
string sd="";
|
|
if (s is TextBox)
|
|
sd = ((TextBox)s).Text;
|
|
else
|
|
sd = s.ToString();
|
|
|
|
decimal d = 0;
|
|
//Case 512 - as part of fix for 512 discovered this method wasn't handling
|
|
//currency at all, wonder what else wasn't working before this?
|
|
if (!decimal.TryParse(sd, out d))
|
|
decimal.TryParse(sd,
|
|
NumberStyles.Currency,
|
|
System.Threading.Thread.CurrentThread.CurrentCulture, out d);
|
|
return d;
|
|
}
|
|
|
|
public static bool ParseBool(object s)
|
|
{
|
|
if (s == null) return false;
|
|
bool b = false;
|
|
bool.TryParse(s.ToString(), out b);
|
|
return b;
|
|
}
|
|
|
|
public static int ParseInt(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
int d = 0;
|
|
int.TryParse(s.ToString(), out d);
|
|
return d;
|
|
}
|
|
|
|
public static long ParseLong(object s)
|
|
{
|
|
if (s == null) return 0;
|
|
long d = 0;
|
|
long.TryParse(s.ToString(), out d);
|
|
return d;
|
|
}
|
|
|
|
|
|
//Attempts to parse a string based on current thread culture
|
|
//if that fails then tries the invariant culture (to catch US users who have accidentally
|
|
//set their web browser to some other language or international users
|
|
//browsing through a US site for the most part as it won't work
|
|
//for other circumstances, so supporting most common scenario)
|
|
//if it can't figure it out at all then it will return an empty dbnull date
|
|
//the ideal fix is of course to convert dates to the invariant culture when they are
|
|
//first entered into AyaNova in custom fields where this is mostly used
|
|
//
|
|
public static object ParseDateToDbValue(object s)
|
|
{
|
|
if (s == null) return System.DBNull.Value;
|
|
string sd = "";
|
|
if (s is TextBox)
|
|
{
|
|
sd = ((TextBox)s).Text;
|
|
}
|
|
else if (s is string)
|
|
sd = (string)s;
|
|
else
|
|
sd = s.ToString();
|
|
|
|
if (sd == "") return System.DBNull.Value;
|
|
|
|
DateTime dt = new DateTime();
|
|
if (!DateTime.TryParse(sd, out dt))
|
|
if (!DateTime.TryParse(sd, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat, System.Globalization.DateTimeStyles.None, out dt))
|
|
return System.DBNull.Value;
|
|
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// True if object contains a non empty guid
|
|
/// false if object is null or contains an empty guid
|
|
/// </summary>
|
|
/// <param name="s"></param>
|
|
/// <returns></returns>
|
|
public static bool GuidSelected(object s)
|
|
{
|
|
if (s == null || s.ToString()=="") return false;
|
|
Guid g = new Guid(s.ToString());
|
|
if (g == Guid.Empty) return false;
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// convert object to string, if null returns empty string
|
|
/// </summary>
|
|
/// <param name="o"></param>
|
|
/// <returns></returns>
|
|
public static string ObjectToString(object o)
|
|
{
|
|
if (o == null) return "";
|
|
return o.ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Security / set readonly
|
|
/// <summary>
|
|
/// Set the passed in control and all it's children as read only
|
|
/// </summary>
|
|
/// <param name="TheControl"></param>
|
|
public static void SetReadOnly(System.Web.UI.Control TheControl)
|
|
{
|
|
switch (TheControl.GetType().ToString())
|
|
{
|
|
|
|
|
|
case "System.Web.UI.WebControls.TextBox":
|
|
{
|
|
((TextBox)TheControl).Enabled = false;
|
|
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.CheckBox":
|
|
{
|
|
((CheckBox)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.Button":
|
|
{
|
|
((Button)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.LinkButton":
|
|
{
|
|
LinkButton lb = ((LinkButton)TheControl);
|
|
lb.Enabled = false;
|
|
if (lb.ID == "btnNew" || lb.ID == "btnNew2")
|
|
lb.Visible = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.ImageButton":
|
|
{
|
|
ImageButton lb = ((ImageButton)TheControl);
|
|
lb.Enabled = false;
|
|
if (lb.ID == "btnNew" || lb.ID == "btnNew2")
|
|
lb.Visible = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.RadioButtonList":
|
|
{
|
|
((RadioButtonList)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
case "System.Web.UI.WebControls.DropDownList"://case 1622
|
|
{
|
|
((DropDownList)TheControl).Enabled = false;
|
|
}
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//Now localize any child controls if contained in it
|
|
foreach (Control c in TheControl.Controls)
|
|
{
|
|
SetReadOnly(c);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
#endregion
|
|
//-------------------
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|