コード例 #1
0
        private void ShowReport()
        {
            try
            {
                //if (rdbtnLate.Checked == true)
                //{
                //    ReportViewer1.LocalReport.ReportPath = "RDLC\\Late_Report.rdlc";
                //}
                //else
                //{
                //    ReportViewer1.LocalReport.ReportPath = "RDLC\\Early.rdlc";
                //}
                ReportViewer1.LocalReport.ReportPath = "RDLC\\EarlyOrLate.rdlc";
                viewer.Visible        = true;
                ReportViewer1.Visible = true;

                String        dataSetName = "DataSet1";
                SqlConnection conn        = new SqlConnection(m_connectons);
                SqlCommand    cmd         = new SqlCommand();
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.Connection     = conn;
                cmd.CommandTimeout = 0;
                cmd.CommandText    = "usp_rpt_getLateEarlyDetails";
                cmd.Parameters.AddWithValue("@strEmployeeHdn", EmployeeHdn.Value);
                cmd.Parameters.AddWithValue("@strComapnyHdn", ComapnyHdn.Value);
                cmd.Parameters.AddWithValue("@strLocationHdn", LocationHdn.Value);
                cmd.Parameters.AddWithValue("@strDivisionHdn", DivisionHdn.Value);
                cmd.Parameters.AddWithValue("@strDepartmentHdn", DepartmentHdn.Value);
                cmd.Parameters.AddWithValue("@strGradeHdn", GradeHdn.Value);
                cmd.Parameters.AddWithValue("@strGoupHdn", GroupHdn.Value);
                cmd.Parameters.AddWithValue("@strFromDate", txtCalendarFrom.Text);
                cmd.Parameters.AddWithValue("@strToDate", txtToDate.Text);
                cmd.Parameters.AddWithValue("@strCheck", ddlReportType.SelectedValue == "1" ? "1" : ddlReportType.SelectedValue == "2" ? "2" : ddlReportType.SelectedValue == "0" ? "3" : "0");
                cmd.Parameters.AddWithValue("@strPersonnelType", ddlPersonnelType.SelectedValue);

                DataTable      dtData = new DataTable();
                SqlDataAdapter da     = new SqlDataAdapter(cmd);
                da.Fill(dtData);
                string          param2, strLateEarly = "", strInOut = "", strAll = string.Empty;
                ReportParameter para3;
                if (dtData.Rows.Count > 0)
                {
                    para3 = new ReportParameter("count", dtData.Rows.Count.ToString());

                    ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { para3 });
                }
                else
                {
                    para3 = new ReportParameter("count", "0");

                    ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { para3 });
                }


                if (ddlReportType.SelectedValue == "1")
                {
                    param2 = "Late Report";
                }
                else if (ddlReportType.SelectedValue == "2")
                {
                    param2 = "Early Going Report";
                }
                else
                {
                    param2 = "Late/Early Going Report";
                }

                if (ddlReportType.SelectedValue == "1")
                {
                    strLateEarly = "Late By";
                    strInOut     = "In Time";
                    strAll       = "P";
                }
                else if (ddlReportType.SelectedValue == "2")
                {
                    strLateEarly = "Early Going";
                    strInOut     = "Out Time";
                    strAll       = "P";
                }
                else
                {
                    strLateEarly = "and";
                    strInOut     = "and";
                    strAll       = "A";
                }

                string strReportHeader = "Generated on " + DateTime.Today.ToString("dd/MM/yyyy") + " at " + DateTime.Now.ToString("HH:mm") + " Hrs for ";
                if (txtCalendarFrom.Text == txtToDate.Text)
                {
                    strReportHeader = strReportHeader + strDate;
                }
                else
                {
                    strReportHeader = strReportHeader + strDate + " to " + txtToDate.Text;
                }
                ReportParameter para         = new ReportParameter("myparameter1", strReportHeader);
                ReportParameter para2        = new ReportParameter("myparameter2", param2);
                DataTable       dtReport     = clsCommonHandler.GetReportHeader();
                ReportParameter header       = new ReportParameter("header", dtReport.Rows[0]["value"].ToString());
                ReportParameter address      = new ReportParameter("address", dtReport.Rows[1]["value"].ToString());
                ReportParameter parLateEarly = new ReportParameter("parLateEarly", strLateEarly);
                ReportParameter parInOut     = new ReportParameter("parInOut", strInOut);
                ReportParameter parAll       = new ReportParameter("parAll", strAll);
                ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { para, para2, header, address, parAll, parInOut, parLateEarly });
                ReportDataSource datasource = new ReportDataSource();
                datasource.Name  = dataSetName;
                datasource.Value = dtData;
                ReportViewer1.LocalReport.DataSources.Add(datasource);
                ReportViewer1.LocalReport.Refresh();

                HeadPnl.Visible = false;
                //Panel1.Visible = false;
                HeadPanel.Visible = false;
            }

            catch (Exception ex)
            {
                UNOException.UNO_DBErrorLog(ex.Message, ex.StackTrace, clsCommonHandler.PageName());
            }
        }
コード例 #2
0
        private void ShowReport()
        {
            try
            {
                ReportViewer1.LocalReport.ReportPath = "RDLC\\MultifilterAccess.rdlc";
                ReportViewer1.Visible = true;

                SqlConnection conn = new SqlConnection(m_connectons);
                conn.Open();
                SqlCommand cmd = new SqlCommand("SP_SAC_Multifilter_Access_Report", conn);

                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.Connection     = conn;
                cmd.CommandTimeout = 0;
                cmd.Parameters.AddWithValue("@EMP_ID", EmployeeHdn.Value);
                cmd.Parameters.AddWithValue("@FROM_DATE", txtCalendarFrom.Text);
                cmd.Parameters.AddWithValue("@TODATE", txtToDate.Text);
                cmd.Parameters.AddWithValue("@ENTITY", DivisionHdn.Value);
                cmd.Parameters.AddWithValue("@GROUP", DepartmentHdn.Value);
                cmd.Parameters.AddWithValue("@Division", GradeHdn.Value);
                cmd.Parameters.AddWithValue("@Center", ComapnyHdn.Value);
                cmd.Parameters.AddWithValue("@Unit", LocationHdn.Value);
                cmd.Parameters.AddWithValue("@Section", GroupHdn.Value);
                cmd.Parameters.AddWithValue("@DESIGNATION", "");
                cmd.Parameters.AddWithValue("@EOD_TYPE", ddlPersonnelType.SelectedValue);
                cmd.Parameters.AddWithValue("@ACS_STATUS", ddlStatus.SelectedValue);
                cmd.Parameters.AddWithValue("@Reader", RederHdn.Value);


                DataTable      dt  = new DataTable();
                SqlDataAdapter dap = new SqlDataAdapter(cmd);
                dap.Fill(dt);

                //OPEN RDLC,GO TO REPORT MENU ->DATASOURCES ,CHECK NAME OF DATASOURCE USED IN THIS RDLC,
                String dataSetName = "DataSet1";

                string strReportHeader = "Generated on " + DateTime.Today.ToString("dd/MM/yyyy") + " at " + DateTime.Now.ToString("HH:mm") + " Hrs for ";
                if (txtCalendarFrom.Text == txtToDate.Text)
                {
                    strReportHeader = strReportHeader + strDate;
                }
                else
                {
                    strReportHeader = strReportHeader + strDate + " to " + txtToDate.Text;
                }
                ReportParameter para     = new ReportParameter("ReportParameter1", strReportHeader);
                ReportParameter para3    = new ReportParameter("count", dt.Rows.Count.ToString());
                ReportParameter para4    = new ReportParameter("AlarmType", ddlStatus.SelectedItem.Text);
                ReportParameter para5    = new ReportParameter("userName", Session["uid"].ToString() + " " + Session["loginName"].ToString());
                DataTable       dtReport = clsCommonHandler.GetReportHeader();
                ReportParameter header   = new ReportParameter("header", dtReport.Rows[0]["value"].ToString());
                ReportParameter address  = new ReportParameter("address", dtReport.Rows[1]["value"].ToString());
                ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { para, para3, para4, para5, header, address });


                ReportDataSource datasource = new ReportDataSource();
                datasource.Name = dataSetName;
                //datasource.Value = thisDataSet.Tables[tableName];
                datasource.Value = dt;
                ReportViewer1.LocalReport.DataSources.Add(datasource);
                ReportViewer1.LocalReport.Refresh();

                HeadPnl.Visible = false;
                //Panel1.Visible = false;
                HeadPanel.Visible = false;
            }

            catch (Exception ex)
            {
                UNOException.UNO_DBErrorLog(ex.Message, ex.StackTrace, clsCommonHandler.PageName());
            }
        }