using FCOMMON;
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 FCM0000.Inventory
{
    public partial class RepInvStock : fBase
    {
        public RepInvStock()
        {
            InitializeComponent();
            Properties.Settings.Default["gwcs"] = FCOMMON.info.CS;
        }
      

        private void RepInvStock_Load(object sender, EventArgs e)
        {
            EnsureVisibleAndUsableSize();
            this.Show();
            Application.DoEvents();

            this.tbDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
            this.reportViewer1.PageCountMode = Microsoft.Reporting.WinForms.PageCountMode.Actual;
            this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            refreshData();
        }
        void refreshData()
        {
            try
            {
                if (checkBox1.Checked == false)
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "FCM0000.Inventory.RepInvStock.rdlc";
                else
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "FCM0000.Inventory.RepInvStockPlace.rdlc";

                var plist = new List<Microsoft.Reporting.WinForms.ReportParameter>();
                plist.Add(new Microsoft.Reporting.WinForms.ReportParameter("pdate", this.tbDate.Text));
                plist.Add(new Microsoft.Reporting.WinForms.ReportParameter("gname", FCOMMON.info.Login.dept));
                plist.Add(new Microsoft.Reporting.WinForms.ReportParameter("gcode", FCOMMON.info.Login.gcode));
                this.reportViewer1.LocalReport.SetParameters(plist);

                if (checkBox1.Checked)
                {
                    this.bs.DataMember = "jagosummaryPlace"; 
                    this.taPlace.Fill(this.dSReport.jagosummaryPlace, FCOMMON.info.Login.gcode, tbDate.Text,"%"); 
                }
                else
                {
                    this.bs.DataMember = "jagosummary";
                    this.ta.Fill(this.dSReport.jagosummary, FCOMMON.info.Login.gcode, tbDate.Text);
                }




                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                FCOMMON.Util.MsgE(ex.Message);
            }
        }

        private void btrefresh_Click(object sender, EventArgs e)
        {
            refreshData();
        }
    }
}
