Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //this.Session["idplanning"] = "";
                idplanning = Convert.ToInt32(this.Session["iplanning"]);


                ReportBrief.ZoomMode = Microsoft.Reporting.WebForms.ZoomMode.FullPage;


                ReportBrief.ServerReport.ReportPath = "/Developer_Report/BRIEF DE CAMPAÑA";
                //FMARTINEZ SE DEJA LA RUTA DESDE EL WEB CONFIG
                //ReportBrief.ServerReport.ReportServerUrl = new Uri("http://LUCKYDC/ReportServer");

                String strConnection = ConfigurationSettings.AppSettings["SERVIDOR_REPORTING_SERVICES"];
                ReportBrief.ServerReport.ReportServerUrl = new Uri(strConnection);



                //Array de parametros

                List <Microsoft.Reporting.WebForms.ReportParameter> parametros = new List <Microsoft.Reporting.WebForms.ReportParameter>();


                parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("IDPLANNING", Convert.ToString(idplanning)));

                //Se añadedn los parametros al reportViewer

                ReportBrief.ServerReport.SetParameters(parametros);

                //Obtener la coleccion de parametros
                Microsoft.Reporting.WebForms.ReportParameterInfoCollection parametrosr = ReportBrief.ServerReport.GetParameters();
            }
        }
Exemplo n.º 2
0
        public static void SetReportParameter(Microsoft.Reporting.WebForms.LocalReport localreport, System.Collections.Hashtable Para)
        {
            Microsoft.Reporting.WebForms.ReportParameterInfoCollection RPara = localreport.GetParameters();

            foreach (Microsoft.Reporting.WebForms.ReportParameterInfo item in RPara)
            {
                switch (item.Name)
                {
                case "CompanyName":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyName"].ToString()) });
                    break;

                case "CompanyAddress":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyAddress"].ToString()) });
                    break;

                case "CompanyPhone":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyPhone"].ToString()) });
                    break;

                case "CompanyFax":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyFax"].ToString()) });
                    break;

                case "CompanyTaxCode":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysCompany()["CompanyTaxCode"].ToString()) });
                    break;

                case "QDBTC":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["QDBTC"].ToString()) });
                    break;

                case "DirectorName":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["DirectorName"].ToString()) });
                    break;

                case "ChiefAccountantName":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ChiefAccountantName"].ToString()) });
                    break;

                case "ReportCreatorName":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ReportCreatorName"].ToString()) });
                    break;

                case "ReportFontSize":
                    localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Services.GlobalVariant.GetSysOption()["ReportFontSize"].ToString()) });
                    break;

                default:
                    if (Para[item.Name] != null)
                    {
                        localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Para[item.Name].ToString()) });
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
    protected void rptViewer_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connString"].ToString());

        conn.Open();
        SqlCommand cmd = new SqlCommand();

        cmd.Connection  = conn;
        cmd.CommandText = "uspRptDetailByOrigin";
        cmd.CommandType = CommandType.StoredProcedure;
        if (Session["profilename"].ToString() == "Client")
        {
            cmd.Parameters.Add(new SqlParameter("@ClientId", Session["ClientId"].ToString()));
        }
        else
        {
            cmd.Parameters.Add(new SqlParameter("@ClientId", this.lstClient.SelectedValue.ToString()));
        }

        Microsoft.Reporting.WebForms.ReportParameterInfoCollection DrillThroughValues = e.Report.GetParameters();

        cmd.Parameters.Add(new SqlParameter("@Src", DrillThroughValues[0].Values[0]));
        SqlDataReader dr = cmd.ExecuteReader();

        dsInvoiceDetail ds = new dsInvoiceDetail();

        while (dr.Read())
        {
            ds.Tables[0].Rows.Add(dr[0].ToString(), System.Convert.ToDateTime(dr[1].ToString()), dr[2].ToString(), dr[3].ToString(), System.Convert.ToInt32(dr[4].ToString()), System.Convert.ToDouble(dr[5].ToString()));
        }

        dr.Close();
        conn.Close();
        conn.Dispose();

        this.rptViewer.LocalReport.DataSources.Clear();
        this.rptViewer.Reset();

        LocalReport drillThroughReport = (LocalReport)e.Report;

        Microsoft.Reporting.WebForms.ReportDataSource rdInvDetail = new Microsoft.Reporting.WebForms.ReportDataSource("dsInvoiceDetailwhatever", ds.Tables[0]);
        drillThroughReport.DataSources.Add(rdInvDetail);

        this.rptViewer.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
        this.rptViewer.LocalReport.ReportPath = @"Reports\StatementDetailBySrc.rdlc";

        Microsoft.Reporting.WebForms.ReportParameter Origin = new Microsoft.Reporting.WebForms.ReportParameter("Origin", DrillThroughValues[0].Values[0]);
        this.rptViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { Origin });

        this.rptViewer.LocalReport.Refresh();
    }
Exemplo n.º 4
0
        /// <summary>
        /// Note: SSRS cannot render the report if required parameters are missing.
        /// This will load any report parameters.
        /// If any of the parameters were required, but they were not provided, show an error message.
        /// </summary>
        /// <param name="report">Instance of the ReportViewer control or equiv object</param>
        private void CheckReportParameters(WebForms.LocalReport report)
        {
            //copy-in any report parameters which were not part of the DB query
            try
            {
                WebForms.ReportParameterInfoCollection rdlParams = report.GetParameters();
                foreach (WebForms.ReportParameterInfo rdlParam in rdlParams)
                {
                    if (this._reportParameters.ContainsKey(rdlParam.Name))
                    {
                        string val = this._reportParameters[rdlParam.Name].ToString();
                        if (string.IsNullOrEmpty(val))
                        {
                            if (rdlParam.Nullable)
                            {
                                val = null;
                                report.SetParameters(new WebForms.ReportParameter(rdlParam.Name, val, false));
                            }
                            else
                            {
                                ErrorMessages.Add(new ErrorMessage("Erro on Report Parameters.", $"Report Parameter value \"{ rdlParam.Name }\" is required, but was not provided."));
                            }
                        }
                        else
                        {
                            report.SetParameters(new WebForms.ReportParameter(rdlParam.Name, val));
                        }
                    }
                    else if (!rdlParam.AllowBlank)
                    {
                        ErrorMessages.Add(new ErrorMessage("Erro on Report Parameters.", $"Report Parameter \"{ rdlParam.Name }\" is required, but was not provided."));
                    }
                }
                if (ErrorMessages.Any())
                {
                    OnError?.Invoke(this, new EngineErrorEventArgs(ErrorMessages));
                }
            }
            catch (WebForms.LocalProcessingException ex)
            {
                ErrorMessages.Add(new ErrorMessage(ex.Message, ex.StackTrace));
                Exception exIn = ex.InnerException;
                while (exIn != null)
                {
                    ErrorMessages.Add(new ErrorMessage(exIn.Message, exIn.StackTrace));
                    exIn = exIn.InnerException;
                }

                OnError?.Invoke(this, new EngineErrorEventArgs(ErrorMessages));
            }
        }
        protected void btngenerar_Click(object sender, EventArgs e)
        {
            reportPrueba.ZoomMode = Microsoft.Reporting.WebForms.ZoomMode.FullPage;
            reportPrueba.ServerReport.ReportPath = "/Reportes_Clientes/Panel_Precio";

            //Array de parametros

            List <Microsoft.Reporting.WebForms.ReportParameter> parametros = new List <Microsoft.Reporting.WebForms.ReportParameter>();

            parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("Categoria", cmbcategorias.SelectedValue));
            //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("PERIODOINI", txtfecini.Text));
            //parametros.Add(new Microsoft.Reporting.WebForms.ReportParameter("PERIODOFIN", txtfecfin.Text));
            //reportPrueba.ServerReport.SetParameters(parametros);
            //Obtener la coleccion de parametros
            Microsoft.Reporting.WebForms.ReportParameterInfoCollection parametrosr = reportPrueba.ServerReport.GetParameters();
        }
Exemplo n.º 6
0
        public static void InitUIReport(Microsoft.Reporting.WebForms.LocalReport localreport, string metaname)
        {
            #region Set giá trị cho tham số Report

            Microsoft.Reporting.WebForms.ReportParameterInfoCollection RPara = localreport.GetParameters();
            var Columns = Services.GlobalMeta.GetMetaObject(metaname).GetMetaTable();


            foreach (Microsoft.Reporting.WebForms.ReportParameterInfo item in RPara)
            {
                if (item.Name.Length > 6)
                {
                    string FieldName = item.Name.Substring(6);
                    if (Columns.ContainsKey(FieldName))
                    {
                        if (item.Name.IndexOf("Header") == 0)
                        {
                            localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Columns[FieldName].Des) });
                        }
                        if (item.Name.IndexOf("Format") == 0)
                        {
                            string Format = "";
                            if (Columns[FieldName].FormatValue != null)
                            {
                                Format = Columns[FieldName].FormatValue.ToString();
                            }

                            if (Columns[FieldName].CultureInfo != null)
                            {
                                switch (Columns[FieldName].CultureInfo.ToString())
                                {
                                case "CIFC":
                                    if (Format == "n")
                                    {
                                        //Format += Services.GlobalVariant.GetSysOption()["RoundAmountFC"].ToString();


                                        Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundAmountFC"].ToString()));
                                    }
                                    break;

                                case "CIUPCC":
                                    if (Format == "n")
                                    {
                                        //Format += Services.GlobalVariant.GetSysOption()["RoundUnitPrice"].ToString();
                                        Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundUnitPrice"].ToString()));
                                    }
                                    break;

                                case "CIUPFC":
                                    if (Format == "n")
                                    {
                                        //Format += Services.GlobalVariant.GetSysOption()["RoundUnitPriceFC"].ToString();
                                        Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundUnitPriceFC"].ToString()));
                                    }
                                    break;

                                default:
                                    switch (Format)
                                    {
                                    case "c":
                                        //hiện format dấu tiền tệ
                                        //Format += Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString();
                                        //Không hiện format dấu tiền tệ
                                        //Format = "n"+Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString();
                                        Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString()));
                                        break;

                                    case "n":
                                        //Format += Services.GlobalVariant.GetSysOption()["RoundQuantity"].ToString();
                                        Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundQuantity"].ToString()));
                                        break;

                                    default:
                                        break;
                                    }

                                    break;
                                }
                            }
                            else
                            {
                                switch (Format)
                                {
                                case "c":
                                    //hiện format dấu tiền tệ
                                    //Format += Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString();
                                    //Không hiện format dấu tiền tệ
                                    //Format = "n"+Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString();
                                    Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundAmount"].ToString()));
                                    break;

                                case "n":
                                    //Format += Services.GlobalVariant.GetSysOption()["RoundQuantity"].ToString();
                                    Format = "#,##0" + SetRound(int.Parse(Services.GlobalVariant.GetSysOption()["RoundQuantity"].ToString()));
                                    break;

                                default:
                                    break;
                                }
                            }

                            if (!string.IsNullOrEmpty(Format))
                            {
                                Format = string.Format("{0};-{1};{2}", Format, Format, "#.#");

                                //Format = string.Format("{0};{1};'-'", Format, Format);
                                localreport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter(item.Name, Format) });
                            }
                        }
                    }
                }
            }
            #endregion
        }