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 TaxiTelphoni
{
    public partial class frmRepServiceInfo : Form
    {
        public frmRepServiceInfo()
        {
            InitializeComponent();
        }
        private void UDF_Cmb_ShowCustomers()
        {
            LSC_TaxiTelfoniDataContext db = new LSC_TaxiTelfoniDataContext();
            var Query = from Row in db.Customers
                        select new
                        {
                            Row.CustomerID,
                            Row.CompanyName,
                        };

            Cmb_CustomerName.ValueMember = "CustomerID";
            Cmb_CustomerName.DisplayMember = "CompanyName";
            Cmb_CustomerName.DataSource = Query;
        }
        private void UDF_Cmb_ShowRanandegan()
        {
            LSC_TaxiTelfoniDataContext db = new LSC_TaxiTelfoniDataContext();
            var Query = from Row in db.RanandehGans
                        select new
                        {
                            Row.RowID,
                            Row.NamSmane,
                        };

            Cmb_RanandeName.ValueMember = "RowID";
            Cmb_RanandeName.DisplayMember = "NamSmane";
            Cmb_RanandeName.DataSource = Query;
        }
        private void frmRepServiceInfo_Load(object sender, EventArgs e)
        {
            UDF_Cmb_ShowCustomers();
            UDF_Cmb_ShowRanandegan();

            LSC_TaxiTelfoniDataContext db = new LSC_TaxiTelfoniDataContext();
            var Query = from Row in db.xtblServiceInfos
                        select new
                        {
                            Row.CustomerID,
                            Row.CompanyName,
                            Row.ServiceMabda,
                            Row.ServiceMaghsad,
                            Row.ServDate1,
                            Row.MablaghKeraieh,
                            Row.NamSmane,
                            Row.MachineName,
                          
                        };
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 25;

            xtblServiceInfoBindingSource.DataSource = Query;
            reportViewer1.RefreshReport();
        }

        private void Btn_ShowByCustomer_Click(object sender, EventArgs e)
        {
            LSC_TaxiTelfoniDataContext db = new LSC_TaxiTelfoniDataContext();
            var Query = from Row in db.xtblServiceInfos
                        where Row.CustomerID == Cmb_CustomerName.SelectedValue.ToString()
                        select new
                        {
                            Row.CustomerID,
                            Row.CompanyName,
                            Row.ServiceMabda,
                            Row.ServiceMaghsad,
                            Row.ServDate1,
                            Row.MablaghKeraieh,
                            Row.NamSmane,
                            Row.MachineName,

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

            xtblServiceInfoBindingSource.DataSource = Query;
            reportViewer1.RefreshReport();
        }
        private void Btn_ShowByRanande_Click(object sender, EventArgs e)
        {
            LSC_TaxiTelfoniDataContext db = new LSC_TaxiTelfoniDataContext();
            var Query = from Row in db.xtblServiceInfos
                        where Row.RowID == int.Parse(Cmb_RanandeName.SelectedValue.ToString())
                        select new
                        {
                            Row.CustomerID,
                            Row.CompanyName,
                            Row.ServiceMabda,
                            Row.ServiceMaghsad,
                            Row.ServDate1,
                            Row.MablaghKeraieh,
                            Row.NamSmane,
                            Row.MachineName,

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

            xtblServiceInfoBindingSource.DataSource = Query;
            reportViewer1.RefreshReport();
        }
    }
}
