<dx:ASPxGridView ID="gvSummary" runat="server" AutoGenerateColumns="False" SkinID="AspxGridSkin"
Width="100%" KeyFieldName="Muser_userid">
<Columns>
<dx:GridViewDataTextColumn Caption="Emp. No." FieldName="Muser_empno" VisibleIndex="0">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Name" FieldName="Muser_displayName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Grade" FieldName="Grade_desc" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Travel Expense" FieldName="TE" VisibleIndex="3">
<DataItemTemplate>
<asp:HyperLink ID="hlTE" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("TE")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTETotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Travel Ticket" FieldName="Ticket" VisibleIndex="4">
<DataItemTemplate>
<asp:HyperLink ID="hlTicket" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("Ticket")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTTTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Pettycash Expense" FieldName="PettyCash" VisibleIndex="5">
<DataItemTemplate>
<asp:HyperLink ID="hlPettyCash" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("PettyCash")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlPCTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Other Expense" FieldName="NewExpense" VisibleIndex="6">
<DataItemTemplate>
<asp:HyperLink ID="hlNewExpense" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("NewExpense")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlNETotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Total" FieldName="Total" VisibleIndex="7">
<DataItemTemplate>
<asp:HyperLink ID="hlTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("Total")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTotalTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
</Columns>
<Settings ShowFilterRow="True" ShowFooter="True" />
<TotalSummary>
<dx:ASPxSummaryItem DisplayFormat="{0:Total}" FieldName="Muser_empno" ShowInColumn="Emp. No."
SummaryType="Count" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="TE" ShowInColumn="Travel Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="Ticket" ShowInColumn="Travel Ticket"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="PettyCash" ShowInColumn="Pettycash Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="NewExpense" ShowInColumn="Other Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="Total" ShowInColumn="Total"
SummaryType="Sum" />
</TotalSummary>
<SettingsPager PageSize="15">
</SettingsPager>
</dx:ASPxGridView>
Protected Sub gvHL_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim hl As HyperLink = DirectCast(sender, HyperLink)
Dim container As GridViewDataItemTemplateContainer = TryCast(hl.NamingContainer, GridViewDataItemTemplateContainer)
hl.NavigateUrl = "frmExpenseReport_Detail.aspx?EmpNo=" & objEncrypt.Encrypt1(container.KeyValue) & _
"&FromDate=" & objEncrypt.Encrypt1(txtFrom.Text) & _
"&ToDate=" & objEncrypt.Encrypt1(txtTo.Text) & _
"&Type=" & objEncrypt.Encrypt1(container.Column.Caption.ToString())
End Sub
Protected Sub gvFooterHL_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim hl As HyperLink = DirectCast(sender, HyperLink)
Dim container As GridViewFooterCellTemplateContainer = TryCast(hl.NamingContainer, GridViewFooterCellTemplateContainer)
If container.Grid.VisibleRowCount > 0 Then
hl.Text = GetSummaryValue(container)
End If
If hl.Text <> "0" Then
hl.NavigateUrl = "frmExpenseReport_Detail.aspx?EmpNo=" & objEncrypt.Encrypt1("%") & _
"&FromDate=" & objEncrypt.Encrypt1(txtFrom.Text) & _
"&ToDate=" & objEncrypt.Encrypt1(txtTo.Text) & _
"&Type=" & objEncrypt.Encrypt1(container.Column.Caption.ToString())
Else
hl.NavigateUrl = ""
End If
End Sub
Protected Function GetSummaryValue(ByVal container As GridViewFooterCellTemplateContainer) As String
Dim gridView As ASPxGridView = container.Grid
Dim column As GridViewDataColumn = TryCast(container.Column, GridViewDataColumn)
If column Is Nothing Then
Return String.Empty
End If
For i As Integer = 0 To gridView.TotalSummary.Count - 1
If gridView.TotalSummary(i).FieldName = column.FieldName Then
Return gridView.GetTotalSummaryValue(gridView.TotalSummary(column.FieldName)).ToString()
End If
Next
Return String.Empty
End Function
Width="100%" KeyFieldName="Muser_userid">
<Columns>
<dx:GridViewDataTextColumn Caption="Emp. No." FieldName="Muser_empno" VisibleIndex="0">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Name" FieldName="Muser_displayName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Grade" FieldName="Grade_desc" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Travel Expense" FieldName="TE" VisibleIndex="3">
<DataItemTemplate>
<asp:HyperLink ID="hlTE" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("TE")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTETotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Travel Ticket" FieldName="Ticket" VisibleIndex="4">
<DataItemTemplate>
<asp:HyperLink ID="hlTicket" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("Ticket")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTTTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Pettycash Expense" FieldName="PettyCash" VisibleIndex="5">
<DataItemTemplate>
<asp:HyperLink ID="hlPettyCash" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("PettyCash")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlPCTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Other Expense" FieldName="NewExpense" VisibleIndex="6">
<DataItemTemplate>
<asp:HyperLink ID="hlNewExpense" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("NewExpense")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlNETotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="Total" FieldName="Total" VisibleIndex="7">
<DataItemTemplate>
<asp:HyperLink ID="hlTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvHL_Init"><%#Eval("Total")%></asp:HyperLink>
</DataItemTemplate>
<FooterTemplate>
<asp:HyperLink ID="hlTotalTotal" NavigateUrl="#" runat="server" Target="_blank" OnInit="gvFooterHL_Init"></asp:HyperLink>
</FooterTemplate>
</dx:GridViewDataTextColumn>
</Columns>
<Settings ShowFilterRow="True" ShowFooter="True" />
<TotalSummary>
<dx:ASPxSummaryItem DisplayFormat="{0:Total}" FieldName="Muser_empno" ShowInColumn="Emp. No."
SummaryType="Count" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="TE" ShowInColumn="Travel Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="Ticket" ShowInColumn="Travel Ticket"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="PettyCash" ShowInColumn="Pettycash Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="NewExpense" ShowInColumn="Other Expense"
SummaryType="Sum" />
<dx:ASPxSummaryItem DisplayFormat="{0:0}" FieldName="Total" ShowInColumn="Total"
SummaryType="Sum" />
</TotalSummary>
<SettingsPager PageSize="15">
</SettingsPager>
</dx:ASPxGridView>
Protected Sub gvHL_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim hl As HyperLink = DirectCast(sender, HyperLink)
Dim container As GridViewDataItemTemplateContainer = TryCast(hl.NamingContainer, GridViewDataItemTemplateContainer)
hl.NavigateUrl = "frmExpenseReport_Detail.aspx?EmpNo=" & objEncrypt.Encrypt1(container.KeyValue) & _
"&FromDate=" & objEncrypt.Encrypt1(txtFrom.Text) & _
"&ToDate=" & objEncrypt.Encrypt1(txtTo.Text) & _
"&Type=" & objEncrypt.Encrypt1(container.Column.Caption.ToString())
End Sub
Protected Sub gvFooterHL_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim hl As HyperLink = DirectCast(sender, HyperLink)
Dim container As GridViewFooterCellTemplateContainer = TryCast(hl.NamingContainer, GridViewFooterCellTemplateContainer)
If container.Grid.VisibleRowCount > 0 Then
hl.Text = GetSummaryValue(container)
End If
If hl.Text <> "0" Then
hl.NavigateUrl = "frmExpenseReport_Detail.aspx?EmpNo=" & objEncrypt.Encrypt1("%") & _
"&FromDate=" & objEncrypt.Encrypt1(txtFrom.Text) & _
"&ToDate=" & objEncrypt.Encrypt1(txtTo.Text) & _
"&Type=" & objEncrypt.Encrypt1(container.Column.Caption.ToString())
Else
hl.NavigateUrl = ""
End If
End Sub
Protected Function GetSummaryValue(ByVal container As GridViewFooterCellTemplateContainer) As String
Dim gridView As ASPxGridView = container.Grid
Dim column As GridViewDataColumn = TryCast(container.Column, GridViewDataColumn)
If column Is Nothing Then
Return String.Empty
End If
For i As Integer = 0 To gridView.TotalSummary.Count - 1
If gridView.TotalSummary(i).FieldName = column.FieldName Then
Return gridView.GetTotalSummaryValue(gridView.TotalSummary(column.FieldName)).ToString()
End If
Next
Return String.Empty
End Function
No comments:
Post a Comment