334 lines
11 KiB
C#
334 lines
11 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;
|
|
|
|
public partial class ClientServiceRequestEdit : BaseEditPage
|
|
{
|
|
#region BizObject
|
|
public ClientServiceRequest mClientServiceRequest;
|
|
protected ClientServiceRequest CurrentClientServiceRequest
|
|
{
|
|
get
|
|
{
|
|
if (mClientServiceRequest != null) return mClientServiceRequest;
|
|
|
|
string idstring = Request.QueryString["id"];
|
|
Guid oID = Guid.Empty;
|
|
if (!string.IsNullOrEmpty(idstring))
|
|
oID = new Guid(idstring);
|
|
|
|
|
|
|
|
|
|
mClientServiceRequest = (ClientServiceRequest)Session["ClientServiceRequest"];
|
|
//ensure if object in session is the same as the one requested
|
|
if (mClientServiceRequest == null || (oID != Guid.Empty && mClientServiceRequest.ID != oID))//Case 912
|
|
{
|
|
try
|
|
{
|
|
if (oID != Guid.Empty)
|
|
mClientServiceRequest = ClientServiceRequest.GetItem(oID);
|
|
else
|
|
{
|
|
//making a new one, do they have the rights to do that?
|
|
if (AyaBizUtils.Right("Object.ClientServiceRequest") < (int)SecurityLevelTypes.ReadWrite)
|
|
{
|
|
Util.Denied(Context);
|
|
|
|
}
|
|
|
|
string clientstring = Request.QueryString["clientid"];
|
|
Guid clientid = Guid.Empty;
|
|
if (!string.IsNullOrEmpty(clientstring))
|
|
clientid = new Guid(clientstring);
|
|
mClientServiceRequest = ClientServiceRequest.NewItem(clientid);
|
|
|
|
//case 1449
|
|
mClientServiceRequest.RequestedBy = System.Threading.Thread.CurrentPrincipal.Identity.Name;
|
|
}
|
|
|
|
Session["ClientServiceRequest"] = mClientServiceRequest;
|
|
}
|
|
catch (System.Security.SecurityException)
|
|
{
|
|
CloseMe();
|
|
}
|
|
}
|
|
|
|
return mClientServiceRequest;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region Page events
|
|
protected void Page_Init()
|
|
{
|
|
|
|
|
|
if ( AyaBizUtils.Right("Object.ClientServiceRequest") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack && !IsAjaxCallback)
|
|
{
|
|
|
|
//clear any remnants from prior session not removed
|
|
//due to improper close
|
|
Session.Remove("ClientServiceRequest");
|
|
|
|
//populate pickers
|
|
DataTable dt = Util.GetDataNonBiz("ClientServiceRequestPriority");
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
|
|
rbPriorities.Items.Add(new ListItem(dr[0].ToString(), dr[1].ToString()));
|
|
}
|
|
|
|
//Add to the "list" the existing one in case it's no longer for the same client
|
|
//or not visible, done in this convoluted way to fit in with system already in place
|
|
//for a workorder item unit combo
|
|
System.Collections.Generic.List<Guid> l = new System.Collections.Generic.List<Guid>();
|
|
if(CurrentClientServiceRequest.UnitID!=Guid.Empty)
|
|
l.Add(CurrentClientServiceRequest.UnitID);
|
|
Util.ComboPopulateBizList("ClientUnitList", cbUnit, true, this.CurrentClientServiceRequest.ClientID, l, null, false);
|
|
}
|
|
|
|
Page.Title = Util.LocaleText("O.ClientServiceRequest");
|
|
Util.Localize(this.Page);
|
|
|
|
}
|
|
|
|
protected void Page_LoadComplete(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
if (IsPostBack && CurrentClientServiceRequest.IsEditable)
|
|
GetData();
|
|
|
|
SetData();
|
|
|
|
if (!CurrentClientServiceRequest.IsEditable)
|
|
Util.SetReadOnly(this.Page);
|
|
else
|
|
{
|
|
if (!Util.CurrentUser.IsClientOrHeadOfficeAccount)
|
|
{
|
|
//it's a tech viewing so remove all editing ability and add or enable
|
|
//tech only menu items
|
|
Util.SetReadOnly(this.Page);
|
|
|
|
|
|
//case 1936
|
|
RadMenu1.Items.FindItemByValue("Reject").Visible = (CurrentClientServiceRequest.Status != ClientServiceRequestStatus.Declined);
|
|
|
|
RadMenu1.Items.FindItemByValue("AcceptToExisting").Visible = true;
|
|
RadMenu1.Items.FindItemByValue("AcceptToNew").Visible = true;
|
|
}
|
|
else
|
|
{
|
|
//client login should never see these
|
|
RadMenu1.Items.FindItemByValue("Reject").Visible = false;
|
|
RadMenu1.Items.FindItemByValue("AcceptToExisting").Visible = false;
|
|
RadMenu1.Items.FindItemByValue("AcceptToNew").Visible = false;
|
|
}
|
|
|
|
//Case 431
|
|
if (AyaBizUtils.Right("Object.ClientServiceRequest") < (int)SecurityLevelTypes.ReadWriteDelete)
|
|
RadMenu1.Items.FindItemByValue("Delete").Visible = false;
|
|
}
|
|
//Case 201 save then save and exit causes duplicate record
|
|
//so removed save option :)
|
|
RadMenu1.Items.FindItemByValue("Save").Visible = false;
|
|
}
|
|
#endregion
|
|
|
|
#region SetData
|
|
private void SetData()
|
|
{
|
|
ClientServiceRequest o = CurrentClientServiceRequest;
|
|
lblClient.Text = Util.LocaleText("O.Client") + ": " + Util.GetBizObjectName("Client", o.ClientID);
|
|
lblCreated.Text = Util.LocaleText("Common.Label.Created") + ": " + o.Created;
|
|
lblStatus.Text = Util.LocaleText("ClientServiceRequest.Label.Status") + ": " + Util.GetNonBizName("ClientServiceRequestStatus", (int)o.Status);
|
|
edTitle.Text = o.Title;
|
|
edRef.Text = o.ClientRef;
|
|
|
|
edRequestedBy.Text = o.RequestedBy;
|
|
//combo
|
|
|
|
cbUnit.SelectedValue = o.UnitID.ToString();
|
|
|
|
edDetails.Text = o.Details;
|
|
rbPriorities.SelectedValue = ((int)o.Priority).ToString();
|
|
|
|
litCSRInfoText.Text = Util.StringWebify(Util.IntegrationData.CSRInfoText);
|
|
}
|
|
#endregion
|
|
|
|
#region get Data
|
|
private void GetData()
|
|
{
|
|
ClientServiceRequest o = CurrentClientServiceRequest;
|
|
o.Title = edTitle.Text;
|
|
o.Details = edDetails.Text;
|
|
o.ClientRef = edRef.Text;
|
|
o.RequestedBy = edRequestedBy.Text;
|
|
o.UnitID = Util.ComboValue(cbUnit);
|
|
switch (rbPriorities.SelectedValue)
|
|
{
|
|
case "0":
|
|
o.Priority = ClientServiceRequestPriority.NotUrgent;
|
|
break;
|
|
case "1":
|
|
o.Priority = ClientServiceRequestPriority.ASAP;
|
|
break;
|
|
case "2":
|
|
o.Priority = ClientServiceRequestPriority.Emergency;
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Menu events
|
|
protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
|
{
|
|
|
|
switch (e.Item.Value)
|
|
{
|
|
case "Close":
|
|
CloseForm();
|
|
break;
|
|
case "Save":
|
|
SaveRecord();
|
|
break;
|
|
case "SaveClose":
|
|
if (SaveRecord())
|
|
{
|
|
|
|
CloseForm();
|
|
}
|
|
break;
|
|
case "Delete":
|
|
if (CurrentClientServiceRequest.IsEditable)
|
|
{
|
|
if (AyaBizUtils.Right("Object.ClientServiceRequest") < (int)SecurityLevelTypes.ReadWriteDelete)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
else
|
|
{
|
|
if (CurrentClientServiceRequest.IsNew)
|
|
{
|
|
|
|
CloseForm();
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
CurrentClientServiceRequest.Delete();
|
|
CurrentClientServiceRequest.Save();
|
|
|
|
CloseForm();
|
|
}
|
|
}
|
|
}
|
|
|
|
CloseForm();
|
|
break;
|
|
case "AcceptToNew": // ButtonTool
|
|
{
|
|
//Generate workorder
|
|
Workorder w = CurrentClientServiceRequest.AcceptToNewWorkorder();
|
|
Session.Remove("ClientServiceRequest");
|
|
Response.Redirect("WorkorderEdit.aspx?id=" + w.ID.ToString());
|
|
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
case "AcceptToExisting": // ButtonTool
|
|
{
|
|
Guid clientid = CurrentClientServiceRequest.ClientID;
|
|
////Keep in session as workorderselector needs it
|
|
//Session.Remove("ClientServiceRequest");
|
|
Response.Redirect("WorkorderSelector.aspx?id=" + clientid.ToString());
|
|
|
|
|
|
|
|
}
|
|
break;
|
|
|
|
case "Reject": // ButtonTool
|
|
CurrentClientServiceRequest.Reject();
|
|
|
|
CloseForm();
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
private bool SaveRecord()
|
|
{
|
|
GetData();
|
|
if (!CurrentClientServiceRequest.IsDirty) return true;
|
|
if (CurrentClientServiceRequest.IsSavable)
|
|
{
|
|
Session["ClientServiceRequest"] = mClientServiceRequest = (ClientServiceRequest)mClientServiceRequest.Save();//case 912
|
|
|
|
SetErrors("");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
|
|
SetErrors(mClientServiceRequest.BrokenRulesText);
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
private void CloseForm()
|
|
{
|
|
Session.Remove("ClientServiceRequest");
|
|
CloseMe();
|
|
}
|
|
|
|
public void SetErrors(string sErrors)
|
|
{
|
|
|
|
if (sErrors == "")
|
|
{
|
|
this.divError.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
|
|
this.divError.Visible = true;
|
|
this.phErrors.Controls.Add(new LiteralControl(Util.BrokenRuleCollectionLocalizer(sErrors).Replace("\r\n", "<br>")));
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|