using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using System.Globalization;
using System.Web.Caching;
using System.IO;
using System.Threading;
using Microsoft.Reporting.WebForms;


namespace CheckSheet.setting
{
    public partial class rptLinegroupCSV : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


            if (!Page.IsPostBack)
            {

                try
                {
                    _genReport(Page.Request["filter"].ToString(), Page.Request["item"].ToString());
                }
                catch { };


            }
        }








        private void _genReport(string filter, string item)
        {

            // Set the processing mode for the ReportViewer to Local
            rptview.ProcessingMode = ProcessingMode.Local;
            LocalReport rep = rptview.LocalReport;
            rep.ReportPath = "setting/rptLinegroupCSV.rdlc";

            // Create a report data source for the sales order data
            ReportDataSource dsMaintenanceDS = new ReportDataSource();
            dsMaintenanceDS.Name = "dsRpt";
            DataTable dt = _genDataSource(filter);
            dsMaintenanceDS.Value = dt;
            rep.DataSources.Clear();
            string filpara = string.Empty;
           

            ReportParameter param1 = new ReportParameter("hdpara", filpara);
            rep.SetParameters(new ReportParameter[] { param1 });


            rep.DataSources.Add(dsMaintenanceDS);
            rep.Refresh();


            //}
        }
        private DataTable _genDataSource(string filter)
        {
            DataTable dt = new DataTable();



            string sqlquery = string.Empty;
            using (FcSql.Function fc = new FcSql.Function())
            {





                string strquery = string.Empty;
                strquery = string.Format("select * from LineGroupMaster Order by Create_datetime ", filter);
                dt = fc.SQL_DataTable(strquery.ToString());
                fc.closeconnection();
                foreach (DataRow dr in dt.Rows)
                {

                    try
                    {
                        if (dr["Create_user"].ToString().Length > 0)
                        {
                            dr["Create_user"] = dr["Create_user"].ToString() + ":" + clsControlUI.getEmpName(dr["Create_user"].ToString());
                        }

                    }
                    catch { };
                    try
                    {
                        if (dr["Update_user"].ToString().Length > 0)
                        {
                            dr["Update_user"] = dr["Update_user"].ToString() + ":" + clsControlUI.getEmpName(dr["Update_user"].ToString());
                        }

                    }
                    catch { };
                   
                }






            }
            return dt;





        }


    }
}