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;

namespace Nano_System.Reports
{
    public partial class frmRptFaktorForosh : Form
    {
        string Str_Id, Str_Sick, Str_DateFaktor;
        public frmRptFaktorForosh()
        {
            InitializeComponent();
        }

        private void frmRptFaktorForosh_Load(object sender, EventArgs e)
        {
            cmbFil();
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
        }
        private void cmbFil()
        {
            FirstClass db = new FirstClass();
            DataTable dt = new DataTable();

            dt = db.dbOut(@"SELECT     FactoreForooshID FROM  W_FactoreForoosh GROUP BY FactoreForooshID");

            comboBox1.DataSource = dt;
            comboBox1.DisplayMember = "FactoreForooshID";
            comboBox1.ValueMember = "FactoreForooshID";
        }
        private void repShw()
        {
            Lsc_DarookhaneDataContext db=new Lsc_DarookhaneDataContext();
            var Query = from Row in db.W_FactoreForooshes 
                        where Row.FactoreForooshID == int.Parse(comboBox1.SelectedValue.ToString())
                        select Row;
             
            foreach(var query in Query)
            {
                Str_Id=query.FactoreForooshID.ToString() ;
                Str_Sick=query.Expr1 .ToString();
                Str_DateFaktor=query.DtOfSodoor.ToString();
            }

            Microsoft.Reporting.WinForms.ReportParameter Id = new Microsoft.Reporting.WinForms.ReportParameter("FaktorId", Str_Id);
            Microsoft.Reporting.WinForms.ReportParameter Sick=new Microsoft.Reporting.WinForms.ReportParameter ("Sick",Str_Sick);
            Microsoft.Reporting.WinForms.ReportParameter DateFaktor = new Microsoft.Reporting.WinForms.ReportParameter("DateFaktor", Str_DateFaktor);
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter []{Id, Sick, DateFaktor });
            xtblFaktorForoshBindingSource.DataSource = Query;
            this.reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            repShw();
        }
    }
}
