protected override void BindData() { base.BindData(); List <Int32> financialYears = new List <Int32>(); DateTime fromDate = new DateTime(DateTime.Now.Year, 02, 28); if (DateTime.Now.Month <= 2) { if (DateTime.IsLeapYear(DateTime.Now.Year - 2)) { fromDate = new DateTime(DateTime.Now.Year - 2, 02, 29); } else { fromDate = new DateTime(DateTime.Now.Year - 2, 02, 28); } } else { if (DateTime.IsLeapYear(DateTime.Now.Year - 1)) { fromDate = new DateTime(DateTime.Now.Year - 1, 02, 29); } else { fromDate = new DateTime(DateTime.Now.Year - 1, 02, 28); } } //At the time when this software was spawned you could not put DateTime.Today.AddMonths(1) //in the where clause of the Linq to Entity query DateTime oneMonthInTheFuture = DateTime.Today.AddMonths(1); switch (balanceType) { case BalanceType.TrialBalance: //BindingSource.DataSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && /*n.PeriodStartDate > DateTime.Now.AddMonths(-17) && /*financialYears.Contains(n.FinancialYear.Value) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture).ToList(); EntityServerModeSource.QueryableSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && /*n.PeriodStartDate > DateTime.Now.AddMonths(-17) && /*financialYears.Contains(n.FinancialYear.Value) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture); break; case BalanceType.IncomeStatement: //BindingSource.DataSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && n.TypeFlag1 == "I" && /*n.PeriodStartDate > DateTime.Now.AddMonths(-36) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture).ToList(); EntityServerModeSource.QueryableSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && n.TypeFlag1 == "I" && /*n.PeriodStartDate > DateTime.Now.AddMonths(-36) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture); break; case BalanceType.BalanceSheet: //BindingSource.DataSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && n.TypeFlag1 == "B" && /*n.PeriodStartDate > DateTime.Now.AddMonths(-36) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture).ToList(); EntityServerModeSource.QueryableSource = DataContext.ReadonlyContext.VW_Balance.Where(n => n.AccountMasterControlId == null && n.TypeFlag1 == "B" && /*n.PeriodStartDate > DateTime.Now.AddMonths(-36) &&*/ n.PeriodEndDate >= fromDate && n.PeriodEndDate < oneMonthInTheFuture); break; } PivotControl.BestFit(); }
/// <summary> /// Opens the Entry screen showing the Entries that caused the selected cells movement /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Created: Werner Scheffer 07/03/2014</remarks> private void PivotControl_CellDoubleClick(object sender, DevExpress.XtraPivotGrid.PivotCellEventArgs e) { if (PivotControl.GetFieldValue(fieldAccountCode1, e.RowIndex) != null) { Entry.EntryList childForm = new Entry.EntryList(); childForm.AutoFilter(string.Format("StartsWith([EntityId.Title], '{0}') And StartsWith([HeaderId.PeriodId.Code], '{1}')", //AccountName PivotControl.GetFieldValue(fieldAccountCode1, e.RowIndex).ToString().Substring(0, 5), //Period Code PivotControl.GetFieldValue(e.ColumnField, e.ColumnIndex))); ShowForm(childForm); } }
/// <summary> /// Show the print preview form for the PivotControl. /// </summary> /// <remarks>Created: Theo Crous 14/11/2011</remarks> public override void OnPrintPreview() { try { base.OnPrintPreview(); if (PivotControl.IsPrintingAvailable) { PivotControl.ShowRibbonPrintPreview(); } } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
/// <summary> /// Export the current layout and values in the PivotControl to Csv file format. /// </summary> /// <remarks>Created: Theo Crous 14/11/2011</remarks> public override void OnExportToCSV() { try { base.OnExportToCSV(); string filepath = GetExportFilePath("CSV Files|*.csv"); if (filepath != null) { PivotControl.ExportToCsv(filepath); OpenExportFile(filepath); } } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }
/// <summary> /// Print the current layout and values in the PivotControl. /// </summary> /// <remarks>Created: Theo Crous 14/11/2011</remarks> public override void OnPrint() { try { base.OnPrint(); PivotControl.Print(); //DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem(); //DevExpress.XtraPrinting.PrintableComponentLink printableComponentLink = new DevExpress.XtraPrinting.PrintableComponentLink(ps); //printableComponentLink.Component = PivotControl; //printableComponentLink.Landscape = true; //printableComponentLink.PaperKind = System.Drawing.Printing.PaperKind.A4; //printableComponentLink.PrintingSystem.Document.AutoFitToPagesWidth = 1; //printableComponentLink.PrintingSystem.PrintDlg(); } catch (Exception ex) { if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex)) { throw ex; } } }