private void InitReportPanel() { var report = this.Reports.Single(x => x.Id == (int)currentReport); if (report == null) { ShowStop("Failed to get entity of current report."); return; } this.lblReportTitle.Text = report.Name; this.SelectedColumns.Clear(); this.SelectedColumns1.Clear(); this.SelectedColumns2.Clear(); ShowAsOfDate2(); ShowExportDate(); ShowSelectColumnButton(); var dao = new SqlDbHelper(); var lastSelectValue = ""; var lastSelectValue2 = ""; if (IsMonthly()) { this.lblExportDate.Text = "数据月份:"; if (this.cmbReportMonth.SelectedIndex >= 0) { lastSelectValue = this.cmbReportMonth.Text; } this.cmbReportMonth.Items.Clear(); DataTable table; if (currentReport == XEnum.ReportType.C_DQDKQK_M) { table = dao.ExecuteDataTable("SELECT * FROM dbo.sfGetMonthsInFuture()"); } else { table = dao.ExecuteDataTable("SELECT ImportDate, dbo.sfGetImportStatus(ImportDate) AS status FROM Import WHERE DAY(ImportDate + 1) = 1 ORDER BY ImportDate DESC"); } if (table != null) { foreach (DataRow row in table.Rows) { var value = ((DateTime)row[0]).ToString("yyyy-MM"); if (row.ItemArray.Length > 1 && !((string)row[1]).StartsWith("1111111")) { value += " *"; } this.cmbReportMonth.Items.Add(value); if (!string.IsNullOrEmpty(lastSelectValue) && value.Equals(lastSelectValue)) { this.cmbReportMonth.Text = value; } } // Select the latest one by default if (this.cmbReportMonth.Items.Count > 0) { if (this.cmbReportMonth.SelectedIndex < 0) { this.cmbReportMonth.SelectedIndex = 0; } } } } else { this.lblExportDate.Text = "数据日期:"; var table = dao.ExecuteDataTable("SELECT ImportDate FROM Import ORDER BY ImportDate DESC"); if (this.cmbReportMonth.SelectedIndex >= 0) { lastSelectValue = this.cmbReportMonth.Text; } if (this.cmbReportMonth2.SelectedIndex >= 0) { lastSelectValue2 = this.cmbReportMonth2.Text; } this.cmbReportMonth.Items.Clear(); this.cmbReportMonth2.Items.Clear(); if (table != null) { foreach (DataRow row in table.Rows) { var value = ((DateTime)row[0]).ToString("yyyy-MM-dd"); this.cmbReportMonth.Items.Add(value); this.cmbReportMonth2.Items.Add(value); if (!string.IsNullOrEmpty(lastSelectValue) && value.Equals(lastSelectValue)) { this.cmbReportMonth.Text = value; } if (!string.IsNullOrEmpty(lastSelectValue2) && value.Equals(lastSelectValue2)) { this.cmbReportMonth2.Text = value; } } // Select the latest one by default if (this.cmbReportMonth.Items.Count > 0) { if (this.cmbReportMonth.SelectedIndex < 0) { this.cmbReportMonth.SelectedIndex = 0; } } if (this.cmbReportMonth2.Items.Count > 0) { if (this.cmbReportMonth2.SelectedIndex < 0) { this.cmbReportMonth2.SelectedIndex = 0; } } } } this.txtReportPath.Text = BaseReport.GetReportFolder(); }