200 lines
6.5 KiB
C#
200 lines
6.5 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;
|
|
|
|
|
|
/// <summary>
|
|
/// Added for Case 205
|
|
/// </summary>
|
|
public partial class ServiceBankEdit : BaseThemePage
|
|
{
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (Util.CurrentUser.IsClientOrHeadOfficeAccount ||
|
|
AyaBizUtils.Right("Object.ServiceBank") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
if (!IsPostBack && !IsAjaxCallback)
|
|
{
|
|
Util.GridInitEditable("ServiceBank", Grid, "ServiceBank");
|
|
}
|
|
|
|
if (!IsAjaxCallback)
|
|
{
|
|
//Localize the page
|
|
Util.Localize(this.Page);
|
|
this.Title = Util.LocaleText("O.ServiceBank") + " - " + Util.GetBizObjectName(((RootObjectTypes)int.Parse(Request.QueryString["type"].ToString())).ToString(),
|
|
new Guid(Request.QueryString["id"].ToString()));
|
|
|
|
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
|
|
mnu.Items[0].Visible = false;
|
|
else
|
|
Util.ReportFillList(mnu.Items[0], ServiceBankList.ReportKey, "");
|
|
|
|
}
|
|
}
|
|
|
|
#region Grid populate and edit
|
|
protected void Grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
|
|
{
|
|
Grid.DataSource = ServiceBankList.GetList((RootObjectTypes)int.Parse(Request.QueryString["type"].ToString()),
|
|
new Guid(Request.QueryString["id"].ToString()),
|
|
"");
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void Grid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
|
|
{
|
|
|
|
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
|
|
{
|
|
GridEditableItem edititem = (GridEditableItem)e.Item;
|
|
Util.Localize(edititem);
|
|
}
|
|
|
|
|
|
if (e.Item is GridDataItem)
|
|
{
|
|
GridNameValueCellItem gnv = ((ServiceBankList.ServiceBankListInfo)e.Item.DataItem).LT_ServiceBank_Label_SourceRootObjectType;
|
|
GridDataItem dataItem = e.Item as GridDataItem;
|
|
if (e.Item.IsInEditMode)
|
|
{
|
|
|
|
//RadComboBox cb = e.Item.FindControl("cbtitle") as Telerik.Web.UI.RadComboBox;
|
|
//Util.ComboPopulateBizList("ContactTitle", cb, false, null);
|
|
//cb.SelectedValue = selectedTitleID;
|
|
|
|
}
|
|
else
|
|
{
|
|
GridColumn gc = e.Item.OwnerTableView.Columns.FindByUniqueName("LT_ServiceBank_Label_SourceRootObjectType");
|
|
HyperLink hl = dataItem[gc].Controls[0] as HyperLink;
|
|
|
|
|
|
switch (gnv.RootObjectType)
|
|
{
|
|
case RootObjectTypes.WorkorderItemLabor:
|
|
{
|
|
Guid woid = WorkorderIDFetcher.GetWorkorderByRelative(RootObjectTypes.WorkorderItemLabor, gnv.Value);
|
|
hl.NavigateUrl = "WorkorderEdit.aspx?id=" + woid.ToString();
|
|
}
|
|
break;
|
|
case RootObjectTypes.ServiceBank:
|
|
{
|
|
//stub for future possibility of
|
|
//the link causing the correct record row to be highlighted (or something)
|
|
hl.NavigateUrl = "";
|
|
}
|
|
break;
|
|
|
|
}
|
|
hl.Text = gnv.Display;
|
|
hl.Target = "_blank";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void Grid_UpdateCommand(object source, GridCommandEventArgs e)
|
|
{
|
|
if (e.Item is GridEditFormItem)
|
|
{
|
|
|
|
GridEditFormItem editFormItem = e.Item as GridEditFormItem;
|
|
|
|
TextBox notes = editFormItem.FindControl("tbNotes") as TextBox;
|
|
TextBox currency = editFormItem.FindControl("tbCurrency") as TextBox;
|
|
TextBox hours = editFormItem.FindControl("tbHours") as TextBox;
|
|
TextBox incidents = editFormItem.FindControl("tbIncidents") as TextBox;
|
|
Telerik.Web.UI.RadDateTimePicker dp = editFormItem.FindControl("dtDate") as Telerik.Web.UI.RadDateTimePicker;
|
|
|
|
ServiceBank s = ServiceBank.NewItem();
|
|
s.AppliesToRootObjectID=new Guid(Request.QueryString["id"].ToString());
|
|
s.AppliesToRootObjectType=(RootObjectTypes)int.Parse(Request.QueryString["type"].ToString());
|
|
|
|
s.Currency = Util.ParseDecimal(currency.Text);
|
|
s.Incidents = Util.ParseDecimal(incidents.Text);
|
|
s.Hours = Util.ParseDecimal(hours.Text);
|
|
s.EffectiveDate = dp.DbSelectedDate;
|
|
s.Description = Util.ObjectToString(notes.Text);
|
|
if (s.IsSavable)
|
|
{
|
|
s.Save();
|
|
}
|
|
else
|
|
{
|
|
//TODO: display errors here, popup maybe or on the edit form itself
|
|
e.Canceled = true;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
protected void Grid_ItemCommand(object source, GridCommandEventArgs e)
|
|
{
|
|
if (e.CommandName == RadGrid.InitInsertCommandName)
|
|
{
|
|
e.Canceled = true;
|
|
e.Item.OwnerTableView.InsertItem();
|
|
|
|
|
|
GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
|
|
GridEditFormItem editFormItem = insertedItem as GridEditFormItem;
|
|
Telerik.Web.UI.RadDateTimePicker dp = editFormItem.FindControl("dtDate") as Telerik.Web.UI.RadDateTimePicker;
|
|
dp.DbSelectedDate = DBUtil.CurrentWorkingDateTime;//case 1163
|
|
|
|
//Util.Localize(editFormItem); Moved to item databound
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Menu items
|
|
protected void mnu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
|
{
|
|
if (e.Item.Value.StartsWith("PRINT"))
|
|
{
|
|
|
|
string[] s = e.Item.Value.Split(',');
|
|
Util.Report(Page, s[1], ServiceBankList.ReportKey,
|
|
ServiceBankList.GetList((RootObjectTypes)int.Parse(Request.QueryString["type"].ToString()),
|
|
new Guid(Request.QueryString["id"].ToString()),
|
|
""));
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|