private void CreateDetailReportParameters(XtraReport detailReport) { Parameter categoryNameParameter = new DevExpress.XtraReports.Parameters.Parameter(); categoryNameParameter.Visible = false; categoryNameParameter.Name = "catNameParam"; categoryNameParameter.Type = typeof(string); detailReport.Parameters.Add(categoryNameParameter); Parameter categoryIDParameter = new DevExpress.XtraReports.Parameters.Parameter(); categoryIDParameter.Visible = false; categoryIDParameter.Name = "catIDParam"; categoryIDParameter.Type = typeof(int); detailReport.Parameters.Add(categoryIDParameter); }
public static IReport CreateModel(ReportType r, Dictionary <string, string> parameter) { var model = CreateModel(r); if (parameter != null) { foreach (var key in parameter.Keys) { DevExpress.XtraReports.Parameters.Parameter param = model.Report.Parameters[key]; if (param == null) { continue; } param.Value = ObjectHelper.ConvertType(parameter[key], param.Type); } } return(model); }
public byte[] exportarPdf(long tipoDocumento, COMPROBANTE comprobante) { try { byte[] formatoReporte; PUNTOEMISIONDOCUMENTO puntoEmisionDocumento = (from puntoE in comprobante.PUNTOEMISION.PUNTOEMISIONDOCUMENTO where puntoE.CODIGOTIPOCOMPROBANTE == comprobante.TIPOCOMPROBANTE.CODIGOTIPOCOMPROBANTE select puntoE).FirstOrDefault(); if (puntoEmisionDocumento.ARCHIVOREPORTE != null) { formatoReporte = puntoEmisionDocumento.ARCHIVOREPORTE; } else if (comprobante.TIPOCOMPROBANTE.ARCHIVOREPORTE == null) { XtraMessageBox.Show("NO SE HAN DEFINIDO REPORTE DE FACTURA"); return(null); } else { formatoReporte = comprobante.TIPOCOMPROBANTE.ARCHIVOREPORTE; } System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(formatoReporte); xtraReport.LoadLayout(memoryStream); Parameter parametro = new DevExpress.XtraReports.Parameters.Parameter(); parametro.Value = comprobante.CODIGOCOMPROBANTE; parametro.Name = "codigoComprobante";; xtraReport.Parameters["codigoComprobante"].Value = comprobante.CODIGOCOMPROBANTE; xtraReport.DrawWatermark = (comprobante.CLAVEDEACCESO.Substring(23, 1).Equals("1") ? true : false); xtraReport.Watermark.Text = (comprobante.CLAVEDEACCESO.Substring(23, 1).Equals("1") ? "LA INFORMACIÓN IMPRESA NO TIENE VALIDEZ." + Environment.NewLine + "COMPROBANTE GENERADO EN EL AMBIENTE DE PRUEBAS" : ""); formaReporte.Text = comprobante.TIPOCOMPROBANTE.NOMBRE + "-" + comprobante.NUMEROCOMPROBANTE; formaReporte.getdocumentViewer1().DocumentSource = xtraReport; var archivopdf = new MemoryStream(); xtraReport.ExportToPdf(archivopdf); return(archivopdf.ToArray()); } catch (Exception ex) { XtraMessageBox.Show(ex.ToString()); } return(null); }
public void imprimir(long tipoDocumento, COMPROBANTE comprobante) { try { byte[] formatoReporte; PUNTOEMISIONDOCUMENTO puntoEmisionDocumento = (from puntoE in comprobante.PUNTOEMISION.PUNTOEMISIONDOCUMENTO where puntoE.CODIGOTIPOCOMPROBANTE == comprobante.TIPOCOMPROBANTE.CODIGOTIPOCOMPROBANTE select puntoE).FirstOrDefault(); if (puntoEmisionDocumento.ARCHIVOREPORTE != null) { formatoReporte = puntoEmisionDocumento.ARCHIVOREPORTE; } else if (comprobante.TIPOCOMPROBANTE.ARCHIVOREPORTE == null) { XtraMessageBox.Show("NO SE HAN DEFINIDO REPORTE DE FACTURA"); return; } else { formatoReporte = comprobante.TIPOCOMPROBANTE.ARCHIVOREPORTE; } System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(formatoReporte); xtraReport.LoadLayout(memoryStream); Parameter parametro = new DevExpress.XtraReports.Parameters.Parameter(); parametro.Value = comprobante.CODIGOCOMPROBANTE; parametro.Name = "codigoComprobante"; formaReporte.WindowState = FormWindowState.Maximized; xtraReport.Parameters["codigoComprobante"].Value = comprobante.CODIGOCOMPROBANTE; xtraReport.DrawWatermark = (comprobante.CLAVEDEACCESO.Substring(23, 1).Equals("1") ? true : false); xtraReport.Watermark.Text = (comprobante.CLAVEDEACCESO.Substring(23, 1).Equals("1") ? "LA INFORMACIÓN IMPRESA NO TIENE VALIDEZ." + Environment.NewLine + "COMPROBANTE GENERADO EN EL AMBIENTE DE PRUEBAS" : ""); formaReporte.Text = comprobante.TIPOCOMPROBANTE.NOMBRE + "-" + comprobante.NUMEROCOMPROBANTE; formaReporte.getdocumentViewer1().DocumentSource = xtraReport; formaReporte.getdocumentViewer1().Show(); formaReporte.getdocumentViewer1().PrintingSystem.SetCommandVisibility(DevExpress.XtraPrinting.PrintingSystemCommand.Open, DevExpress.XtraPrinting.CommandVisibility.None); formaReporte.ShowDialog(); } catch (Exception ex) { XtraMessageBox.Show(ex.ToString()); } }
public DialogResult Run() { if (this.Report == null) { return(DialogResult.Cancel); } XtraReportWizardForm form = new XtraReportWizardForm(Wizard.DesignerHost); form.Controls.AddRange(new Control[] { new WizPageWelcome(this), //new WizPageWelcomeCustom(this), //new WizPageDataset(this), //new WizPageConnectionCustom(this), // Custom //new WizPageDataOption(this), // New //new WizPageTablesCustom(this), // Custom //new WizPageQuery(this), // New //new WizPageChooseFieldsCustom(this), // Custom //new WizPageGrouping(this), //new WizPageSummary(this), ////new WizPageGroupedLayout(this), //new WizPageLayoutCustom(this), //new WizPageUngroupedLayout(this), ////new WizPageStyle(this), //custom //new WizPageStylesCustom(this), //new WizPageReportTitle(this), //new WizPageLabelType(this), //new WizPageLabelOptions(this) //, and so on... }); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { Wizard.BuildReport(); foreach (SqlParameter param in ((SqlDataAdapter)Report.DataAdapter).SelectCommand.Parameters) { DevExpress.XtraReports.Parameters.Parameter xParam = new DevExpress.XtraReports.Parameters.Parameter(); xParam.Description = param.ParameterName.Replace('_', ' '); xParam.Name = param.ParameterName; xParam.Visible = true; xParam.Value = param.Value; switch (param.SqlDbType.ToString()) { case "BigInt": xParam.Type = typeof(Int64); break; case "Bit": xParam.Type = typeof(Boolean); break; case "DateTime": xParam.Type = typeof(DateTime); break; case "Money": case "Decimal": xParam.Type = typeof(Decimal); break; case "Int": xParam.Type = typeof(Int32); break; case "NVarChar": xParam.Type = typeof(String); break; } Report.Parameters.Add(xParam); } } return(result); }
public DialogResult Run() { if (this.Report == null) { return(DialogResult.Cancel); } XtraReportWizardForm form = new XtraReportWizardForm(Wizard.DesignerHost); form.Controls.AddRange(new Control[] { new WizPageDataOption(this), // New new WizPageTablesCustom(this), // Custom new WizPageQuery(this), // New new WizPageChooseFieldsCustom(this), // Custom new WizPageGrouping(this), new WizPageSummary(this), new WizPageGroupedLayout(this), new WizPageUngroupedLayout(this), new WizPageStylesCustom(this), new WizPageReportTitle(this), new WizPageLabelType(this), new WizPageLabelOptions(this) }); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { //Wizard.BuildReport(); //var kk = this.Wizard; NewStandardReportWizard wiz = this.Wizard as NewStandardReportWizard; //this.Report.DataSource = wiz.Dataset; //this.Report.DataMember = wiz.Dataset.Tables[0]; //this.Report.DataAdapter = wiz.DataAdapters[0]; this.adapter = wiz.DataAdapters[0] as DataAdapter; this.dataset = wiz.Dataset; //((NewStandardReportWizard)this.Wizard).Dataset.DataSetName = wiz.Dataset.Tables[0].ToString() + "DataSet"; //((NewStandardReportWizard)this.Wizard).DatasetName = wiz.Dataset.Tables[0].ToString() + "DataSet"; //this.dataset.DataSetName = wiz.Dataset.Tables[0].ToString() + "DataSet"; //((DevExpress.XtraReports.Design.XRWizardRunnerBase)(this)) var host = ((DevExpress.XtraReports.Design.XRWizardRunnerBase)(this)).Wizard.DesignerHost; //var component = ((DevExpress.XtraReports.Design.XRWizardRunnerBase)(this)).Report.DataSource as System.ComponentModel.IComponent; //if (component != null) //{ // host.Container.Remove(component); //} //host.Container.Add(((DevExpress.XtraReports.Design.NewStandardReportWizard)(this.Wizard)).DataAdapters[0] as DataAdapter); //host.Container.Add(((NewStandardReportWizard)this.Wizard).Dataset); host.Container.Add(wiz.DataAdapters[0] as DataAdapter); host.Container.Add(wiz.Dataset); //Report.DataSource = wiz.Dataset; //var fieldList = (DevExpress.XtraReports.UserDesigner.FieldListDockPanel)xrDesignDockManager1[DevExpress.XtraReports.UserDesigner.DesignDockPanelType.FieldList]; //var host = (IDesignerHost)xrDesignMdiController1.ActiveDesignPanel.GetService(typeof(IDesignerHost)); //var component = Report.DataSource as IComponent; //if (component != null) //{ // host.Container.Remove(component); //} //host.Container.Add(dataSet); //Report.DataSource = dataSet; //fieldList.UpdateDataSource(host); foreach (SqlParameter param in ((SqlDataAdapter)Report.DataAdapter).SelectCommand.Parameters) { DevExpress.XtraReports.Parameters.Parameter xParam = new DevExpress.XtraReports.Parameters.Parameter(); xParam.Description = param.ParameterName.Replace('_', ' '); xParam.Name = param.ParameterName; xParam.Visible = true; xParam.Value = param.Value; switch (param.SqlDbType.ToString()) { case "BigInt": xParam.Type = typeof(Int64); break; case "Bit": xParam.Type = typeof(Boolean); break; case "DateTime": xParam.Type = typeof(DateTime); break; case "Money": case "Decimal": xParam.Type = typeof(Decimal); break; case "Int": xParam.Type = typeof(Int32); break; case "NVarChar": xParam.Type = typeof(String); break; } Report.Parameters.Add(xParam); } } return(result); }
protected XtraReport GetReport() { string dataINI = string.Empty; string dataFIM = string.Empty; rel_EmpLiqPag report = new rel_EmpLiqPag(); if (ASPxDateEdit1.Value == null) { //dataINI = "01/01/" + DateTime.Now.Year.ToString(); dataINI = "01/01/" + Configuracoes.Dados.getExercicioAtual(); } else { dataINI = DateTime.Parse(ASPxDateEdit1.Value.ToString()).ToShortDateString(); } //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "DATAINI", Value = dataINI, Type = typeof(string), Visible = false }); if (ASPxDateEdit2.Value == null) { dataFIM = DateTime.Now.ToShortDateString(); } else { dataFIM = DateTime.Parse(ASPxDateEdit2.Value.ToString()).ToShortDateString(); } DateTime d1 = DateTime.Parse(dataINI); DateTime d2 = DateTime.Parse(dataFIM); dataINI = d1.Year.ToString() +"-"+ d1.Month.ToString()+"-" + d1.Day.ToString(); dataFIM = d2.Year.ToString() +"-"+ d2.Month.ToString()+"-" + d2.Day.ToString(); //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "DATAFIM", Value = dataINI, Type = typeof(string), Visible = false }); //report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false }); //report.FilterString = "[EMPDATA] Between(#" + dataINI.Replace("/", "-") + "#, #" + dataFIM.Replace("/", "-") + "#)"; DevExpress.XtraReports.Parameters.Parameter fromParameter = new DevExpress.XtraReports.Parameters.Parameter() { Name = "fromParameter", Type = typeof(DateTime), Value = dataINI, Visible = false }; DevExpress.XtraReports.Parameters.Parameter toParameter = new DevExpress.XtraReports.Parameters.Parameter() { Name = "toParameter", Type = typeof(DateTime), Value = dataFIM, Visible = false }; report.Parameters.AddRange(new DevExpress.XtraReports.Parameters.Parameter[] { fromParameter, toParameter }); //report.FilterString = "[EMPDATA] Between(?fromParameter, ?toParameter)"; report.FilterString = "[EMPDATA] Between(#"+ dataINI+"#, #"+ dataFIM+"#)"; if (ASPxTokenBox1.Value != null && ASPxTokenBox1.Text.ToString() != string.Empty) { if (report.FilterString == string.Empty || report.FilterString == "") { string undOrc = ASPxTokenBox1.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false }); report.FilterString += "[UNDUNIFICADO] In ('" + undOrc.Replace(",", "','") + "')"; } else { string undOrc = ASPxTokenBox1.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false }); report.FilterString += " And [UNDUNIFICADO] In ('" + undOrc.Replace(",", "','") + "')"; } } else { Control.UsuariosControle ctrlUsu = new UsuariosControle(); bool parametro = Control.Configuracoes.Dados.getParametroGradeDIDComplementar(); string idUsu = ctrlUsu.GetUsuarioByLogin(HttpContext.Current.Session["pUId"].ToString()).UsuarioID.ToString(); string idUndFunc = Control.UndFuncionalCtrl.getUndFuncByUsuID(idUsu).ToString(); string unidOrcDefault = Control.UnidadeOrcamentariaCtrl.GetUnidadeOrcamentriaByUnidadeFuncional(idUndFunc).undUnificado; string sql = "select undunificado, undnome from unidadeorcamentaria UO where "; if (parametro == false) { //sql += "uo.undunificado in (SELECT UO.undunificado " + //" FROM unidadeorcamentaria UO " + //" JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " + //" WHERE " + //" uog.uogunidadegestora = " + //" (SELECT UOG.uogunidadegestora " + //" FROM unidadeorcamentaria UO " + //" JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " + //" where uo.undunificado = '" + unidOrcDefault + "' " + //" ) " + //")"; sql = string.Concat(sql, "uo.undunificado IN ( " + " SELECT UO.undunificado " + " FROM unidadeorcamentaria UO " + " JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " + " WHERE " + " uog.uogunidadegestora = " + " (SELECT UOG.uogunidadegestora " + " FROM unidadeorcamentaria UO " + " JOIN und_orc_und_ges UOG ON UOG.uogorgao = UO.undcodorgao AND UOG.uogunidade = UO.undcodigo " + " where uo.undunificado = '" + unidOrcDefault + "' " + " ) " + ") "); } else { sql += "uo.undunificado in (select UNDUNIFICADO from SCI_USUARIOS_UNDORC where usu_codigo = " + idUsu + " )"; } AcessoDados.AcessoDados.abrirConn(); FirebirdSql.Data.FirebirdClient.FbDataReader dr = AcessoDados.AcessoDados.DataReader(sql); string und = string.Empty; while (dr.Read()) { if (und == string.Empty) { und = "'" + dr["UNDUNIFICADO"].ToString() + "'"; } else { und += ",'" + dr["UNDUNIFICADO"].ToString() + "'"; } } dr.Close(); AcessoDados.AcessoDados.fecharConn(); if (report.FilterString == string.Empty || report.FilterString == "") { string undOrc = ASPxTokenBox1.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false }); report.FilterString += "[UNDUNIFICADO] In ("+ und +")"; } else { string undOrc = ASPxTokenBox1.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "UNDORCAMENTARIA", Value = undOrc, Type = typeof(string), Visible = false }); report.FilterString += " And [UNDUNIFICADO] In (" + und + ")"; } } if (tokenElementodespesa.Value != null && tokenElementodespesa.Text.ToString() != string.Empty) { if (report.FilterString == string.Empty || report.FilterString == "") { string elemento = tokenElementodespesa.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "ELEMENTODESPESA", Value = elemento, Type = typeof(string), Visible = false }); report.FilterString += "[EMPELEMENTO] In ('" + elemento.Replace(",", "','") + "')"; } else { string elemento = tokenElementodespesa.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "ELEMENTODESPESA", Value = elemento, Type = typeof(string), Visible = false }); report.FilterString += " And [EMPELEMENTO] In ('" + elemento.Replace(",", "','") + "')"; } } if (TOKENCREDOR.Value != null && TOKENCREDOR.Text.ToString() != string.Empty) { if (report.FilterString == string.Empty || report.FilterString == "") { string credor = TOKENCREDOR.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "CREDOR", Value = credor, Type = typeof(string), Visible = false }); report.FilterString += "[PESCOD] In ('" + credor.Replace(",", "','") + "')"; } else { string credor = TOKENCREDOR.Value.ToString(); report.Parameters.Add(new DevExpress.XtraReports.Parameters.Parameter() { Name = "CREDOR", Value = credor, Type = typeof(string), Visible = false }); report.FilterString += " And [PESCOD] In ('" + credor.Replace(",", "','") + "')"; } } report.CreateDocument(); return report; }