296 lines
8.9 KiB
C#
296 lines
8.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 ClientNotesEdit : BaseEditPage
|
|
{
|
|
|
|
|
|
#region BizObject
|
|
public ClientNotes mClientNotes;
|
|
public Guid mClientID;
|
|
protected Guid CurrentClientID
|
|
{
|
|
get
|
|
{
|
|
if (mClientID != Guid.Empty) return mClientID;
|
|
|
|
string idstring = Request.QueryString["id"];
|
|
mClientID = Guid.Empty;
|
|
if (!string.IsNullOrEmpty(idstring))
|
|
{
|
|
mClientID = new Guid(idstring);
|
|
}
|
|
|
|
return mClientID;
|
|
}
|
|
}
|
|
|
|
protected ClientNotes CurrentClientNotes
|
|
{
|
|
get
|
|
{
|
|
if (mClientNotes != null) return mClientNotes;
|
|
|
|
|
|
|
|
mClientNotes = (ClientNotes)Session["clientnotes"];
|
|
|
|
if (mClientNotes == null )
|
|
{
|
|
try
|
|
{
|
|
if (CurrentClientID != Guid.Empty)
|
|
mClientNotes = ClientNotes.GetItems(CurrentClientID);
|
|
else
|
|
throw new System.ApplicationException("Client Notes - No Client ID was specified");
|
|
|
|
Session["clientnotes"] = mClientNotes;
|
|
}
|
|
catch (System.Security.SecurityException)
|
|
{
|
|
CloseMe();
|
|
}
|
|
}
|
|
|
|
return mClientNotes;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
//Test comment for subversion testing
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (Util.CurrentUser.IsClientOrHeadOfficeAccount || AyaBizUtils.Right("Object.Client") < (int)SecurityLevelTypes.ReadOnly)//Less than read only instead of NoAccess to catch records where it's zero instead of 1
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
if (!IsPostBack && !IsAjaxCallback)
|
|
{
|
|
//clear any remnants from prior session not removed
|
|
//due to improper close
|
|
Session.Remove("clientnotes");
|
|
Util.GridInitEditable("ClientNotes", Grid, "ClientNote");
|
|
|
|
}
|
|
//Case 283 moved out of if block above
|
|
this.Title = Util.LocaleText("ClientNote.Label.List") + " - " + Util.GetBizObjectName("Client", new Guid(Request.QueryString["id"].ToString()));
|
|
|
|
if (AyaBizUtils.Right("Object.Client") < (int)SecurityLevelTypes.ReadWrite)
|
|
Util.SetReadOnly(this);
|
|
|
|
FillReportList();
|
|
}
|
|
|
|
#region Edit
|
|
|
|
|
|
private void UpdateNoteFromGrid(GridCommandEventArgs e)
|
|
{
|
|
Hashtable newValues = Util.GridExtractValues(e.Item);
|
|
if (newValues["ID"] != null)
|
|
{
|
|
ClientNote o = CurrentClientNotes[newValues["ID"].ToString()];
|
|
|
|
Telerik.Web.UI.RadComboBox cb = e.Item.FindControl("cbtype") as Telerik.Web.UI.RadComboBox;
|
|
o.ClientNoteTypeID = Util.ComboValue(cb);
|
|
|
|
TextBox tb = e.Item.FindControl("tbnotes") as TextBox;
|
|
o.Notes = tb.Text;
|
|
|
|
//Case 153
|
|
Telerik.Web.UI.RadDateTimePicker picker = (Telerik.Web.UI.RadDateTimePicker)e.Item.FindControl("dtNoteDate");
|
|
o.NoteDate = picker.DbSelectedDate;
|
|
|
|
CurrentClientNotes.Save();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
protected void Grid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
|
|
{
|
|
|
|
switch (e.CommandName)
|
|
{
|
|
case RadGrid.UpdateCommandName:
|
|
{
|
|
UpdateNoteFromGrid(e);
|
|
}
|
|
break;
|
|
case RadGrid.InitInsertCommandName:
|
|
{
|
|
e.Canceled = true;
|
|
ClientNote newnote = CurrentClientNotes.Add();
|
|
newnote.ClientID = new Guid(Request.QueryString["id"].ToString());
|
|
|
|
e.Item.OwnerTableView.InsertItem(newnote);
|
|
|
|
}
|
|
break;
|
|
case RadGrid.PerformInsertCommandName:
|
|
{
|
|
|
|
UpdateNoteFromGrid(e);
|
|
}
|
|
break;
|
|
case RadGrid.DeleteCommandName:
|
|
{
|
|
Hashtable newValues = Util.GridExtractValues(e.Item);
|
|
if (newValues["ID"] != null)
|
|
CurrentClientNotes.Remove(newValues["ID"].ToString());
|
|
|
|
}
|
|
break;
|
|
case RadGrid.CancelCommandName:
|
|
{
|
|
if (e.Item is Telerik.Web.UI.GridDataInsertItem)
|
|
{
|
|
Hashtable newValues = Util.GridExtractValues(e.Item);
|
|
if (newValues["ID"] != null)
|
|
CurrentClientNotes.Remove(newValues["ID"].ToString());
|
|
}
|
|
}
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Populate
|
|
protected void Grid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
|
|
{
|
|
|
|
if (e.Item is GridEditFormItem)
|
|
{
|
|
string selectedType = ((ClientNote)e.Item.DataItem).ClientNoteTypeID.ToString();
|
|
string notes = ((ClientNote)e.Item.DataItem).Notes;
|
|
if (e.Item.IsInEditMode)
|
|
{
|
|
|
|
Telerik.Web.UI.RadComboBox cb = e.Item.FindControl("cbtype") as Telerik.Web.UI.RadComboBox;
|
|
Util.ComboPopulateBizList("ClientNoteType", cb, false, null, false);
|
|
cb.SelectedValue = selectedType;
|
|
|
|
TextBox tb = e.Item.FindControl("tbnotes") as TextBox;
|
|
tb.Text = notes;
|
|
|
|
//Case 153
|
|
Telerik.Web.UI.RadDateTimePicker rdp = e.Item.FindControl("dtNoteDate") as Telerik.Web.UI.RadDateTimePicker;
|
|
rdp.DbSelectedDate = ((ClientNote)e.Item.DataItem).NoteDate;
|
|
|
|
//TODO: HIDE THE ID FIELD IN THE EDIT FORM AWAITING FORUM POST ANSWER
|
|
GridEditFormItem gefi = e.Item as GridEditFormItem;
|
|
gefi["ID"].Style.Add("Display", "none");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
else if (e.Item is GridDataItem)
|
|
{
|
|
string selectedType = ((ClientNote)e.Item.DataItem).ClientNoteTypeID.ToString();
|
|
string notes = ((ClientNote)e.Item.DataItem).Notes;
|
|
Label l = e.Item.FindControl("lbltype") as Label;
|
|
l.Text = Util.GetBizObjectName("ClientNoteType", selectedType);
|
|
|
|
l = e.Item.FindControl("lblnotes") as Label;
|
|
//case 2056
|
|
l.Text = Util.StringWebify(notes);
|
|
//l.Text = notes;
|
|
|
|
//Case 153
|
|
l = e.Item.FindControl("lbldate") as Label;
|
|
l.Text = ((ClientNote)e.Item.DataItem).NoteDate.ToString();
|
|
|
|
//Case 153
|
|
l = e.Item.FindControl("lblcreated") as Label;
|
|
l.Text = ((ClientNote)e.Item.DataItem).Created.ToString();
|
|
|
|
//Case 30
|
|
l = e.Item.FindControl("lblcreator") as Label;
|
|
l.Text = Util.GetBizObjectName("User", ((ClientNote)e.Item.DataItem).Creator);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
////Case 153
|
|
//RadDatePicker picker = (RadDatePicker)e.Item.FindControl("dtNoteDate");
|
|
//if (picker != null)
|
|
//{
|
|
// picker.SharedCalendar = dpShared;
|
|
// dpShared.Visible = true;
|
|
//}
|
|
}
|
|
protected void Grid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
|
|
{
|
|
Grid.DataSource = CurrentClientNotes;
|
|
}
|
|
#endregion
|
|
|
|
#region Reporting and main menu
|
|
private void FillReportList()
|
|
{
|
|
if (AyaBizUtils.Right("Object.Report") < (int)SecurityLevelTypes.ReadOnly)
|
|
{
|
|
mnu.Visible = false;
|
|
}
|
|
else
|
|
{
|
|
mnu.Visible = true;
|
|
Util.ReportFillList(mnu.Items[0], ClientNotesReportList.ReportKey, "");
|
|
mnu.Items[0].ToolTip = Util.LocaleText("UI.Toolbar.Print");
|
|
}
|
|
}
|
|
|
|
protected void mnu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
|
|
{
|
|
|
|
if (e.Item.Value.StartsWith("PRINT"))
|
|
{
|
|
doPrint(e.Item.Value);
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void doPrint(string report)
|
|
{
|
|
|
|
|
|
string[] s = report.Split(',');
|
|
if (s[0] == "PRINTDETAILED")
|
|
{
|
|
//There are no detailed reports for these sub grids
|
|
}
|
|
else
|
|
{
|
|
|
|
Util.Report(Page, s[1], ClientNotesReportList.ReportKey, ClientNotesReportList.GetList(CurrentClientID));
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
}
|