using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;

namespace Library
{
    public partial class FormReport : Form
    {
        public FormReport()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ReportDocument rd = new ReportDocument();
            DataAccess da = new DataAccess();
            DataTable dt = new DataTable();
            da.Connect();
            string sql;
            switch (comboBox1.Text)
            {
                case "کتاب":
                    rd.FileName = "BookReport.rpt";
                    sql = "select * from book";
                    dt = da.Select(sql);
                    rd.SetDataSource(dt);
                    crystalReportViewer1.ReportSource = rd;
                    crystalReportViewer1.Show();
                    break;
                case "امانت" :
                    rd.FileName = "BorrowReport.rpt";
                    sql = "select * from borrow";
                    dt = da.Select(sql);
                    rd.SetDataSource(dt);
                    crystalReportViewer1.ReportSource = rd;
                    crystalReportViewer1.Show();
                    break;
                case "اعضاء" :
                    rd.FileName = "MemberReport.rpt";
                    sql = "select * from member";
                    dt = da.Select(sql);
                    rd.SetDataSource(dt);
                    crystalReportViewer1.ReportSource = rd;
                    crystalReportViewer1.Show();
                    break;
            }
            da.DisConnect();
        }
    }
}
