237 lines
7.9 KiB
C#
237 lines
7.9 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 Telerik.Web.UI;
|
|
|
|
public partial class ClientWorkorders : BaseThemePage
|
|
{
|
|
#region BizObject
|
|
public ClientWorkorderListEx mDataSource;
|
|
protected ClientWorkorderListEx DataSource
|
|
{
|
|
get
|
|
{
|
|
if (mDataSource != null) return mDataSource;
|
|
|
|
|
|
mDataSource = (ClientWorkorderListEx)Session["ClientWorkorderListEx"];
|
|
if (mDataSource == null)
|
|
{
|
|
try
|
|
{
|
|
//case 1262
|
|
CheckBox ckShowClosed = (CheckBox)mnu.Items.FindItemByValue("SHOWCLOSED").FindControl("ckShowClosed");
|
|
|
|
User u = Util.CurrentUser;
|
|
if (u.IsClientAccount)
|
|
mDataSource = ClientWorkorderListEx.GetListForClient(u.ClientID,ckShowClosed.Checked);
|
|
else if (u.IsHeadOfficeAccount)
|
|
{
|
|
DropDownList cl = (DropDownList)mnu.Items.FindItemByValue("CLIENT").FindControl("cbClients");
|
|
Guid selected = new Guid(cl.SelectedValue);
|
|
if (selected == Guid.Empty)
|
|
mDataSource = ClientWorkorderListEx.GetListForHeadOffice(u.HeadOfficeID, ckShowClosed.Checked);
|
|
else
|
|
mDataSource = ClientWorkorderListEx.GetListForClient(selected, ckShowClosed.Checked);
|
|
}
|
|
|
|
Session["ClientWorkorderListEx"] = mDataSource;
|
|
}
|
|
catch (System.Security.SecurityException)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
}
|
|
|
|
return mDataSource;
|
|
}
|
|
}
|
|
|
|
|
|
private void ResetDataSource()
|
|
{
|
|
mDataSource = null;
|
|
Session.Remove("ClientWorkorderListEx");
|
|
Grid.DataSource = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void Page_Init()
|
|
{
|
|
//case 1387
|
|
if (!Util.CurrentUser.IsClientOrHeadOfficeAccount || AyaBizUtils.Right("Object.WorkorderService") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
}
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
this.divError.Visible = false;
|
|
|
|
if (!IsPostBack && !IsAjaxCallback)
|
|
{
|
|
User u = Util.CurrentUser;
|
|
if (u.IsHeadOfficeAccount)
|
|
{
|
|
//Add items localized for TopRows combo box
|
|
DropDownList cl = (DropDownList)mnu.Items.FindItemByValue("CLIENT").FindControl("cbClients");
|
|
cl.Items.Add(new ListItem(Util.LocaleText("UI.Label.FilterNone"), Guid.Empty.ToString()));
|
|
ClientPickList cpl = ClientPickList.GetListForHeadOffice(u.HeadOfficeID);
|
|
foreach (ClientPickList.ClientPickListInfo i in cpl)
|
|
{
|
|
cl.Items.Add(new ListItem(i.Name, i.ID.ToString()));
|
|
}
|
|
|
|
cl.SelectedValue = Guid.Empty.ToString();
|
|
}
|
|
else
|
|
{
|
|
mnu.Items.FindItemByValue("CLIENT").Visible = false;
|
|
|
|
}
|
|
Util.Localize(this.Page);
|
|
Util.LocalizeGrid(Grid);
|
|
}
|
|
|
|
this.Title = Util.LocaleText("WorkorderService.Label.List");
|
|
|
|
//case 1169
|
|
if (Util.IntegrationData.ClientViewWorkorderWiki == false)
|
|
{
|
|
Grid.Columns.FindByUniqueName("LT_O_WikiPage").Visible = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
protected void Page_LoadComplete(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack && !IsAjaxCallback)
|
|
{
|
|
ResetDataSource();
|
|
Grid.Rebind();
|
|
}
|
|
}
|
|
|
|
protected void Grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
|
|
{
|
|
Grid.DataSource = DataSource;
|
|
|
|
}
|
|
|
|
|
|
protected void Grid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
|
|
{
|
|
if (e.Item is GridDataItem)
|
|
{
|
|
Guid id = ((ClientWorkorderListEx.ClientWorkorderListExInfo)e.Item.DataItem).ID;
|
|
GridDataItem dataItem = e.Item as GridDataItem;
|
|
|
|
//case 1169
|
|
bool bHasWiki = ((ClientWorkorderListEx.ClientWorkorderListExInfo)e.Item.DataItem).HasWikiPage;
|
|
|
|
if (id != Guid.Empty)
|
|
{
|
|
if (Util.IntegrationData.ClientWorkorderReportID != Guid.Empty)
|
|
{
|
|
GridColumn gc = e.Item.OwnerTableView.Columns.FindByUniqueName("LT_O_Workorder");
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
|
|
//Open report here
|
|
hl.NavigateUrl = "ClientWorkorderView.aspx?id=" + id.ToString();
|
|
|
|
hl.Target = "_blank";
|
|
}
|
|
|
|
//case 1169
|
|
if (Util.IntegrationData.ClientViewWorkorderWiki == true && bHasWiki)
|
|
{
|
|
|
|
GridColumn gc = e.Item.OwnerTableView.Columns.FindByUniqueName("LT_O_WikiPage");
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
hl.NavigateUrl = "Wiki.aspx" + TypeAndID.ToAyaURLQueryParameter(RootObjectTypes.WorkorderService, id);
|
|
hl.Target = "_blank";
|
|
hl.ImageUrl = "~/graphics/Wiki24.png";
|
|
hl.ToolTip = Util.LocaleText("O.WikiPage");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void mnu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
|
{
|
|
//switch (e.Item.Value)
|
|
//{
|
|
//case "NEW":
|
|
// {
|
|
|
|
// User u = Util.CurrentUser;
|
|
// Guid gclient = Guid.Empty;
|
|
// if (u.IsClientAccount)
|
|
// gclient=u.ClientID;
|
|
// else if (u.IsHeadOfficeAccount)
|
|
// {
|
|
// DropDownList cl = (DropDownList)mnu.Items.FindItemByValue("CLIENT").FindControl("cbClients");
|
|
// gclient = new Guid(cl.SelectedValue);
|
|
|
|
// }
|
|
|
|
// if (gclient == Guid.Empty)
|
|
// {
|
|
// this.divError.Visible = true;
|
|
// this.phErrors.Controls.Add(new LiteralControl("Select a client from the menu to proceed"));
|
|
// return;
|
|
|
|
// }
|
|
// else
|
|
// this.divError.Visible = false;
|
|
|
|
// string toUrl = "ClientWorkorderEdit.aspx?clientid=" + gclient.ToString();
|
|
// Response.Write("<script>\r\n");
|
|
// Response.Write("window.open('" + toUrl + "');");
|
|
// Response.Write("\r\n</script>");
|
|
// }
|
|
// break;
|
|
// }
|
|
|
|
}
|
|
|
|
//restrict filtering options
|
|
protected void Grid_Init(object sender, EventArgs e)
|
|
{
|
|
GridFilterMenu menu = Grid.FilterMenu;
|
|
RemoveFilterMenuItem(menu, "IsNull");
|
|
RemoveFilterMenuItem(menu, "NotIsNull");
|
|
RemoveFilterMenuItem(menu, "IsEmpty");
|
|
RemoveFilterMenuItem(menu, "NotIsEmpty");
|
|
RemoveFilterMenuItem(menu, "EqualTo");
|
|
RemoveFilterMenuItem(menu, "NotEqualTo");
|
|
}
|
|
|
|
private void RemoveFilterMenuItem(GridFilterMenu m, string remove)
|
|
{
|
|
RadMenuItem ri = m.Items.FindItemByText(remove);
|
|
if (ri != null)
|
|
m.Items.Remove(ri);
|
|
}
|
|
|
|
}
|