240 lines
8.0 KiB
C#
240 lines
8.0 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 ClientClientServiceRequests : BaseThemePage
|
|
{
|
|
#region BizObject
|
|
public ClientClientServiceRequestList mDataSource;
|
|
protected ClientClientServiceRequestList DataSource
|
|
{
|
|
get
|
|
{
|
|
if (mDataSource != null) return mDataSource;
|
|
|
|
|
|
mDataSource = (ClientClientServiceRequestList)Session["ClientClientServiceRequestList"];
|
|
if (mDataSource == null)
|
|
{
|
|
try
|
|
{
|
|
User u = Util.CurrentUser;
|
|
if (u.IsClientAccount)
|
|
mDataSource = ClientClientServiceRequestList.GetListForClient(u.ClientID);
|
|
else if (u.IsHeadOfficeAccount)
|
|
{
|
|
RadComboBox cl = (RadComboBox)mnu.Items.FindItemByValue("CLIENT").FindControl("cbClients");
|
|
Guid selected = new Guid(cl.SelectedValue);
|
|
if (selected == Guid.Empty)
|
|
mDataSource = ClientClientServiceRequestList.GetListForHeadOffice(u.HeadOfficeID);
|
|
else
|
|
mDataSource = ClientClientServiceRequestList.GetListForClient(selected);
|
|
}
|
|
|
|
Session["ClientClientServiceRequestList"] = mDataSource;
|
|
}
|
|
catch (System.Security.SecurityException)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
}
|
|
|
|
return mDataSource;
|
|
}
|
|
}
|
|
|
|
|
|
private void ResetDataSource()
|
|
{
|
|
mDataSource = null;
|
|
Session.Remove("ClientClientServiceRequestList");
|
|
Grid.DataSource = null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void Page_Init()
|
|
{
|
|
|
|
if (!Util.CurrentUser.IsClientOrHeadOfficeAccount || AyaBizUtils.Right("Object.ClientServiceRequest") < (int)SecurityLevelTypes.ReadOnly)//Less than read only instead of NoAccess to catch records where it's zero instead of 1
|
|
{
|
|
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
|
|
RadComboBox cl = (RadComboBox)mnu.Items.FindItemByValue("CLIENT").FindControl("cbClients");
|
|
cl.Items.Add(new RadComboBoxItem(Util.LocaleText("UI.Label.FilterNone"), Guid.Empty.ToString()));
|
|
ClientPickList cpl = ClientPickList.GetListForHeadOffice(u.HeadOfficeID);
|
|
|
|
|
|
foreach (ClientPickList.ClientPickListInfo i in cpl)
|
|
{
|
|
cl.Items.Add(new RadComboBoxItem(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("ClientServiceRequest.Label.List");
|
|
|
|
mnu.Items.FindItemByValue("NEW").Visible=AyaBizUtils.Right("Object.ClientServiceRequest") > (int)SecurityLevelTypes.ReadOnly;
|
|
//case 1670
|
|
mnu.Items.FindItemByValue("WO").Visible = AyaBizUtils.Right("Object.WorkorderService") > (int)SecurityLevelTypes.NoAccess;
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
{
|
|
//todo comment out whatever needs to be changed here
|
|
//see if the sort and filter works then fixup the href links here
|
|
|
|
if (e.Item is GridDataItem)
|
|
{
|
|
//GridNameValueCellItem gnv = ((ClientClientServiceRequestList.ClientClientServiceRequestListInfo)e.Item.DataItem).LT_O_ClientServiceRequest;
|
|
|
|
Guid id = ((ClientClientServiceRequestList.ClientClientServiceRequestListInfo)e.Item.DataItem).ID;
|
|
|
|
GridDataItem dataItem = e.Item as GridDataItem;
|
|
|
|
GridColumn gc = e.Item.OwnerTableView.Columns.FindByUniqueName("LT_O_ClientServiceRequest");
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
|
|
if (id != Guid.Empty)
|
|
{
|
|
|
|
hl.NavigateUrl = "ClientServiceRequestEdit.aspx?id=" + id.ToString();
|
|
|
|
hl.Target = "_blank";
|
|
}
|
|
|
|
|
|
|
|
id = ((ClientClientServiceRequestList.ClientClientServiceRequestListInfo)e.Item.DataItem).WorkorderID;
|
|
|
|
|
|
gc = e.Item.OwnerTableView.Columns.FindByUniqueName("LT_O_Workorder");
|
|
hl = dataItem[gc].Controls[0] as HyperLink;
|
|
|
|
if (id != Guid.Empty &&
|
|
Util.IntegrationData.ClientWorkorderReportID != Guid.Empty &&
|
|
AyaBizUtils.Right("Object.Report") > (int)SecurityLevelTypes.NoAccess)
|
|
{
|
|
//Open report here
|
|
hl.NavigateUrl = "ClientWorkorderView.aspx?id=" + id.ToString();
|
|
|
|
hl.Target = "_blank";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
{
|
|
RadComboBox cl = (RadComboBox)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 = "ClientServiceRequestEdit.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);
|
|
}
|
|
|
|
|
|
}
|