MARKUP
Landscaping
Sweeping
Snow
Electric
Work Order Number
Request Date
Location ID
Order Status
***********************************************************************************
Code
///
/// Method uwgNotes_InitializeRow sets the carriage return and line
/// feeds replacing the ~ character for the note field.
///
///
///
protected void uwgNotes_InitializeRow(object sender, RowEventArgs e)
{
// Have to handle null for adding a new row.
if (e.Row.Cells.FromKey("Note").Text == null)
{
e.Row.Cells.FromKey("Note").Text = string.Empty;
}
else
{
e.Row.Cells.FromKey("Note").Text = e.Row.Cells.FromKey("Note").Text.Replace("~", "\r\n").Replace("''", "'");
}
}
///
/// Method uwgNotes_AddRow is an event that happens when the
/// UltraWebGrid adds a row.
///
///
///
protected void uwgNotes_AddRow(object sender, RowEventArgs e)
{
// Get the user name and truncate to 50 characters if needed.
string sUser;
if (HttpContext.Current.User.Identity.Name.Length > 50)
{
sUser = HttpContext.Current.User.Identity.Name.Substring(0, 50);
}
else
{
sUser = HttpContext.Current.User.Identity.Name;
}
// Set the fields from the CMS-Note record that the user does
// not input for a row add and fix the carriage return and
// line feed.
e.Row.Cells.FromKey("Identifier").Text = tbVendID.Text;
e.Row.Cells.FromKey("Note").Text = e.Row.Cells.FromKey("Note").Text.Replace("\r\n", "~").Replace("'", "''");
e.Row.Cells.FromKey("CreatedBy").Text = sUser;
e.Row.Cells.FromKey("LastUpdateBy").Text = sUser;
string sInsertDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
e.Row.Cells.FromKey("CreatedDate").Text = sInsertDateTime;
e.Row.Cells.FromKey("LastUpdateDate").Text = sInsertDateTime;
}
///
/// Method uwgNotes_UpdateRow is an event that happens when the
/// UltraWebGrid updates a row. It also processes each row add so
/// I cancel out of those as the uwgNotes_AddRow has already handles
/// the add row processing and I do not want the CMS-Note record
/// to happen as it is not needed and it updates the LastUpdateDate
/// field with a new value that does not match the CreatedDate
/// field and the Note field with the same value it already has.
///
///
///
protected void uwgNotes_UpdateRow(object sender, RowEventArgs e)
{
switch (e.Row.DataChanged)
{
case DataChanged.Added:
e.Cancel = true;
break;
case DataChanged.Modified:
// Get the user name and truncate to 50 characters if needed.
string sUser;
if (HttpContext.Current.User.Identity.Name.Length > 50)
{
sUser = HttpContext.Current.User.Identity.Name.Substring(0, 50);
}
else
{
sUser = HttpContext.Current.User.Identity.Name;
}
// Set the LastUpdateBy field that the user does
// not input and fix the carriage return and line feed.
e.Row.Cells.FromKey("Note").Text = e.Row.Cells.FromKey("Note").Text.Replace("\r\n", "~").Replace("'", "''");
e.Row.Cells.FromKey("LastUpdateBy").Text = sUser;
break;
}
}
///
/// Method uwgNotes_PageIndexChanged fires when the UltraWebGrid
/// paging event occurs. We need to update the database when paging
/// or changes will be lost.
///
///
///
protected void uwgNotes_PageIndexChanged(object sender, Infragistics.WebUI.UltraWebGrid.PageEventArgs e)
{
uwgNotes.DataBind();
}
///
/// Method uwgNotes_InitializeLayout is used to set any layout
/// for the Notes ultimate web grid.
///
///
///
protected void uwgNotes_InitializeLayout(object sender, LayoutEventArgs e)
{
if (!((sAccess == "RW") || (sAccess == "RC")))
{
e.Layout.Bands[0].AllowAdd = AllowAddNew.No;
e.Layout.Bands[0].AllowUpdate = AllowUpdate.No;
e.Layout.Bands[0].Columns.FromKey("Note").AllowUpdate = AllowUpdate.No;
}
//e.Layout.Bands[0].DataKeyField = "NoteType, Identifier, CreatedDate";
}