Exemplo n.º 1
0
        public void FormatoCpVentaImpresora(int idCpVenta)
        {
            const string nameRelation = "ventas.vwcpventaimpresion";
            string       whereList    = string.Format("idcpventa = {0}", idCpVenta);
            const string ordersList   = "numeroitem";
            const string fieldsList   = "*";

            DataTable dtCpVenta = HelperDb.SqlConsulta(nameRelation, whereList, ordersList, fieldsList);

            dtCpVenta.TableName = "cp";

            DataRow row = dtCpVenta.Rows[0];

            string  nombreArchivoReporte = row["nombrereporte"].ToString();
            decimal totalDocumento       = Convert.ToDecimal(row["totaldocumento"]);
            string  nombreTipoMoneda     = row["nombretipomoneda"].ToString();
            string  nombreReporte        = string.Format("{0} {1}-{2}", row["nombretipoformato"].ToString().Trim(), row["seriecpventa"].ToString().Trim(), row["numerocpventa"].ToString().Trim());

            if (string.IsNullOrEmpty(nombreArchivoReporte))
            {
                XtraMessageBox.Show("No se asignó un formato de impresión", "Atención", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                return;
            }

            string importeDocumentoLetra  = string.Format("{0} {1}", UtilityReport.ToNumberLetters(totalDocumento.ToString(CultureInfo.InvariantCulture)), nombreTipoMoneda);
            string nombreArchivoImpresion = FilesHelper.FindingFileName(Application.StartupPath, string.Format("Reportes\\Ventas\\{0}", nombreArchivoReporte));

            object[] parametrosReporte =
            {
                importeDocumentoLetra
            };

            XtraReportCustom report = PrepareReport(dtCpVenta, parametrosReporte, nombreArchivoImpresion, nombreReporte);

            report.PrintDialog();
        }
Exemplo n.º 2
0
        private XtraReportCustom PrepareReport(DataTable dataSource, object[] parameters, string fileName, string nameReport)
        {
            XtraReportCustom report = new XtraReportCustom
            {
                DataSource   = dataSource,
                DisplayName  = string.IsNullOrEmpty(nameReport) ? "Reporte" : nameReport,
                Name         = nameReport,
                NameDocument = nameReport
            };

            report.LoadLayout(fileName);

            //Asignar parametros
            if (report.Parameters != null && parameters != null)
            {
                for (var i = 0; i < report.Parameters.Count; i++)
                {
                    report.Parameters[i].Value = parameters[i];
                }
            }
            report.RequestParameters       = false;
            report.ShowPrintMarginsWarning = false;
            return(report);
        }