示例#1
0
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        Page_Load(sender, e);
        string            strCurrentDate1 = ddlStartYear.SelectedValue.ToString() + "-" + ddlStartMonth.SelectedValue.ToString();
        OracleConnection  conn            = DB.createConn();
        OracleDataAdapter da = new OracleDataAdapter();

        DataSet ds = new DataSet();

        string strSQL = "";

        try
        {
            if (newdate)
            {
                newdate = false;
            }
            conn.Open();
            strSQL = "Select * from ts_sbdjzb where LOGTIME ='" + strCurrentDate1 + "' and zhou='" + ddlzhou.SelectedValue.ToString() + "'";

            //strSQL += " order by logtime";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            ds = new DataSet();
            da.Fill(ds, "tb");
            ReportViewer1.Visible = true;
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.Reset();
            ReportDataSource rds = new ReportDataSource("dssbzb", ds.Tables[0]);

            //查询第二个,对点检(维修)进行查询
            strSQL           = "Select * from ts_sbdjzb where LOGTIME ='" + strCurrentDate1 + "' and zhou='" + ddlzhou.SelectedValue.ToString() + "' and djdw in('连铸维修车间','冶炼维修车间','运行车间')";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            DataSet dsdjwx = new DataSet();
            da.Fill(dsdjwx, "djwx");
            ReportDataSource rdsdjwx = new ReportDataSource("dsdjwx", dsdjwx.Tables[0]);
            //查询第三个,对点检(分类)进行查询
            strSQL           = "select '" + strCurrentDate1 + "' as logtime ,'" + ddlzhou.SelectedValue.ToString() + "' as zhou,djfl,djsl,wtsl from ";
            strSQL          += "(";
            strSQL          += "SELECT '管理点检' as djfl,sum(zysl)  as djsl,sum(glwtsl) as wtsl from xgwebrpt.TS_SBDJZB where djdw in('冶炼维修车间','连铸维修车间','运行车间') and logtime='" + strCurrentDate1 + "'";
            strSQL          += " union ";
            strSQL          += "SELECT '岗位点检' as djfl,sum(gwsl)  as djsl,sum(wtsl) as wtsl from xgwebrpt.TS_SBDJZB where djdw in('连铸车间','精炼车间','冶炼一车间') and logtime='" + strCurrentDate1 + "'";
            strSQL          += " union ";
            strSQL          += "SELECT '维修点检' as djfl,sum(jssl)  as djsl,sum(wtsl-glwtsl) as wtsl from xgwebrpt.TS_SBDJZB where djdw in('冶炼维修车间','连铸维修车间','冶炼一车间') and logtime='" + strCurrentDate1 + "'";
            strSQL          += ")";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            DataSet dsdjfl = new DataSet();
            da.Fill(dsdjfl, "djfl");
            ReportDataSource rdsdjfl = new ReportDataSource("Dsdjfl", dsdjfl.Tables[0]);

            //查询第四个,对计划检修进行查询
            strSQL           = "Select * from ts_sbjxzb where LOGTIME ='" + strCurrentDate1 + "' and zhou='" + ddlzhou.SelectedValue.ToString() + "'";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            DataSet dsjx = new DataSet();
            da.Fill(dsjx, "jx");
            ReportDataSource rdsjx = new ReportDataSource("Dssbjx", dsjx.Tables[0]);

            //查询第五个,对故障保修进行查询
            strSQL           = "Select * from ts_sbbxzb where LOGTIME ='" + strCurrentDate1 + "' and zhou='" + ddlzhou.SelectedValue.ToString() + "'";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            DataSet dsgzbx = new DataSet();
            da.Fill(dsgzbx, "gzbx");
            ReportDataSource rdsgzbx = new ReportDataSource("DsGzbx", dsgzbx.Tables[0]);
            //查询第六个,对故障保修(维修)进行查询
            strSQL           = "Select * from ts_sbbxzb where LOGTIME ='" + strCurrentDate1 + "' and zhou='" + ddlzhou.SelectedValue.ToString() + "' and djdw in('连铸维修车间','冶炼维修车间','运行车间')";
            da.SelectCommand = new OracleCommand(strSQL, conn);
            DataSet dsgzbxwx = new DataSet();
            da.Fill(dsgzbxwx, "gzbxwx");
            ReportDataSource rdsgzbxwx = new ReportDataSource("Dsgzbxwx", dsgzbxwx.Tables[0]);

            ReportViewer1.LocalReport.DataSources.Add(rds);
            ReportViewer1.LocalReport.DataSources.Add(rdsdjfl);
            ReportViewer1.LocalReport.DataSources.Add(rdsdjwx);
            ReportViewer1.LocalReport.DataSources.Add(rdsjx);
            ReportViewer1.LocalReport.DataSources.Add(rdsgzbx);
            ReportViewer1.LocalReport.DataSources.Add(rdsgzbxwx);
            ReportViewer1.LocalReport.ReportPath = "Quality\\sbzbzh.rdlc";
            ReportViewer1.LocalReport.Refresh();
            ds.Dispose();
            conn.Close();
        }
        catch (Exception ee)
        {
            string strMessage = ee.Message.ToString();
        }
        finally
        {
            ds.Dispose();
            conn.Close();
        }
    }
    protected void Cetak_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtnopo.Text != "")
            {
                DataTable dt = new DataTable();
                Page.Header.Title = "CARIAN MAKLUMAT BELIAN ASET";
                if ((DD_down.SelectedValue != "") && (txtalamat.Value != ""))
                {
                    cur_qury1();
                    DataSet dsCustomers = GetData("" + qr1 + "");
                    dt = dsCustomers.Tables[0];
                }
                DataSet   ds1 = new DataSet();
                DataTable dt2 = new DataTable();
                dt2 = dbcon.Ora_Execute_table("select acp_do_no,acp_po_no,acp_receive_dt,acp_receive_id,sp.stf_name,asu.sup_name from (select acp_po_no,acp_do_no,acp_receive_id,format(acp_receive_dt,'dd/MM/yyyy') as acp_receive_dt,acp_supplier_id from ast_acceptance where acp_po_no='" + txtnopo.Text + "' group by acp_po_no,acp_do_no,acp_receive_id,acp_receive_dt,acp_supplier_id) as a left join hr_staff_profile sp on sp.stf_staff_no=a.acp_receive_id left join ast_supplier asu on asu.sup_id=a.acp_supplier_id");
                ds1.Tables.Add(dt2);

                ReportViewer1.Reset();

                List <DataRow> listResult = dt.AsEnumerable().ToList();
                listResult.Count();
                int countRow = 0;
                countRow = listResult.Count();

                //if (countRow != 0)
                //{
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportDataSource rds  = new ReportDataSource("ast_pta", dt);
                ReportDataSource rds1 = new ReportDataSource("ast_pta1", dt2);
                ReportViewer1.LocalReport.DataSources.Add(rds);
                ReportViewer1.LocalReport.DataSources.Add(rds1);
                //Path
                ReportViewer1.LocalReport.ReportPath = "Aset/AST_pen_ast.rdlc";
                //Parameters
                ReportParameter[] rptParams = new ReportParameter[] {
                    new ReportParameter("d1", DD_down.SelectedItem.Text),
                    new ReportParameter("d2", txtalamat.Value),
                    new ReportParameter("d3", TextBox3.Text),
                    new ReportParameter("d4", TextBox2.Text),
                    new ReportParameter("d5", txtnopo.Text),
                };
                //     //new ReportParameter("toDate",ToDate .Text )
                //     //new ReportParameter("fromDate",datedari  ),
                //     //new ReportParameter("toDate",datehingga ),
                //          //new ReportParameter("caw",branch ),
                //            //new ReportParameter("Cdate",DateTime.Now.ToString("dd/MM/yyyy") ),
                //     //new ReportParameter("Date",DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")  )
                //     };


                ReportViewer1.LocalReport.SetParameters(rptParams);
                //Refresh
                ReportViewer1.LocalReport.Refresh();

                Warning[] warnings;

                string[] streamids;

                string mimeType;

                string encoding;

                string extension;

                string devinfo = "<DeviceInfo>" +
                                 "  <OutputFormat>PDF</OutputFormat>" +
                                 "  <PageSize>A4</PageSize>" +
                                 "  <PageWidth>8in</PageWidth>" +
                                 "  <PageHeight>11in</PageHeight>" +
                                 "  <MarginTop>0.25in</MarginTop>" +
                                 "  <MarginLeft>0.5in</MarginLeft>" +
                                 "  <MarginRight>0.5in</MarginRight>" +
                                 "  <MarginBottom>0.5in</MarginBottom>" +
                                 "</DeviceInfo>";

                byte[] bytes = ReportViewer1.LocalReport.Render("PDF", devinfo, out mimeType, out encoding, out extension, out streamids, out warnings);

                Response.Buffer = true;
                Response.Clear();
                Response.ContentType = mimeType;
                string extfile = txtnopo.Text.Trim();
                Response.AddHeader("content-disposition", "attachment; filename=PENGESAHAN_TERIMAAN_ASET" + extfile + "." + extension);
                Response.BinaryWrite(bytes);
                Response.Flush();
                Response.End();
                view_details();
                //}
                //else if (countRow == 0)
                //{
                //    bind2();
                //    ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "alert('Rekod tidak dijumpai. Sila pastikan semua maklumat dimasukkan dengan betul.');", true);
                //}
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "$.Zebra_Dialog('Sila Masukan No PO.',{'type': 'warning','title': 'warning','auto_close': 2000});", true);
            }
        }
        catch (Exception ex)
        {
            //txtError.Text = ex.ToString();
        }
    }
        protected void BindSSRS()
        {
            try
            {
                ReportViewer1.ShowParameterPrompts = false;
                ReportViewer1.ShowToolBar          = true;
                ReportViewer1.WaitMessageFont.Bold = true;

                ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServerURL"].ToString());
                ReportViewer1.ServerReport.ReportPath      = "/EPGMHeightStatistics";

                ReportViewer1.ProcessingMode = ProcessingMode.Remote;
                IReportServerCredentials irsc = new CustomReportCredentials(ConfigurationManager.AppSettings["RSDomainUserName"].ToString(), ConfigurationManager.AppSettings["RSDomainPassword"].ToString(), ConfigurationManager.AppSettings["RSDomainName"].ToString());
                ReportViewer1.ServerReport.ReportServerCredentials = irsc;

                ReportViewer1.SizeToReportContent = true;
                ReportViewer1.Width  = Unit.Percentage(100);
                ReportViewer1.Height = Unit.Percentage(100);

                List <ReportParameter>        parmList = new List <ReportParameter>();
                ReportParameterInfoCollection parameters;
                parameters = ReportViewer1.ServerReport.GetParameters();
                for (int i = 0; i < parameters.Count; i++)
                {
                    if (parameters[i].Name.ToLower() == "centertypeid")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["CenterType"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "statecode")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["statecode"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "distcode")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["distcode"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "projectcode")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["projectcode"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "sectorcode")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["sectorcode"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "centercode")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["centercode"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "distname")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["distname"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "projectname")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["projectname"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "sectorname")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["sectorname"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "awcname")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["centername"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "month")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["month"].ToString(), false));
                    }
                    if (parameters[i].Name.ToLower() == "year")
                    {
                        parmList.Add(new ReportParameter(parameters[i].Name.ToString(), Request.QueryString["year"].ToString(), false));
                    }
                }

                ReportViewer1.ServerReport.SetParameters(parmList);
                ReportViewer1.DataBind(); //ReportViewer1.ServerReport.Refresh();
            }
            catch (Exception ex)
            {
                lblerror.Text      = ex.Message;
                lblerror.ForeColor = Color.DarkRed;
            }
        }