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 CofeeShop
{
    public partial class frmRptFactorPrint : Form
    {
        public frmRptFactorPrint()
        {
            InitializeComponent();
        }

        private void frmRptFactorPrint_Load(object sender, EventArgs e)
        {
            Class_tblLogs LogReg = new Class_tblLogs(this.Text + " فعال گردید.");
            LogReg.UDF_SaveLogToDb();
            UDF_GetDropFill();
            //reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            //reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            //reportViewer1.ZoomPercent = 50;

            //LSC_CofeeShopDataContext db = new LSC_CofeeShopDataContext();
            //var Query = from Row in db.xtblFactorRpts
            //            select new
            //            {
            //                Row.FactorID,
            //                Row.CustomerID,
            //                Row.FactorShDate,
            //                Row.FoodDescription ,
            //                Row.FoodQuantity ,
            //                Row.FoodID,
            //                Row.NameSname,
            //                Row.Takhfif,
            //                Row.TaxRate,
            //                Row.UnitPrice
            //            };
            //lSCRestuRantDataContextBindingSource.DataSource = Query;

            //this.reportViewer1.RefreshReport();
        }

        private void UDF_GetDropFill()
        {
            LSC_CofeeShopDataContext db = new LSC_CofeeShopDataContext();
            var Query = from Row in db.xtblDropFactors
                        orderby Row.FactorID descending
                        select new
                        {
                            Row.FactorID,
                            Row.NameSnameCust
                        };
            xtblDropFactorBindingSource.DataSource = Query;
        }

        private void frmRptFactorPrint_FormClosed(object sender, FormClosedEventArgs e)
        {
            Class_tblLogs LogReg = new Class_tblLogs(this.Text + " بسته شد.");
            LogReg.UDF_SaveLogToDb();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 50;

            LSC_CofeeShopDataContext db = new LSC_CofeeShopDataContext();
            var Query = from Row in db.xtblFactorRpts
                        where Row.FactorID == int.Parse(Cmb_Factors.SelectedValue.ToString().Trim())
                        orderby Row.FoodQuantity
                        select new
                        {
                            Row.FactorID,
                            Row.CustomerID,
                            Row.FactorShDate,
                            Row.FoodDescription,
                            Row.FoodQuantity,
                            Row.FoodID,
                            Row.NameSname,
                            Row.Takhfif,
                            Row.TaxRate,
                            Row.UnitPrice
                        };
            lSCRestuRantDataContextBindingSource.DataSource = Query;

            this.reportViewer1.RefreshReport();
        }
    }
}
