<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Register TagPrefix="Hersh" TagName="nav" Src="nav.ascx" %>
<html>
<script language="VB" runat="server">
Dim ConnStr      As String
Dim SQL          As String

Sub Page_Load(Source As Object, E As EventArgs) 
   ConnStr = "Provider=SQLOLEDB; Data Source=(local); "
   ConnStr = ConnStr+" Initial Catalog=ASPNET;User ID=sa;"
    if NOT (isPostBack)
	rebind
    end if	
End Sub
Sub ReBind()
    Dim t As New NameSpaceHersh.SQLService
    Dim ds as DataSet 	   
    sql = "SELECT  code_display, closing, "
    sql = sql + " dr_amount =  CASE type  WHEN 'A'   THEN "
    sql = sql + " closing  WHEN 'E'   THEN closing  ELSE  0     END, "
    sql = sql + "  cr_amount = CASE type  WHEN 'I'  "
    sql = sql + "  THEN closing   WHEN 'L'   THEN closing  ELSE  0   END "
    sql = sql + " From Masters"  
    ds = t.Populate(ConnStr, SQL)
    Grid1.DataSource=ds.Tables("vTable").DefaultView
    Grid1.DataBind()
     'totals
     sql =  "SELECT 'Total' as nothing ,"
     sql = sql + " (Select sum(closing) From masters "
     sql = sql + " where type in('A','E')) as dr_total , "
     sql = sql + " (Select sum(closing) From masters  "
     sql = sql + " where type in('I','L')) as cr_total "
     ds = t.Populate(ConnStr, sql)
     Grid2.DataSource=ds.Tables("vTable").DefaultView
     Grid2.DataBind()
End Sub
</script>
  
<head>
    	<style>
    	a	{	color:black;
    			text-decoration:none;}
    	a:hover	{	color:red;
    			text-decoration:underline;}
    	</style>
 </head>
<body style="font: 10pt verdana; background-color:ivory">
       <!---- 导航条 开始-------------->
              <Hersh:nav id="menu" runat = server 
              vGridlines = Both
              vBorderColor = "Black"
              vCellPadding = 7 />
       <!---- 导航条 结束-------------->
        <h3><font face="Verdana">Trial Balance </font></h3>
	<br> 
       <asp:DataGrid id="Grid1" runat="server"
           AutoGenerateColumns="false"
           BackColor="White"
           BorderWidth="1px" BorderStyle="Solid" BorderColor="Tan"
           CellPadding="2" CellSpacing="0"
           Font-Name="Verdana" Font-Size="8pt"
           >
<Columns>
           <asp:BoundColumn HeaderText="Account" DataField="code_display" >
             <HeaderStyle Width="150px">
          
             </HeaderStyle>
           </asp:BoundColumn>
           <asp:BoundColumn HeaderText="Debit Amount" DataField="dr_amount">
                 <HeaderStyle Width="150px">
             
                 </HeaderStyle>
           </asp:BoundColumn>
           <asp:BoundColumn HeaderText="Credit Amount" DataField="cr_amount">
             <HeaderStyle Width="150px">
             
             </HeaderStyle>
           </asp:BoundColumn>
         </Columns>
         <HeaderStyle BackColor="teal" ForeColor="white" Font-Bold="true">
          
         </HeaderStyle>
         <ItemStyle ForeColor="DarkSlateBlue">
         
         </ItemStyle>
         <AlternatingItemStyle BackColor="Beige">
         
         </AlternatingItemStyle>
       </asp:DataGrid>
       <!----所有 //---->
	  <asp:DataGrid id="Grid2" runat="server"
	            AutoGenerateColumns="false"
	            BackColor="White"
	            BorderWidth="1px" BorderStyle="Solid" BorderColor="Tan"
	            CellPadding="2" CellSpacing="0"
	            Font-Name="Verdana" Font-Size="8pt"
	            >
		   <Columns>
	            <asp:BoundColumn HeaderText="" DataField="nothing">
	              <HeaderStyle Width="150px">
	              
	              </HeaderStyle>
	            </asp:BoundColumn> 
	             </Columns>
<Columns>
	            <asp:BoundColumn HeaderText="" DataField="dr_total">
	              <HeaderStyle Width="150px">
	               
	              </HeaderStyle>
	            </asp:BoundColumn>
	            <asp:BoundColumn HeaderText="" DataField="cr_total">
	                  <HeaderStyle Width="150px">
	                 
	                  </HeaderStyle>
	            </asp:BoundColumn>
	          </Columns>
	          <ItemStyle BackColor="teal" foreColor="white" Font-Bold="true">
	          
	          </ItemStyle>
       </asp:DataGrid>
       </form>
    </body>
</html>
