Exemplo n.º 1
0
//-------------------------------------------------------------------------------------------
    private void BindByMonth()
    {
        string sql = @"select 
               month(postat) as 'Month',
               Sum(Amount) as 'Total'
               from Accounting_LedgerItems
               where
                    OrganizationId = @OrganizationId and
                    LedgerType != @Receivable and
                    LedgerType = @CreditCard and
                    Year(PostAt) = @Year
               Group By Year(PostAt), Month(PostAt)
               Order By Year(PostAt) desc, Month(PostAt) desc";

        SqlCommand command = new SqlCommand(sql, connection);

        command.Parameters.AddWithValue("OrganizationId", SelectedOrganization.Id);
        command.Parameters.AddWithValue("Year", Int32.Parse(YearFilter.Text));
        command.Parameters.AddWithValue("Receivable", (byte)LedgerType.Receivable);
        command.Parameters.AddWithValue("CreditCard", (byte)LedgerType.CreditCard);
        SqlDataReader reader = command.ExecuteReader();

        ByMonth.DataSource = reader;
        ByMonth.DataBind();
        reader.Close();
    }