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 frmRptFaktorKharid : Form
    {
        string Str_Id, Str_SealsPerson, Str_DateFaktor;
        public frmRptFaktorKharid()
        {
            InitializeComponent();
        }

        private void frmRptFaktorKharid_Load(object sender, EventArgs e)
        {
            cmbFil();
            this.reportViewer1.RefreshReport();
        }
        private void cmbFil()
        {
            FirstClass db = new FirstClass();
            DataTable dt = new DataTable();
            dt = db.dbOut(@"SELECT     FactoreKaridID
                            FROM         W_FactoreKharid GROUP BY FactoreKaridID");
            comboBox1.DataSource = dt;
            comboBox1.ValueMember = "FactoreKaridID";
            comboBox1.DisplayMember = "FactoreKaridID";
        }
        private void repShw()
        {
            Lsc_DarookhaneDataContext db = new Lsc_DarookhaneDataContext();
            var Query = from Row in db.W_FactoreKharids 
                        where Row.FactoreKaridID  == int.Parse(comboBox1.SelectedValue.ToString())
                        select Row;

            foreach (var query in Query)
            {
                Str_Id = query.FactoreKaridID .ToString();
                Str_SealsPerson = 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 SelesPerson = new Microsoft.Reporting.WinForms.ReportParameter("SalesPerson", Str_SealsPerson);
            Microsoft.Reporting.WinForms.ReportParameter DateFaktor = new Microsoft.Reporting.WinForms.ReportParameter("FaktorDate", Str_DateFaktor);
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { Id, SelesPerson, DateFaktor });
            W_FactoreKharidBindingSource .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();
        }

    }
}
