1652 lines
65 KiB
C#
1652 lines
65 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Collections;
|
|
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 System.Collections.Generic;
|
|
using Telerik.Web.UI;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
|
|
public partial class maingrid : BaseThemePage
|
|
{
|
|
private DropDownList cbTopControl
|
|
{
|
|
get
|
|
{
|
|
return (DropDownList)this.tbMain.Items.FindItemByValue("LIMIT").FindControl("cbTop");
|
|
}
|
|
}
|
|
|
|
private DropDownList cbFilterControl
|
|
{
|
|
get
|
|
{
|
|
return (DropDownList)this.tbMain.Items.FindItemByValue("FILTER").FindControl("cbFilters");
|
|
}
|
|
}
|
|
|
|
#region Load
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (RadAjaxManager1.IsAjaxRequest) return;
|
|
|
|
if (Util.CurrentUser.IsClientOrHeadOfficeAccount)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
|
|
//Localize the page
|
|
Util.Localize(Page);
|
|
if (AyaBizUtils.MRU.IsDirty)
|
|
AyaBizUtils.MRU.Save();
|
|
// AyaBizUtils.MRU = null;
|
|
if (!IsPostBack && !IsAjaxCallback)
|
|
{
|
|
//Add items localized for TopRows combo box
|
|
DropDownList top = cbTopControl;
|
|
top.Items.Add(new ListItem(Util.LocaleText("UI.Label.FirstRowsAll"), "-1"));
|
|
top.Items.Add(new ListItem(Util.LocaleText("UI.Label.FirstRows100"), "100"));
|
|
top.Items.Add(new ListItem(Util.LocaleText("UI.Label.FirstRows500"), "500"));
|
|
top.Items.Add(new ListItem(Util.LocaleText("UI.Label.FirstRows1000"), "1000"));
|
|
top.SelectedValue = "100";
|
|
//case 3275
|
|
if (AyaBizUtils.REGTO == "Condair")
|
|
top.SelectedValue = "1000";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private bool bRefreshGrid = false;
|
|
protected void Page_LoadComplete(object sender, EventArgs e)
|
|
{
|
|
//case 173 - will probably need to allow some of the stuff in this method
|
|
//to be called not on the first ajax request for the filter menu
|
|
//but on the second one if an item is selected in the ajax menu
|
|
//to rebuild the grid.
|
|
|
|
if (RadAjaxManager1.IsAjaxRequest && !bRefreshGrid) return;
|
|
bRefreshGrid = false;
|
|
PreparePage();
|
|
GenerateColumns();
|
|
Util.GridSetLayout(CurrentListKey, Grid);
|
|
Grid.DataSource = mCurrentDataSource;
|
|
Grid.DataBind();
|
|
|
|
//Set ctx context menu items for grid type
|
|
BuildListTypeContextMenu();
|
|
|
|
//Set hidden variable ctxRowOpts
|
|
SetGridColumnContextMenuOptions();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region Caching
|
|
|
|
private string mCurrentListKey = "";
|
|
private string CurrentListKey
|
|
{
|
|
get
|
|
{
|
|
if (mCurrentListKey == "")
|
|
{
|
|
mCurrentListKey = Request.QueryString["l"];
|
|
System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(mCurrentListKey));
|
|
}
|
|
|
|
return mCurrentListKey;
|
|
}
|
|
}
|
|
|
|
private RootObjectTypes mBaseObject = RootObjectTypes.Nothing;
|
|
private RootObjectTypes BaseObject
|
|
{
|
|
get
|
|
{
|
|
if (mBaseObject == RootObjectTypes.Nothing)
|
|
{
|
|
//this session cache is set by the get list object method below
|
|
mBaseObject = (RootObjectTypes)Session["ActiveObjectType"];
|
|
}
|
|
|
|
return mBaseObject;
|
|
}
|
|
set
|
|
{
|
|
Session["ActiveObjectType"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Return a cached displayattributes collection
|
|
/// for the object type passed in.
|
|
///
|
|
/// If not in application cache, adds
|
|
///
|
|
/// (this is static and global unchanging info)
|
|
/// </summary>
|
|
/// <param name="t">Type of read only collection object</param>
|
|
/// <returns></returns>
|
|
private Dictionary<string, DisplayAttribute> DisplayAttributes(Type t)
|
|
{
|
|
if (Cache["DispAttr_" + t.Name] == null)
|
|
Cache.Insert("DispAttr_" + t.Name, AyaBizUtils.GetDisplayAttributes(t),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromHours(2));
|
|
return (Dictionary<string, DisplayAttribute>)Cache["DispAttr_" + t.Name];
|
|
}
|
|
|
|
Dictionary<string, DisplayAttribute> currentDisplayAttributes;
|
|
|
|
|
|
//case 173
|
|
/// <summary>
|
|
/// Return a cached SqlColumnNameAttribute collection
|
|
/// for the object type passed in.
|
|
///
|
|
/// If not in application cache, adds
|
|
///
|
|
/// (this is static and global unchanging info)
|
|
/// </summary>
|
|
/// <param name="t">Type of read only collection object</param>
|
|
/// <returns></returns>
|
|
private Dictionary<string, SqlColumnNameAttribute> SqlColumnNameAttributes(Type t)
|
|
{
|
|
if (Cache["SQLColumnAttr_" + t.Name] == null)
|
|
Cache.Insert("SQLColumnAttr_" + t.Name, AyaBizUtils.GetSqlColumnNameAttributes(t),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromHours(2));
|
|
|
|
|
|
return (Dictionary<string, SqlColumnNameAttribute>)Cache["SQLColumnAttr_" + t.Name];
|
|
}
|
|
|
|
Dictionary<string, SqlColumnNameAttribute> currentSqlColumnNameAttributes;
|
|
|
|
|
|
|
|
string sCurrentViewXML = "";
|
|
//This is a temporary page load duration cache
|
|
//to hold the current list object data
|
|
//so that it can be prefetched at PreparePage method
|
|
//then used by grid.needdatasource without
|
|
//going directly to get method below twice
|
|
object mCurrentDataSource = null;
|
|
|
|
//This is set true when a user clicks on the refresh button in the toolbar
|
|
//and forces a requery of the database in GetListObject below
|
|
bool bUserSelectedForcedRefresh = false;
|
|
/// <summary>
|
|
/// Fetch the read only collection object based on the key passed in
|
|
///
|
|
/// </summary>
|
|
/// <param name="key"></param>
|
|
/// <returns></returns>
|
|
private void GetListObject()
|
|
{
|
|
|
|
bool Refresh;
|
|
string FilterXML;
|
|
|
|
DropDownList cbFilters = cbFilterControl;
|
|
|
|
if (CurrentListKey == "SearchResultList")
|
|
{
|
|
|
|
TextBox edSearch = (TextBox)tbMain.Items.FindItemByValue("EDSEARCH").FindControl("edSearch");
|
|
Refresh = false;
|
|
FilterXML = edSearch.Text;
|
|
}
|
|
else
|
|
{
|
|
UIUserGridLastView lv = lastViews[CurrentListKey];
|
|
|
|
Guid CurrentFilterID = new Guid(cbFilters.SelectedValue);
|
|
|
|
if (lv.FilterID != CurrentFilterID)
|
|
{
|
|
//The filter id has changed so provide the viewxml and force a refresh as appropriate
|
|
//In the winform app this is done by setting the grid filters then fetching them to pass to
|
|
//GetListObject, here since we currently won't set the grid filters we need to replicate
|
|
//the process entirely through xml and datasets
|
|
|
|
//Take the current lastview column order, combine it with the filter criteria then
|
|
//send on to getlistobject
|
|
|
|
//first record the selected filter id
|
|
lv.FilterID = CurrentFilterID;
|
|
|
|
//now munge together...
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
sb.Append("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?>\r\n");
|
|
sb.Append("<GRIDCRITERIA>\r\n");
|
|
|
|
//Sort order items...
|
|
DataTable SortTable = lv.ViewOrder;
|
|
foreach (DataRow ci in SortTable.Rows)
|
|
{
|
|
sb.Append("<COLUMNITEM ");
|
|
foreach (DataColumn dc in SortTable.Columns)
|
|
{
|
|
sb.Append(" ");
|
|
sb.Append(dc.ColumnName);
|
|
sb.Append(" =\"");
|
|
sb.Append(ci[dc].ToString());
|
|
sb.Append("\"");
|
|
}
|
|
sb.Append(" />\r\n");
|
|
|
|
}
|
|
|
|
//Filters
|
|
if (gridFilterList.Contains(CurrentFilterID))
|
|
{
|
|
DataTable FilterTable = gridFilterList[CurrentFilterID].ViewFilter;
|
|
foreach (DataRow GroupRow in FilterTable.Rows)
|
|
{
|
|
//It's possible that there is a group but no children in the case
|
|
//of certain types of criteria that we don't handle (regex etc) so check first
|
|
if (GroupRow.GetChildRows("WHEREITEMGROUP_WHEREITEM").GetLength(0) < 1)
|
|
continue;
|
|
|
|
sb.Append("<WHEREITEMGROUP ");
|
|
foreach (DataColumn groupcolumn in FilterTable.Columns)
|
|
{
|
|
sb.Append(" ");
|
|
sb.Append(groupcolumn.ColumnName);
|
|
sb.Append(" =\"");
|
|
sb.Append(GroupRow[groupcolumn].ToString());
|
|
sb.Append("\"");
|
|
}
|
|
sb.Append(" >\r\n");
|
|
|
|
foreach (DataRow ChildRow in GroupRow.GetChildRows("WHEREITEMGROUP_WHEREITEM"))
|
|
{
|
|
sb.Append("<WHEREITEM ");
|
|
|
|
|
|
foreach (DataColumn whereitemcolumn in ChildRow.Table.Columns)
|
|
{
|
|
sb.Append(" ");
|
|
sb.Append(whereitemcolumn.ColumnName);
|
|
sb.Append(" =\"");
|
|
sb.Append(ChildRow[whereitemcolumn].ToString());
|
|
sb.Append("\"");
|
|
}
|
|
sb.Append(" />\r\n");
|
|
}
|
|
|
|
sb.Append("</WHEREITEMGROUP>\r\n");
|
|
|
|
}
|
|
}
|
|
sb.Append("</GRIDCRITERIA>");
|
|
|
|
Refresh = true;
|
|
FilterXML = sb.ToString();
|
|
|
|
//store filter and column order in last view
|
|
lv.ViewXML = FilterXML;
|
|
|
|
}
|
|
else
|
|
{
|
|
Refresh = false;
|
|
FilterXML = lastViews[CurrentListKey].ViewXML;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//save the filter xml in case it's needed for the
|
|
//detailed report
|
|
sCurrentViewXML = FilterXML;
|
|
|
|
//put the list in the cache with a 20 minute sliding expiration
|
|
if (bUserSelectedForcedRefresh || Refresh || Cache["mg" + Util.CurrentUserID.ToString() + CurrentListKey] == null)
|
|
{
|
|
DropDownList top = cbTopControl;
|
|
Cache.Insert(Util.CurrentUserID.ToString() + "mg" + CurrentListKey, ListFactory.GetList(CurrentListKey, FilterXML, System.Convert.ToInt32(top.SelectedValue)),
|
|
null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20));
|
|
}
|
|
|
|
mCurrentDataSource = Cache[Util.CurrentUserID.ToString() + "mg" + CurrentListKey];
|
|
////Get the display attributes so they can be known before grid is bound
|
|
////to data source so that initializerow and other early events can
|
|
////use this info
|
|
currentDisplayAttributes = DisplayAttributes(mCurrentDataSource.GetType());
|
|
|
|
//case 173
|
|
currentSqlColumnNameAttributes = SqlColumnNameAttributes(mCurrentDataSource.GetType());
|
|
|
|
//Set the baseobject session key
|
|
//for this grid
|
|
BaseObject = (RootObjectTypes)AyaBizUtils.GetBizObjectStaticPropertyValue(mCurrentDataSource, "BaseObjectType");
|
|
|
|
//PreBindInitialize();
|
|
|
|
|
|
}
|
|
|
|
//case 173 - used when responding to an ajax filter request
|
|
private void GetListObjectLite()
|
|
{
|
|
mCurrentDataSource = Cache[Util.CurrentUserID.ToString() + "mg" + CurrentListKey];
|
|
////Get the display attributes so they can be known before grid is bound
|
|
////to data source so that initializerow and other early events can
|
|
////use this info
|
|
currentDisplayAttributes = DisplayAttributes(mCurrentDataSource.GetType());
|
|
|
|
//case 173
|
|
currentSqlColumnNameAttributes = SqlColumnNameAttributes(mCurrentDataSource.GetType());
|
|
}
|
|
|
|
|
|
//case 173
|
|
/// <summary>
|
|
/// Called when loading or when user customizes the filters in the grid
|
|
/// </summary>
|
|
private void cbFilterAddAndSelectUnsavedItem()
|
|
{
|
|
DropDownList cbFilters = cbFilterControl;
|
|
cbFilters.Items.Add(new ListItem(Util.LocaleText("UI.Label.FilterUnsaved"), GridFilter.UnsavedFilterID.ToString()));
|
|
cbFilters.SelectedValue = GridFilter.UnsavedFilterID.ToString();
|
|
|
|
}
|
|
|
|
|
|
//Intermediate cache of last views held for life of page preparation
|
|
//used to ease copying code from winform app
|
|
private UIUserGridLastViews mLastViews = null;
|
|
private UIUserGridLastViews lastViews
|
|
{
|
|
get
|
|
{
|
|
if (mLastViews == null)
|
|
mLastViews = Util.gGridLastViews;
|
|
|
|
return mLastViews;
|
|
}
|
|
}
|
|
|
|
//Intermediate cache held for life of page preparation
|
|
//used to ease copying code from winform app
|
|
private GridFilterPickList mgridFilterList = null;
|
|
|
|
private GridFilterPickList gridFilterList
|
|
{
|
|
get
|
|
{
|
|
if (mgridFilterList == null)
|
|
{
|
|
if (Cache["UserGridFilters" + Util.CurrentUserID.ToString()] == null)
|
|
{
|
|
mgridFilterList = GridFilterPickList.GetList(Util.CurrentUser);
|
|
|
|
Cache.Insert("UserGridFilters" + Util.CurrentUserID.ToString(),
|
|
mgridFilterList, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20));
|
|
}
|
|
else
|
|
{
|
|
mgridFilterList = (GridFilterPickList)Cache["UserGridFilters" + Util.CurrentUserID.ToString()];
|
|
|
|
}
|
|
}
|
|
|
|
return mgridFilterList;
|
|
}
|
|
}
|
|
#endregion caching
|
|
|
|
#region Page preparation
|
|
RootObjectTypes baseObject = RootObjectTypes.Nothing;
|
|
//string sCurrentListKey = "";
|
|
|
|
//case 173
|
|
//break out of grid related stuff from prepare page below
|
|
private void PrepareGrid()
|
|
{
|
|
//May not need this, keep here though in case
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called by page load to load selected list into grid
|
|
/// </summary>
|
|
/// <param name="listkey"></param>
|
|
private void PreparePage()
|
|
{
|
|
|
|
|
|
|
|
//If there is a current layout then save it?
|
|
//SaveGridLayout(false);
|
|
|
|
//SET MAX RESULTS AND LAST FILTER TO LAST USED VALUE HERE
|
|
|
|
bool bFilterable = true;
|
|
if (CurrentListKey == "SearchResultList")
|
|
bFilterable = false;
|
|
if (bFilterable)
|
|
{
|
|
//This line essentially turns off row filtering by the grid so that the
|
|
//queries can handle it instead
|
|
// Grid.DisplayLayout.Override.RowFilterAction = RowFilterAction.AppearancesOnly;
|
|
|
|
//Load the list of filters into the combo and select the last filter
|
|
//that was in use, if it's not in the list then unsaved will be selected
|
|
LoadFilterList(lastViews[CurrentListKey].FilterID);
|
|
|
|
//LoadFilterList(Util.gGridLastViews[sCurrentListKey].FilterID);
|
|
|
|
this.tbMain.Items.FindItemByValue("FILTER").Visible = true;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//This line essentially turns on row filtering by the grid so that
|
|
//unfilterable lists can be filtered in the grid itself
|
|
//Grid.DisplayLayout.Override.RowFilterAction = RowFilterAction.DisableFilteredOutRows;
|
|
this.tbMain.Items.FindItemByValue("FILTER").Visible = false;
|
|
}
|
|
|
|
|
|
|
|
|
|
//Two of the lists require row selectors (quotes and pm's) so
|
|
//disable by default for the others and those items can enable below if required
|
|
|
|
//case 724, case 725
|
|
// Grid.DisplayLayout.RowSelectorsDefault = RowSelectors.No;
|
|
//the above code is from the winform app there is a way to show a selection icon but
|
|
//it's a bit convoluted: http://www.telerik.com/help/aspnet-ajax/grdshowindicatorforselecteditems.html
|
|
|
|
//INVENTORY: special handling for inventory form which is the only hiearchical form
|
|
//and requires row selectors to show the expansion indicators for serial numbers
|
|
|
|
if (CurrentListKey == "PartWarehouseInventoryList")
|
|
{
|
|
Grid.ClientSettings.AllowExpandCollapse = true;
|
|
}
|
|
else
|
|
{
|
|
|
|
Grid.ClientSettings.AllowExpandCollapse = false;
|
|
}
|
|
|
|
//SEARCH: special settings
|
|
if (CurrentListKey == "SearchResultList")
|
|
{
|
|
Grid.AllowSorting = true;
|
|
this.tbMain.Items.FindItemByValue("SEARCH").Visible = true;
|
|
this.tbMain.Items.FindItemByValue("EDSEARCH").Visible = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
Grid.AllowSorting = false;
|
|
this.tbMain.Items.FindItemByValue("SEARCH").Visible = false;
|
|
this.tbMain.Items.FindItemByValue("EDSEARCH").Visible = false;
|
|
}
|
|
|
|
//REPORTLIST: special settings
|
|
if (CurrentListKey == "ReportList")
|
|
{
|
|
this.tbMain.Items.FindItemByValue("IMPORTLAYOUT").Visible = false;//case 757 not a feature
|
|
|
|
}
|
|
else
|
|
{
|
|
this.tbMain.Items.FindItemByValue("IMPORTLAYOUT").Visible = false;
|
|
}
|
|
|
|
//QuoteList: special settings
|
|
if (CurrentListKey == "WorkorderQuoteList" && AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
//Grid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;
|
|
this.tbMain.Items.FindItemByValue("QUOTEGENWO").Visible = true;//case 724 - now a feature
|
|
}
|
|
else
|
|
{
|
|
this.tbMain.Items.FindItemByValue("QUOTEGENWO").Visible = false;
|
|
}
|
|
|
|
//PMList: special settings
|
|
if (CurrentListKey == "WorkorderPMList" && AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
//Grid.DisplayLayout.RowSelectorsDefault = RowSelectors.Yes;
|
|
this.tbMain.Items.FindItemByValue("PMGENWO").Visible = true;//case 725 - now a feature
|
|
|
|
}
|
|
else
|
|
{
|
|
this.tbMain.Items.FindItemByValue("PMGENWO").Visible = false;
|
|
}
|
|
|
|
//Populate mCurrentDataSource with the list object data
|
|
//based on filter etc
|
|
GetListObject();
|
|
|
|
|
|
//initialize report list
|
|
|
|
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
this.tbMain.Items.FindItemByValue("PRINT").Visible = false;
|
|
|
|
}
|
|
else
|
|
{
|
|
this.tbMain.Items.FindItemByValue("PRINT").Visible = true;
|
|
|
|
|
|
Util.ReportFillList(this.tbMain.Items.FindItemByValue("PRINT"),
|
|
System.Convert.ToString(AyaBizUtils.GetBizObjectStaticPropertyValue(mCurrentDataSource, "ReportKey")),
|
|
System.Convert.ToString(AyaBizUtils.GetBizObjectStaticPropertyValue(mCurrentDataSource, "DetailedReportKey")));
|
|
}
|
|
|
|
//case 535 Initialize MRU list
|
|
Util.MRUFillList(this.tbMain.Items.FindItemByValue("MNUMRU"));
|
|
|
|
baseObject = (RootObjectTypes)AyaBizUtils.GetBizObjectStaticPropertyValue(mCurrentDataSource, "BaseObjectType");
|
|
|
|
//case 743
|
|
switch (BaseObject)
|
|
{
|
|
case RootObjectTypes.WorkorderItemPartRequest:
|
|
case RootObjectTypes.ClientServiceRequest:
|
|
case RootObjectTypes.PurchaseOrder:
|
|
case RootObjectTypes.PurchaseOrderReceiptItem:
|
|
case RootObjectTypes.Part:
|
|
case RootObjectTypes.Contract:
|
|
case RootObjectTypes.Vendor:
|
|
case RootObjectTypes.User:
|
|
case RootObjectTypes.PartInventoryAdjustment:
|
|
this.tbMain.Items.FindItemByValue("NEW").Visible = false;
|
|
break;
|
|
default:
|
|
this.tbMain.Items.FindItemByValue("NEW").Visible = AyaBizUtils.Right(baseObject) > (int)SecurityLevelTypes.ReadOnly;
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
//if (baseObject == RootObjectTypes.PurchaseOrderReceiptItem)
|
|
//{
|
|
// //poreceiptitem uses the rights from purchase order
|
|
// this.tbMain.Items.FindItemByValue("NEW").Visible =
|
|
// AyaBizUtils.Right(RootObjectTypes.PurchaseOrder) > (int)SecurityLevelTypes.ReadOnly;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.tbMain.Items.FindItemByValue("NEW").Visible =
|
|
// CurrentListKey != "ClientServiceRequestList" && AyaBizUtils.Right(baseObject) > (int)SecurityLevelTypes.ReadOnly;
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#region load filter list
|
|
/// <summary>
|
|
/// Load the filter list based on the current gridlist
|
|
/// </summary>
|
|
private void LoadFilterList(Guid SelectedItem)
|
|
{
|
|
DropDownList cbFilters = cbFilterControl;
|
|
|
|
if (!string.IsNullOrEmpty(cbFilters.SelectedValue))
|
|
SelectedItem = new Guid(cbFilters.SelectedValue);
|
|
|
|
cbFilters.Items.Clear();
|
|
|
|
|
|
bool bFilterSelected = false;
|
|
|
|
//Default ID value when first opened
|
|
//and selected by user to clear all filters from grid in one go
|
|
cbFilters.Items.Add(new ListItem(Util.LocaleText("UI.Label.FilterNone"), GridFilter.NoFilterID.ToString()));
|
|
|
|
//special case when no filter was selected
|
|
//this is required so that no filter setting "sticks" otherwise it's erased each load and
|
|
//last filter ID is used instead
|
|
if (SelectedItem == GridFilter.NoFilterID)
|
|
{
|
|
cbFilters.SelectedValue = GridFilter.NoFilterID.ToString();
|
|
bFilterSelected = true;
|
|
}
|
|
|
|
foreach (KeyValuePair<string, Guid> kvp in gridFilterList.GetListOfGridKey(CurrentListKey))
|
|
{
|
|
cbFilters.Items.Add(new ListItem(kvp.Key, kvp.Value.ToString()));
|
|
if (kvp.Value == SelectedItem)
|
|
{
|
|
cbFilters.SelectedValue = kvp.Value.ToString();
|
|
bFilterSelected = true;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* <telerik:RadMenuItem ID="mnuSaveFilter" Value="SAVEFILTER" runat="server">
|
|
<ItemTemplate>
|
|
<asp:ImageButton ID="btnSaveFilter" ImageUrl="~/graphics/SaveExit24.png" runat="server" />
|
|
</ItemTemplate>
|
|
</telerik:RadMenuItem>
|
|
* */
|
|
// this.tbMain.Items.FindItemByValue("SAVEFILTER").Visible = false;
|
|
|
|
|
|
//If no match was found in the list then set a default in the combo
|
|
if (!bFilterSelected)
|
|
{
|
|
//case 173
|
|
if (lastViews[CurrentListKey].HasFilter)
|
|
{
|
|
cbFilterAddAndSelectUnsavedItem();
|
|
//this.tbMain.Items.FindItemByValue("SAVEFILTER").Visible = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//nothing set in last view to filtered, no matching filter id
|
|
//so set to none
|
|
cbFilters.SelectedValue = GridFilter.NoFilterID.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion load filter list
|
|
|
|
#endregion
|
|
|
|
#region Initialize columns
|
|
private void GenerateColumns()
|
|
{
|
|
Grid.MasterTableView.Columns.Clear();
|
|
//Grid.ClientSettings.Resizing.AllowColumnResize = true;
|
|
// Grid.ClientSettings.Resizing.ClipCellContentOnResize = true;
|
|
Grid.ClientSettings.Resizing.ResizeGridOnColumnResize = false;
|
|
|
|
|
|
//clear the color columns dictionary which
|
|
//will be filled in below and used by initializerow
|
|
colorColumns.Clear();
|
|
hasColoredColumns = false;
|
|
|
|
//loop through current display attributes generating columns
|
|
foreach (KeyValuePair<string, DisplayAttribute> kvp in currentDisplayAttributes)
|
|
{
|
|
|
|
//case 759 exceptions
|
|
if (kvp.Key == "LT_O_PurchaseOrderReceipt")
|
|
continue;
|
|
#region set display type
|
|
|
|
//case 1584
|
|
RootObjectTypes cmObjectType = kvp.Value.RootObjectType;
|
|
|
|
if (cmObjectType == RootObjectTypes.Workorder)
|
|
{
|
|
//whups, there is no workorder object so need to translate to proper object type
|
|
if ((BaseObject == RootObjectTypes.WorkorderService || BaseObject == RootObjectTypes.PurchaseOrderReceiptItem) && kvp.Key == "LT_O_Workorder")
|
|
{
|
|
cmObjectType = RootObjectTypes.WorkorderService;
|
|
}
|
|
else if (kvp.Key == "LT_UI_Label_LastWorkorder")
|
|
{
|
|
cmObjectType = RootObjectTypes.WorkorderService;
|
|
}
|
|
else
|
|
cmObjectType = BaseObject;
|
|
|
|
}
|
|
|
|
|
|
//case 1279
|
|
if (AyaBizUtils.Right(cmObjectType) == (int)SecurityLevelTypes.NoAccess)
|
|
{
|
|
AddHiddenColumn(kvp.Key);
|
|
}
|
|
else
|
|
{
|
|
switch (kvp.Value.DisplayAs)
|
|
{
|
|
case DisplayType.Hidden:
|
|
AddHiddenColumn(kvp.Key);
|
|
break;
|
|
case DisplayType.Button:
|
|
if (!Util.ObjectCanOpenInWBI(kvp.Key))
|
|
AddBoundColumn(kvp.Key, "<nobr>{0}</nobr>");
|
|
else
|
|
AddButtonColumn(kvp.Key);
|
|
break;
|
|
case DisplayType.Currency:
|
|
AddBoundColumn(kvp.Key, "{0:c}");
|
|
break;
|
|
case DisplayType.DateTime:
|
|
AddBoundColumn(kvp.Key, "<nobr>{0:g}</nobr>");
|
|
break;
|
|
case DisplayType.DateOnly:
|
|
AddBoundColumn(kvp.Key, "{0:d}");
|
|
break;
|
|
case DisplayType.TrueFalse:
|
|
AddCheckBoxColumn(kvp.Key);
|
|
//Do nothing, underlying bool value will translate to checkbox automatically
|
|
//update: woops, no it doesn't need to add a bound checkbox column....
|
|
break;
|
|
case DisplayType.DecimalNumber:
|
|
AddBoundColumn(kvp.Key, "{0:g29}");
|
|
break;
|
|
case DisplayType.GeoCoordinate:
|
|
AddBoundColumn(kvp.Key, "<nobr>{0}</nobr>");
|
|
break;
|
|
case DisplayType.Percentage:
|
|
AddBoundColumn(kvp.Key, "{0:P}");
|
|
break;
|
|
case DisplayType.Text:
|
|
AddBoundColumn(kvp.Key, "<nobr>{0}</nobr>");
|
|
break;
|
|
case DisplayType.TimeOnly:
|
|
AddBoundColumn(kvp.Key, "{0:t}");
|
|
break;
|
|
case DisplayType.URL_Email:
|
|
AddHyperLinkColumn(kvp.Key);
|
|
break;
|
|
case DisplayType.URL_Web:
|
|
AddHyperLinkColumn(kvp.Key);
|
|
break;
|
|
case DisplayType.URL_Document:
|
|
AddHyperLinkColumn(kvp.Key);
|
|
break;
|
|
case DisplayType.WholeNumber:
|
|
AddBoundColumn(kvp.Key, null);
|
|
break;
|
|
case DisplayType.ListAyaDayOfWeek:
|
|
{
|
|
AddListItemColumn(kvp.Key, "DaysOfWeek", false);
|
|
}
|
|
break;
|
|
case DisplayType.ListAyaUnitsOfTime:
|
|
{
|
|
AddListItemColumn(kvp.Key, "UnitsOfTime", false);
|
|
}
|
|
break;
|
|
case DisplayType.ListPurchaseOrderStatus:
|
|
{
|
|
AddListItemColumn(kvp.Key, "PurchaseOrderStatus", false);
|
|
}
|
|
break;
|
|
case DisplayType.ListVendorTypes:
|
|
{
|
|
AddListItemColumn(kvp.Key, "VendorTypes", false);
|
|
}
|
|
break;
|
|
case DisplayType.ListUsers:
|
|
{
|
|
AddListItemColumn(kvp.Key, "UserPickList", true);
|
|
}
|
|
break;
|
|
case DisplayType.ListClientServiceRequestPriority:
|
|
{
|
|
AddListItemColumn(kvp.Key, "ClientServiceRequestPriority", false);
|
|
}
|
|
break;
|
|
case DisplayType.ListClientServiceRequestStatus:
|
|
{
|
|
AddListItemColumn(kvp.Key, "ClientServiceRequestStatus", false);
|
|
}
|
|
break;
|
|
|
|
|
|
case DisplayType.SpecialControl:
|
|
AddBoundColumn(kvp.Key, null);
|
|
break;
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
if (kvp.Value.Color)
|
|
{
|
|
hasColoredColumns = true;
|
|
colorColumns[kvp.Key] = kvp.Value.ColorField;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Add hidden column
|
|
private void AddHiddenColumn(string DataField)
|
|
{
|
|
GridBoundColumn b = new GridBoundColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.DataField = DataField;
|
|
b.UniqueName = DataField;
|
|
b.Display = false;
|
|
//b.ReadOnly = true;
|
|
//b.ForceExtractValue = GridForceExtractValues.Always;
|
|
|
|
// return b;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a templated text column to display
|
|
/// an item in databound for what would normally
|
|
/// be a valuelist in winform ayaNova,
|
|
/// here is a text box filled in on itemdatabound
|
|
/// </summary>
|
|
/// <param name="DataField"></param>
|
|
private void AddListItemColumn(string DataField, string ListName, bool Biz)
|
|
{
|
|
GridTemplateColumn b = new GridTemplateColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.ItemTemplate = new ListItemTemplate(DataField,ListName,Biz);
|
|
b.HeaderText = headertext(DataField);
|
|
b.UniqueName = DataField;
|
|
|
|
}
|
|
|
|
private GridCheckBoxColumn AddCheckBoxColumn(string DataField)
|
|
{
|
|
GridCheckBoxColumn b = new GridCheckBoxColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.UniqueName = DataField;
|
|
b.HeaderText = headertext(DataField);
|
|
b.DataField = DataField;
|
|
|
|
return b;
|
|
}
|
|
|
|
private GridHyperLinkColumn AddHyperLinkColumn(string DataField)
|
|
{
|
|
GridHyperLinkColumn b = new GridHyperLinkColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.UniqueName = DataField;
|
|
b.HeaderText = headertext(DataField);
|
|
string[] s=new string[1];
|
|
s[0]=DataField;
|
|
b.DataNavigateUrlFields = s;
|
|
return b;
|
|
}
|
|
|
|
private GridBoundColumn AddBoundColumn(string DataField, string FormatString)
|
|
{
|
|
GridBoundColumn b = new GridBoundColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.HeaderText = headertext(DataField);
|
|
b.DataField = DataField;
|
|
b.UniqueName = DataField;
|
|
if(!string.IsNullOrEmpty(FormatString))
|
|
b.DataFormatString = FormatString;
|
|
b.ReadOnly=true;
|
|
b.ForceExtractValue = GridForceExtractValues.Always;
|
|
|
|
return b;
|
|
}
|
|
|
|
private GridHyperLinkColumn AddButtonColumn(string DataField)
|
|
{
|
|
GridHyperLinkColumn b = new GridHyperLinkColumn();
|
|
Grid.MasterTableView.Columns.Add(b);
|
|
b.HeaderText = headertext(DataField);
|
|
string[] s = new string[1];
|
|
s[0] = DataField;
|
|
b.DataNavigateUrlFields = s;
|
|
b.UniqueName = DataField;
|
|
|
|
b.Text = "GNV";
|
|
|
|
return b;
|
|
|
|
//GridButtonColumn b = new GridButtonColumn();
|
|
//b.HeaderText = headertext(DataField);
|
|
//b.ButtonType = GridButtonColumnType.PushButton;
|
|
//b.DataTextField = DataField;
|
|
//return b;
|
|
}
|
|
|
|
|
|
private string headertext(string DataField)
|
|
{
|
|
if (DataField.StartsWith("LT_"))
|
|
return Util.LocaleText(DataField.Replace("LT_", "").Replace("_", "."));
|
|
else
|
|
return DataField;
|
|
}
|
|
|
|
|
|
protected void Grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
|
|
{
|
|
|
|
//Grid.DataSource = mCurrentDataSource;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// A shortcut for initialize row to know if there is any color to deal with
|
|
/// </summary>
|
|
private bool hasColoredColumns = false;
|
|
//A cache to hold the colored column key names and the column that sets their color
|
|
private Dictionary<string, string> colorColumns = new Dictionary<string, string>();
|
|
|
|
|
|
protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)
|
|
{
|
|
if (e.Item is GridDataItem)
|
|
{
|
|
|
|
GridDataItem dataItem = e.Item as GridDataItem;
|
|
|
|
//color?
|
|
if (hasColoredColumns)
|
|
{
|
|
foreach (KeyValuePair<string, string> kvp in colorColumns)
|
|
{
|
|
if (kvp.Value != "FIXED")
|
|
{
|
|
int nColor = Util.ParseInt(dataItem[kvp.Value].Text);
|
|
if (nColor != 0)
|
|
{
|
|
//dataItem[kvp.Key].BackColor = System.Drawing.Color.FromArgb(nColor);
|
|
dataItem[kvp.Key].BorderColor = System.Drawing.Color.FromArgb(nColor);
|
|
dataItem[kvp.Key].BorderWidth = System.Web.UI.WebControls.Unit.Pixel(2);
|
|
//dataItem[kvp.Key].ForeColor = Util.InvertColor(System.Drawing.Color.FromArgb(nColor));
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Color clr = new Color();
|
|
//It's a preset color that is not user configurable
|
|
switch (kvp.Key)
|
|
{
|
|
case "LT_ClientServiceRequest_Label_Priority":
|
|
{
|
|
ClientServiceRequestPriority p = (ClientServiceRequestPriority)DataBinder.GetPropertyValue(e.Item.DataItem, kvp.Key);
|
|
|
|
switch (p)
|
|
{
|
|
case ClientServiceRequestPriority.NotUrgent:
|
|
clr = Color.Green;
|
|
break;
|
|
case ClientServiceRequestPriority.ASAP:
|
|
clr = Color.Orange;
|
|
break;
|
|
case ClientServiceRequestPriority.Emergency:
|
|
clr = Color.Red;
|
|
break;
|
|
|
|
}
|
|
|
|
dataItem[kvp.Key].BackColor = clr;
|
|
dataItem[kvp.Key].ForeColor = Util.InvertColor(clr);
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
foreach (GridColumn gc in e.Item.OwnerTableView.Columns)
|
|
{
|
|
|
|
if (gc is GridHyperLinkColumn)
|
|
{
|
|
GridHyperLinkColumn h = gc as GridHyperLinkColumn;
|
|
|
|
if (h.Text == "GNV")
|
|
{
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
|
|
hl.NavigateUrl = "";
|
|
hl.Text = "";
|
|
|
|
//purportedly faster than reflection method below
|
|
//however can't get definitive answer, will have to test
|
|
//with large database
|
|
string sPropName = "";
|
|
if (h.DataNavigateUrlFields.Length > 0)
|
|
sPropName = h.DataNavigateUrlFields[0];
|
|
GridNameValueCellItem gnv = DataBinder.GetPropertyValue(e.Item.DataItem, sPropName) as GridNameValueCellItem;
|
|
// GridNameValueCellItem gnv = e.Item.DataItem.GetType().GetProperty(h.DataNavigateUrlField).GetValue(e.Item.DataItem, null) as GridNameValueCellItem;
|
|
|
|
if (gnv.Value != Guid.Empty)
|
|
{
|
|
//todo: temporary workaround for wokorder item types
|
|
//until workorder form modified to accept workorder item as the id value and object type passed in
|
|
if (gnv.RootObjectType == RootObjectTypes.WorkorderItem)
|
|
{
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" +
|
|
WorkorderIDFetcher.GetWorkorderByRelative(RootObjectTypes.WorkorderItem, gnv.Value).ToString();
|
|
|
|
}
|
|
else
|
|
{
|
|
//Case 521
|
|
//NOTE NOTE: all supported for editing object types must be listed here
|
|
//and have a corresponding xxxEdit.aspx page
|
|
//anything not listed here will get a unclickable hyperlink
|
|
switch (gnv.RootObjectType)
|
|
{
|
|
//Case 207 openable objects in WBI
|
|
//also change here needs to go into
|
|
//Util.ObjectCanOpenInWBI
|
|
case RootObjectTypes.Client:
|
|
case RootObjectTypes.ClientNote:
|
|
case RootObjectTypes.ClientServiceRequest:
|
|
case RootObjectTypes.HeadOffice:
|
|
case RootObjectTypes.LoanItem:
|
|
case RootObjectTypes.Memo:
|
|
case RootObjectTypes.Project:
|
|
case RootObjectTypes.ScheduleMarker:
|
|
case RootObjectTypes.ServiceBank:
|
|
case RootObjectTypes.Unit:
|
|
case RootObjectTypes.UnitModel:
|
|
case RootObjectTypes.Workorder:
|
|
case RootObjectTypes.Contract:
|
|
hl.NavigateUrl = gnv.RootObjectType.ToString() + "Edit.aspx?id=" + gnv.Value.ToString();
|
|
break;
|
|
//case 207 additions:
|
|
case RootObjectTypes.WorkorderQuote:
|
|
case RootObjectTypes.WorkorderPreventiveMaintenance:
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" + gnv.Value.ToString()+"&relative=" + ((int)gnv.RootObjectType).ToString();
|
|
|
|
break;
|
|
case RootObjectTypes.Part:
|
|
hl.NavigateUrl = "PartInventoryView.aspx?id=" + gnv.Value.ToString();
|
|
break;
|
|
//case 1417
|
|
case RootObjectTypes.WikiPage:
|
|
hl.NavigateUrl = "Wiki.aspx?id=" + gnv.Value.ToString();
|
|
break;
|
|
//case 1417
|
|
case RootObjectTypes.WorkorderItemLabor:
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" +
|
|
WorkorderIDFetcher.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor, gnv.Value).ToString();
|
|
break;
|
|
//case 1417
|
|
case RootObjectTypes.WorkorderItemTravel:
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" +
|
|
WorkorderIDFetcher.GetWorkorderByRelative(RootObjectTypes.WorkorderItemTravel, gnv.Value).ToString();
|
|
break;
|
|
//case 1699
|
|
case RootObjectTypes.WorkorderItemPartRequest:
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" +
|
|
WorkorderIDFetcher.GetWorkorderByRelative(RootObjectTypes.WorkorderItemPartRequest, gnv.Value).ToString();
|
|
break;
|
|
default:
|
|
hl.NavigateUrl = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
hl.Text = "<nobr>" + gnv.Display + "</nobr>";
|
|
hl.Target = "_blank";
|
|
}
|
|
}
|
|
else//This entire block Case 314
|
|
{
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
hl.Text = "<nobr>" + hl.NavigateUrl.Replace("http://","") + "</nobr>";
|
|
if (hl.NavigateUrl.Contains("@"))
|
|
{
|
|
if (!hl.NavigateUrl.StartsWith("mailto:"))
|
|
hl.NavigateUrl = "mailto:" + hl.NavigateUrl;
|
|
}
|
|
else
|
|
{
|
|
if (!hl.NavigateUrl.StartsWith("http://"))
|
|
hl.NavigateUrl = "http://" + hl.NavigateUrl;
|
|
}
|
|
hl.Target = "_blank";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion init data source
|
|
|
|
#region Toolbar items
|
|
|
|
protected void tbMain_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
|
{
|
|
|
|
|
|
if (e.Item.Value.StartsWith("PRINT"))
|
|
{
|
|
doPrint(e.Item.Value);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
if (e.Item.Value.StartsWith("MRU"))
|
|
{
|
|
TypeAndID tid = TypeAndID.Parse(e.Item.Value.Replace("MRU", ""));
|
|
Util.OpenEditWindow(this.Page, tid.RootObjectType, tid.ID);
|
|
return;
|
|
}
|
|
switch (e.Item.Value)
|
|
{
|
|
|
|
case "NEW":
|
|
{
|
|
#region
|
|
if (BaseObject == RootObjectTypes.WorkorderService ||
|
|
BaseObject == RootObjectTypes.WorkorderQuote ||
|
|
BaseObject == RootObjectTypes.WorkorderPreventiveMaintenance)
|
|
{
|
|
|
|
Response.Write("<script>window.open('WorkorderNew.aspx','_blank');</script>");
|
|
return;
|
|
|
|
}
|
|
else if (BaseObject == RootObjectTypes.Memo)
|
|
{
|
|
Memo m = Memo.NewItem();
|
|
Session.Add("memo" + m.ID.ToString(), m);
|
|
Response.Write("<script>window.open('MemoComposer.aspx?id=" + m.ID.ToString() + "','_blank');</script>");
|
|
return;
|
|
|
|
}
|
|
else if (BaseObject == RootObjectTypes.PurchaseOrderReceiptItem)
|
|
{
|
|
//PurchaseOrderReceiptSelectVendor psv = new PurchaseOrderReceiptSelectVendor();
|
|
//DialogResult dr = psv.ShowDialog();
|
|
//if (dr == DialogResult.Cancel || psv.SelectedVendor == Guid.Empty)
|
|
//{
|
|
// //Cancel
|
|
// return;
|
|
//}
|
|
|
|
////OK was selected so prompt for user to select open PO's for the vendor...
|
|
|
|
//PurchaseOrderReceiptSelectVendorsPurchaseOrders p = new PurchaseOrderReceiptSelectVendorsPurchaseOrders(psv.SelectedVendor);
|
|
//dr = p.ShowDialog();
|
|
//if (dr == DialogResult.Cancel)
|
|
//{
|
|
// //Cancel
|
|
// return;
|
|
//}
|
|
|
|
////Get settings
|
|
//DataSet ds = p.SelectedPurchaseOrders;
|
|
|
|
////start a new receipt object
|
|
//PurchaseOrderReceipt por = PurchaseOrderReceipt.NewItem();
|
|
////por.ReceivedDate=System.DateTime.Now;
|
|
//por.VendorID = psv.SelectedVendor;
|
|
|
|
////Add selected purchase order contents to receiving...
|
|
//foreach (DataRow r in ds.Tables[0].Rows)
|
|
//{
|
|
// por.AddContentsOfPurchaseOrder((Guid)r["PO"]);
|
|
|
|
//}
|
|
|
|
//PurchaseOrderReceiptInfoForm porForm = new PurchaseOrderReceiptInfoForm(false);
|
|
//porForm.PurchaseOrderReceiptToEdit = por;
|
|
//porForm.ShowDialog();
|
|
//porForm.Dispose();
|
|
//BindData(true);
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
string toUrl = BaseObject.ToString() + "Edit.aspx";
|
|
|
|
Response.Write("<script>window.open('" + toUrl + "','_blank');</script>");
|
|
return;
|
|
|
|
|
|
////Not a workorder so pass to edit record to handle
|
|
//if (Util.EditRecord(BaseObject, AyaBizUtils.NewObjectGuid) == true)
|
|
//{
|
|
|
|
// BindData(true);
|
|
//}
|
|
}
|
|
#endregion
|
|
}
|
|
break;
|
|
case "SERVICE":
|
|
{
|
|
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
|
//case 58
|
|
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.Service);
|
|
return;
|
|
}
|
|
|
|
case "QUOTE":
|
|
{
|
|
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
|
//case 58
|
|
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.Quote);
|
|
return;
|
|
}
|
|
|
|
case "PM":
|
|
{
|
|
TextBox t = (TextBox)tbMain.Items.FindItemByValue("OPENWO").FindControl("edOpenWoNumber");
|
|
//case 58
|
|
Util.DirectOpenWO(this.Page, t.Text, WorkorderTypes.PreventiveMaintenance);
|
|
return;
|
|
}
|
|
|
|
case "REFRESH":
|
|
{
|
|
//checked in GetListObject
|
|
bUserSelectedForcedRefresh = true;
|
|
|
|
}
|
|
break;
|
|
case "MNUWIKI":
|
|
{
|
|
//open global object wiki page
|
|
Util.OpenWikiPage(this.Page, new TypeAndID(RootObjectTypes.Global, Address.GlobalAddressID));
|
|
return;
|
|
}
|
|
case "QUOTEGENWO":
|
|
{
|
|
//case 724
|
|
//get id of quote selected
|
|
//generate service workorder
|
|
if (Grid.SelectedItems.Count > 0)
|
|
{
|
|
GetListObjectLite();
|
|
WorkorderQuoteList.WorkorderQuoteListInfo i = (WorkorderQuoteList.WorkorderQuoteListInfo)((IList)mCurrentDataSource)[Grid.SelectedItems[0].ItemIndex];
|
|
Workorder w=Workorder.NewServiceWorkorderFromQuote(i.LT_O_WorkorderQuote.Value);
|
|
w = (Workorder)w.Save();
|
|
Util.OpenEditWindow(this.Page, RootObjectTypes.Workorder, w.ID);
|
|
}
|
|
return;
|
|
}
|
|
case "PMGENWO":
|
|
{
|
|
//case 725
|
|
//get id of PM selected
|
|
//generate service workorder
|
|
if (Grid.SelectedItems.Count > 0)
|
|
{
|
|
GetListObjectLite();
|
|
WorkorderPMList.WorkorderPMListInfo i = (WorkorderPMList.WorkorderPMListInfo)((IList)mCurrentDataSource)[Grid.SelectedItems[0].ItemIndex];
|
|
if (i.LT_Common_Label_Active)
|
|
{
|
|
Workorder w = Workorder.NewServiceWorkorderFromPM(i.LT_O_WorkorderPreventiveMaintenance.Value);
|
|
w = (Workorder)w.Save();
|
|
Util.OpenEditWindow(this.Page, RootObjectTypes.Workorder, w.ID);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void doPrint(string report)
|
|
{
|
|
|
|
GetListObject();
|
|
|
|
string[] s = report.Split(',');
|
|
if (s[0] == "PRINTDETAILED")
|
|
{
|
|
//Detail report so need to fetch the data
|
|
string sReportKeyDetailed = System.Convert.ToString(AyaBizUtils.GetBizObjectStaticPropertyValue(mCurrentDataSource, "DetailedReportKey"));
|
|
DropDownList top = cbTopControl;
|
|
Util.Report(this.Page, s[1], "mg" + sReportKeyDetailed, ListFactory.GetList(sReportKeyDetailed, sCurrentViewXML, System.Convert.ToInt32(top.SelectedValue)));
|
|
|
|
}
|
|
else
|
|
{
|
|
//It's a summary report, just re-use the same datasource that was last bound to the grid
|
|
Util.Report(Page, s[1], "mg" + CurrentListKey, null);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
#endregion tbar
|
|
|
|
#region Filtering
|
|
protected void Grid_ItemCreated(object sender, GridItemEventArgs e)
|
|
{
|
|
|
|
if (e.Item is GridHeaderItem)
|
|
{
|
|
GridHeaderItem gh = e.Item as GridHeaderItem;
|
|
if (gh == null) return;
|
|
|
|
//get the lastview for the filter criteria
|
|
UIUserGridLastView lv = lastViews[CurrentListKey];
|
|
|
|
//case 1418
|
|
if (lv.GridKey == "SearchResultList") return;
|
|
|
|
if(currentSqlColumnNameAttributes==null)
|
|
GetListObjectLite();
|
|
|
|
|
|
foreach (GridColumn gc in Grid.MasterTableView.Columns)
|
|
{
|
|
//check if filterable at all
|
|
SqlColumnNameAttribute sa = currentSqlColumnNameAttributes[gc.UniqueName];
|
|
if (sa != null && sa.SqlColumnName == "grid") continue;
|
|
|
|
//Don't allow filter on Custom fields
|
|
if ((gc.UniqueName.IndexOf("_Label_Custom")) != -1 && (gc.UniqueName.IndexOf("Customer") == -1))
|
|
continue;
|
|
|
|
System.Web.UI.WebControls.Image i = new System.Web.UI.WebControls.Image();
|
|
i.ImageUrl = "~/graphics/FilterNot.png";
|
|
|
|
//Here we need to see if the column already has a filter for it
|
|
//and display a different image (blue filter) than if it isn't already
|
|
//filtered (gray image)
|
|
if (lv.HasFilter)
|
|
{
|
|
//see if the current column is filtered
|
|
if (lv.IsFiltered(gc.UniqueName))
|
|
{
|
|
i.ImageUrl = "~/graphics/Filtered.png";
|
|
|
|
}
|
|
}
|
|
|
|
//sample image.Attributes("onclick") = "showMenu(" & (column.OrderIndex - 2) & ", event)"
|
|
//mine i.Attributes.Add("onclick", "showMenu('" + gc.UniqueName + "', event)");
|
|
i.Attributes.Add("onclick", "showMenu('" + gc.UniqueName + "', event)");
|
|
gh[gc.UniqueName].Controls.Add(i);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Build filter menu
|
|
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
|
|
{
|
|
//Get the column name clicked on
|
|
string columnname = e.Argument.Split(':')[1];
|
|
|
|
//clear out and set up the popup context menu
|
|
RadMenu1.Items.Clear();
|
|
|
|
RadMenu1.DefaultGroupSettings.Flow = ItemFlow.Vertical;
|
|
|
|
|
|
//RadMenu1.Flow = ItemFlow.Vertical;
|
|
//RadMenu1.Height = System.Web.UI.WebControls.Unit.Pixel(300);
|
|
RadMenu1.CollapseAnimation.Type = AnimationType.None;
|
|
RadMenu1.CollapseAnimation.Duration = 0;
|
|
RadMenu1.ExpandAnimation.Type = AnimationType.None;
|
|
RadMenu1.ExpandAnimation.Duration = 0;
|
|
RadMenu1.ExpandDelay = 0;
|
|
|
|
//keep track of which column this is for
|
|
//so click event knows
|
|
RadMenu1.DataValueField = columnname;
|
|
|
|
#region Standard built in filter items
|
|
AddMenuItem(Util.LocaleText("UI.Grid.RowFilterDropDownAllItem"), "ALL");
|
|
AddMenuItem(Util.LocaleText("UI.Grid.RowFilterDropDownBlanksItem"), "BLANK");
|
|
//down the road this will go here:
|
|
// AddMenuItem(Util.LocaleText("UI.Grid.RowFilterDropDownCustomItem"), "UI.Grid.RowFilterDropDownCustomItem");
|
|
AddMenuItem( Util.LocaleText("UI.Grid.RowFilterDropDownNonBlanksItem"),"NONBLANK");
|
|
|
|
#endregion standard filter items
|
|
|
|
#region Specialty built in filters based on data type
|
|
//based on data type of column insert custom filters here
|
|
|
|
//check display attributes to see if it's a special case for filtering
|
|
CompareType ct = currentDisplayAttributes[columnname].CompareAs;
|
|
|
|
//Get data type of column
|
|
Type t = GridFilterHelper.GetColumnDataType(columnname, mCurrentDataSource.GetType());
|
|
if (t == null)
|
|
throw new System.ApplicationException("Maingrid->FilterMenuBuilder: call to GridFilterHelper.GetcolumnDataType(" + columnname + ", " + mCurrentDataSource.GetType().ToString() + ") failed to determine column type");
|
|
//load appropriate filters
|
|
//Replicated from winform app Util class SetCustomFilters method
|
|
if (ct!= CompareType.StringToInt32 && (t == typeof(string) || t.ToString() == "GZTW.AyaNova.BLL.GridNameValueCellItem"))
|
|
{
|
|
AddMenuItem("[A - H]","AH");
|
|
AddMenuItem("[I - P]", "IP");
|
|
AddMenuItem("[Q - Z]", "QZ");
|
|
AddMenuItem("[0 - 3]", "03");
|
|
AddMenuItem("[4 - 6]", "46");
|
|
AddMenuItem("[7 - 9]", "79");
|
|
}
|
|
else if ((t == typeof(System.DateTime)) || (t == typeof(System.Object)))
|
|
{
|
|
AddMenuItem("["+Util.LocaleText("UI.Label.DateRange.Yesterday")+"]", "[YESTERDAY]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.Today") + "]", "[TODAY]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.Tomorrow") + "]", "[TOMORROW]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.LastWeek") + "]", "[LAST WEEK]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.ThisWeek") + "]", "[THIS WEEK]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.NextWeek") + "]", "[NEXT WEEK]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.LastMonth") + "]", "[LAST MONTH]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.ThisMonth") + "]", "[THIS MONTH]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.NextMonth") + "]", "[NEXT MONTH]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.14DayWindow") + "]", "[14DAYWINDOW]");
|
|
|
|
//case 2067 new items
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.Past") + "]", "[PAST]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.Future") + "]", "[FUTURE]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.LastYear") + "]", "[LASTYEAR]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.ThisYear") + "]", "[THISYEAR]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.InTheLastThreeMonths") + "]", "[INTHELAST3MONTHS]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.InTheLastSixMonths") + "]", "[INTHELAST6MONTHS]");
|
|
AddMenuItem("[" + Util.LocaleText("UI.Label.DateRange.InTheLastYear") + "]", "[INTHELASTYEAR]");
|
|
|
|
}
|
|
else if ((t == typeof(System.Decimal)) || (t == typeof(System.Int32)) || (t == typeof(System.Int64)))
|
|
{
|
|
AddMenuItem("[<0]", "<0");
|
|
AddMenuItem("[=0]", "=0");
|
|
AddMenuItem("[>0]", ">0");
|
|
}
|
|
|
|
#endregion custom filters
|
|
|
|
RadMenuItem mi = new RadMenuItem();
|
|
mi.IsSeparator=true;
|
|
RadMenu1.Items.Add(mi);
|
|
|
|
#region Column data filter items
|
|
//Fetch the values stored in the grid column
|
|
SortedDictionary<string, object> l = GridFilterHelper.GetUniqueColumnValues(columnname, mCurrentDataSource);
|
|
//sort the dictionary
|
|
foreach (KeyValuePair<string, object> kvp in l)
|
|
AddMenuItem(kvp.Key, "=");
|
|
|
|
|
|
#endregion column data items
|
|
|
|
|
|
//for (int x = 0; x < 100; x++)
|
|
// AddMenuItem("FAKE ITEM " + x.ToString(), "=");
|
|
|
|
//If the group settings height is set here and there are fewer than the number of items required
|
|
//for the scroll arrow to show (12 in my testing) then a phantom   shows at the bottom of the menu
|
|
//probably a bug of some kind in the component but this works
|
|
RadMenu1.DefaultGroupSettings.Height = System.Web.UI.WebControls.Unit.Empty;
|
|
|
|
if(RadMenu1.Items.Count>12)
|
|
RadMenu1.DefaultGroupSettings.Height = System.Web.UI.WebControls.Unit.Pixel(300);
|
|
|
|
//Tell the browser to open the context menu
|
|
ScriptManager.RegisterStartupScript(Page, typeof(Page), "displayMenu", "Sys.Application.add_load(displayMenu);", true);
|
|
}
|
|
|
|
//used by RadAjaxManager1_AjaxRequest above to add menu items
|
|
//for filter context menu
|
|
private void AddMenuItem(string text, string value)
|
|
{
|
|
RadMenuItem mi = new RadMenuItem();
|
|
mi.Text = text;
|
|
mi.Value = value;
|
|
if (value != "=")
|
|
mi.Font.Bold = true;
|
|
RadMenu1.Items.Add(mi);
|
|
}
|
|
|
|
//User choice from filter menu
|
|
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
|
|
{
|
|
|
|
//Need a black box approach
|
|
//the existing ayanova grid filtering system is highly tied into the infragistics model
|
|
//need to make a biz object level function that can take minimal info that is biz object only
|
|
//and create/modify a standard filter so that this code
|
|
//is not at all dependant on the type of grid so that in future we may be
|
|
//able to use it for other grids in windows or other interfaces and ditch infragistics
|
|
//as well as use it here
|
|
|
|
//to do this need the following:
|
|
|
|
// - Filter that was previously used for current grid display
|
|
UIUserGridLastView currentfilter = lastViews[CurrentListKey];
|
|
// - column sorted
|
|
RadContextMenu cm = (RadContextMenu)sender;
|
|
string columnname = cm.DataValueField;
|
|
|
|
// - criteria type custom or column value as a collection to support custom filters in future
|
|
// that will contain more than one criteria
|
|
|
|
//fetch the list object and attributes
|
|
if (currentSqlColumnNameAttributes == null)
|
|
GetListObjectLite();
|
|
|
|
// - column data type
|
|
Type columndatatype = GridFilterHelper.GetColumnDataType(columnname, mCurrentDataSource.GetType());
|
|
if (columndatatype == null)
|
|
throw new System.ApplicationException("Maingrid->FilterMenuBuilder: call to GridFilterHelper.GetcolumnDataType(" + columnname + ", " + mCurrentDataSource.GetType().ToString() + ") failed to determine column type");
|
|
|
|
//column object if it's not a builtin filter
|
|
|
|
|
|
// - custom filter attributes i.e. sql display and sort name
|
|
//will be null if there are no special attributes beyond the name itself
|
|
SqlColumnNameAttribute sa = currentSqlColumnNameAttributes[columnname];
|
|
|
|
//Get the column data list
|
|
SortedDictionary<string, object> l = GridFilterHelper.GetUniqueColumnValues(columnname, mCurrentDataSource);
|
|
|
|
GridFilterHelper.AyFilterItem afi;
|
|
//special case or straight filter off
|
|
//existing value
|
|
if (string.IsNullOrEmpty(e.Item.Value)) throw new System.ApplicationException("Maingrid->FilterMenuBuilder: e.item.value is empty");
|
|
|
|
if(e.Item.Value!="=")
|
|
{
|
|
//special case preset item, process accordingly
|
|
afi = new GridFilterHelper.AyFilterItem("~", e.Item.Value,null);
|
|
|
|
}
|
|
else
|
|
{
|
|
object compareobject=l[e.Item.Text];
|
|
afi = new GridFilterHelper.AyFilterItem("=", e.Item.Text,compareobject);
|
|
}
|
|
|
|
List<GridFilterHelper.AyFilterItem> filteritems = new List<GridFilterHelper.AyFilterItem>();
|
|
filteritems.Add(afi);
|
|
string newFilterXML = GridFilterHelper.UpdateSortFilterXML(currentfilter.ViewXML, columnname, filteritems,
|
|
columndatatype, sa);
|
|
|
|
currentfilter.ViewXML = newFilterXML;
|
|
|
|
//Added March 10 2009 without this the
|
|
//getlistobject code was causing the filter to be reset
|
|
//because it thought the user had made a new selection in the
|
|
//drop down presaved filters combo box
|
|
currentfilter.FilterID = GridFilter.UnsavedFilterID;
|
|
|
|
bRefreshGrid = true;
|
|
//finally, rebind the datasource
|
|
Grid.MasterTableView.Rebind();
|
|
//Now an unsaved filter
|
|
cbFilterAddAndSelectUnsavedItem();
|
|
|
|
}
|
|
|
|
#endregion filtering
|
|
|
|
#region Cell context menu
|
|
private void BuildListTypeContextMenu()
|
|
{
|
|
//StringBuilder sb = new StringBuilder();
|
|
//RadMenuItem r = null;
|
|
|
|
//r=new RadMenuItem();
|
|
//r.Text = "Test 1";
|
|
//r.Value = "t1";
|
|
////r.ImageUrl = "~/graphics/Delete24.png";
|
|
//ctx.Items.Add(r);
|
|
//switch (CurrentListKey)
|
|
//{
|
|
// case "WorkorderQuoteList":
|
|
// r = new RadMenuItem();
|
|
// r.Text = Util.LocaleText("WorkorderQuote.Label.GenerateServiceWorkorder");
|
|
// r.Value = "CONVERTQUOTE";
|
|
// r.ImageUrl = "~/graphics/Delete16.png";
|
|
// ctx.Items.Add(r);
|
|
// break;
|
|
|
|
//}
|
|
|
|
|
|
////test items
|
|
//r = new RadMenuItem();
|
|
//r.Text = "Test 2";
|
|
//r.Value = "t2";
|
|
//ctx.Items.Add(r);
|
|
}
|
|
|
|
private void SetGridColumnContextMenuOptions()
|
|
{
|
|
|
|
}
|
|
|
|
protected void ctx_ItemClick(object sender, RadMenuEventArgs e)
|
|
{
|
|
|
|
string ctxRow = Request.Form["ctxRow"];
|
|
string ctxClm = Request.Form["ctxClm"];
|
|
string ctxCommand = e.Item.Value;
|
|
|
|
}
|
|
#endregion row context
|
|
}
|