<
PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" />
paging for Master level with pagesize=10, and i have set paging = false for the details tables in GridTableView. It is showing like "Item 0 to 0 of 0" and only page 1 is displayed, in the paging, even If I have more than 100 rows. And sorting is also not working. Is it because of the hierarchy grid of 3 levels, these are not working?. Because these both functionalites are working at other places where I have not used any Details Table.
<
telerik:RadGrid
ID
=
"RadGridProject"
DataSourceID
=
"sds_p"
runat
=
"server"
AllowAutomaticUpdates
=
"True"
AutoGenerateColumns
=
"False"
OnDataBound
=
"RadGridProject_DataBound"
PageSize
=
"10"
AllowSorting
=
"true"
OnItemCommand
=
"RadGridProject_ItemCommand"
AutoGenerateHierarchy
=
"true"
OnItemDataBound
=
"RadGridProject_ItemDataBound"
AllowCustomPaging
=
"True"
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
AlwaysVisible
=
"true"
/>
<
MasterTableView
Name
=
"PTable"
DataKeyNames
=
"P_id,p_y_id"
AllowMultiColumnSorting
=
"True"
AllowSorting
=
"true"
TableLayout
=
"Fixed"
EditMode
=
"InPlace"
AllowCustomPaging
=
"true"
AllowPaging
=
"true"
>
<
HeaderStyle
CssClass
=
"Level1HeaderStyle"
/>
<
Columns
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"faf_id, faf_year_id"
DataSourceID
=
"sds_f"
AllowPaging
=
"false"
Width
=
"60%"
HeaderStyle-Width
=
"10px"
Name
=
"FTable"
TableLayout
=
"Auto"
AllowFilteringByColumn
=
"false"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"p_id"
MasterKeyField
=
"P_id"
/>
</
ParentTableRelation
>
<
DetailTables
>
<
telerik:GridTableView
DataSourceID
=
"sds_d"
DataKeyNames
=
"f_id, d_id"
Width
=
"80%"
AllowFilteringByColumn
=
"false"
Name
=
"DTable"
runat
=
"server"
AllowPaging
=
"false"
EditMode
=
"InPlace"
TableLayout
=
"Auto"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"year_id"
MasterKeyField
=
"year_id"
/>
</
ParentTableRelation
>
<
HeaderStyle
CssClass
=
"Level3HeaderStyle"
/>
<
ItemStyle
CssClass
=
"Level3ItemStyle"
Width
=
"10px"
/>
<
AlternatingItemStyle
CssClass
=
"Level3AltItemStyle"
/>
<
Columns
>
</
Columns
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"name"
sortOrder
=
"Ascending"
> </
telerik:GridSortExpression
>
</
SortExpressions
>
</
telerik:GridTableView
>
</
DetailTables
>
<
ItemStyle
Width
=
"200px"
/>
<
HeaderStyle
CssClass
=
"Level2HeaderStyle"
Width
=
"100%"
/>
<
ItemStyle
CssClass
=
"Level2ItemStyle"
/>
<
AlternatingItemStyle
CssClass
=
"Level2AltItemStyle"
/>
<
Columns
>
</
Columns
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"f_id"
></
telerik:GridSortExpression
>
</
SortExpressions
>
</
telerik:GridTableView
>
</
DetailTables
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"t_name"
></
telerik:GridSortExpression
>
</
SortExpressions
>
</
MasterTableView
>
<
ClientSettings
AllowColumnsReorder
=
"true"
ReorderColumnsOnClient
=
"true"
>
</
ClientSettings
>
</
telerik:RadGrid
>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplyPaymentList.ascx.cs"
Inherits="LaundryLogic.Modules.LL_ARActivities.ApplyPaymentList" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
telerik:RadScriptBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function RebindCredits()
{
var masterTable = $find("<%= rgCredits.ClientID %>").get_masterTableView();
masterTable.rebind();
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"rgCredits"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadToolTipManager1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"rgCredits"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadToolTipManager
ID
=
"RadToolTipManager1"
OffsetY
=
"-1"
HideEvent
=
"ManualClose"
Width
=
"800"
Height
=
"800"
runat
=
"server"
EnableShadow
=
"true"
OnAjaxUpdate
=
"OnAjaxUpdate"
RelativeTo
=
"BrowserWindow"
Position
=
"Center"
ShowCallout
=
"false"
ShowEvent
=
"OnClick"
OnClientHide
=
"RebindCredits"
>
</
telerik:RadToolTipManager
>
<
table
width
=
"100%"
>
<
tr
>
<
td
>
<
asp:Label
ID
=
"lblHeader1"
runat
=
"server"
CssClass
=
"moduleheader"
Text
=
"Apply Customer Payments to Invoices"
></
asp:Label
>
-
<
asp:Label
ID
=
"lblHeader2"
runat
=
"server"
CssClass
=
"moduleheader"
Text
=
"You are working on Payment Batch Number "
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
hr
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
asp:Label
ID
=
"lblHeader3"
runat
=
"server"
CssClass
=
"moduleheader"
Text
=
"Customer Payments in this Batch"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadGrid
ID
=
"rgCredits"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
EnableEmbeddedSkins
=
"False"
onneeddatasource
=
"rgCredits_NeedDataSource"
Skin
=
"Sitefinity"
onitemcommand
=
"rgCredits_ItemCommand"
onitemdatabound
=
"rgCredits_ItemDataBound"
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
<
MasterTableView
DataKeyNames
=
"ID,EntityType,EntityID"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridDateTimeColumn
DataField
=
"CreditDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter CreditDate column"
HeaderText
=
"Credit Date"
UniqueName
=
"CreditDate"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"AccountName"
FilterControlAltText
=
"Filter AccountName column"
HeaderText
=
"Account Name"
MaxLength
=
"20"
UniqueName
=
"AccountName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"AccountNumber"
FilterControlAltText
=
"Filter AccountNumber column"
HeaderText
=
"Account Number"
MaxLength
=
"20"
UniqueName
=
"AccountNumber"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"ActivityTypeID"
FilterControlAltText
=
"Filter ActivityType column"
HeaderText
=
"Type"
UniqueName
=
"ActivityType"
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"rcbActivityType"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblActivityType"
runat
=
"server"
Text='<%# Eval("ActivityTypeID") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"CreditIdentifier"
FilterControlAltText
=
"Filter CreditIdentifier column"
HeaderText
=
"Credit Identifier"
MaxLength
=
"20"
UniqueName
=
"CreditIdentifier"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"OriginalAmount"
HeaderText
=
"Original Amt."
UniqueName
=
"OriginalAmount"
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"rntOriginalAmount"
runat
=
"server"
CausesValidation
=
"True"
DataType
=
"System.Decimal"
Type
=
"Currency"
>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblOriginalAmount"
runat
=
"server"
Text='<%# Eval("OriginalAmount", "{0:c}") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridNumericColumn
DataField
=
"RemainingAmount"
DataType
=
"System.Decimal"
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter RemainingAmount column"
HeaderText
=
"Remaining Amt."
NumericType
=
"Currency"
ReadOnly
=
"True"
UniqueName
=
"RemainingAmount"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"PaymentBatchID"
Display
=
"false"
FilterControlAltText
=
"Filter Payment Batch ID column"
HeaderText
=
"Payment Batch ID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
ColumnEditorID
=
"GridTextBoxColumnEditor1"
DataField
=
"Notes"
FilterControlAltText
=
"Filter Notes column"
HeaderText
=
"Notes"
MaxLength
=
"500"
UniqueName
=
"Notes"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CreatedBy"
Display
=
"False"
FilterControlAltText
=
"Filter CreatedBy column"
HeaderText
=
"Created By"
MaxLength
=
"50"
ReadOnly
=
"True"
UniqueName
=
"CreatedBy"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Apply"
FilterControlAltText
=
"Filter Apply column"
Text
=
"Apply This Payment"
UniqueName
=
"Apply"
>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
cancelimageurl
=
"Cancel.gif"
editimageurl
=
"Edit.gif"
insertimageurl
=
"Update.gif"
updateimageurl
=
"Update.gif"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
hr
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadButton
ID
=
"rbtnPaymentBatchManagement"
runat
=
"server"
Text
=
"Batch Manager"
CausesValidation
=
"false"
onclick
=
"rbtnPaymentBatchManagement_Click"
>
<
Icon
PrimaryIconCssClass
=
"rbPrevious"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
using
DotNetNuke.Common;
using
EntitySpaces.Interfaces;
using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
namespace
LaundryLogic.Modules.LL_ARActivities
{
public
partial
class
ApplyPaymentList : LL_ARActivitiesModuleBase
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(Request[
"PaymentBatchID"
] !=
null
)
{
lblHeader2.Text = lblHeader2.Text + Request[
"PaymentBatchID"
].ToString();
}
}
protected
void
rgCredits_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataTable oDTMaster =
new
DataTable();
DataTable oDTStandard =
new
DataTable();
DataTable oDT =
new
DataTable();
oDTMaster = LoadMasterPayments();
oDTStandard = LoadStandardPayments();
oDT.Merge(oDTMaster);
oDT.Merge(oDTStandard);
if
(oDT !=
null
)
{
rgCredits.DataSource = oDT;
}
else
{
rgCredits.DataSource =
new
object
[0];
}
}
private
DataTable LoadMasterPayments()
{
LaundryLogicDAL.ARCreditsQuery oARCQ =
new
LaundryLogicDAL.ARCreditsQuery(
"arc"
);
LaundryLogicDAL.ARActivityTypeQuery oARATQ =
new
LaundryLogicDAL.ARActivityTypeQuery(
"arat"
);
LaundryLogicDAL.ARAccountsQuery oARAQ =
new
LaundryLogicDAL.ARAccountsQuery(
"araq"
);
LaundryLogicDAL.ARMasterQuery oARMQ =
new
LaundryLogicDAL.ARMasterQuery(
"armq"
);
DataTable oDT =
new
DataTable();
DataTable oDTStandard =
new
DataTable();
try
{
oARCQ.es2.Connection.Name =
"NAS"
;
oARCQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARATQ.es2.Connection.Name =
"NAS"
;
oARATQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ.es2.Connection.Name =
"NAS"
;
oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARMQ.es2.Connection.Name =
"NAS"
;
oARMQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARCQ.Select(
oARCQ.Id,
oARCQ.EntityType,
oARCQ.EntityID,
oARMQ.AccountName,
"<'N/A' AS [AccountNumber]>"
,
oARCQ.CreditDate,
oARCQ.ActivityTypeID,
oARATQ.ActivityType,
oARCQ.CreditIdentifier,
oARCQ.OriginalAmount,
oARCQ.RemainingAmount,
oARCQ.Notes,
oARCQ.PaymentBatchID,
oARCQ.CreatedBy,
oARCQ.CreateDate
);
oARCQ.InnerJoin(oARATQ).On(oARCQ.ActivityTypeID == oARATQ.Id);
oARCQ.InnerJoin(oARMQ).On(oARCQ.EntityID == oARMQ.Id);
oARCQ.Where(oARCQ.EntityType ==
"Master"
);
if
(Request[
"PaymentBatchID"
] !=
null
)
{
oARCQ.Where(oARCQ.PaymentBatchID == Convert.ToInt16(Request[
"PaymentBatchID"
]));
}
return
oARCQ.LoadDataTable();
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
return
null
;
}
finally
{
//oARCC.Dispose();
//oARCC = null;
oARCQ =
null
;
oARATQ =
null
;
oARAQ =
null
;
oARMQ =
null
;
oDT =
null
;
}
}
private
DataTable LoadStandardPayments()
{
LaundryLogicDAL.ARCreditsQuery oARCQ =
new
LaundryLogicDAL.ARCreditsQuery(
"arc"
);
LaundryLogicDAL.ARActivityTypeQuery oARATQ =
new
LaundryLogicDAL.ARActivityTypeQuery(
"arat"
);
LaundryLogicDAL.ARAccountsQuery oARAQ =
new
LaundryLogicDAL.ARAccountsQuery(
"araq"
);
LaundryLogicDAL.ARMasterQuery oARMQ =
new
LaundryLogicDAL.ARMasterQuery(
"armq"
);
DataTable oDT =
new
DataTable();
DataTable oDTStandard =
new
DataTable();
try
{
oARCQ.es2.Connection.Name =
"NAS"
;
oARCQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARATQ.es2.Connection.Name =
"NAS"
;
oARATQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ.es2.Connection.Name =
"NAS"
;
oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARMQ.es2.Connection.Name =
"NAS"
;
oARMQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARCQ.Select(
oARCQ.Id,
oARCQ.EntityType,
oARCQ.EntityID,
oARAQ.AccountName,
oARAQ.Account.As(
"AccountNumber"
),
oARCQ.CreditDate,
oARCQ.ActivityTypeID,
oARATQ.ActivityType,
oARCQ.CreditIdentifier,
oARCQ.OriginalAmount,
oARCQ.RemainingAmount,
oARCQ.Notes,
oARCQ.PaymentBatchID,
oARCQ.CreatedBy,
oARCQ.CreateDate
);
oARCQ.InnerJoin(oARATQ).On(oARCQ.ActivityTypeID == oARATQ.Id);
oARCQ.InnerJoin(oARAQ).On(oARCQ.EntityID == oARAQ.Id);
oARCQ.Where(oARCQ.EntityType ==
"Standard"
);
if
(Request[
"PaymentBatchID"
] !=
null
)
{
oARCQ.Where(oARCQ.PaymentBatchID == Convert.ToInt16(Request[
"PaymentBatchID"
]));
}
return
oARCQ.LoadDataTable();
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
return
null
;
}
finally
{
//oARCC.Dispose();
//oARCC = null;
oARCQ =
null
;
oARATQ =
null
;
oARAQ =
null
;
oARMQ =
null
;
oDT =
null
;
}
}
protected
void
rbtnPaymentBatchManagement_Click(
object
sender, EventArgs e)
{
Response.Redirect(Globals.NavigateURL(),
true
);
}
protected
void
OnAjaxUpdate(
object
sender, ToolTipUpdateEventArgs args)
{
this
.UpdateToolTip(args.Value, args.UpdatePanel);
rgCredits.Rebind();
}
private
void
UpdateToolTip(
string
elementID, UpdatePanel panel)
{
string
[] separator =
new
string
[] {
"|"
};
string
[] arrElementID = elementID.Split(separator,StringSplitOptions.None);
ApplyPayments oApplyPayments = (ApplyPayments)LoadControl(
"ApplyPayments.ascx"
);
oApplyPayments.ID =
"ApplyPayments1"
;
panel.ContentTemplateContainer.Controls.Add(oApplyPayments);
oApplyPayments.EntityType = arrElementID[1].ToString();
oApplyPayments.EntityID = Convert.ToInt16(arrElementID[2]);
oApplyPayments.PaymentID = Convert.ToInt16(arrElementID[0]);
RadGrid rgDebits = (RadGrid)oApplyPayments.FindControl(
"rgDebits"
);
RadAjaxManager1.AjaxSettings.AddAjaxSetting(rgDebits, oApplyPayments);
}
protected
void
rgCredits_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
int
iPaymentID = (
int
)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"ID"
];
string
sEntityType = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"EntityType"
].ToString();
int
iEntityID = (
int
)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"EntityID"
];
GridDataItem oDataItem = (GridDataItem)e.Item;
LinkButton lnkTarget = (LinkButton)oDataItem[
"Apply"
].Controls[0];
if
(!Object.Equals(lnkTarget,
null
))
{
lnkTarget.Attributes.Add(
"onclick"
,
"javascript:return false;"
);
if
(!Object.Equals(
this
.RadToolTipManager1,
null
))
{
//Add the button (target) id to the tooltip manager
string
sValue = iPaymentID.ToString() +
"|"
+ sEntityType +
"|"
+ iEntityID.ToString();
this
.RadToolTipManager1.TargetControls.Add(lnkTarget.ClientID, sValue,
true
);
}
}
}
}
protected
void
rgCredits_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName ==
"Sort"
|| e.CommandName ==
"Page"
)
{
RadToolTipManager1.TargetControls.Clear();
}
}
}
}
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ApplyPayments.ascx.cs"
Inherits="LaundryLogic.Modules.LL_ARActivities.ApplyPayments" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
link
href
=
"module.css"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
table
width
=
"100%"
>
<
tr
>
<
td
width
=
"20%"
colspan
=
"5"
>
<
asp:Label
ID
=
"lblCustomerPaymentHeader"
CssClass
=
"moduleheader"
runat
=
"server"
Text
=
"Apply Customer Payment"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
width
=
"20%"
>
</
td
>
<
td
colspan
=
"4"
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"5"
>
<
div
class
=
"divborder"
>
<
table
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblCustomerSelectedCaption"
runat
=
"server"
Text
=
"Customer Selected:"
></
asp:Label
>
</
td
>
<
td
>
<
asp:Label
ID
=
"lblAccountNumber"
runat
=
"server"
></
asp:Label
>
</
td
>
<
td
>
<
asp:Label
ID
=
"lblAccountName"
runat
=
"server"
></
asp:Label
>
</
td
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblMasterCaption"
runat
=
"server"
Text
=
"Master?"
></
asp:Label
>
</
td
>
<
td
>
<
asp:Label
ID
=
"lblIsMasterAccount"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblCreditIdentifierHeader"
runat
=
"server"
Text
=
"Payment/Check Number:"
></
asp:Label
>
</
td
>
<
td
colspan
=
"4"
>
<
asp:Label
ID
=
"lblCreditIdentifier"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblCreditDateHeader"
runat
=
"server"
Text
=
"Payment/Credit Date:"
></
asp:Label
>
</
td
>
<
td
colspan
=
"4"
>
<
asp:Label
ID
=
"lblCreditDate"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblPaymentActivityTypeHeader"
runat
=
"server"
Text
=
"Payment/Credit Type:"
></
asp:Label
>
</
td
>
<
td
colspan
=
"4"
>
<
asp:Label
ID
=
"lblPaymentActivityType"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblPaymentAmountHeader"
runat
=
"server"
Text
=
"Payment/Credit Amount:"
></
asp:Label
>
</
td
>
<
td
colspan
=
"4"
>
<
asp:Label
ID
=
"lblPaymentAmount"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
>
<
asp:Label
ID
=
"lblPaymentRemainingHeader"
runat
=
"server"
Text
=
"Amount Remaining:"
></
asp:Label
>
</
td
>
<
td
colspan
=
"4"
>
<
asp:Label
ID
=
"lblPaymentRemaining"
runat
=
"server"
></
asp:Label
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
colspan
=
"4"
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"5"
>
<
asp:Label
ID
=
"lblOpenInvoicesHeader"
CssClass
=
"moduleheader"
runat
=
"server"
Text
=
"Open Invoices"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
colspan
=
"4"
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"5"
>
<
asp:Button
ID
=
"btnAutoApply"
runat
=
"server"
OnClick
=
"btnAutoApply_Click"
Text
=
"AutoApply"
ToolTip
=
"Automatically apply payment to as many invoices as possible beginning with the oldest invoice"
/>
<
asp:Button
ID
=
"btnRollbackAll"
runat
=
"server"
onclick
=
"btnRollbackAll_Click"
Text
=
"Rollback All"
/>
<
asp:Button
ID
=
"btnRollbackSelected"
runat
=
"server"
onclick
=
"btnRollbackSelected_Click"
Text
=
"Rollback Selected"
CommandName
=
"RollbackSelected"
/>
<
asp:Button
ID
=
"btnClearAll"
runat
=
"server"
OnClick
=
"btnClearAll_Click"
Text
=
"Clear All"
/>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"5"
>
<
telerik:RadGrid
Width
=
"100%"
ID
=
"rgDebits"
runat
=
"server"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
OnNeedDataSource
=
"rgDebits_NeedDataSource"
OnItemCreated
=
"rgDebits_ItemCreated"
OnSortCommand
=
"rgDebits_SortCommand"
Skin
=
"Sitefinity"
EnableEmbeddedSkins
=
"False"
onprerender
=
"rgDebits_PreRender"
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
ValidationSettings
EnableValidation
=
"False"
/>
<
MasterTableView
EditMode
=
"InPlace"
DataKeyNames
=
"ID"
AllowPaging
=
"True"
ShowFooter
=
"false"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridTemplateColumn
FilterControlAltText
=
"Filter TemplateColumn column"
HeaderText
=
"Apply?"
UniqueName
=
"Apply"
>
<
EditItemTemplate
>
<
asp:CheckBox
ID
=
"chkApply"
runat
=
"server"
AutoPostBack
=
"True"
OnCheckedChanged
=
"chkApply_CheckedChanged"
/>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"chkApply"
runat
=
"server"
AutoPostBack
=
"True"
OnCheckedChanged
=
"chkApply_CheckedChanged"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
FilterControlAltText
=
"Filter AmountApplied column"
HeaderText
=
"Amount Applied"
UniqueName
=
"AmountApplied"
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtAmountApplied"
runat
=
"server"
Type
=
"Currency"
>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Account"
DataType
=
"System.String"
FilterControlAltText
=
"Filter Account column"
HeaderText
=
"Account Number"
ReadOnly
=
"true"
UniqueName
=
"Account"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"AccountName"
FilterControlAltText
=
"Filter AccountName column"
HeaderText
=
"Account Name"
ReadOnly
=
"True"
UniqueName
=
"AccountName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DebitDate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter DebitDate column"
DataFormatString
=
"{0:d}"
HeaderText
=
"Debit Date"
ReadOnly
=
"True"
UniqueName
=
"DebitDate"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DebitIdentifier"
FilterControlAltText
=
"Filter DebitIdentifier column"
HeaderText
=
"Debit Id"
MaxLength
=
"20"
ReadOnly
=
"True"
UniqueName
=
"DebitIdentifier"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
AllowSorting
=
"False"
DataField
=
"OriginalAmount"
DataFormatString
=
"{0:C2}"
DataType
=
"System.Decimal"
FilterControlAltText
=
"Filter OriginalAmount column"
HeaderText
=
"Original Amount"
ReadOnly
=
"True"
UniqueName
=
"OriginalAmount"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RemainingAmount"
DataFormatString
=
"{0:C2}"
DataType
=
"System.Decimal"
FilterControlAltText
=
"Filter RemainingAmount column"
HeaderText
=
"Remaining Amount"
ReadOnly
=
"True"
UniqueName
=
"RemainingAmount"
AllowSorting
=
"False"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
</
telerik:RadGrid
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"5"
>
<
telerik:RadButton
runat
=
"server"
ID
=
"rbtnApply"
OnClick
=
"cmdApply_Click"
Text
=
"Done with Applications"
>
<
Icon
PrimaryIconCssClass
=
"rbPrevious"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
using
EntitySpaces.Interfaces;
using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Globalization;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
namespace
LaundryLogic.Modules.LL_ARActivities
{
public
partial
class
ApplyPayments : LL_ARActivitiesModuleBase
{
private
string
msEntityType;
private
int
miEntityID;
private
double
sum = 0;
public
string
EntityType
{
set
{
Session[
"EntityType"
] = value;
}
}
public
int
EntityID
{
set
{
Session[
"EntityID"
] = value;
}
}
public
int
PaymentID
{
set
{
int
iEntityID = 0;
string
sEntityType =
""
;
Session[
"PaymentID"
] = value;
LoadAccountInfo(Session[
"EntityType"
].ToString(), (
int
)Session[
"EntityID"
]);
LoadPayment();
rgDebits.Rebind();
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
SetConnection();
}
#region Events
protected
void
chkApply_CheckedChanged(
object
sender, EventArgs e)
{
bool
bHasRemainder =
true
;
CheckBox chk = (CheckBox)sender;
GridEditableItem edititem = (GridEditableItem)chk.Parent.Parent;
try
{
TextBox txtRemainingAmount = (TextBox)edititem[
"RemainingAmount"
].Controls[0];
decimal
decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
decimal
decAmountDue = LL_Utility.CurrencyToDecimal(txtRemainingAmount.Text);
//TextBox txtAmountApplied = (TextBox)edititem["AmountApplied"].FindControl("txtAmountApplied");
RadNumericTextBox txtAmountApplied = (RadNumericTextBox)edititem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
#region Region Checked
if
(chk.Checked)
{
if
(decRemaining > decAmountDue)
{
if
(txtAmountApplied.Text ==
""
|| txtAmountApplied.Value == 0)
{
txtAmountApplied.Text = decAmountDue.ToString();
}
decRemaining = decRemaining - decAmountDue;
lblPaymentRemaining.Text = decRemaining.ToString(
"C2"
);
if
(decRemaining > 0)
{
bHasRemainder =
true
;
}
else
{
bHasRemainder =
false
;
}
}
else
if
(decRemaining < decAmountDue)
{
txtAmountApplied.Text = decRemaining.ToString();
decRemaining = 0;
lblPaymentRemaining.Text = decRemaining.ToString(
"C2"
);
bHasRemainder =
false
;
}
}
#endregion Checked
#region Region Unchecked
else
{
decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
//get the amount to be applied from the txtAmount textbox
decimal
decAmountApplied = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
decRemaining = decRemaining + decAmountApplied;
txtAmountApplied.Text =
""
;
// 0.ToString("C2");
lblPaymentRemaining.Text = decRemaining.ToString(
"C2"
);
bHasRemainder =
true
;
}
#endregion Region Unchecked
if
(!bHasRemainder)
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridDataItem dataitem = (GridDataItem)item;
CheckBox chkApply = (CheckBox)dataitem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
if
(!chkApply.Checked)
{
chkApply.Enabled =
false
;
txtAmountApplied2.Enabled =
false
;
}
}
}
else
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridDataItem dataitem = (GridDataItem)item;
CheckBox chkApply = (CheckBox)dataitem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
chkApply.Enabled =
true
;
txtAmountApplied2.Enabled =
true
;
}
}
//SetVisibility("Apply");
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
}
protected
void
cmdApply_Click(
object
sender, EventArgs e)
{
ApplyCredit();
rgDebits.Rebind();
}
private
void
ApplyCredit()
{
LaundryLogicDAL.ARApplicationsCollection oARAC =
new
LaundryLogicDAL.ARApplicationsCollection();
LaundryLogicDAL.ARCredits oARC =
new
LaundryLogicDAL.ARCredits();
LaundryLogicDAL.ARDebits oARD =
new
LaundryLogicDAL.ARDebits();
try
{
oARAC.es.Connection.Name =
"NAS"
;
oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARC.es.Connection.Name =
"NAS"
;
oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARD.es.Connection.Name =
"NAS"
;
oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
using
(EntitySpaces.Interfaces.esTransactionScope scope =
new
esTransactionScope())
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridEditableItem edititem = (GridEditableItem)item;
RadNumericTextBox txtAmountApplied = (RadNumericTextBox)edititem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
CheckBox chkApply = (CheckBox)edititem[
"Apply"
].FindControl(
"chkApply"
);
decimal
decAppliedAmount = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
//int iCreditID = (int)ViewState["PaymentID"];
int
iCreditID = (
int
)Session[
"PaymentID"
];
int
iDebitID = (
int
)edititem.OwnerTableView.DataKeyValues[edititem.ItemIndex][
"ID"
];
if
(chkApply.Checked)
{
//check to see if the application exists for this credit and debit,
//and update the amounts if it does, otherwise add it.
oARAC.Query.Where(oARAC.Query.CreditID == iCreditID, oARAC.Query.DebitID == iDebitID);
if
(oARAC.Query.Load())
{
oARAC[0].MarkAsDeleted();
oARAC.Save();
}
//Application Record
LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
oARA.CreditID = iCreditID;
oARA.DebitID = iDebitID;
oARA.Notes =
""
;
oARA.Amount = decAppliedAmount;
oARA.ApplicationDate = DateTime.Now;
oARA.IsVoid =
false
;
oARA.CreateDate = DateTime.Now;
oARA.CreatedBy = UserInfo.FullName;
oARAC.Save();
//Credit Record
//Set Remaining Amount = Remaining Amount - decAppliedAmount
if
(oARC.LoadByPrimaryKey(iCreditID))
{
oARC.RemainingAmount = oARC.RemainingAmount - decAppliedAmount;
oARC.Save();
}
//Debit Record
//Set Remaining Amount = Remaining Amount - decAppliedAmount
if
(oARD.LoadByPrimaryKey(iDebitID))
{
oARD.RemainingAmount = oARD.RemainingAmount - decAppliedAmount;
oARD.Save();
}
}
}
scope.Complete();
//PlaceHolder phApplication = (PlaceHolder)cmdApply.Parent.Parent;
//phApplication.Visible = false;
//UserControl ucPayment = (UserControl)phApplication.Parent;
//PlaceHolder phPayment = (PlaceHolder)ucPayment.FindControl("phApplyPayments");
//phPayment.Visible = true;
//RadGrid rg = (RadGrid)ucPayment.FindControl("rgDebits");
//rg.Rebind();
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
//SetVisibility("Apply");
}
finally
{
oARAC.Dispose();
oARAC =
null
;
oARC =
null
;
oARD =
null
;
}
}
protected
void
cmdCancel_Click(
object
sender, EventArgs e)
{
LoadPayment();
rgDebits.Rebind();
}
protected
void
rgDebits_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataTable oDTOpenDebits;
DataTable oDTClosedDebits;
DataTable oDT =
new
DataTable(); ;
int
iEntityID = 0;
string
sEntityType =
""
;
try
{
if
(Session[
"EntityID"
] !=
null
)
{
iEntityID = (
int
)Session[
"EntityID"
];
sEntityType = Session[
"EntityType"
].ToString();
}
if
(sEntityType !=
""
&& iEntityID > 0)
{
oDTOpenDebits = LoadOpenDebits(sEntityType, iEntityID);
oDTClosedDebits = LoadClosedDebits((
int
)Session[
"PaymentID"
]);
oDT.Merge(oDTOpenDebits);
oDT.Merge(oDTClosedDebits);
if
(oDT !=
null
)
{
rgDebits.DataSource = oDT;
}
else
{
rgDebits.DataSource =
new
object
[0];
}
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
}
protected
void
rgDebits_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item.ItemType == GridItemType.EditItem && e.Item.IsInEditMode)
//check whether the grid is in edit mode
{
GridEditableItem editItem = (GridEditableItem)e.Item;
CheckBox chkApply = (CheckBox)editItem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied = (RadNumericTextBox)editItem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
//accessing the textBox
txtAmountApplied.AutoPostBack =
true
;
txtAmountApplied.TextChanged +=
new
EventHandler(txtAmountApplied_TextChanged);
}
}
protected
void
rgDebits_SortCommand(
object
sender, GridSortCommandEventArgs e)
{
//SetRowsToEditMode();
}
protected
void
txtAmountApplied_TextChanged(
object
sender, EventArgs e)
{
bool
bHasRemainder =
true
;
RadNumericTextBox txt = (RadNumericTextBox)sender;
GridEditableItem edititem = (GridEditableItem)txt.Parent.Parent;
try
{
TextBox txtRemainingAmount = (TextBox)edititem[
"RemainingAmount"
].Controls[0];
decimal
decPaymentAmount = LL_Utility.CurrencyToDecimal(lblPaymentAmount.Text);
decimal
decCurrentAppliedAmount = LL_Utility.CurrencyToDecimal(txt.Text);
decimal
decRemaining = LL_Utility.CurrencyToDecimal(lblPaymentRemaining.Text);
decRemaining = 0;
foreach
(GridEditableItem editItem
in
rgDebits.EditItems)
{
//GridEditableItem editItem = (GridEditableItem)item;
CheckBox chkApply = (CheckBox)editItem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied = (RadNumericTextBox)editItem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
if
(chkApply.Checked)
{
decimal
decTemp = LL_Utility.CurrencyToDecimal(txtAmountApplied.Text);
decRemaining = decRemaining + decTemp;
}
}
if
(decRemaining > decPaymentAmount)
{
txt.Text =
""
;
CheckBox chkApply = (CheckBox)edititem[
"Apply"
].FindControl(
"chkApply"
);
chkApply.Checked =
false
;
//return;
}
if
(decRemaining == decPaymentAmount)
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridDataItem dataitem = (GridDataItem)item;
CheckBox chkApply = (CheckBox)dataitem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
if
(!chkApply.Checked)
{
chkApply.Enabled =
false
;
txtAmountApplied2.Enabled =
false
;
}
}
}
else
if
(decRemaining < decPaymentAmount)
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridDataItem dataitem = (GridDataItem)item;
CheckBox chkApply = (CheckBox)dataitem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)dataitem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
chkApply.Enabled =
true
;
txtAmountApplied2.Enabled =
true
;
}
}
//Recalculate
decRemaining = 0;
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridEditableItem editItem2 = (GridEditableItem)item;
CheckBox chkApply2 = (CheckBox)editItem2[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied2 = (RadNumericTextBox)editItem2[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
if
(chkApply2.Checked)
{
decimal
decTemp = LL_Utility.CurrencyToDecimal(txtAmountApplied2.Text);
decRemaining = decRemaining + decTemp;
}
}
lblPaymentRemaining.Text = (decPaymentAmount - decRemaining).ToString(
"C2"
);
//SetVisibility("Apply");
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(ex.Message,
this
, ex);
}
}
#endregion Events
#region Methods
private
void
AutoApplyCredit(
int
iCreditID,
int
iEntityID,
string
sEntityType)
{
LaundryLogicDAL.ARDebitsCollection oARDC =
new
LaundryLogicDAL.ARDebitsCollection();
LaundryLogicDAL.ARDebitsQuery oARDQ =
new
LaundryLogicDAL.ARDebitsQuery(
"ard"
);
LaundryLogicDAL.ARAccountsQuery oARAQ =
new
LaundryLogicDAL.ARAccountsQuery(
"ara"
);
LaundryLogicDAL.ARApplicationsCollection oARAC =
new
LaundryLogicDAL.ARApplicationsCollection();
decimal
decRemainingAmount = 0;
try
{
oARDC.es.Connection.Name =
"NAS"
;
oARDC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARDQ.es2.Connection.Name =
"NAS"
;
oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAC.es.Connection.Name =
"NAS"
;
oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ.es2.Connection.Name =
"NAS"
;
oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
//if standard account passed in
if
(sEntityType ==
"Standard"
)
//get open debits for entity type and ID in descending order
{
oARDQ.Where(
oARDQ.EntityID == iEntityID,
oARDQ.EntityType == sEntityType,
oARDQ.RemainingAmount > 0
);
}
//if master account, we need the sub accounts.
else
{
oARDQ.InnerJoin(oARAQ).On(
oARDQ.EntityType ==
"Standard"
&&
oARDQ.EntityID == oARAQ.Id);
oARDQ.Where(
oARAQ.MasterAccountID == iEntityID,
oARDQ.RemainingAmount > 0
);
}
oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
if
(oARDC.Load(oARDQ))
{
//begin transaction
using
(EntitySpaces.Interfaces.esTransactionScope scope =
new
esTransactionScope())
{
//for each debit
foreach
(LaundryLogicDAL.ARDebits oARD
in
oARDC)
{
LaundryLogicDAL.ARCredits oARC =
new
LaundryLogicDAL.ARCredits();
try
{
oARC.es.Connection.Name =
"NAS"
;
oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
if
(oARC.LoadByPrimaryKey(iCreditID))
{
decimal
decDebitRemainingAmount = (
decimal
)oARD.RemainingAmount;
//if credit remaining amount > debit remaining amount
if
(oARC.RemainingAmount > oARD.RemainingAmount && oARD.RemainingAmount > 0)
{
//create application record with credit id and debit id and amount = debit remaining amount
LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
oARA.CreditID = iCreditID;
oARA.DebitID = oARD.Id;
oARA.Amount = decDebitRemainingAmount;
oARA.ApplicationDate = DateTime.Today;
oARA.CreateDate = DateTime.Now;
oARA.CreatedBy = UserInfo.FullName;
oARAC.Save();
//update debit set remaining amount = 0
oARD.RemainingAmount = 0;
oARDC.Save();
//update credit set remaining amount = credit original amount - debit original amount
oARC.RemainingAmount = oARC.RemainingAmount - decDebitRemainingAmount;
oARC.Save();
}
//if credit remaining amount < debit remaining amount
else
if
(oARC.RemainingAmount < oARD.RemainingAmount && oARD.RemainingAmount > 0)
{
//create application record with credit id and debit id and amount = credit remaining amount
LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
oARA.CreditID = iCreditID;
oARA.DebitID = oARD.Id;
oARA.Amount = oARC.RemainingAmount;
oARA.ApplicationDate = DateTime.Today;
oARA.CreateDate = DateTime.Now;
oARA.CreatedBy = UserInfo.FullName;
oARAC.Save();
//update debit set remaining amount = debit original amount - credit original amount
if
(oARC.RemainingAmount > 0)
{
oARD.RemainingAmount = decDebitRemainingAmount - oARC.RemainingAmount;
}
else
{
oARD.RemainingAmount = decDebitRemainingAmount - oARC.OriginalAmount;
}
//update credit set remaining amount = 0
oARC.RemainingAmount = 0;
oARC.Save();
oARDC.Save();
}
//if credit remaining amount = debit remaining amount
else
if
(oARC.RemainingAmount == oARD.RemainingAmount && oARD.RemainingAmount > 0)
{
//create application record with credit id and debit id and amount = credit remaining amount
LaundryLogicDAL.ARApplications oARA = oARAC.AddNew();
oARA.CreditID = iCreditID;
oARA.DebitID = oARD.Id;
oARA.Amount = oARC.RemainingAmount;
oARA.ApplicationDate = DateTime.Today;
oARA.CreateDate = DateTime.Now;
oARA.CreatedBy = UserInfo.FullName;
oARAC.Save();
//update debit set remaining amount = 0
oARD.RemainingAmount = 0;
oARDC.Save();
//update credit set remaining amount = 0
oARC.RemainingAmount = 0;
oARC.Save();
}
decRemainingAmount = (
decimal
)oARC.RemainingAmount;
}
}
finally
{
oARC =
null
;
}
if
(decRemainingAmount == 0)
{
break
;
}
}
//commit transaction
scope.Complete();
}
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
//SetVisibility("Apply");
}
finally
{
oARDC.Dispose();
oARDC =
null
;
}
}
public
void
LoadAccountInfo(
string
sEntityType,
int
iEntityID)
{
LaundryLogicDAL.ARAccounts oARA =
new
LaundryLogicDAL.ARAccounts();
LaundryLogicDAL.ARMaster oARM =
new
LaundryLogicDAL.ARMaster();
try
{
oARA.es.Connection.Name =
"NAS"
;
oARA.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARM.es.Connection.Name =
"NAS"
;
oARM.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
if
(sEntityType ==
"Master"
)
{
if
(oARM.LoadByPrimaryKey(iEntityID))
{
lblAccountName.Text = oARM.AccountName;
lblAccountNumber.Text =
"(N/A)"
;
lblIsMasterAccount.Text =
"Y"
;
}
}
else
if
(sEntityType ==
"Standard"
)
{
if
(oARA.LoadByPrimaryKey(iEntityID))
{
lblAccountName.Text = oARA.AccountName;
lblAccountNumber.Text = oARA.Account;
lblIsMasterAccount.Text =
"N"
;
}
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
oARA =
null
;
oARM =
null
;
}
}
private
DataTable LoadClosedDebits(
int
iPaymentID)
{
LaundryLogicDAL.ARDebitsQuery oARDQ =
new
LaundryLogicDAL.ARDebitsQuery(
"ard"
);
LaundryLogicDAL.ARAccountsQuery oARAQ =
new
LaundryLogicDAL.ARAccountsQuery(
"ara"
);
LaundryLogicDAL.ARApplicationsQuery oARAQ2 =
new
LaundryLogicDAL.ARApplicationsQuery(
"ara2"
);
try
{
oARDQ.es2.Connection.Name =
"NAS"
;
oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ.es2.Connection.Name =
"NAS"
;
oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ2.es2.Connection.Name =
"NAS"
;
oARAQ2.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARDQ.Select(
oARDQ.Id,
oARDQ.DebitDate,
oARDQ.DebitIdentifier,
oARAQ.Account,
oARAQ.AccountName,
oARDQ.OriginalAmount,
oARDQ.RemainingAmount);
oARDQ.InnerJoin(oARAQ).On(
oARDQ.EntityID == oARAQ.Id);
oARDQ.InnerJoin(oARAQ2).On(
oARDQ.Id == oARAQ2.DebitID);
oARDQ.Where(
oARAQ2.CreditID == iPaymentID,
oARDQ.RemainingAmount == 0
);
oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
return
oARDQ.LoadDataTable();
}
catch
(Exception ex)
{
System.Text.StringBuilder oSB =
new
System.Text.StringBuilder();
oSB.AppendLine(
"Missing variable:"
);
oSB.AppendLine(
"iPaymentID: "
+ iPaymentID);
DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(oSB.ToString(),
this
, ex);
return
null
;
}
finally
{
oARDQ =
null
;
oARAQ =
null
;
}
}
private
DataTable LoadOpenDebits(
string
sEntityType,
int
iEntityID)
{
LaundryLogicDAL.ARDebitsQuery oARDQ =
new
LaundryLogicDAL.ARDebitsQuery(
"ard"
);
LaundryLogicDAL.ARAccountsQuery oARAQ =
new
LaundryLogicDAL.ARAccountsQuery(
"ara"
);
try
{
oARDQ.es2.Connection.Name =
"NAS"
;
oARDQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARAQ.es2.Connection.Name =
"NAS"
;
oARAQ.es2.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARDQ.Select(
oARDQ.Id,
oARDQ.DebitDate,
oARDQ.DebitIdentifier,
oARAQ.Account,
oARAQ.AccountName,
oARDQ.OriginalAmount,
oARDQ.RemainingAmount);
if
(sEntityType ==
"Standard"
)
{
oARDQ.InnerJoin(oARAQ).On(oARDQ.EntityID == oARAQ.Id);
oARDQ.Where(
oARDQ.EntityID == iEntityID,
oARDQ.EntityType == sEntityType,
oARDQ.RemainingAmount > 0,
oARDQ.OriginalAmount > 0
);
}
else
{
oARDQ.InnerJoin(oARAQ).On(
oARDQ.EntityID == oARAQ.Id);
oARDQ.Where(
oARAQ.MasterAccountID == iEntityID,
oARDQ.RemainingAmount > 0,
oARDQ.OriginalAmount > 0
);
}
oARDQ.OrderBy(oARDQ.DebitDate.Ascending);
return
oARDQ.LoadDataTable();
}
catch
(Exception ex)
{
System.Text.StringBuilder oSB =
new
System.Text.StringBuilder();
oSB.AppendLine(
"Missing variable:"
);
oSB.AppendLine(
"iEntityID: "
+ iEntityID);
oSB.AppendLine(
"sEntityType: "
+ sEntityType);
DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(oSB.ToString(),
this
, ex);
return
null
;
}
finally
{
oARDQ =
null
;
oARAQ =
null
;
}
}
private
void
LoadPayment()
{
LaundryLogicDAL.ARCredits oARC =
new
LaundryLogicDAL.ARCredits();
LaundryLogicDAL.ARActivityType oART =
new
LaundryLogicDAL.ARActivityType();
try
{
oARC.es.Connection.Name =
"NAS"
;
oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oART.es.Connection.Name =
"NAS"
;
oART.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
//if (oARC.LoadByPrimaryKey((int)ViewState["PaymentID"]))
if
(oARC.LoadByPrimaryKey((
int
)Session[
"PaymentID"
]))
{
if
(oART.LoadByPrimaryKey((
int
)oARC.ActivityTypeID))
{
this
.lblPaymentActivityType.Text = oART.ActivityType;
}
this
.lblCreditIdentifier.Text = oARC.CreditIdentifier;
DateTime dteCreditDate = (DateTime)oARC.CreditDate;
this
.lblCreditDate.Text = dteCreditDate.ToShortDateString();
this
.lblPaymentAmount.Text =
string
.Format(
"{0:C2}"
, oARC.OriginalAmount);
this
.lblPaymentRemaining.Text =
string
.Format(
"{0:C2}"
, oARC.RemainingAmount);
if
(oARC.RemainingAmount > 0)
{
//btnAutoApply.Enabled = true;
}
else
{
//btnAutoApply.Enabled = false;
}
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
oARC =
null
;
oART =
null
;
}
}
private
void
RollbackCredit(
int
iID)
{
LaundryLogicDAL.ARApplicationsCollection oARAC =
new
LaundryLogicDAL.ARApplicationsCollection();
LaundryLogicDAL.ARDebits oARD =
new
LaundryLogicDAL.ARDebits();
LaundryLogicDAL.ARCredits oARC =
new
LaundryLogicDAL.ARCredits();
try
{
string
sCreditIdentifier =
""
;
oARAC.es.Connection.Name =
"NAS"
;
oARAC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARD.es.Connection.Name =
"NAS"
;
oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARC.es.Connection.Name =
"NAS"
;
oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
//Get all applications with the Credit ID = iID
oARAC.Query.Where(
oARAC.Query.CreditID == iID
);
if
(oARAC.Query.Load())
{
//begin transaction
using
(esTransactionScope scope =
new
esTransactionScope())
{
//for each application record
for
(
int
i = 0; i < oARAC.Count; i++)
{
//get invoice record
if
(oARD.LoadByPrimaryKey((
int
)oARAC[i].DebitID))
{
//update invoice record set remaining amount = remaining amount + application amount
oARD.RemainingAmount = oARD.RemainingAmount + oARAC[i].Amount;
oARD.Save();
}
//get credit record
if
(oARC.LoadByPrimaryKey(iID))
{
//update credit record set remaining amount = remaining amount + application amount
oARC.RemainingAmount = oARC.RemainingAmount + oARAC[i].Amount;
sCreditIdentifier = oARC.CreditIdentifier;
oARC.Save();
}
}
oARAC.MarkAllAsDeleted();
oARAC.Save();
scope.Complete();
}
}
//else
//{
// if (oARC.LoadByPrimaryKey(iID))
// {
// //update credit record set remaining amount = remaining amount + application amount
// oARC.RemainingAmount = oARC.RemainingAmount + oARAC[i].Amount;
// sCreditIdentifier = oARC.CreditIdentifier;
// //oARC.MarkAsDeleted();
// oARC.Save();
// }
//}
//commit transaction
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
oARAC.Dispose();
oARAC =
null
;
oARC =
null
;
oARD =
null
;
}
}
private
void
SetConnection()
{
//If there is no default connection named DNNFulcrum
if
(esConfigSettings.ConnectionInfo.Default !=
"DNNFulcrum"
)
{
//Get the connectionInfo section from the web.config
esConfigSettings ConnectionInfoSettings = esConfigSettings.ConnectionInfo;
//loop through each connection...
foreach
(esConnectionElement connection
in
ConnectionInfoSettings.Connections)
{
//if there is a DNNFulcrum in es connections set it default
if
(connection.Name ==
"DNNFulcrum"
)
{
esConfigSettings.ConnectionInfo.Default = connection.Name;
return
;
}
}
}
// Register the Loader
esProviderFactory.Factory =
new
EntitySpaces.LoaderMT.esDataProviderFactory();
}
private
void
SetRowsToEditMode()
{
//try
//{
// for (int i = 0; i < rgDebits.PageSize; i++)
// {
// rgDebits.EditIndexes.Add(i);
// }
//}
//catch(Exception ex)
//{
// DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
//}
}
private
void
SetVisibility(
string
sFunction)
{
//System.Web.UI.UserControl ucPayments = (System.Web.UI.UserControl)this.Parent.Parent;
//PlaceHolder phAccounts = (PlaceHolder)ucPayments.FindControl("phAccounts");
//PlaceHolder phCredits = (PlaceHolder)ucPayments.FindControl("phCredits");
//PlaceHolder phApplyPayments = (PlaceHolder)ucPayments.FindControl("phApplyPayments");
//System.Web.UI.UserControl ucCredits = (System.Web.UI.UserControl)phCredits.FindControl("Credits1");
//RadGrid rgCredits = (RadGrid)ucCredits.FindControl("rgCredits");
//rgCredits.Rebind();
//switch (sFunction)
//{
// case "Customer":
// {
// phAccounts.Visible = true;
// phCredits.Visible = false;
// phApplyPayments.Visible = false;
// break;
// }
// case "Payment":
// {
// phAccounts.Visible = false;
// phCredits.Visible = true;
// phApplyPayments.Visible = false;
// break;
// }
// case "Apply":
// {
// phAccounts.Visible = false;
// phCredits.Visible = false;
// phApplyPayments.Visible = true;
// break;
// }
//}
}
#endregion Methods
protected
void
btnClearAll_Click(
object
sender, EventArgs e)
{
ClearAll();
//SetVisibility("Apply");
}
private
void
ClearAll()
{
foreach
(GridItem item
in
rgDebits.EditItems)
{
GridDataItem dataitem = (GridDataItem)item;
CheckBox chkApply = (CheckBox)dataitem[
"Apply"
].FindControl(
"chkApply"
);
RadNumericTextBox txtAmountApplied = (RadNumericTextBox)dataitem[
"AmountApplied"
].FindControl(
"txtAmountApplied"
);
chkApply.Checked =
false
;
txtAmountApplied.Text =
""
;
}
//lblPaymentRemaining.Text = lblPaymentAmount.Text;
}
protected
void
btnAutoApply_Click(
object
sender, EventArgs e)
{
if
(Session[
"EntityType"
] !=
null
&&
Session[
"EntityID"
] !=
null
&&
Session[
"PaymentID"
] !=
null
)
{
string
sEntityType = Session[
"EntityType"
].ToString();
int
iEntityID = (
int
)Session[
"EntityID"
];
int
iCreditID = (
int
)Session[
"PaymentID"
];
AutoApplyCredit(iCreditID, iEntityID, sEntityType);
LoadPayment();
rgDebits.Rebind();
ClearAll();
//SetVisibility("Apply");
}
}
protected
void
btnRollbackAll_Click(
object
sender, EventArgs e)
{
if
(Session[
"PaymentID"
] !=
null
)
{
int
iPaymentID = (
int
)Session[
"PaymentID"
];
RollbackCredit(iPaymentID);
rgDebits.Rebind();
ClearAll();
}
}
protected
void
rgDebits_PreRender(
object
sender, EventArgs e)
{
try
{
for
(
int
i = 0; i < rgDebits.PageSize; i++)
{
rgDebits.EditIndexes.Add(i);
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
}
protected
void
btnRollbackSelected_Click(
object
sender, EventArgs e)
{
foreach
(GridEditableItem oEditItem
in
rgDebits.MasterTableView.Items)
{
CheckBox chkApply = (CheckBox)oEditItem.FindControl(
"chkApply"
);
if
(chkApply.Checked)
{
int
iApplicationID = (
int
)oEditItem.OwnerTableView.DataKeyValues[oEditItem.ItemIndex][
"ID"
];
RollbackApplication((
int
)Session[
"PaymentID"
], iApplicationID);
}
}
LoadPayment();
rgDebits.Rebind();
UpdatePanel oUP = (UpdatePanel)
this
.Parent.Parent;
oUP.Update();
}
private
void
RollbackApplication(
int
iCreditID,
int
iDebitID)
{
//need to get the creditID and debit ID from the application record, then
//add the applied amount to the credit remaining amount
//add the applied amount to the debit remaining amount
//delete the application
LaundryLogicDAL.ARApplications oARA =
new
LaundryLogicDAL.ARApplications();
LaundryLogicDAL.ARDebits oARD =
new
LaundryLogicDAL.ARDebits();
LaundryLogicDAL.ARCredits oARC =
new
LaundryLogicDAL.ARCredits();
try
{
string
sCreditIdentifier =
""
;
oARA.es.Connection.Name =
"NAS"
;
oARA.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARD.es.Connection.Name =
"NAS"
;
oARD.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
oARC.es.Connection.Name =
"NAS"
;
oARC.es.Connection.SqlAccessType = esSqlAccessType.DynamicSQL;
//Get all applications with the Credit ID = iID
oARA.Query.Where(oARA.Query.CreditID == iCreditID, oARA.Query.DebitID == iDebitID);
if
(oARA.Query.Load())
{
//begin transaction
using
(esTransactionScope scope =
new
esTransactionScope())
{
//get invoice record
if
(oARD.LoadByPrimaryKey((
int
)oARA.DebitID))
{
//update invoice record set remaining amount = remaining amount + application amount
oARD.RemainingAmount = oARD.RemainingAmount + oARA.Amount;
oARD.Save();
}
//get credit record
if
(oARC.LoadByPrimaryKey((
int
)oARA.CreditID))
{
//update credit record set remaining amount = remaining amount + application amount
oARC.RemainingAmount = oARC.RemainingAmount + oARA.Amount;
sCreditIdentifier = oARC.CreditIdentifier;
oARC.Save();
}
oARA.MarkAsDeleted();
oARA.Save();
scope.Complete();
}
}
}
catch
(Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(
this
, ex);
}
finally
{
oARA =
null
;
oARC =
null
;
oARD =
null
;
}
}
}
}
<
telerik:RadWindowManager
ID
=
"winmanParolee"
runat
=
"server"
ReloadOnShow
=
"false"
VisibleOnPageLoad
=
"false"
KeepInScreenBounds
=
"true"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"winPopup"
runat
=
"server"
OpenerElementID
=
"Button1"
ShowContentDuringLoad
=
"true"
KeepInScreenBounds
=
"true"
Modal
=
"true"
Width
=
"600px"
Height
=
"400px"
>
<
ContentTemplate
>
<
script
type
=
"text/javascript"
>
function Close() {
GetRadWindow().Close();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
</
script
>
<
div
>
My dialog content here...
<
telerik:RadSchedulerRecurrenceEditor
ID
=
"RadSchedulerRecurrenceEditor1"
runat
=
"server"
>
</
telerik:RadSchedulerRecurrenceEditor
>
<
asp:Button
ID
=
"Button3"
runat
=
"server"
Text
=
"Close"
OnClick
=
"close_click"
/>
</
div
>
</
ContentTemplate
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
protected void close_click(object sender, EventArgs e)
{
Label1.Text = "<
script
type
=
'text/javascript'
>Close()</" + "script>";
// Page.ClientScript.RegisterStartupScript(this.GetType(), "", "Close()",true);
}
Hi
I'm using the telerik RadGrid. What I want to do is to add a row in the header of the grid to group the columns which has checboxes in it.
Currently I have the columns as GridCheckbox column in the masterview table.
Example:
<MasterTableView >
<Columns>
<telerik:GridCheckBoxColumn DataField="1" HeaderText="1" />
<telerik:GridCheckBoxColumn DataField="2" HeaderText="2" />
<telerik:GridCheckBoxColumn DataField="3" HeaderText="3" />
All I want to do is just add a customer header that show two or more column headers grouped togeather. I don't need to group any data.
like
header 1: group Header
header 2: 1 2 3
and then the values of the columns 1 2 and 3 in check boxes
How can i do this?
Does anyone have any idea?
<
telerik:RadAjaxLoadingPanel
ID
=
"LocationsLoadingPanel"
runat
=
"server"
Transparency
=
"30"
Skin
=
"Vista"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
ID
=
"LocationsPanel"
runat
=
"server"
LoadingPanelID
=
"LocationsLoadingPanel"
>
<
telerik:RadTreeView
ID
=
"LocationsTreeView"
runat
=
"server"
EnableDragAndDrop
=
"true"
MultipleSelect
=
"true"
EnableDragAndDropBetweenNodes
=
"true"
AllowNodeEditing
=
"true"
OnContextMenuItemClick
=
"LocationsTreeView_ContextMenuItemClick"
OnClientContextMenuItemClicking
=
"onClientContextMenuItemClicking"
OnClientContextMenuShowing
=
"onClientContextMenuShowing"
OnNodeEdit
=
"LocationsTreeView_NodeEdit"
OnNodeDrop
=
"LocationsTreeView_NodeDrop"
OnClientNodeDropping
=
"onNodeDropping"
OnClientNodeDragging
=
"onNodeDragging"
>
<
ContextMenus
>
<
telerik:RadTreeViewContextMenu
ID
=
"MainContextMenu"
runat
=
"server"
>
<
Items
>
<
telerik:RadMenuItem
Value
=
"Rename"
Text
=
"Rename ..."
Enabled
=
"true"
ImageUrl
=
"images/icons/edit_48.png"
PostBack
=
"false"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
IsSeparator
=
"true"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Value
=
"addLocation"
Text
=
"Add Location"
ImageUrl
=
"images/icons/add_16.png"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Value
=
"editDetails"
Text
=
"Edit Details"
PostBack
=
"true"
/>
</
Items
>
<
CollapseAnimation
Type
=
"none"
/>
</
telerik:RadTreeViewContextMenu
>
</
ContextMenus
>
</
telerik:RadTreeView
>
<
telerik:RadFormDecorator
ID
=
"RadFormDecorator1"
runat
=
"server"
Skin
=
"Vista"
DecoratedControls
=
"All"
/>
<
telerik:RadWindow
ID
=
"editDetails_RadWindow"
runat
=
"server"
Modal
=
"true"
Behaviors
=
"Close"
Width
=
"300px"
Height
=
"150px"
DestroyOnClose
=
"true"
VisibleStatusbar
=
"false"
>
<
ContentTemplate
>
<
table
>
<
tr
>
<
td
><
asp:Label
ID
=
"editDetailsIDlbl"
Text
=
"ID: "
runat
=
"server"
/></
td
>
<
td
><
telerik:RadTextBox
ID
=
"editDetailsIDtxt"
runat
=
"server"
Enabled
=
"false"
/>
<
asp:Label
ID
=
"InjectScript"
runat
=
"server"
/></
td
>
</
tr
>
<
tr
>
<
td
><
asp:Label
ID
=
"editDetailsCostCtrLbl"
Text
=
"Cost Center:"
runat
=
"server"
/></
td
>
<
td
><
telerik:RadTextBox
ID
=
"editDetailsCostCtrTxt"
runat
=
"server"
EmptyMessage
=
"Enter Cost Center"
/>
</
td
>
</
tr
>
<
tr
>
<
td
><
asp:Label
ID
=
"editDetailsAuxLocLbl"
Text
=
"Aux Location: "
runat
=
"server"
/></
td
>
<
td
><
telerik:RadTextBox
ID
=
"editDetailsAuxLocTxt"
runat
=
"server"
EmptyMessage
=
"Enter Aux Location"
/></
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
><
telerik:RadButton
ID
=
"editDetailsUpdateBtn"
runat
=
"server"
Text
=
"Update"
CommandArgument
=
"LocationID"
OnClick
=
"editDetailsUpdateBtn_Click"
/></
td
>
</
tr
>
</
table
>
</
ContentTemplate
>
</
telerik:RadWindow
>
<
telerik:RadWindowManager
ID
=
"locationRadWindow"
runat
=
"server"
/>
</
telerik:RadAjaxPanel
>
protected
void
LocationsTreeView_ContextMenuItemClick(
object
sender, RadTreeViewContextMenuEventArgs e)
{
RadTreeNode clickedNode = e.Node;
switch
(e.MenuItem.Value)
{
case
"addLocation"
:
RadTreeNode newLocation =
new
RadTreeNode(
string
.Format(
"New Location"
));
newLocation.Selected =
true
;
newLocation.ImageUrl = clickedNode.ImageUrl;
clickedNode.Nodes.Add(newLocation);
clickedNode.Expanded =
true
;
//update the number in the brackets
if
(Regex.IsMatch(clickedNode.Text, unreadPattern))
clickedNode.Text = Regex.Replace(clickedNode.Text, unreadPattern,
"("
+ clickedNode.Nodes.Count.ToString() +
")"
);
clickedNode.Font.Bold =
true
;
//set node's value so we can find it in startNodeInEditMode
// Add Location Record to Database
string
ParentID = clickedNode.Value;
Guid ID = Guid.NewGuid();
string
LocationID = ID.ToString();
// Used for naming the node after adding it
newLocation.Value = LocationID;
startNodeInEditMode(newLocation.Value);
string
Name = newLocation.Text;
LocationsTreeView_AddLocation(ParentID, LocationID, Name);
break
;
case
"editDetails"
:
// Get the location of the item were editing
string
LocID = clickedNode.Value;
string
CostCtr =
""
;
string
AuxLoc =
""
;
// Get Cost Center and Aux Location if it exists
SqlCommand locationDetailsCmd =
new
SqlCommand(
"SELECT CostCenter, AuxLocationID FROM dbo.Locations WHERE ID='"
+ LocID +
"'"
, connection);
connection.Open();
SqlDataReader rdr = locationDetailsCmd.ExecuteReader();
while
(rdr.Read())
{
if
(!rdr.IsDBNull(0))
CostCtr = rdr.GetString(0).ToString();
if
(!rdr.IsDBNull(1))
AuxLoc = rdr.GetString(1).ToString();
}
connection.Close();
editDetails_RadWindow.VisibleOnPageLoad =
true
;
// Set the RadWindow TextBox Values
editDetailsCostCtrTxt.Text = CostCtr;
editDetailsAuxLocTxt.Text = AuxLoc;
editDetailsIDtxt.Text = LocID;
locationRadWindow.Windows.Add(editDetails_RadWindow);
break
;
}
}
protected
void
editDetailsUpdateBtn_Click(
object
sender, EventArgs e)
{
string
AuxLocation = editDetailsAuxLocTxt.Text;
string
CostCenter = editDetailsCostCtrTxt.Text;
string
LocationID = editDetailsIDtxt.Text;
SqlCommand editDetailsUpdateCmd =
new
SqlCommand(
"UPDATE dbo.locations SET CostCenter='"
+ CostCenter +
"', AuxLocationID='"
+ AuxLocation +
"' WHERE ID ='"
+ LocationID +
"'"
, connection);
connection.Open();
editDetailsUpdateCmd.ExecuteNonQuery();
connection.Close();
}
<
telerik:RadEditor
runat
=
"server"
ID
=
"CntntRadEditor"
Height
=
"500px"
Width
=
"100%"
style
=
"z-index:1000;"
Content='<%# DataBinder.Eval( Container, "DataItem.Cntnt") %>' ToolsFile="~/Common/Controls/RadEditor/xml/CustomFullSetOfToolsForSecureTables.xml">
<
Modules
>
<
telerik:EditorModule
Visible
=
"false"
/>
</
Modules
>
<
ImageManager
ViewPaths
=
"~/P/Design/Contents/Guide"
UploadPaths
=
"~/P/Design/Contents/Guide"
DeletePaths
=
"~/P/Design/Contents/Guide"
/>
<
DocumentManager
ViewPaths
=
"~/P/Design/Contents/Guide"
UploadPaths
=
"~/P/Design/Contents/Guide"
DeletePaths
=
"~/P/Design/Contents/Guide"
/>
</
telerik:RadEditor
>
function
onSaveNotificationPanel_Updating(sender, args) {
var
callbackresult = Sys.Serialization.JavaScriptSerializer.deserialize(args.get_content());
//Put the content into the panel
args.set_cancel(
true
);
args.set_content(callbackresult.Message);
}