ReportForm.cs
上传用户:xyl529207
上传日期:2022-08-03
资源大小:935k
文件大小:4k
源码类别:

行业应用

开发平台:

SQL

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Data.SqlClient;
  9. namespace BookStoreMan
  10. {
  11.     public partial class ReportForm : Form
  12.     {
  13.         public ReportForm()
  14.         {
  15.             InitializeComponent();
  16.         }
  17.         private void ReportForm_Load(object sender, EventArgs e)
  18.         {
  19.             try
  20.             {
  21.                 this.V_BookSellTableAdapter.Fill(this.BookStoreDataSet.V_BookSell);
  22.                 this.reportViewer1.LocalReport.DataSources[0].Value = this.BookStoreDataSet.V_BookSell.DefaultView;
  23.                 this.reportViewer2.LocalReport.DataSources[0].Value = this.BookStoreDataSet.V_BookSell.DefaultView;
  24.                 this.reportViewer3.LocalReport.DataSources[0].Value = this.BookStoreDataSet.V_BookSell.DefaultView;
  25.                 this.RefreshReports();
  26.             }
  27.             catch (Exception exp)
  28.             {
  29.                 MessageBox.Show(exp.Message + exp.StackTrace);
  30.             }
  31.         }
  32.         private void radioButton1_CheckedChanged(object sender, EventArgs e)
  33.         {
  34.             if (radioButton1.Checked)
  35.             {
  36.                 this.BookStoreDataSet.V_BookSell.DefaultView.RowFilter = "";
  37.                 this.RefreshReports();
  38.             }
  39.         }
  40.         private void radioButton2_CheckedChanged(object sender, EventArgs e)
  41.         {
  42.             if (radioButton2.Checked)
  43.             {
  44.                 string sFilter = string.Format("TIME>'1/1/{0}' AND TIME<'12/31/{0} 23:59:59'", DateTime.Now.Year);
  45.                 this.BookStoreDataSet.V_BookSell.DefaultView.RowFilter = sFilter;
  46.                 this.RefreshReports();
  47.             }
  48.         }
  49.         private void radioButton3_CheckedChanged(object sender, EventArgs e)
  50.         {
  51.             if (radioButton3.Checked)
  52.             {
  53.                 int iYear = DateTime.Now.Year;
  54.                 int iMonth = DateTime.Now.Month;
  55.                 int iLastDay = DateTime.DaysInMonth(iYear, iMonth);
  56.                 string sFilter = string.Format("TIME>'{0}/1/{1}' AND TIME<'{0}/{2}/{1} 23:59:59'", iMonth, iYear, iLastDay);
  57.                 this.BookStoreDataSet.V_BookSell.DefaultView.RowFilter = sFilter;
  58.                 this.RefreshReports();
  59.             }
  60.         }
  61.         private void radioButton4_CheckedChanged(object sender, EventArgs e)
  62.         {
  63.             if (radioButton4.Checked)
  64.             {
  65.                 string sFilter = string.Format("TIME>'{0}/{1}/{2} 00:00:00' AND TIME<'{0}/{1}/{2} 23:59:59'", DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year);
  66.                 this.BookStoreDataSet.V_BookSell.DefaultView.RowFilter = sFilter;
  67.                 this.RefreshReports();
  68.             }        
  69.         }
  70.         private void radioButton5_CheckedChanged(object sender, EventArgs e)
  71.         {
  72.             button1.Enabled = radioButton5.Checked;
  73.         }
  74.         private void button1_Click(object sender, EventArgs e)
  75.         {
  76.             string sFilter = string.Format("TIME>'{0} 00:00:00' AND TIME<'{1} 23:59:59'", dateTimePicker1.Value.ToString("d"), dateTimePicker2.Value.ToString("d"));
  77.             this.BookStoreDataSet.V_BookSell.DefaultView.RowFilter = sFilter;
  78.             this.RefreshReports();
  79.         }
  80.         protected void RefreshReports()
  81.         {
  82.             this.reportViewer1.RefreshReport();
  83.             this.reportViewer2.RefreshReport();
  84.             this.reportViewer3.RefreshReport();
  85.         }
  86.     }
  87. }