using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LibraryMembers
{
    public partial class rptBooks : Form
    {
        DataSet1 d1 = new DataSet1();
        DataSet1 d11 = new DataSet1();
        DataSet1 d12 = new DataSet1();

        public rptBooks()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {



        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {

                SqlConnection con = new SqlConnection();
                con.ConnectionString = Properties.Settings.Default.LibraryMembersConnectionString.ToString(); 
                   
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = con;
                cmd.CommandText = @"SELECT     dbo.Books.BookID, dbo.Books.Title, dbo.Subjects.Subject, dbo.Books.WriterN, dbo.Books.PurchasePrice, dbo.Books.Pages, 
                                  dbo.Books.TahYeNo
                                    FROM         dbo.Books INNER JOIN
                                                          dbo.Subjects ON dbo.Books.TopicID = dbo.Subjects.SubId";
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt;
                con.Open();
                da.Fill(d1, "rptBooksShow");
                con.Close();
                rptBooksShowBindingSource.DataSource = d1;
               
                this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.ZoomPercent = 25;
                this.reportViewer1.RefreshReport();
          
            }
            else if (radioButton2.Checked == true)
            {

                SqlConnection con1 = new SqlConnection();
                con1.ConnectionString = Properties.Settings.Default.LibraryMembersConnectionString.ToString();
                SqlCommand cmd1 = new SqlCommand();
                cmd1.Connection = con1;
                cmd1.CommandText = @"SELECT     dbo.Books.BookID, dbo.Books.Title, dbo.Subjects.Subject, dbo.Books.WriterN, dbo.Books.PurchasePrice, dbo.Books.Pages, 
                                  dbo.Books.TahYeNo
                                    FROM         dbo.Books INNER JOIN
                                                          dbo.Subjects ON dbo.Books.TopicID = dbo.Subjects.SubId
                                    WHERE     (dbo.Books.TahYeNo = 1)";
                SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
                DataTable dt1;
                con1.Open();
                da1.Fill(d11, "rptBooksShow");
                con1.Close();
               
                rptBooksShowBindingSource.DataSource = d11;
               
                reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                reportViewer1.ZoomPercent = 25;
                this.reportViewer1.RefreshReport();
            }
            else if (radioButton3.Checked == true)
            {

                SqlConnection con2 = new SqlConnection();
                con2.ConnectionString = Properties.Settings.Default.LibraryMembersConnectionString.ToString();
                SqlCommand cmd2 = new SqlCommand();
                cmd2.Connection = con2;
                cmd2.CommandText = @"SELECT     dbo.Books.BookID, dbo.Books.Title, dbo.Subjects.Subject, dbo.Books.WriterN, dbo.Books.PurchasePrice, dbo.Books.Pages, 
                                  dbo.Books.TahYeNo
                                    FROM         dbo.Books INNER JOIN
                                                          dbo.Subjects ON dbo.Books.TopicID = dbo.Subjects.SubId
                                    WHERE     (dbo.Books.TahYeNo = 0)";
                SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
                DataTable dt2;
                con2.Open();
                da2.Fill(d12, "rptBooksShow");
                con2.Close();
                
                rptBooksShowBindingSource.DataSource = d12;
                
                reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                reportViewer1.ZoomPercent = 25;
                this.reportViewer1.RefreshReport();
            }
        }

        private void rptBooks_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'DataSet1.rptBooksShow' table. You can move, or remove it, as needed.
            this.rptBooksShowTableAdapter.Fill(this.DataSet1.rptBooksShow);

            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
           
            
            this.reportViewer1.RefreshReport();
        }


    }
}