public string BuildReports(ExportDataOption option)
 {
     System.Text.StringBuilder contentForEmail = new System.Text.StringBuilder();
     string income = LocalizedStrings.GetLanguageInfoByKey("Income");
     string expense = LocalizedStrings.GetLanguageInfoByKey("Expense");
     (from p in this.AccountBookDataContext.AccountItems
      where (p.CreateTime.Date > option.StartDate.Value.Date) && (p.CreateTime.Date <= option.EndDate.Value.Date)
      orderby p.CreateTime descending
      select p into p
      orderby p.Type
      select p).ToList<AccountItem>().ForEach(delegate(AccountItem x)
     {
         contentForEmail.AppendFormat("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", new object[] { x.CreateTime, (x.Type == ItemType.Expense) ? expense : income, x.Category.ParentCategory.Name, x.Category.Name, x.AccountName, x.MoneyInfo, x.Description });
         contentForEmail.AppendLine();
     });
     return contentForEmail.ToString();
 }
        public ExportDataOptionPanel(ExportDataOption option, Func<string> expentionScope = null)
        {
            InitializeComponent();

            fileNameTag = LocalizedStrings.GetLanguageInfoByKey("FileName");
            subjectNameTag = LocalizedStrings.GetLanguageInfoByKey("SubjectName");

            SearchScopeSelector.ItemsSource = new string[] { 
                LocalizedStrings.GetLanguageInfoByKey("Today"),
                LocalizedStrings.GetLanguageInfoByKey("CurrentWeek"),
                LocalizedStrings.GetLanguageInfoByKey("CurrentMonth"),
                LocalizedStrings.GetLanguageInfoByKey("CurrentYear"),
                expentionScope==null?string.Empty:expentionScope(),
            };


            ExportDataOption = option ?? new ExportDataOption();
            ExportDataOption.ExportDataMode = ExportDataOption.ExportDataMode;
            ExportDataOption.ExportDataType = SummaryDataType.Statistics;
            ExportDataOption.SearchingScopeIndex = 2;//Component.SearchingScope.CurrentMonth;
            this.DataContext = ExportDataOption;

        }
 public string BuildReportsForExcel(ExportDataOption exportDataOption)
 {
     IOrderedQueryable<AccountItem> dataSource = from p in this.AccountBookDataContext.AccountItems
                                                 where (p.CreateTime.Date > exportDataOption.StartDate.Value.Date) && (p.CreateTime.Date <= exportDataOption.EndDate.Value.Date)
                                                 orderby p.CreateTime descending
                                                 select p into p
                                                 orderby p.Type
                                                 select p;
     return this.BuildAccountItemReport(dataSource);
 }