Пример #1
0
        private void btnSelectColumns_Click(object sender, EventArgs e)
        {
            if (this.currentReport == XEnum.ReportType.C_DQDKQK_M)
            {
                var form   = new frmCustomizeDQDK(this.SelectedColumns1, this.SelectedColumns2);
                var result = form.ShowDialog(this);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    this.SelectedColumns1.Clear();
                    this.SelectedColumns2.Clear();
                    this.SelectedColumns1.AddRange(TableMapping.GetFrozenColumnNames("ImportPublic"));
                    this.SelectedColumns1.AddRange(form.PublicColumns);
                    this.SelectedColumns1.AddRange(new string[] { "彻底从我行退出", "倒贷", "逾期", "化解方案" });

                    this.SelectedColumns2.AddRange(TableMapping.GetFrozenColumnNames("ImportPrivate"));
                    this.SelectedColumns2.AddRange(form.PrivateColumns);
                    this.SelectedColumns2.AddRange(new string[] { "彻底从我行退出", "倒贷", "展期", "逾期", "化解方案" });
                }
            }
            else if (this.currentReport == XEnum.ReportType.C_XZDKMX_D)
            {
                var form = new frmCustomizeOne(this.SelectedColumns)
                {
                    MappingTable = Consts.C_XZDKMX_D, FormTitle = "新增贷款明细表自定义"
                };
                var result = form.ShowDialog(this);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    this.SelectedColumns.Clear();
                    this.SelectedColumns.AddRange(TableMapping.GetFrozenColumns(Consts.C_XZDKMX_D));
                    this.SelectedColumns.AddRange(form.Columns);
                }
            }
            else if (this.currentReport == XEnum.ReportType.C_JQDKMX_D)
            {
                var form = new frmCustomizeOne(this.SelectedColumns)
                {
                    MappingTable = Consts.C_JQDKMX_D, FormTitle = "结清贷款明细表自定义"
                };
                var result = form.ShowDialog(this);
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    this.SelectedColumns.Clear();
                    this.SelectedColumns.AddRange(TableMapping.GetFrozenColumns(Consts.C_JQDKMX_D));
                    this.SelectedColumns.AddRange(form.Columns);
                }
            }
        }
Пример #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            DateTime asOfDate, asOfDate2;

            if (!IsValidToExport(out asOfDate, out asOfDate2))
            {
                return;
            }
            var exporter = new Exporter();

            if (this.currentReport == XEnum.ReportType.C_DQDKQK_M)
            {
                if (this.SelectedColumns1.Count == 0)
                {
                    this.SelectedColumns1.AddRange(TableMapping.GetFrozenColumnNames("ImportPublic"));
                    this.SelectedColumns1.AddRange(new string[] { "彻底从我行退出", "倒贷", "逾期", "化解方案" });
                }
                if (this.SelectedColumns2.Count == 0)
                {
                    this.SelectedColumns2.AddRange(TableMapping.GetFrozenColumnNames("ImportPrivate"));
                    this.SelectedColumns2.AddRange(new string[] { "彻底从我行退出", "倒贷", "展期", "逾期", "化解方案" });
                }
            }
            else if (this.currentReport == XEnum.ReportType.C_XZDKMX_D)
            {
                if (this.SelectedColumns.Count == 0)
                {
                    this.SelectedColumns.AddRange(TableMapping.GetFrozenColumns(Consts.C_XZDKMX_D));
                }
                exporter.AsOfDate2 = asOfDate2;
                exporter.Columns   = this.SelectedColumns;
            }
            else if (this.currentReport == XEnum.ReportType.C_JQDKMX_D)
            {
                if (this.SelectedColumns.Count == 0)
                {
                    this.SelectedColumns.AddRange(TableMapping.GetFrozenColumns(Consts.C_JQDKMX_D));
                }
                exporter.AsOfDate2 = asOfDate2;
                exporter.Columns   = this.SelectedColumns;
            }
            this.Cursor = Cursors.WaitCursor;
            try {
                var startTime = DateTime.Now;                 // Use to count time cost
                var result    = exporter.ExportData(this.currentReport, asOfDate, asOfDate2, this.SelectedColumns1, this.SelectedColumns2);
                this.Cursor = Cursors.Default;
                if (string.IsNullOrEmpty(result))
                {
                    var seconds  = Math.Round((DateTime.Now - startTime).TotalSeconds);
                    var timeSpan = seconds > 3 ? string.Format("({0}秒)", seconds) : "";                     // Show time cost if longer than 3s
                    ShowInfo(string.Format("报表导出完毕。{0}", timeSpan));
                }
                else
                {
                    ShowError(result);
                }
            }
            catch (IOException ex) {
                if (ex.Message.IndexOf("it is being used by another process") > 0)
                {
                    ShowError("报表文件已经被打开,请先从Excel里关闭该报表然后再导出。");
                }
                else
                {
                    ShowError("导出发生错误");
                }
                logger.Error(ex);
            }
            catch (Exception ex) {
                logger.Error(ex);
                ShowError("导出发生错误");
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }