Пример #1
1
        protected void btnpdf_Click(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("ListadoArticulos1.rpt");
            myReportDocument.Load(strRuta);

            DataTable dt = objListado.ListarTodos();
            myReportDocument.SetDataSource(dt);

            myReportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Listado");
        }
Пример #2
0
 protected void btnImprimmer_Click(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpth = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpth.Load(Server.MapPath("~/Report/rptAgence.rpt"));
     rpth.SetDataSource(GetTableAgence());
     rpth.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, String.Format("Liste_Agence_{0}", DateTime.Now));
 }
Пример #3
0
        protected void btnReporte_Click(object sender, EventArgs e)
        {
            PedidoDAO objPedidoDAO = new PedidoDAO();
            ParametroDAO objParametroDAO  = new ParametroDAO();
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            dsReportes dsReporte = new dsReportes();

            List<PedidoDTO> Lista = objPedidoDAO.ListarReporte(AppUtilidad.stringToDateTime(this.txtFechaInicial.Text, "DD/MM/YYYY"),
                                                   AppUtilidad.stringToDateTime(this.txtFechaFinal.Text, "DD/MM/YYYY"),
                                                   Convert.ToInt32(this.ddlSede.SelectedValue),
                                                   Convert.ToInt32(this.ddlProyecto.SelectedValue));

            this.lblMensaje.Text = "";

            if (Lista.Count > 0)
            {
                dsReportes.ParametroRow drParametroRow = dsReporte.Parametro.NewParametroRow();

                drParametroRow.id_reporte = 1;
                drParametroRow.titulo1 = "REPORTE DE SOLICITUDES DE PEDIDOS DE COMPRA";
                drParametroRow.titulo2 = "Desde " + this.txtFechaInicial.Text + " al " + this.txtFechaFinal.Text;
                drParametroRow.empresa = objParametroDTO.RazonSocial;
                dsReporte.Parametro.AddParametroRow(drParametroRow);

                foreach (PedidoDTO reg in Lista)
                {
                    dsReportes.PedidoRow drPedidoRow = dsReporte.Pedido.NewPedidoRow();

                    drPedidoRow.id_reporte = 1;
                    drPedidoRow.id_pedido = reg.IdPedido;
                    drPedidoRow.fecha = reg.FechaPedido.ToString("dd/MM/yyyy");
                    drPedidoRow.descripcion = reg.Descripcion;
                    drPedidoRow.sede = reg.NombreSede;
                    drPedidoRow.proyecto = reg.NombreProyecto;
                    drPedidoRow.estado_aprobacion = reg.NombreEstado;
                    drPedidoRow.estado_control = reg.NombreEstadoControl;
                    drPedidoRow.solicitante = reg.NombreSolicitante;
                    drPedidoRow.orden_compra = reg.OrdenCompra;
                    drPedidoRow.tipo_pedido = reg.NombreTipoPedido;

                    dsReporte.Pedido.AddPedidoRow(drPedidoRow);
                }

                CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
                myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string strRuta = Server.MapPath("rptPedido.rpt");
                myReportDocument.Load(strRuta);
                myReportDocument.SetDataSource(dsReporte);
                Session.Add("ReporteCrystal", myReportDocument);
                Session.Add("FormatoReporte", "PDF");

                string strRutaWeb = Request.ApplicationPath;

                Response.Write("<script language='javascript'>window.open('ReportePedido.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            }
            else
            {
                this.lblMensaje.Text = "Noy registros con los parametros indicados";
            }
        }
Пример #4
0
        private void ImprimirListadoDeProveedores()
        {
            try
            {
                ProveedorEN oRegistroEN = new ProveedorEN();
                ProveedorLN oRegistroLN = new ProveedorLN();

                oRegistroEN = (ProveedorEN)this.Entidad;

                if (oRegistroLN.ListadoParaReportes(oRegistroEN, Program.oDatosDeConexion))
                {
                    RPT = new rptListadoDeProveedores();
                    AgregarTablaEmpresaADataSet();
                    RPT.SetDataSource(AgregarTablaADataSet(oRegistroLN.TraerDatos(), "ListadoProveedores"));
                    LlenarParametros(new string[, ] {
                        { "NombreDelSistema", Program.NombreVersionSistema }, { "TituloDelReporte", oRegistroEN.TituloDelReporte }, { "SubTituloDeReporte", oRegistroEN.SubTituloDelReporte }, { "AplicarBorde", this.AplicarBorder.ToString() }
                    });
                    this.Text             = "Listado de Reportes";
                    crvVista.ReportSource = RPT;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show(oRegistroLN.Error, "Listado de Reportes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                oRegistroLN  = null;
                this.Entidad = null;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
 private void crystalReportViewer1_Load(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     reportDocument.Load(_crystalReportFilePath);
     reportDocument.SetDataSource(_reportSourceTable);  // C:\VisualStudio2008_SVN\MyPlayground\MyPlayground\FieldLabel1.rpt
     crystalReportViewer1.ReportSource = reportDocument;
 }
Пример #6
0
 protected void btnImpression_Click(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpth = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpth.Load(Server.MapPath("~/Report/rptPersonne.rpt"));
     rpth.SetDataSource(GetTablePersonne());
     rpth.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Liste Personne");
 }
Пример #7
0
 private void crystalReportViewer1_Load(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     reportDocument.Load(_crystalReportFilePath);
     reportDocument.SetDataSource(_reportSourceTable);  // C:\VisualStudio2008_SVN\MyPlayground\MyPlayground\FieldLabel1.rpt
     crystalReportViewer1.ReportSource = reportDocument;
 }
Пример #8
0
        private void GenerarCodigoBarras(string code)
        {
            if (code != null)
            {
                Reportes.Code39 c39 = new Reportes.Code39();
                MemoryStream    ms  = new MemoryStream();
                c39.FontFamilyName = "Free 3 of 9";
                c39.FontFileName   = Server.MapPath("FREE3OF9.TTF");
                c39.FontSize       = 30;
                c39.ShowCodeString = true;
                System.Drawing.Bitmap objBitmap = c39.GenerateBarcode(code);
                objBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

                codigobarrasRpt = facturaRpt.OpenSubreport("CodigoBarra.rpt");

                CrearTabla();

                DataRow dr = this.dsImages.Tables["images"].NewRow();
                dr["path"]  = "ninguno";
                dr["image"] = ms.ToArray();
                this.dsImages.Tables["images"].Rows.Add(dr);

                codigobarrasRpt.SetDataSource(this.dsImages);
            }
        }
Пример #9
0
        public ActionResult ExportData_IU(ApplicationHeaderInfo pInfo, App_Detail_PLD01_HDCN_Info pDetail,
                                          List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();

                // Fill export_header
                string fileName_docx = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VI_" + TradeMarkAppCode.AppCode_TM_4C2_PLD_01_HDCN + ".docx");

                AppsCommon.Prepare_Data_Export_D01(ref pDetail, pInfo, pAppDocumentInfo, pFeeFixInfo);

                List <App_Detail_PLD01_HDCN_Info> _lst = new List <App_Detail_PLD01_HDCN_Info>();
                _lst.Add(pDetail);

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLD01_HDCN_Info>(_lst, false);
                _ds_all.Tables[0].TableName = "Table_4c2";

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile    = "TM_PLD01_HDCN.rpt";
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    _tempfile    = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));
                //oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), "TM_PLD01_HDCN.rpt"));

                if (_ds_all != null)
                {
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                System.IO.Stream oStream   = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[]           byteArray = new byte[oStream.Length];
                oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
                System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Пример #10
0
        protected void TroskoviKalkulacije_KalkulacijeSelected(string ids)
        {
            DataTable troskovi = _kalkulacijaBL.GetTroskovi(ids);

            Reports.reportDataSet rds = new Reports.reportDataSet();
            DataRow newRow;

            foreach (DataRow row in troskovi.Rows)
            {
                newRow = rds.Tables["KalkulacijeTroskovi"].NewRow();
                newRow["KalkulacijaID"]    = row["kalkulacija_id"];
                newRow["KalkulacijaNaziv"] = row["kalkulacija_naziv"];
                newRow["SmesaNaziv"]       = row["smesa_naziv"];
                newRow["SirovinaNaziv"]    = row["sirovina_naziv"];
                newRow["Kolicina"]         = row["kolicina"];
                newRow["JmID"]             = row["jm_id"];
                newRow["JmNaziv"]          = row["jm_naziv"];
                newRow["SirovinaCena"]     = row["sirovina_cena"];
                newRow["Ukupno"]           = row["ukupno"];

                rds.Tables["KalkulacijeTroskovi"].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rd.Load("Reports/KalkulacijeTroskovi.rpt");
            rd.SetDataSource(rds);

            frmPrint objfrmPrint = new frmPrint();

            objfrmPrint.crystalReportViewer1.ReportSource = rd;
            objfrmPrint.Show();
        }
Пример #11
0
        protected void PotrosnjaKalkulacije_KalkulacijeSelected(string ids)
        {
            DataTable potrosnja = _kalkulacijaBL.GetPotrosnja(ids);

            Reports.reportDataSet rds = new Reports.reportDataSet();
            DataRow newRow;

            foreach (DataRow row in potrosnja.Rows)
            {
                newRow = rds.Tables["KalkulacijePotrosnja"].NewRow();
                newRow["KalkulacijaID"]    = row["kalkulacija_id"];
                newRow["KalkulacijaNaziv"] = row["kalkulacija_naziv"];
                newRow["SmesaNaziv"]       = row["smesa_naziv"];
                newRow["Dnevno"]           = row["dnevno"];
                newRow["Mesecno"]          = row["mesecno"];
                newRow["Godisnje"]         = row["godisnje"];

                rds.Tables["KalkulacijePotrosnja"].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rd.Load("Reports/KalkulacijePotrosnja.rpt");
            rd.SetDataSource(rds);

            frmPrint objfrmPrint = new frmPrint();

            objfrmPrint.crystalReportViewer1.ReportSource = rd;
            objfrmPrint.Show();
        }
Пример #12
0
        protected void Kalkulacije_KalkulacijeSelected(string ids)
        {
            DataTable potrosnja = _sirovinaBL.GetPotrosnjaUPeriodu(ids);

            Reports.reportDataSet rds = new Reports.reportDataSet();
            DataRow newRow            = rds.Tables["PotrosnjaKabastihSirovinaUPeriodu"].NewRow();

            foreach (DataRow row in potrosnja.Rows)
            {
                newRow = rds.Tables["PotrosnjaKabastihSirovinaUPeriodu"].NewRow();
                newRow["NazivKalkulacije"]  = row["kalkulacija_naziv"];
                newRow["NazivSirovine"]     = row["sirovina_naziv"];
                newRow["Kolicina"]          = row["kolicina"];
                newRow["MesecnaPotrosnja"]  = row["mesecno"];
                newRow["GodisnjaPotrosnja"] = row["godisnje"];
                rds.Tables["PotrosnjaKabastihSirovinaUPeriodu"].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            if (_reportID == 1)
            {
                rd.Load("Reports/PotrosnjaKabastihSirovinaUPeriodu.rpt");
            }
            else if (_reportID == 2)
            {
                rd.Load("Reports/PotrosnjaKabastihSirovina.rpt");
            }
            rd.SetDataSource(rds);

            frmPrint objfrmPrint = new frmPrint();

            objfrmPrint.crystalReportViewer1.ReportSource = rd;
            objfrmPrint.Show();
        }
Пример #13
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Reports.reportDataSet rds = new Reports.reportDataSet();
            DataRow newRow            = rds.Tables["Kalkulacija"].NewRow();

            newRow["NazivSmese"]       = _smesaNaziv;
            newRow["UkupnoKabaste"]    = lblTotalKabaste1.Text;
            newRow["UkupnoKupovne"]    = lblTotalKupovne1.Text;
            newRow["UkupnoAmk"]        = lblTotalAmk1.Text;
            newRow["Ukupno"]           = lblTotal1.Text;
            newRow["NazivKalkulacije"] = _kalkulacijaNaziv;
            rds.Tables["Kalkulacija"].Rows.Add(newRow);

            foreach (DataRow row in _sirovinaCenaDT[0].Rows)
            {
                newRow                    = rds.Tables["KalkulacijaSirovina"].NewRow();
                newRow["naziv"]           = row["Naziv"];
                newRow["kolicina"]        = row["KolicinaKorigovano"].ToString() != string.Empty ? row["KolicinaKorigovano"] : row["Kolicina"];
                newRow["cena"]            = row["Cena"];
                newRow["ukupno"]          = row["Ukupno"];
                newRow["jmNaziv"]         = row["Jm"];
                newRow["tipSirovineCode"] = int.Parse(row["TipSirovineID"].ToString()) == 1 ? "Kabaste" : "Kupovne";
                newRow["udeo"]            = decimal.Parse(row["Ukupno"].ToString()) / decimal.Parse(lblTotal1.Text) * 100;
                rds.Tables["KalkulacijaSirovina"].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rd.Load("Reports/KalkulacijaTroskovi.rpt");
            rd.SetDataSource(rds);

            frmPrint objfrmPrint = new frmPrint();

            objfrmPrint.crystalReportViewer1.ReportSource = rd;
            objfrmPrint.Show();
        }
Пример #14
0
        public void ShowReport(CrystalDecisions.Windows.Forms.CrystalReportViewer obj, string sql, string repname)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument objReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo();
            try
            {
                objReport.Load(repname);


                foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in objReport.Database.Tables)
                {
                    ConInfo = tbCurrent.LogOnInfo;
                    ConInfo.ConnectionInfo.ServerName   = ConfigurationManager.AppSettings["ReportProvider"];
                    ConInfo.ConnectionInfo.UserID       = ConfigurationManager.AppSettings["User ID"];
                    ConInfo.ConnectionInfo.Password     = ConfigurationManager.AppSettings["Password"];
                    ConInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["Database Name"];

                    tbCurrent.ApplyLogOnInfo(ConInfo);
                }

                DataSet objds = Select(sql);
                objReport.SetDataSource(objds.Tables[0]);
                obj.ReportSource = objReport;
            }
            catch
            {
                //return null;
            }
            finally
            {
            }
        }
Пример #15
0
        private void PrintPreView()
        {
            var cmd = contxt.Database.Connection.CreateCommand();
            //System.Data.Common.DataAdapter da = new System.Data.Common.DataAdapter();

            string spName = "";

            //var DataReport;
            if (partner.id == 0)
            {
                spName = "PartnerLedger " + dtMonth.Value.Month + ", -1";
                //DataReport = contxt.Database.SqlQuery(spName,dtMonth.Value.Month, -1).ToList()
            }
            else
            {
                spName = "PartnerLedger " + dtMonth.Value.Month + ", " + contxt.SupplierMasters.FirstOrDefault(o => o.AddressBookId == partner.id);
            }
            cmd.CommandText = spName;
            //cmd.ExecuteReader();
            contxt.Database.Connection.Open();
            report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(ReportName);
            report.SetDataSource((IDataReader)cmd.ExecuteReader());
            report.SetParameterValue("MonthName", String.Format("{0:MMM-yyyy}", dtMonth.Value));
            crv.ParameterFieldInfo = new CrystalDecisions.Shared.ParameterFields();
            foreach (CrystalDecisions.Shared.ParameterField fld in report.ParameterFields)
            {
                crv.ParameterFieldInfo.Add(fld);
            }
            crv.ReportSource = report;
        }
Пример #16
0
        private void PRO007RViewRC_Load(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument drPrint = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            DataRow oRow  = dtPrint.Rows[0];
            String  sFile = ConfigurationManager.AppSettings["pathpdfRecibos"] + "RC-" + oRow["DOCV_Serie"] + "-" + oRow["DOCV_Numero"] + ".pdf";

            try
            {
                drPrint.FileName = System.IO.Directory.GetCurrentDirectory() + "\\Reportes\\" + RptFile;
                drPrint.SetDataSource(dtPrint);
                for (int p = 0; p <= aParams.Count - 1; p++)
                {
                    drPrint.SetParameterValue(p, aParams[p]);
                }
                if (!File.Exists(sFile))
                {
                    drPrint.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, sFile);
                    SendMessage(sFile, oRow);
                }
                CrystalReportViewer.ReportSource = drPrint;
            }
            catch (Exception ex)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #17
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                ser = AdmSerie.MuestraSerie(factur.CodSerie, frmLogin.iCodAlmacen);
                CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                rd.Load("CRNotaDebito.rpt");
                CRNotaDebito rpt = new CRNotaDebito();
                rd.SetDataSource(ds.ReportNotaDebitoCompra(Convert.ToInt32(CodNotaS), frmLogin.iCodAlmacen));
                CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rd.PrintOptions;
                rptoption.PrinterName = ser.NombreImpresora;
                rptoption.PaperSize   = (CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(ser.NombreImpresora, ser.PaperSize);
                rptoption.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(1100, 1850, 200, 1300));
                //CrystalDecisions.Shared.PageMargins margenes = rd.PrintOptions.PageMargins;
                rd.PrintToPrinter(1, false, 1, 1);
                rd.Close();
                rd.Dispose();

                //CRNotaDebito rpt = new CRNotaDebito();
                //frmRptNotaCredito frm = new frmRptNotaCredito();
                //CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rpt.PrintOptions;
                //rptoption.PrinterName = ser.NombreImpresora;//Convert.ToString(System.Drawing.Printing.PrinterSettings.InstalledPrinters[3]);
                //rptoption.PaperSize = (CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(ser.NombreImpresora, ser.PaperSize);
                //rpt.SetDataSource(ds.ReportNotaDebitoCompra(Convert.ToInt32(CodNotaS), frmLogin.iCodAlmacen).Tables[0]);
                //frm.crvNotaCredito.ReportSource = rpt;
                //frm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Se encontro el siguiente problema " + ex.Message, "Nota de Credito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #18
0
    protected void Page_Init(object sender, System.EventArgs e)
    {
        try
        {
            string sPath = HttpContext.Current.Request.MapPath("~/Report\\");

            //表示一个报表,并且包含定义、格式化、加载、导出和打印该报表的属性和方法。

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report      = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.Shared.ParameterDiscreteValue        discreteVal = new CrystalDecisions.Shared.ParameterDiscreteValue();
            CrystalDecisions.Shared.ParameterValues paraValues = new CrystalDecisions.Shared.ParameterValues();

            //加载你事先做好的Crystal Report报表文件
            Report.Load(sPath + Request.QueryString["ReportName"], CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);
            string sData = PublicApi.fnGetConStr("MNDT").Replace(";", ",");
            // 設定報表內SQL Server資料庫的登入資訊
            CrystalDecisions.Shared.TableLogOnInfo logonInfo = new CrystalDecisions.Shared.TableLogOnInfo();

            foreach (CrystalDecisions.CrystalReports.Engine.Table table in Report.Database.Tables)
            {
                logonInfo = table.LogOnInfo;
                var _with1 = logonInfo.ConnectionInfo;
                _with1.ServerName   = fnGetData(sData, "Data Source");
                _with1.DatabaseName = fnGetData(sData, "Initial Catalog");
                _with1.UserID       = fnGetData(sData, "User ID");
                _with1.Password     = fnGetData(sData, "Password");
                table.ApplyLogOnInfo(logonInfo);
            }


            Report.SetDataSource(Session["PrintDT"]);
            //Session["PrintDT"] = null;
            if (Report.ParameterFields["列印人員"] != null)
            {
                Report.SetParameterValue("列印人員", Session["sId"]);
            }

            if (Report.ParameterFields["進貨稅額"] != null)
            {
                string sSql =
                    "  SELECT [parameter]   " +
                    "  FROM   [mndtkind_details]   " +
                    "  WHERE  [kind_id] = 'TAX'   " +
                    "         AND [code_id] = 'IN'   ";
                Report.SetParameterValue("進貨稅額", PublicApi.fnGetValue(sSql, "MNDT"));
            }
            CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX; //列印顯示列印選項,但只有IE會出現這功能
            //Report.PrintToPrinter(1, true, 0, 0); // 直接列印
            CrystalReportViewer1.ReportSource = Report;
            //CrystalReportViewer1.HasExportButton = false; //將匯出的功能False掉
            //CrystalReportViewer1.HasPrintButton = false;
            //CrystalReportViewer1.HasToggleGroupTreeButton = false; //將樹狀結構的按鈕False掉
            //CrystalReportViewer1.DisplayGroupTree = false; //將樹狀結構狀態False掉
        }
        catch (Exception e1)
        {
            //Functions.fnMessageBox(e1.ToString(), this);
        }
    }
Пример #19
0
 private void bPreview_Click(object sender, EventArgs e)
 {
     GetAUditReport();
     CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     report.Load("LeafAnalysis2.rpt");
     report.SetDataSource(auditReport);
     crv.ReportSource = report;
     crv.Refresh();
 }
Пример #20
0
        private static void ImprimirTicket(string Identificador)
        {
            string returnValue = null;

            // Look for the name in the connectionStrings section.
            ConnectionStringSettings settings =
                ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

            // If found, return the connection string.
            if (settings != null)
            {
                returnValue = settings.ConnectionString;
            }

            //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
            SqlConnection sqlConn = new SqlConnection(returnValue);

            SqlCommand comd;

            comd             = new SqlCommand();
            comd.Connection  = sqlConn;
            comd.CommandType = CommandType.StoredProcedure;
            comd.CommandText = "pRepTicket_Pedido";

            comd.Parameters.Add("@Rowguid", SqlDbType.Char);
            comd.Parameters[0].Value = Identificador;

            SqlDataAdapter sqlAdapter = new SqlDataAdapter();

            sqlAdapter.SelectCommand = comd;
            DataSet ds = new DataSet();

            sqlAdapter.Fill(ds, "pRepTicket_Pedido");

            CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            string Filename = @"\\172.16.1.4\Profit\Publicaciones\Profit Expansion\Reportes\RepTicketPedido.rpt";

            oRpt.Load(Filename);

            string NombreImpresora = "";//Donde guardare el nombre de la impresora por defecto

            //Busco la impresora por defecto
            for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                PrinterSettings a = new PrinterSettings();
                a.PrinterName = PrinterSettings.InstalledPrinters[i].ToString();
                if (a.IsDefaultPrinter)
                {
                    NombreImpresora = PrinterSettings.InstalledPrinters[i].ToString();
                }
            }

            oRpt.SetDataSource(ds);                          //Asigno la fuente de datos a mi reporte.
            oRpt.PrintOptions.PrinterName = NombreImpresora; //Asigno la impresora
            oRpt.PrintToPrinter(1, false, 0, 0);             //Imprimo 1 copias
        }
Пример #21
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Error al generar el reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Caja caja = new Caja((int)cbxCaja.SelectedValue);
            string logo = string.Empty;
            if (!caja.IsNull())
                logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
            caja = null;
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rpt.Load("Reportes\\CorteCaja.rpt");
            rpt.Subreports[0].SetDataSource((DataTable)dgvCheques.DataSource);
            rpt.SetDataSource((DataTable)dgvTransacciones.DataSource);
            rpt.SetParameterValue("Caja", cbxCaja.Text);
            rpt.SetParameterValue("PesosR", tbxPesos.Value);
            rpt.SetParameterValue("PesosS", tbxCantidad.Value);
            rpt.SetParameterValue("DolaresR", tbxDolares.Value);
            rpt.SetParameterValue("DolaresS", tbxCantidad2.Value);
            rpt.SetParameterValue("PB1000",tbxPB1000.Text);
            rpt.SetParameterValue("PB500", tbxPB500.Text);
            rpt.SetParameterValue("PB200", tbxPB200.Text);
            rpt.SetParameterValue("PB100", tbxPB100.Text);
            rpt.SetParameterValue("PB50", tbxPB50.Text);
            rpt.SetParameterValue("PB20", tbxPB20.Text);
            rpt.SetParameterValue("PM100", tbxPM100.Text);
            rpt.SetParameterValue("PM20", tbxPM20.Text);
            rpt.SetParameterValue("PM10", tbxPM10.Text);
            rpt.SetParameterValue("PM5", tbxPM5.Text);
            rpt.SetParameterValue("PM2", tbxPM2.Text);
            rpt.SetParameterValue("PM1", tbxPM1.Text);
            rpt.SetParameterValue("PM50C", tbxPC50.Text);
            rpt.SetParameterValue("PM20C", tbxPC20.Text);
            rpt.SetParameterValue("PM10C", tbxPC10.Text);
            rpt.SetParameterValue("PM5C", tbxPC5.Text);

            rpt.SetParameterValue("DB100", tbxDB100.Text);
            rpt.SetParameterValue("DB50", tbxDB50.Text);
            rpt.SetParameterValue("DB20", tbxDB20.Text);
            rpt.SetParameterValue("DB10", tbxDB10.Text);
            rpt.SetParameterValue("DB5", tbxDB5.Text);
            rpt.SetParameterValue("DB1", tbxDB1.Text);
            rpt.SetParameterValue("DM1", tbxDM1.Text);
            rpt.SetParameterValue("DM50", tbxDC50.Text);
            rpt.SetParameterValue("DM25", tbxDC25.Text);
            rpt.SetParameterValue("DM10", tbxDC10.Text);
            rpt.SetParameterValue("DM5", tbxDC5.Text);
            rpt.SetParameterValue("DM1C", tbxDC1.Text);

            rpt.SetParameterValue("Logo", logo);

            frmReporte frm = new frmReporte(rpt);
            frm.ShowDialog();
            rpt.Dispose();
            rpt = null;
            frm.Dispose();
            frm = null;
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            string SearchStr = string.Empty;

            try
            {
                if (Session["CurrentSchoolYearId"] == null)
                {
                    Response.Redirect("~/Login.aspx");
                }

                crdata.Report = rpt;
                rpt1          = crdata.ReportDocument;
                DataSet dsReport = new xmlClassWiseStudentAttendTime();
                DataSet ds       = new DataSet();
                if (Session["FamilyTitle"] != null)
                {
                    //rpt.FileName = Server.MapPath("rptFamilyChildListReport.rpt");
                    rpt.FileName = Server.MapPath("rptFamilyChildList1Report.rpt");
                    DayCareBAL.LedgerService proxy = new DayCareBAL.LedgerService();

                    SearchStr += Session["FamilyTitle"].ToString();
                    SearchStr  = Session["FamilyTitle"].ToString().Replace("'00000000-0000-0000-0000-000000000000',", "");
                    //string[] str = SearchStr.Remove(SearchStr.Length - 1).Remove(0, 1).Replace("','", "$").Split('$');

                    //string strFinalSearhString = "";

                    //foreach (string s in str)
                    //{
                    //    string s1 = "";
                    //    s1 = s.Replace("'", "");
                    //    s1 = "''" + s1 + "'',";
                    //    strFinalSearhString += s1;
                    //}
                    //strFinalSearhString = strFinalSearhString.Remove(strFinalSearhString.Length - 1);
                    //strFinalSearhString = "'" + strFinalSearhString + "'";

                    CrystalDecisions.CrystalReports.Engine.TextObject titleTextSchool = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["Text1"];
                    CrystalDecisions.CrystalReports.Engine.TextObject footer          = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["txtfooter"];
                    footer.Text          = Common.GetSchoolWiseAddress(new Guid(Session["SchoolId"].ToString()));
                    titleTextSchool.Text = Session["SchoolName"].ToString().ToUpper();
                    //ds = proxy.GetAccountReceiable(new Guid(Session["CurrentSchoolYearId"].ToString(), new Guid(Request.QueryString["StartDate"].ToString())));
                    ds = proxy.GetFamilyChildListReport(new Guid(Session["SchoolId"].ToString()), new Guid(Session["CurrentSchoolYearId"].ToString()), SearchStr);
                    dsReport.Tables["dtFamilyChildList"].Merge(ds.Tables[0]);
                    rpt1.SetDataSource(dsReport.Tables["dtFamilyChildList"]);
                }
                crp.DisplayGroupTree = false;
                crp.ReportSource     = rpt1;
                crp.RefreshReport();
                crp.DataBind();
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.Ledger, "rptFamilyChildListReport Page_Load", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
            }
        }
Пример #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string reportPath = Server.MapPath("~/Reports/RptMedico.rpt");

            report.Load(reportPath);
            report.SetDataSource(Session["ReportSource"]);
            report.SetParameterValue("titulo", "General");
            crViewer.ReportSource = report;
            crViewer.DataBind();
        }
Пример #24
0
        /// <summary>
        /// Print the error log
        /// </summary>
        public void m_Print()
        {
            try
            {
                DataSet   dsErrLog  = new DataSet();
                DataTable dtbErrLog = new DataTable("element1");
                CrystalDecisions.CrystalReports.Engine.ReportDocument rdtErrLog = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                rdtErrLog.Load("Report\\crpErrorLog.rpt");
                string columnName1, columnType1;
                for (int i = 0; i < rdtErrLog.Database.Tables[0].Fields.Count; i++)
                {
                    columnName1 = rdtErrLog.Database.Tables[0].Fields[i].Name.ToString();
                    columnType1 = rdtErrLog.Database.Tables[0].Fields[i].GetType().ToString();
                    dtbErrLog.Columns.Add(columnName1, rdtErrLog.Database.Tables[0].Fields[i].GetType());
                }
//					dtbErrLog.Columns.Add(rdt);
                DataRow dtrNewRow;
                //insert data**********************************************
                for (int lines = 0; lines < m_objViewer.m_lsv.Items.Count; lines++)
                {
                    dtrNewRow = dtbErrLog.NewRow();
                    for (int i = 0; i < 12; i++)
                    {
                        dtrNewRow[i] = m_objViewer.m_lsv.Items[lines].SubItems[i + 1].Text;
                    }

/*					dtrNewRow[6] = m_objViewer.m_lsv.Items[lines].SubItems[7].Text
 + m_objViewer.m_lsv.Items[lines].SubItems[8].Text;
 +                                      for (int i = 7; i < 12; i++)
 +                                              dtrNewRow[i] = m_objViewer.m_lsv.Items[lines].SubItems[i+2].Text;
 */                 for (int i = 12; i < 12 + 9; i++)
                    {
                        dtrNewRow[i] = "";
                    }
                    for (int i = 12 + 9; i < 12 + 18; i++)
                    {
                        dtrNewRow[i] = 0;
                    }
                    dtbErrLog.Rows.Add(dtrNewRow);
                }

                dsErrLog.Tables.Add(dtbErrLog);
                rdtErrLog.SetDataSource(dsErrLog);
//				CommonClassReport.clsReport ObjDemo = new CommonClassReport.clsReport();

                m_objViewer.m_crvTemp.ReportSource = rdtErrLog;
                m_objViewer.m_crvTemp.PrintReport();
            }
            catch
            {
                MessageBox.Show("打印故障!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #25
0
        public static bool InitCryReport()
        {
            //// Application.StartupPath + "\\" + Guid.NewGuid() + ".rpt";
            //jianqg 2014-4-15  发现经常不能删除 临时文件
            //WorkStaticFun.ClearTempDir 删除临时文件
            string templateFile = System.Environment.GetFolderPath(Environment.SpecialFolder.Templates) + "\\" + Guid.NewGuid() + ".rpt";

            try
            {
                DataTable dt = new DataTable("temp");
                dt.Columns.Add("Fields0");
                Assembly assembly = Assembly.LoadFile(Application.StartupPath + "\\TrasenFrame.dll");
                using (System.IO.Stream stream = assembly.GetManifestResourceStream("TrasenFrame.Forms.Temp.rpt"))
                {
                    byte[] fileByte = new byte[(int)stream.Length];
                    stream.Read(fileByte, 0, (int)stream.Length);
                    using (System.IO.FileStream fs = new System.IO.FileStream(templateFile, System.IO.FileMode.Create))
                    {
                        fs.Write(fileByte, 0, fileByte.Length);
                        fs.Flush();
                    }
                    stream.Close();
                }
                //WriteFrameLocalLog(new string[] { "InitCryReport1" }, true);
                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                //WriteFrameLocalLog(new string[] { "InitCryReport2" }, true);
                rptDoc.FileName = templateFile;
                //WriteFrameLocalLog(new string[] { "InitCryReport3" }, true);
                rptDoc.SetDataSource(dt);



                WriteFrameLocalLog(new string[] { "初始化水晶报表组件完成" }, true);
                return(true);
            }
            catch (Exception error)
            {
                WriteFrameLocalLog(new string[] { "初始化水晶报表组件发生错误!", error.Message }, true);
                return(false);
            }
            finally
            {
                if (System.IO.File.Exists(templateFile))
                {
                    System.IO.File.Delete(templateFile);
                }

                initCryptEnd = true;
            }
        }
Пример #26
0
        private void IncrustarLogo(string cuit, string PtoVta)
        {
            try
            {
                String path = Server.MapPath("~/ImagenesSubidas/");

                string[] archivos   = System.IO.Directory.GetFiles(path, cuit + "-" + PtoVta + ".*", System.IO.SearchOption.TopDirectoryOnly);
                string   imagenCUIT = "";
                if (archivos.Length > 0)
                {
                    imagenCUIT = "~/ImagenesSubidas/" + archivos[0].Replace(Server.MapPath("~/ImagenesSubidas/"), String.Empty);
                }
                else
                {
                    archivos   = System.IO.Directory.GetFiles(path, cuit + ".*", System.IO.SearchOption.TopDirectoryOnly);
                    imagenCUIT = "";
                    if (archivos.Length > 0)
                    {
                        imagenCUIT = "~/ImagenesSubidas/" + archivos[0].Replace(Server.MapPath("~/ImagenesSubidas/"), String.Empty);
                    }
                }

                if (imagenCUIT != "")
                {
                    FileStream FilStr = new FileStream(Server.MapPath(imagenCUIT), FileMode.Open);
                    CrearTabla();
                    BinaryReader BinRed = new BinaryReader(FilStr);
                    DataRow      dr     = this.dsImages.Tables["images"].NewRow();
                    dr["path"]  = Server.MapPath(imagenCUIT);
                    dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length);
                    this.dsImages.Tables["images"].Rows.Add(dr);
                    FilStr.Close();
                    BinRed.Close();

                    imagenRpt = facturaRpt.OpenSubreport("Imagen.rpt");
                    imagenRpt.SetDataSource(this.dsImages);
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: Imagen OK");
                }
            }
            catch (Exception ex)
            {
                string a = ex.Message.ToString().Replace("'", " ");
                a = a.Replace("<", " ");
                a = a.Replace(">", " ");
                a = a.Replace("/", " ");
                a = a.Replace(@"\", " ");
                RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: Imagen NOT OK " + a);
            }
        }
Пример #27
0
 public static void AddReportParameters(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt, DataTable dt, string ReportName, bool CompanyName, bool Address1, bool Address2, bool City, bool PinCode, bool phone, bool Department, bool State, bool Phone2, bool Fax, bool Email)
 {
     rpt.SetDataSource(dt);
     if (ReportName != "")
     {
         rpt.SetParameterValue("pReportName", ReportName);
     }
     if (CompanyName == true)
     {
         rpt.SetParameterValue("pCompanyName", CurrentCompany.CompanyName);
     }
     if (Address1 == true)
     {
         rpt.SetParameterValue("pAddress1", CurrentCompany.Address1);
     }
     if (Address2 == true)
     {
         rpt.SetParameterValue("pAddress2", CurrentCompany.Address2);
     }
     if (City == true)
     {
         rpt.SetParameterValue("pCity", CurrentCompany.City);
     }
     if (State == true)
     {
         rpt.SetParameterValue("pState", "");
     }
     if (PinCode == true)
     {
         rpt.SetParameterValue("pPinCode", CurrentCompany.Pincode);
     }
     if (phone == true)
     {
         rpt.SetParameterValue("pPhone", CurrentCompany.Phone1);
     }
     if (Phone2 == true)
     {
         rpt.SetParameterValue("pPhone2", CurrentCompany.Phone2);
     }
     if (Fax == true)
     {
         rpt.SetParameterValue("pFax", CurrentCompany.Fax);
     }
     if (Email == true)
     {
         rpt.SetParameterValue("pEmail", CurrentCompany.Email);
     }
 }
Пример #28
0
    private string generatefiles(DataSet ds, DataTable dt1, string fromdate, string todate, string FirstPath, DataTable mailsetting)
    {
        try
        {
            DataView dv                          = new DataView(ds.Tables[0]);
            string   strAttachFirst              = string.Empty;
            string   strAttachSecond             = string.Empty;
            bool     isSendData                  = false;
            System.Collections.ArrayList objList = new ArrayList();
            objList.Add(MailSetting(mailsetting));
            CrystalDecisions.CrystalReports.Engine.ReportDocument crystalReport;
            foreach (DataRow Row in dt1.Rows)
            {
                MailDetails objMails = new MailDetails();
                dv.RowFilter  = "SuperZoneID = " + Row["SuperZoneID"].ToString();
                crystalReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                crystalReport.Load(Server.MapPath("../Report/MissingRecieptNo.rpt"));
                crystalReport.SetDataSource(dv.ToTable());
                crystalReport.SetParameterValue("FromDP", Convert.ToDateTime(fromdate));
                crystalReport.SetParameterValue("TODp", Convert.ToDateTime(todate));
                isSendData     = dv.ToTable().Rows.Count > 0 ? true : false;
                strAttachFirst = Server.MapPath(FirstPath + "MissingRecieptNo_" + Convert.ToDateTime(fromdate).ToString("dd-MMM-yyyy") + "_" + Convert.ToDateTime(todate).ToString("dd-MMM-yyyy") + "_" + Row["SuperZoneID"].ToString() + ".pdf");
                crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, strAttachFirst);

                crystalReport.Close();
                crystalReport.Dispose();
                crystalReport       = null;
                objMails.Attachment = strAttachSecond != "" ? strAttachFirst + "," + strAttachSecond : strAttachFirst;
                objMails.Name       = Row["SuperZoneName"].ToString();
                objMails.EmailId    = Row["Email"].ToString();
                string makesubject = "Missing Receipts from " + Convert.ToDateTime(fromdate).ToString("dd-MMM-yyyy") + " TO " + Convert.ToDateTime(todate).ToString("dd-MMM-yyyy");
                objMails.Subject = makesubject;
                objMails.Desc    = makesubject;

                if (isSendData)
                {
                    objList.Add(objMails);
                }
                objMails = null;
            }
            return(JsonConvert.SerializeObject(objList));
        }
        catch (Exception ex)
        {
            throw;
        }
    }
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                if (Session["CurrentSchoolYearId"] == null)
                {
                    Response.Redirect("~/Login.aspx");
                }

                crdata.Report = rpt;
                rpt1          = crdata.ReportDocument;

                DataSet dsReport = new xmlClassWiseStudentAttendTime();
                DataSet ds       = new DataSet();

                if (!string.IsNullOrEmpty(Request.QueryString["StartDate"]))
                {
                    rpt.FileName = Server.MapPath("rptAccountReceivablesReport.rpt");
                    DayCareBAL.LedgerService proxy = new DayCareBAL.LedgerService();

                    CrystalDecisions.CrystalReports.Engine.TextObject titleTextSchool = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["Text9"];
                    CrystalDecisions.CrystalReports.Engine.TextObject footer          = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["txtfooter"];
                    footer.Text          = Common.GetSchoolWiseAddress(new Guid(Session["SchoolId"].ToString()));
                    titleTextSchool.Text = Session["SchoolName"].ToString().ToUpper();
                    //ds = proxy.GetAccountReceiable(new Guid(Session["CurrentSchoolYearId"].ToString(), new Guid(Request.QueryString["StartDate"].ToString())));
                    ds = proxy.GetAccountReceiable(new Guid(Session["CurrentSchoolYearId"].ToString()), Convert.ToDateTime(Request.QueryString["StartDate"].ToString()), "AccountsReceivable");
                    dsReport.Tables["dtAccountReceiable_Credit"].Merge(ds.Tables[0]);
                    rpt1.SetDataSource(dsReport.Tables["dtAccountReceiable_Credit"]);
                }

                crp.DisplayGroupTree = false;
                crp.ReportSource     = rpt1;
                crp.RefreshReport();

                crp.DataBind();
            }
            catch (Exception ex)
            {
                DayCarePL.Logger.Write(DayCarePL.LogType.EXCEPTION, DayCarePL.ModuleToLog.Ledger, "rptAccountReciableReport Page_Load", ex.Message.ToString(), DayCarePL.Common.GUID_DEFAULT);
            }
        }
Пример #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["dtPrint"] != null)
         {
             CrystalDecisions.CrystalReports.Engine.ReportDocument report =
                 new CrystalDecisions.CrystalReports.Engine.ReportDocument();
             report.Load(System.IO.Path.Combine(Server.MapPath("~/Reports"), "crpTable.rpt"));
             report.SetDataSource(Session["dtPrint"]);
             CrystalReportViewer1.PrintMode     = CrystalDecisions.Web.PrintMode.ActiveX;
             CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
             CrystalReportViewer1.ReportSource  = report;
             lblMsg.Text = "";
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Пример #31
0
        public frmInvoice(string txt)
        {
            InitializeComponent();

            try
            {
                pro.strcon.Open();
                string reportname = "Receipt";

                pro.sqlselect = "SELECT * FROM tblproduct p , tbltransaction t,tblsummary s WHERE p.Barcode = t.Barcode AND t.InvoiceNo = s.InvoiceNo AND s.InvoiceNo ='" + txt + "'";

                pro.cmd             = new SqlCommand();
                pro.cmd.Connection  = pro.strcon;
                pro.cmd.CommandText = pro.sqlselect;
                pro.da = new SqlDataAdapter();
                pro.da.SelectCommand = pro.cmd;
                pro.dt = new DataTable();
                pro.da.Fill(pro.dt);


                CrystalDecisions.CrystalReports.Engine.ReportDocument reportdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();;

                string strReportPath = Application.StartupPath + "\\report\\" + reportname + ".rpt";


                reportdoc.Load(strReportPath);
                reportdoc.SetDataSource(pro.dt);

                crystalReportViewer1.ReportSource = reportdoc;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                pro.da.Dispose();
                pro.strcon.Close();
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Session["CurrentSchoolYearId"] == null)
            {
                Response.Redirect("~/Login.aspx");
            }

            crdata.Report = rpt;
            rpt1          = crdata.ReportDocument;

            DataSet dsReport = new xmlClassWiseStudentAttendTime();
            DataSet ds       = new DataSet();

            String strLastNameFrom = Convert.ToString(Request.QueryString["lastnamefrom"]);
            String strLastNameTo   = Convert.ToString(Request.QueryString["lastnameto"]);

            // crp.AfterRender += this.crp_AfterRender;


            rpt.FileName = Server.MapPath("rptStudentSchedule.rpt");
            DayCareBAL.ClassRoomService proxy = new DayCareBAL.ClassRoomService();
            CrystalDecisions.CrystalReports.Engine.TextObject titleText       = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["Text3"];
            CrystalDecisions.CrystalReports.Engine.TextObject titleTextSchool = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["Text1"];
            CrystalDecisions.CrystalReports.Engine.TextObject footer          = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["txtfooter"];
            footer.Text = Common.GetSchoolWiseAddress(new Guid(Session["SchoolId"].ToString()));
            //CrystalDecisions.CrystalReports.Engine.TextObject titleText4 = (CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.ReportObjects["Text4"];
            //titleText4.Text = ViewState["title"].ToString();

            titleText.Text       = "Student Schedule";
            titleTextSchool.Text = Session["SchoolName"].ToString().ToUpper();
            ds = proxy.GetStudentSchedule(new Guid(DayCarePL.Common.GUID_DEFAULT), new Guid(Session["CurrentSchoolYearId"].ToString()), strLastNameFrom, strLastNameTo);
            dsReport.Tables["dtClassWiseStudent"].Merge(ds.Tables[0]);
            rpt1.SetDataSource(dsReport.Tables["dtClassWiseStudent"]);

            crp.DisplayGroupTree = false;
            crp.ReportSource     = rpt1;
            crp.RefreshReport();

            crp.DataBind();
        }
Пример #33
0
        private void btnPrintConsumptionReport_Click(object sender, EventArgs e)
        {
            Reports.reportDataSet rds          = new Reports.reportDataSet();
            DataRow newRowKalkulacijaPotrosnja = rds.Tables["KalkulacijaPotrosnja"].NewRow();

            newRowKalkulacijaPotrosnja["CenaSmese"]        = decimal.Parse(lblTotal1.Text);
            newRowKalkulacijaPotrosnja["KalkulacijaNaziv"] = _kalkulacijaNaziv;
            newRowKalkulacijaPotrosnja["SmesaNaziv"]       = _smesaNaziv;
            rds.Tables["KalkulacijaPotrosnja"].Rows.Add(newRowKalkulacijaPotrosnja);
            foreach (DataGridViewRow row in dgvTroskovi.Rows)
            {
                DataRow newRow = rds.Tables["KalkulacijaPotrosnjaStavka"].NewRow();
                newRow["KategorijaZivotinja"]        = row.Cells["KategorijaZivotinjaNaziv"].Value;
                newRow["BrojZivotinja"]              = row.Cells["BrojZivotinja"].Value;
                newRow["DnevnaPotrosnjaPoZivotinji"] = row.Cells["DnevnaPotrosnjaPoZivotinji"].Value;
                newRow["DnevnaPotrosnjaKolicina"]    = row.Cells["DnevnaPotrosnja"].Value;
                newRow["DnevnaPotrosnjaIznos"]       = decimal.Parse(row.Cells["DnevnaPotrosnja"].Value.ToString()) * decimal.Parse(lblTotal1.Text) / (decimal)100;
                newRow["NedeljnaPotrosnjaKolicina"]  = row.Cells["NedeljnaPotrosnja"].Value;
                newRow["NedeljnaPotrosnjaIznos"]     = decimal.Parse(row.Cells["NedeljnaPotrosnja"].Value.ToString()) * decimal.Parse(lblTotal1.Text) / (decimal)100;
                //newRow["MesecnaPotrosnjaKolicina"] = decimal.Parse(row.Cells["NedeljnaPotrosnja"].Value.ToString()) * (decimal)4.5;
                newRow["MesecnaPotrosnjaKolicina"] = decimal.Parse(row.Cells["DnevnaPotrosnja"].Value.ToString()) * 31;
                //newRow["MesecnaPotrosnjaIznos"] = decimal.Parse(row.Cells["NedeljnaPotrosnja"].Value.ToString()) * (decimal)4.5 * decimal.Parse(lblTotal1.Text) / (decimal)100;
                newRow["MesecnaPotrosnjaIznos"] = decimal.Parse(row.Cells["DnevnaPotrosnja"].Value.ToString()) * 31 * decimal.Parse(lblTotal1.Text) / (decimal)100;
                //newRow["GodisnjaPotrosnjaKolicina"] = decimal.Parse(newRow["MesecnaPotrosnjaKolicina"].ToString()) * (decimal)12;
                newRow["GodisnjaPotrosnjaKolicina"] = decimal.Parse(row.Cells["DnevnaPotrosnja"].Value.ToString()) * 365;
                //newRow["GodisnjaPotrosnjaIznos"] = decimal.Parse(newRow["MesecnaPotrosnjaKolicina"].ToString()) * (decimal)12 * decimal.Parse(lblTotal1.Text) / (decimal)100;
                newRow["GodisnjaPotrosnjaIznos"] = decimal.Parse(row.Cells["DnevnaPotrosnja"].Value.ToString()) * 365 * decimal.Parse(lblTotal1.Text) / (decimal)100;

                rds.Tables["KalkulacijaPotrosnjaStavka"].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rd.Load("Reports/KalkulacijaPotrosnja.rpt");
            rd.SetDataSource(rds);

            frmPrint objfrmPrint = new frmPrint();

            objfrmPrint.crystalReportViewer1.ReportSource = rd;
            objfrmPrint.Show();
        }
Пример #34
0
        private void m_mthSetData(cls3DItem[] arrItems)
        {
            if (arrItems == null)
            {
                return;
            }

            DataSet   objSet = m_objCreateDS();
            DataTable objDT  = objSet.Tables["tbReport"];

            for (int i = 0; i < arrItems.Length; i++)
            {
                DataRow objRow = objDT.NewRow();
                arrItems[i].ToDataRow(ref objRow);
                objDT.Rows.Add(objRow);
            }

            m_objDocument.SetDataSource(objSet);
            m_objDocument.Refresh();
            crystalReportViewer1.ReportSource = m_objDocument;
            crystalReportViewer1.Refresh();
        }
Пример #35
0
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     Caja caja = new Caja((int)cbxCaja.SelectedValue);
     string logo = string.Empty;
     if (!caja.IsNull())
         logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
     caja = null;
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpt.Load("Reportes\\Inventarios.rpt");
     rpt.SetDataSource(((DataView)dgvTransacciones.DataSource).Table);
     rpt.SetParameterValue("Sucursal", cbxSucursal.Text);
     rpt.SetParameterValue("Caja", cbxCaja.Text);
     rpt.SetParameterValue("Usuario", cbxUsuarios.Text);
     rpt.SetParameterValue("Tipo", cbxTipos.Text);
     rpt.SetParameterValue("FechaIni", dtpFechaIni.Text);
     rpt.SetParameterValue("FechaFin", dtpFechaFin.Text);
     rpt.SetParameterValue("Logo", logo);
     frmReporte frm = new frmReporte(rpt);
     frm.ShowDialog();
     rpt.Dispose();
     rpt = null;
     frm.Dispose();
     frm = null;
 }
Пример #36
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="PickNo">揀貨單號</param>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="reportFormatType">檔案型態</param>
    /// <param name="ReportOrderOption">排序類型 "item":品項 "locate":儲位 </param>
    private void LoadCrystalReport(string PickNo, string s_FileName, string s_rptFilePath, string reportFormatType, string ReportOrderOption)
    {

        try
        {
            IVMModel.MaintainPickData BCO = new IVMModel.MaintainPickData(ConntionDB);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(Server.MapPath(s_rptFilePath));

            ParameterList.Clear();
            ParameterList.Add(PickNo);

            if (s_rptFilePath != "./REPORT/IVM15/CRIVM15R03.rpt")
            {

                DataTable dtResult = new DataTable();

                string ProgName = "";

                if (s_rptFilePath == "./REPORT/IVM15/CRIVM15R01.rpt")
                {
                    dtResult = BCO.GetPrintRpt01(ParameterList);
                    ProgName = "IVM15R01";
                }
                else
                {
                    dtResult = BCO.GetPrintRpt02(ParameterList);
                    ProgName = "IVM15R02";
                }

                DataView dv = new DataView(dtResult);

                switch (ReportOrderOption)
                {
                    case "item":
                        dv.Sort = "item";
                        break;

                    case "locate":
                        dv.Sort = "BLocate_No";
                        break;

                    default:
                        dv.Sort = "item";
                        break;
                }

                report.SetDataSource(dv.ToTable());

                report.SetParameterValue("paraProg", ProgName);
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                report.SetParameterValue("paraPickNo", PickNo);
                report.SetParameterValue("paraSource", this.MenuIVM15.SelectedItem.Text);
                report.SetParameterValue("paraAccDate", "");
                report.SetParameterValue("paraReturnNo", "");
                report.SetParameterValue("paraRemoveNo", "");
                report.SetParameterValue("paraBLocate", "");
                report.SetParameterValue("paraELocate", "");
                report.SetParameterValue("paraVendor", "");

            }
            else
            {
                DataTable dtResult = new DataTable();

                dtResult = BCO.GetPrintRpt03(ParameterList);

                report.SetDataSource(dtResult);

                report.SetParameterValue("paraProg", "IVM15R03");
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                //report.SetParameterValue("paraKind", "");
            }

            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                    Response.ContentType = "application/vnd.ms-excel";


                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":


                    System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    byte[] bytesPDF = new byte[streamPDF.Length];
                    streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                    streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:

                    break;
            }

            report.Close();

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }
Пример #37
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);


        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        #region 前置檢查與參數過濾

        string par_AcceptDate = this.txtST_ACCEPT_DATE.Text;
        string par_ChanName = this.ddlChanNo.SelectedItem.Text.Replace("(", " ") ;
        par_ChanName = par_ChanName.Replace(")", "");

        string par_StoreName = string.Empty;
        if (this.ddlStore.SelectedIndex > 0 )
            par_StoreName = this.ddlStore.SelectedItem.Text;

        par_StoreName = par_StoreName.Replace("(", " ");
        par_StoreName = par_StoreName.Replace(")", " "); 

        par_ProgramID = this.PageCode;
//        par_LoginUser = "******"; 
        par_LoginUser = Session["UID"].ToString();

        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

        returnList.Clear();
        
        report.SetParameterValue("AcceptDate", par_AcceptDate);
        report.SetParameterValue("ProgramName", par_ProgramID);
        report.SetParameterValue("UserName", par_LoginUser);
        report.SetParameterValue("ChanName", par_ChanName);
        report.SetParameterValue("StoreName", par_StoreName);
        

        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";

                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }

    }
Пример #38
0
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);



        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  


                Response.ContentType = "application/vnd.ms-excel";


                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();

                break;
            case "PDF":

                string s_par_Program_ID = string.Empty;
                string s_par_LoginUser = string.Empty;

                s_par_Program_ID = this.PageCode;
                s_par_LoginUser = Session["UID"].ToString();


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                break;
            default:

                break;
        }

    }
Пример #39
0
        private void Guia()
        {
            dsReportes dsReporte = new dsReportes();

            dsReportes.GuiaRemisionRow drFilaGuiaRemision = dsReporte.GuiaRemision.NewGuiaRemisionRow();

            drFilaGuiaRemision.id_guia_remision = 1;
            drFilaGuiaRemision.punto_partida = "LIMA";
            drFilaGuiaRemision.punto_llegada = "San Miguel";
            drFilaGuiaRemision.fecha_emision = "28/12/2013";
            drFilaGuiaRemision.fecha_inicio_traslado = "28/12/2013";

            drFilaGuiaRemision.destinatario = "NOMBRE DEL DESTINATARIO";
            drFilaGuiaRemision.ruc_destinatario = "099227394";
            drFilaGuiaRemision.transportista = "COMESA S.A";
            drFilaGuiaRemision.ruc_transportista = "199227395";
            drFilaGuiaRemision.marca = "KIA";
            drFilaGuiaRemision.placa = "888282828";
            drFilaGuiaRemision.certificado = "2013-09";
            drFilaGuiaRemision.licencia = "201309345";

            dsReporte.GuiaRemision.AddGuiaRemisionRow(drFilaGuiaRemision);
            /*
            dsReportes.GuiaRemisionDetalleRow drFilaGuiaRemisionDetalle1 = dsReporte.GuiaRemisionDetalle.NewGuiaRemisionDetalleRow();

            drFilaGuiaRemisionDetalle1.id_guia_remision = 1;
            drFilaGuiaRemisionDetalle1.item = 1;
            drFilaGuiaRemisionDetalle1.cantidad = Convert.ToDecimal("12.33");
            drFilaGuiaRemisionDetalle1.codigo = "1010010020356";
            drFilaGuiaRemisionDetalle1.descripcion = "SULFATO FERROSO 300MG. TAB.";
            drFilaGuiaRemisionDetalle1.precio = Convert.ToDecimal("1234.23000");

            dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle1);

            dsReportes.GuiaRemisionDetalleRow drFilaGuiaRemisionDetalle2 = dsReporte.GuiaRemisionDetalle.NewGuiaRemisionDetalleRow();

            drFilaGuiaRemisionDetalle2.id_guia_remision = 1;
            drFilaGuiaRemisionDetalle2.item = 2;
            drFilaGuiaRemisionDetalle2.cantidad = Convert.ToDecimal("12.33");
            drFilaGuiaRemisionDetalle2.codigo = "6910080080703";
            drFilaGuiaRemisionDetalle2.descripcion = "FRASCO 500 ML TAPA ROSCA PIREX USA VIDRIO BOROSILICATO AUTOCLAV.";
            drFilaGuiaRemisionDetalle2.precio = Convert.ToDecimal("2004.23000");

            dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle2);
            */
            for (int i = 1; i < 31; i++)
            {
                dsReportes.GuiaRemisionDetalleRow drFilaGuiaRemisionDetalle3 = dsReporte.GuiaRemisionDetalle.NewGuiaRemisionDetalleRow();

                drFilaGuiaRemisionDetalle3.id_guia_remision = 1;
                drFilaGuiaRemisionDetalle3.item = i;
                drFilaGuiaRemisionDetalle3.cantidad = Convert.ToDecimal("12.33");
                drFilaGuiaRemisionDetalle3.codigo = "6910080080703";
                drFilaGuiaRemisionDetalle3.descripcion = "FRASCO 500 ML TAPA ROSCA PIREX USA VIDRIO BOROSILICATO AUTOCLAV.";
                drFilaGuiaRemisionDetalle3.precio = Convert.ToDecimal("2004.23000");

                dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle3);
            }

            //dsReportes.ParametroRow drFilaParametro = dsReporte.Parametro.NewParametroRow();
            //drFilaParametro.IdReporte = 1;
            //drFilaParametro.empresa = "EMPRESA";
            //drFilaParametro.titulo1 = "ORDEN DE COMPRA N° " + objOrdenCompra.NumeroOrdenCompra;
            //dsReporte.Parametro.AddParametroRow(drFilaParametro);

            //dsReportes.OrdenCompraRow  dsFilaOrdenCompra = dsReporte.OrdenCompra.NewOrdenCompraRow();
            //dsFilaOrdenCompra.IdReporte = 1;
            //dsFilaOrdenCompra.IdOrdenCompra = objOrdenCompra.IdOrdenCompra;
            //dsFilaOrdenCompra.Proyecto = objOrdenCompra.NombreProyecto;
            //dsFilaOrdenCompra.RazonSocial = objOrdenCompra.RazonSocial;
            //dsFilaOrdenCompra.Moneda = objOrdenCompra.NombreMoneda;
            //dsFilaOrdenCompra.Subtotal = objOrdenCompra.ImporteOrdenCompra;
            ////MONTO DE IGV
            //IgvDTO IGVDTO = objIGVDAO.ListarIGVVigente(objOrdenCompra.FechaOrdenCompra);
            //dsFilaOrdenCompra.IGV = dsFilaOrdenCompra.Subtotal * IGVDTO.Igv;
            //dsFilaOrdenCompra.Total = dsFilaOrdenCompra.Subtotal + dsFilaOrdenCompra.IGV;

            //dsReporte.OrdenCompra.AddOrdenCompraRow(dsFilaOrdenCompra);

            //foreach (OrdenCompraLineaDTO linea in objOrdenCompraLinea)
            //{
            //    dsReportes.OrdenCompraLineasRow drFilaOrdenCompraLinea = dsReporte.OrdenCompraLineas.NewOrdenCompraLineasRow();

            //    drFilaOrdenCompraLinea.IdReporte = 1;
            //    drFilaOrdenCompraLinea.IdOrdenCompra = objOrdenCompra.IdOrdenCompra;
            //    drFilaOrdenCompraLinea.Linea = linea.NumeroLinea;
            //    drFilaOrdenCompraLinea.Cantidad = linea.Cantidad;
            //    drFilaOrdenCompraLinea.UnidadMedida = linea.NombreUnidadMedida;
            //    drFilaOrdenCompraLinea.DescripcionLinea = linea.DescripcionLinea;
            //    drFilaOrdenCompraLinea.PrecioUnitario = linea.Precio;
            //    drFilaOrdenCompraLinea.Importe = linea.Importe;

            //    dsReporte.OrdenCompraLineas.AddOrdenCompraLineasRow(drFilaOrdenCompraLinea);

            //}

            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("rptGuiaRemision.rpt");
            myReportDocument.Load(strRuta);
            myReportDocument.SetDataSource(dsReporte);
            Session.Add("ReporteCrystal", myReportDocument);
            Session.Add("FormatoReporte", "PDF");

            string strRutaWeb = Request.ApplicationPath;

            Response.Write("<script language='javascript'>window.open('frmVisorReporte.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            //Response.Write("<script language='javascript'>window.open('" + strRutaWeb + "frmOrdenCompraImpresion.aspx?id=" + IdOrdenCompra.ToString() + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            //Response.Write("<script language='javascript'>JS_openWindow('" + strRutaWeb + "frmOrdenCompraImpresion.aspx?id=" + IdOrdenCompra.ToString() + "','Reporte','600','300','no', 'no', 'no', 'no', 'no');</script>");
        }
Пример #40
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
            culture.NumberFormat.CurrencySymbol = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            base.InitializeCulture();

            if (Session["lote"] == null)
            {
                Response.Redirect("~/Inicio.aspx");
            }
            else
            {
                try
                {
                    string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/lote_comprobantes.xsd");
                    System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "lote_comprobantes.xsd", true);

                    string imagen = Server.MapPath("~/Facturacion/Electronica/Reportes/Imagen.xsd");
                    System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                    facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/Factura.rpt");
                    facturaRpt.Load(reportPath);

                    FeaEntidades.InterFacturas.lote_comprobantes lc = (FeaEntidades.InterFacturas.lote_comprobantes)Session["lote"];
                    AsignarCamposOpcionales(lc);
					ReemplarResumenImportesMonedaExtranjera(lc);
					DataSet ds = new DataSet();

                    XmlSerializer objXS = new XmlSerializer(lc.GetType());
                    StringWriter objSW = new StringWriter();
                    objXS.Serialize(objSW, lc);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);

                    bool original = true;
                    try
                    {
                        original = (bool)Session["EsComprobanteOriginal"];
                        if (original == false)
                        {
                            facturaRpt.DataDefinition.FormulaFields["Borrador"].Text = "'BORRADOR'";
                        }
                    }
                    catch
                    { 
                    }

					facturaRpt.SetDataSource(ds);
                    facturaRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                    facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    IncrustarLogo(lc.cabecera_lote.cuit_vendedor.ToString(), lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString());
					string cae = lc.comprobante[0].cabecera.informacion_comprobante.cae;
					if (cae.Replace(" ",string.Empty).Equals(string.Empty))
					{
						cae = "99999999999999";
					}
					GenerarCodigoBarras(lc.cabecera_lote.cuit_vendedor + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + cae +System.DateTime.Now.ToString("yyyyMMdd"));
					AsignarParametros(lc.comprobante[0].resumen.importe_total_factura);

                    facturaRpt.Subreports["impuestos"].DataDefinition.FormulaFields["TipoDeComprobante"].Text = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'"; 
                    facturaRpt.Subreports["resumen"].DataDefinition.FormulaFields["TipoDeComprobante"].Text = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'"; 

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(lc.cabecera_lote.cuit_vendedor);
                    sb.Append("-");
                    sb.Append(lc.cabecera_lote.punto_de_venta.ToString("0000"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.numero_comprobante.ToString("00000000"));
                    if (original == false)
                    {
                        sb.Append("-BORRADOR");
                    }

                    CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: " + ex.Message + " " + ex.StackTrace);
                    throw new Exception(ex.Message); 
                    //WebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepciones.aspx");
                }
            }
        }
Пример #41
0
    //Crystal Report 直接輸出 PDF 檔
    private void ExportReport(DataTable dt, ReportType RType)
    {
        string strFileName = string.Empty;
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(Server.MapPath("./REPORT/PUR052R01.rpt"));

        report.SetDataSource(dt);

        //CrystalReport Parameter 參數設定        

        string Program_ID = string.Empty;
        string LoginUser = string.Empty;
        string LoginName = string.Empty;
        string YearMonth = string.Empty;

        Program_ID = this.PageCode + "R01";
        LoginUser = Session["UID"].ToString();
        LoginName = Get_LoginName();

        report.SetParameterValue("par_Program_ID", Program_ID);
        report.SetParameterValue("par_LoginUser", LoginUser);
        report.SetParameterValue("par_LoginName", LoginName);

        strFileName = "在途單";

        report.SetParameterValue("par_1", txtONWAY_NO.Text);
        report.SetParameterValue("par_2", txtONWAY_DATE.Text);
        report.SetParameterValue("par_3", SLP_VendorBase1.TextBox_Code.Text + " " + SLP_VendorBase1.TextBox_Name.Text);

        //檔案匯出
        if (RType == ReportType.PDF)
        {
            ExportPDF(strFileName, report);
        }
        else
        {
            ExportExcel(strFileName, report);
        }

    }
Пример #42
0
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     Caja caja = new Caja(Globales.IdCaja);
     string logo=string.Empty;
     if (!caja.IsNull())
         logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
     caja = null;
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpt.Load("Reportes\\Historial.rpt");
     rpt.SetDataSource((DataTable)this.dgvPrestamos.DataSource);
     rpt.SetParameterValue("NoPrestamo", cbxPrestamo.SelectedValue.ToString());
     rpt.SetParameterValue("Cliente", cbxCliente.Text);
     rpt.SetParameterValue("Capital", tbxCapital.Value);
     rpt.SetParameterValue("PagoMinimo", tbxPago.Value);
     rpt.SetParameterValue("FechaCorte", dtpFecha.Value);
     rpt.SetParameterValue("Estatus", cbxEstatus.Text);
     rpt.SetParameterValue("Logo", logo);
     frmReporte frm = new frmReporte(rpt);
     frm.ShowDialog();
     rpt.Dispose();
     rpt = null;
     frm.Dispose();
     frm = null;
 }
Пример #43
0
    //匯出Excel
    private void ShowReportB(DataTable dt)
    {
        #region 利用CrystalReport匯出Excel

        //使用者名稱
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        report.Load(Server.MapPath("./REPORT/ITM061/ITM062R01.rpt"));
        report.SetDataSource(dt);        

        //檔案匯出
        System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytesXLS = new byte[streamXLS.Length];
        streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
        streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表_" + System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + ".XLS", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/xls";
        Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
Пример #44
0
        private void IncrustarLogo(string cuit, string PtoVta)
        {
            try
            {
                String path = Server.MapPath("~/ImagenesSubidas/");

                string[] archivos = System.IO.Directory.GetFiles(path, cuit + "-" + PtoVta + ".*", System.IO.SearchOption.TopDirectoryOnly);
                string imagenCUIT = "";
                if (archivos.Length > 0)
                {
                    imagenCUIT = "~/ImagenesSubidas/" + archivos[0].Replace(Server.MapPath("~/ImagenesSubidas/"), String.Empty);
                }
                else
                {
                    archivos = System.IO.Directory.GetFiles(path, cuit + ".*", System.IO.SearchOption.TopDirectoryOnly);
                    imagenCUIT = "";
                    if (archivos.Length > 0)
                    {
                        imagenCUIT = "~/ImagenesSubidas/" + archivos[0].Replace(Server.MapPath("~/ImagenesSubidas/"), String.Empty);
                    }
                }

                if (imagenCUIT != "")
                {
                    FileStream FilStr = new FileStream(Server.MapPath(imagenCUIT), FileMode.Open);
                    CrearTabla();
                    BinaryReader BinRed = new BinaryReader(FilStr);
                    DataRow dr = this.dsImages.Tables["images"].NewRow();
                    dr["path"] = Server.MapPath(imagenCUIT);
                    dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length);
                    this.dsImages.Tables["images"].Rows.Add(dr);
                    FilStr.Close();
                    BinRed.Close();

                    imagenRpt = facturaRpt.OpenSubreport("Imagen.rpt");
                    imagenRpt.SetDataSource(this.dsImages);
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: Imagen OK"  );
                }
            }
            catch (Exception ex)
            {
                string a = ex.Message.ToString().Replace("'", " ");
                a = a.Replace("<", " ");
                a = a.Replace(">", " ");
                a = a.Replace("/", " ");
                a = a.Replace(@"\", " ");
                RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: Imagen NOT OK " + a);
            }
        }
Пример #45
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataSet dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        #region 前置檢查與參數過濾

        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;

        string sTemp;
        par_ProgramID = this.PageCode;
        par_LoginUser = Session["UID"].ToString();

        #endregion

        #region 組合查詢條件至Report ArrayList

        report.SetParameterValue("ProgramName", par_ProgramID);
        report.SetParameterValue("UserName", par_LoginUser); //"/"

        report.SetParameterValue("AcceptDate", this.SLP_Accept_Range.RangeStartTextBox.Text + " - " + this.SLP_Accept_Range.RangeEndTextBox.Text);

        if (this.SLP_VENDER_BEGIN.Text == string.Empty && this.SLP_VENDER_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_VENDER_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name;
        else if (this.SLP_VENDER_END.Text == string.Empty)
            sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - "
                  + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name;

        report.SetParameterValue("Vendor", sTemp);

        if (this.SLP_RootNoStart.Text == string.Empty && this.SLP_RootNoEnd.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_RootNoStart.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name;
        else if (this.SLP_RootNoEnd.Text == string.Empty)
            sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - ";
        else
            sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - "
                  + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name;

        report.SetParameterValue("RootNo", sTemp);

        if (this.SLP_PMA_BEGIN.Text == string.Empty && this.SLP_PMA_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_PMA_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name;
        else if (this.SLP_PMA_END.Text == string.Empty)
            sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - "
                  + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name;

        report.SetParameterValue("PMA", sTemp);

        if (this.SLP_CATEGORY_BEGIN.Text == string.Empty && this.SLP_CATEGORY_END.Text == string.Empty)
            sTemp = string.Empty;
        else if (this.SLP_CATEGORY_BEGIN.Text == string.Empty)
            sTemp = "          " + " - " + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name;
        else if (this.SLP_CATEGORY_END.Text == string.Empty)
            sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - ";
        else
            sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - "
                  + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name;

        report.SetParameterValue("CATEGORY", sTemp);

        report.SetParameterValue("Item", this.SLP_SKU.Text);
        report.SetParameterValue("Period", this.SLP_PERIOD.Text);
        if (this.rdabNormal.Checked == true)
            report.SetParameterValue("Type", this.rdabNormal.Text);
        else if (this.rdNormal.Checked == true)
            report.SetParameterValue("Type", this.rdNormal.Text);

        #endregion

        //判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":

                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/vnd.ms-excel";
                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            case "PDF":


                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";

                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                //Response.OutputStream.Write("AA", 0, 2);

                Response.Flush();
                Response.Close();
                report.Close();

                break;
            default:

                break;
        }

    }
Пример #46
0
    //列印報表
    private void ShowReport(DataSet ds)
    {
        #region 利用CrystalReport列印報表

        //使用者名稱
        DataTable dt1 = new DataTable();
        dt1 = (DataTable)Session["UserInfo"];
        string Login_Name = dt1.Rows[0]["Name"].ToString();

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        report.Load(Server.MapPath("./REPORT/ITM061R.rpt"));
        report.SetDataSource(ds);
        report.Subreports["ITM061R2"].SetDataSource(ds);
        report.Subreports["ITM061R3"].SetDataSource(ds);

        report.SetParameterValue("ProgramName", "ITM061R");
        report.SetParameterValue("UserName", Session["UID"].ToString() + Login_Name);

        if (this.txtCREATEDATE.StartDate.ToString() == "" && this.txtCREATEDATE.EndDate.ToString() == "")
            report.SetParameterValue("QueryDateRange", "全部");
        else
            report.SetParameterValue("QueryDateRange", this.txtCREATEDATE.StartDate.ToString() + "~" + this.txtCREATEDATE.EndDate.ToString());

        if (this.SLP_TimeRange1.StartTime.ToString() == "" && this.SLP_TimeRange1.EndTime.ToString() == "")
            report.SetParameterValue("QueryTime", "全部");
        else
            report.SetParameterValue("QueryTime", this.SLP_TimeRange1.StartTime.ToString() + "~" + this.SLP_TimeRange1.EndTime.ToString());

        report.SetParameterValue("Par_Count", Convert.ToString(ds.Tables["DataTable1"].Rows.Count) + "筆");

        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
Пример #47
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
                culture.NumberFormat.CurrencySymbol = string.Empty;
                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                base.InitializeCulture();
                
                string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/Iva_Ventas.xsd");
                System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "Iva_Ventas.xsd", true);

                oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                bool HayME = false;
                string reportPath = "";
                if (Session["monedasExtranjeras"] != null)
                {
                    HayME = (bool)Session["monedasExtranjeras"];
                }
                if (!HayME)
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaVentasCR.rpt");
                }
                else
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaVentasMECR.rpt");
                }
                oRpt.Load(reportPath);
                Entidades.IvaVentas ivaVentas = new Entidades.IvaVentas();
                if (Session["ivaVentas"] != null)
                {
                    ivaVentas = (Entidades.IvaVentas)Session["ivaVentas"];
                    DataSet ds = new DataSet();
                    XmlSerializer objXS = new XmlSerializer(ivaVentas.GetType());
                    StringWriter objSW = new StringWriter();
                    objXS.Serialize(objSW, ivaVentas);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);
                    oRpt.SetDataSource(ds);
                }
                else
                {
                    Response.Redirect("~/Facturacion/Electronica/Reportes/IvaVentasFiltros.aspx", true);
                }
                string formatoRptExportar = "";
                if (Session["formatoRptExportar"] != null)
                {
                    formatoRptExportar = (string)Session["formatoRptExportar"];
                }
                if (Session["mostrarFechaYHora"] != null)
                {
                    if ((bool)Session["mostrarFechaYHora"] == false)
                    {
                        oRpt.DataDefinition.FormulaFields["MostrarFechaYHora"].Text = "'N'";
                    }
                }
                oRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                oRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                oRpt.DataDefinition.FormulaFields["RazSoc"].Text = "'" + ((Entidades.Sesion)Session["Sesion"]).Cuit.RazonSocial + "'";
                if (formatoRptExportar == "")
                {
                    CrystalReportViewer1.GroupTreeStyle.ShowLines = false;
                    CrystalReportViewer1.HasToggleGroupTreeButton = false;
                    CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
                    CrystalReportViewer1.ReportSource = oRpt;
                    CrystalReportViewer1.HasPrintButton = true;
                }
                else
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(ivaVentas.Cuit);
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaVentas.PeriodoDsd).ToString("yyyyMMdd"));
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaVentas.PeriodoHst).ToString("yyyyMMdd"));

                    if (formatoRptExportar == "PDF")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                    }
                    if (formatoRptExportar == "Excel")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.ExcelFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, Server.MapPath("~/TempExcel/") + sb.ToString() + ".xls");
                        
                        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                        response.ClearContent();
                        response.Clear();
                        response.ContentType = "application/vnd.ms-excel";
                        response.AddHeader("Content-Disposition", "attachment; filename=" + sb.ToString() + ".xls" + ";");
                        response.TransmitFile(Server.MapPath("~/TempExcel/" + sb.ToString() + ".xls"));
                        response.Flush();
                        response.End();  
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Trace.Warn("Thread abortado");
            }
            catch (Exception ex)
            {
                WebForms.Excepciones.Redireccionar(ex, "~/NotificacionDeExcepcion.aspx");
            }
        }
Пример #48
0
    // show報表
    private void ShowReport(DataSet ds)
    {
        try
        {
            string strFileName = "";
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            report.Load(Server.MapPath("./REPORT/MKT05/CRMKT05R01.rpt"));
            strFileName = HttpUtility.UrlEncode("採購卡.PDF", System.Text.Encoding.UTF8);

            report.SetDataSource(ds);

            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ErrMsg.Update();
        }
    }
Пример #49
0
        protected void InicializaPagina()
        {
            int IdOrdenCompra;

            string id = Request.QueryString["id"].ToString();

            IdOrdenCompra = Convert.ToInt32(id);

            OrdenCompraDTO objOrdenCompraDTO = objOrdenCompraDAO.ListarPorClave(IdOrdenCompra);
            ProveedorDTO objProveedorDTO = objProveedorDAO.ListarPorClave(objOrdenCompraDTO.IdProveedor);
            List<OrdenCompraLineaDTO> objOrdenCompraLinea = objOrdenCompraLineaDAO.Listar(IdOrdenCompra);
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            FormaPagoDTO objFormaPagoDTO = objFormaPagoDAO.ListarPorClave(objOrdenCompraDTO.IdFormaPago);
            MonedaDTO objMonedaDTO = objMonedaDAO.ListarPorClave(objOrdenCompraDTO.CodMoneda);
            CotizacionDTO objCotizacionDTO = objCotizacionDAO.ListarPorClave(objOrdenCompraDTO.IdCotizacion);
            PedidoDTO objPedidoDTO = objPedidoDAO.ListarPorClave(objCotizacionDTO.IdPedido);
            UsuarioDTO objUsuarioDTO = objUsuarioDAO.ListarPorClave(objPedidoDTO.IdSolicitante);
            List<PedidoPresupuestoDTO> ListaPedidoPresupuestoDTO = objPedidoPresupuestoDAO.Listar(objPedidoDTO.IdPedido);

            dsReportes dsReporte = new dsReportes();

            dsReportes.ParametroRow drParametroRow = dsReporte.Parametro.NewParametroRow();
            drParametroRow.id_reporte = 1;
            drParametroRow.empresa = objParametroDTO.RazonSocial;

            if (objOrdenCompraDTO.IdTipoOrdenCompra == 1)
                drParametroRow.titulo1 = "ORDEN DE COMPRA N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();
            else
                if (objOrdenCompraDTO.IdTipoOrdenCompra == 2)
                    drParametroRow.titulo1 = "ORDEN DE SERVICIO N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();
                else
                    drParametroRow.titulo1 = "ORDEN N° " + objOrdenCompraDTO.IdOrdenCompra.ToString();

            dsReporte.Parametro.AddParametroRow(drParametroRow);

            //MONTO DE IGV
            IgvDTO objIGVDTO = objIGVDAO.ListarIGVVigente(objOrdenCompraDTO.FechaOrdenCompra);

            dsReportes.OrdenCompraRow drOrdenCompraRow = dsReporte.OrdenCompra.NewOrdenCompraRow();
            drOrdenCompraRow.IdReporte = 1;
            drOrdenCompraRow.IdOrdenCompra = objOrdenCompraDTO.IdOrdenCompra;

            if (objProveedorDTO != null)
            {
                drOrdenCompraRow.RazonSocial = objProveedorDTO.RazonSocial;
                drOrdenCompraRow.Ruc = objProveedorDTO.Ruc;
                drOrdenCompraRow.Direccion = objProveedorDTO.Direccion;
                drOrdenCompraRow.Contacto = objProveedorDTO.Contacto;
            }

            drOrdenCompraRow.Fecha = objOrdenCompraDTO.FechaOrdenCompra.ToString("dd/MM/yyyy");
            drOrdenCompraRow.Cotizacion = "Estimación N° " + objOrdenCompraDTO.IdCotizacion.ToString();

            if (objMonedaDTO!=null)
                drOrdenCompraRow.Moneda = objMonedaDTO.Simbolo;

            drOrdenCompraRow.Subtotal = objOrdenCompraDTO.ImporteOrdenCompra;

            if (objOrdenCompraDTO.FechaEntrega.Year!=1)
                drOrdenCompraRow.FechaEntrega = objOrdenCompraDTO.FechaEntrega.ToString("dd/MM/yyyy");

            if (objFormaPagoDTO!=null)
                drOrdenCompraRow.FormaPago = objFormaPagoDTO.NombreFormaPago;

            if (objParametroDTO != null)
            {
                drOrdenCompraRow.FacturarNombre = objParametroDTO.RazonSocial;
                drOrdenCompraRow.FacturarRuc = objParametroDTO.Ruc;
                drOrdenCompraRow.Direccion = objParametroDTO.Direccion;
            }

            drOrdenCompraRow.Proyecto = objOrdenCompraDTO.NombreProyecto;

            string codigos = "";
            if (ListaPedidoPresupuestoDTO.Count > 0)
            {
                foreach (PedidoPresupuestoDTO item in ListaPedidoPresupuestoDTO)
                {
                    codigos = codigos + " " + item.CodigoPresupuesto;
                }
            }

            drOrdenCompraRow.Descripcion = "Solicitado por " + objUsuarioDTO.NombreUsuario + " - Código: " + codigos;

            if (objOrdenCompraDTO.FlagIGV == "1")
            {
                drOrdenCompraRow.IGV = drOrdenCompraRow.Subtotal * (objIGVDTO.Igv / 100);
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = objIGVDTO.Igv.ToString() + "%";
            }
            else
            {
                drOrdenCompraRow.IGV = 0;
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = "0%";
            }

            /*
            if (objOrdenCompraDTO.IdTipoOrdenCompra == 2)
            {
                drOrdenCompraRow.IGV = 0;
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = "0%";
            }
            else
            {
                drOrdenCompraRow.IGV = drOrdenCompraRow.Subtotal * (objIGVDTO.Igv / 100);
                drOrdenCompraRow.Total = drOrdenCompraRow.Subtotal + drOrdenCompraRow.IGV;
                drOrdenCompraRow.PorcentajeIGV = objIGVDTO.Igv.ToString() + "%";
            }
            */
            drOrdenCompraRow.TotalLetras = "SON: " + AppUtilidad.numberToText(drOrdenCompraRow.Total.ToString()) + " " + objMonedaDTO.NombreMoneda;

            dsReporte.OrdenCompra.AddOrdenCompraRow(drOrdenCompraRow);

            foreach (OrdenCompraLineaDTO linea in objOrdenCompraLinea)
            {

                InvUnidadMedidaDTO objInvUnidadMedidaDTO = objInvUnidadMedidaDAO.ListarPorClave(linea.IdUnidadMedida);
                dsReportes.OrdenCompraLineasRow drOrdenCompraLineasRow = dsReporte.OrdenCompraLineas.NewOrdenCompraLineasRow();

                drOrdenCompraLineasRow.IdReporte = 1;
                drOrdenCompraLineasRow.IdOrdenCompra = objOrdenCompraDTO.IdOrdenCompra;
                drOrdenCompraLineasRow.Linea = linea.NumeroLinea;
                drOrdenCompraLineasRow.Cantidad = linea.Cantidad;

                if (objInvUnidadMedidaDTO != null)
                    drOrdenCompraLineasRow.UnidadMedida = objInvUnidadMedidaDTO.NombreCorto;

                drOrdenCompraLineasRow.DescripcionLinea = linea.DescripcionLinea;
                drOrdenCompraLineasRow.PrecioUnitario = linea.Precio;
                drOrdenCompraLineasRow.Importe = linea.Importe;
                dsReporte.OrdenCompraLineas.AddOrdenCompraLineasRow(drOrdenCompraLineasRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("rptOrdenCompra.rpt");
            myReportDocument.Load(strRuta);
            myReportDocument.SetDataSource(dsReporte);
            Session.Add("ReporteCrystal", myReportDocument);
            Session.Add("FormatoReporte", "PDF");

            MemoryStream stream = new MemoryStream();
            stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ContentType = "application/pdf";

            myReportDocument.Close();
            myReportDocument.Dispose();

            Response.Clear();
            Response.Buffer = true;

            Response.BinaryWrite(stream.ToArray());
            Response.End();

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
Пример #50
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);
        string par_ProgramID = string.Empty;
        string par_LoginUser = string.Empty;
        string par_Chan1 = string.Empty;
        string par_Chan2 = string.Empty;
        string par_Chan3 = string.Empty;

        #region 前置檢查與參數過濾

        string par_PlanAcceptData = this.txtPLAN_ACCEPT_DATE.Text;
        par_ProgramID = this.PageCode;
        string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();

        par_LoginUser = Session["UID"].ToString() + " " + Login_Name;

        if (dt_Source.Rows[0]["No1_Name"] != System.DBNull.Value)
        {
            par_Chan1 = dt_Source.Rows[0]["No1_Name"].ToString();
        }


        if (dt_Source.Rows[0]["No2_Name"] != System.DBNull.Value)
        {
            par_Chan2 = dt_Source.Rows[0]["No2_Name"].ToString();
        }


        if (dt_Source.Rows[0]["No3_Name"] != System.DBNull.Value)
        {
            par_Chan3 = dt_Source.Rows[0]["No3_Name"].ToString();
        }        

        #endregion

        #region 組合查詢條件至ArrayList
        
        report.SetParameterValue("par_ProgramID", par_ProgramID);
        report.SetParameterValue("par_LoginUser", par_LoginUser);
        report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptData, "string"));
        report.SetParameterValue("par_Chan1", par_Chan1);
        report.SetParameterValue("par_Chan2", par_Chan2);
        report.SetParameterValue("par_Chan3", par_Chan3);
        #endregion

        #region 判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "EXCEL":
                System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                byte[] bytesXLS = new byte[streamXLS.Length];
                streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名                
                Response.ContentType = "application/vnd.ms-excel";                
                Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;

            case "PDF":
                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }
        #endregion

    }
        protected void btnDepachar_Click(object sender, EventArgs e)
        {
            try
            {

                GuiaRemisionDTO objGuiaRemisionDTO = new GuiaRemisionDTO();
                DespachoDTO objDespachoDTO = new DespachoDTO();

                UsuarioDTO objUsuarioDTO = objUsuarioDAO.ListarPorLogin(HttpContext.Current.User.Identity.Name);
                objDespachoDTO = objDespachoDAO.ListarPorClave(Convert.ToInt32(this.txtIdDespacho.Text));

                if (this.lblIdGuiaRemision.Text == "")
                {
                    //---------------------------------------------
                    objGuiaRemisionDTO.IdPuntoPartida = Convert.ToInt32(this.ddlPuntoPartida.SelectedValue);
                    objGuiaRemisionDTO.IdPuntoLlegada = Convert.ToInt32(this.ddlPuntoLlegada.SelectedValue);
                    objGuiaRemisionDTO.FechaEmision = AppUtilidad.stringToDateTime(this.txtFechaEmision.Text, "DD/MM/YYYY");
                    objGuiaRemisionDTO.FechaInicioTraslado = AppUtilidad.stringToDateTime(this.txtFechaTraslado.Text, "DD/MM/YYYY");
                    objGuiaRemisionDTO.RazonSocialDestinatario = this.txtDestinatario.Text;
                    objGuiaRemisionDTO.RucDestinatario = this.txtRucDestinatario.Text;
                    objGuiaRemisionDTO.RazonSocialTransportista = this.txtTransportista.Text;
                    objGuiaRemisionDTO.RucTransportista = this.txtRucTransportista.Text;
                    objGuiaRemisionDTO.Marca = this.txtMarca.Text;
                    objGuiaRemisionDTO.Placa = this.txtPlaca.Text;
                    objGuiaRemisionDTO.Certificado = this.txtCetificado.Text;
                    objGuiaRemisionDTO.Licencia = this.txtLicencia.Text;
                    objGuiaRemisionDTO.NumeroComprobantePago = this.txtComprobante.Text;

                    objGuiaRemisionDTO.Serie = this.txtSerie.Text.PadRight(3, '0');
                    objGuiaRemisionDTO.Numero = this.txtNumero.Text.PadLeft(6, '0');

                    objGuiaRemisionDTO.IdUsuarioCreacion = objUsuarioDTO.IdUsuario;
                    objGuiaRemisionDTO.FechaCreacion = DateTime.Now;

                    int IdGuiaRemision = objGuiaRemisionDAO.Agregar(objGuiaRemisionDTO);
                    this.lblIdGuiaRemision.Text = IdGuiaRemision.ToString();

                    //---------------------------------------------
                    objDespachoDTO.IdGuiaRemision = IdGuiaRemision;
                    objDespachoDTO.IdUsuarioModificacion = objUsuarioDTO.IdUsuario;
                    objDespachoDTO.FechaCreacion = DateTime.Now;

                    objDespachoDAO.Actualizar(objDespachoDTO);
                    //---------------------------------------------

                    objGuiaRemisionDTO = objGuiaRemisionDAO.ListarPorClave(IdGuiaRemision);
                    SedeDTO objSedeDTO1 = objSedeDAO.ListarPorClave(objGuiaRemisionDTO.IdPuntoPartida);
                    SedeDTO objSedeDTO2 = objSedeDAO.ListarPorClave(objGuiaRemisionDTO.IdPuntoLlegada);

                    dsReportes dsReporte = new dsReportes();

                    dsReportes.GuiaRemisionRow drFilaGuiaRemision = dsReporte.GuiaRemision.NewGuiaRemisionRow();

                    drFilaGuiaRemision.id_guia_remision = IdGuiaRemision;
                    drFilaGuiaRemision.punto_partida = objSedeDTO1.Direccion;
                    drFilaGuiaRemision.punto_llegada = objSedeDTO2.Direccion;
                    drFilaGuiaRemision.fecha_emision = objGuiaRemisionDTO.FechaEmision.ToString("dd/MM/yyyy");
                    drFilaGuiaRemision.fecha_inicio_traslado = objGuiaRemisionDTO.FechaInicioTraslado.ToString("dd/MM/yyyy");

                    drFilaGuiaRemision.destinatario = objGuiaRemisionDTO.RazonSocialDestinatario;
                    drFilaGuiaRemision.ruc_destinatario = objGuiaRemisionDTO.RucDestinatario;
                    drFilaGuiaRemision.transportista = objGuiaRemisionDTO.RazonSocialTransportista;
                    drFilaGuiaRemision.ruc_transportista = objGuiaRemisionDTO.RazonSocialTransportista;
                    drFilaGuiaRemision.marca = objGuiaRemisionDTO.Marca;
                    drFilaGuiaRemision.placa = objGuiaRemisionDTO.Placa;
                    drFilaGuiaRemision.certificado = objGuiaRemisionDTO.Certificado;
                    drFilaGuiaRemision.licencia = objGuiaRemisionDTO.Licencia;
                    drFilaGuiaRemision.comprobante = objGuiaRemisionDTO.NumeroComprobantePago;
                    drFilaGuiaRemision.numero = objGuiaRemisionDTO.Serie + "-" + objGuiaRemisionDTO.Numero;

                    dsReporte.GuiaRemision.AddGuiaRemisionRow(drFilaGuiaRemision);

                    List<DespachoLineaDTO> ListaDespachoLinea = objDespachoLineaDAO.ListarPorDespacho(Convert.ToInt32(this.txtIdDespacho.Text));

                    foreach (DespachoLineaDTO item in ListaDespachoLinea)
                    {
                        ArticuloDTO objArticuloDTO = objArticuloDAO.ListarPorClave(item.IdArticulo);
                        dsReportes.GuiaRemisionDetalleRow drFilaGuiaRemisionDetalle = dsReporte.GuiaRemisionDetalle.NewGuiaRemisionDetalleRow();

                        drFilaGuiaRemisionDetalle.id_guia_remision = IdGuiaRemision;
                        drFilaGuiaRemisionDetalle.item = item.NumeroLinea;
                        drFilaGuiaRemisionDetalle.cantidad = item.CantidadDespacho; // Convert.ToDecimal("12.33");
                        drFilaGuiaRemisionDetalle.codigo = objArticuloDTO.CodigoArticulo;
                        drFilaGuiaRemisionDetalle.descripcion = objArticuloDTO.Descripcion;
                        drFilaGuiaRemisionDetalle.precio = item.PrecioUnitario; // Convert.ToDecimal("2004.23000");

                        dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle);

                    }
                    //---------------------------------------------
                    CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
                    myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string strRuta = Server.MapPath("rptGuiaRemision.rpt");
                    myReportDocument.Load(strRuta);
                    myReportDocument.SetDataSource(dsReporte);
                    Session.Add("ReporteCrystal", myReportDocument);
                    Session.Add("FormatoReporte", "PDF");

                    string strRutaWeb = Request.ApplicationPath;

                    Response.Write("<script language='javascript'>window.open('frmVisorReporte.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
                }
                else
                {
                    objGuiaRemisionDTO = objGuiaRemisionDAO.ListarPorClave(Convert.ToInt32(this.lblIdGuiaRemision.Text));

                    objGuiaRemisionDTO.IdPuntoPartida = Convert.ToInt32(this.ddlPuntoPartida.SelectedValue);
                    objGuiaRemisionDTO.IdPuntoLlegada = Convert.ToInt32(this.ddlPuntoLlegada.SelectedValue);
                    objGuiaRemisionDTO.FechaEmision = AppUtilidad.stringToDateTime(this.txtFechaEmision.Text, "DD/MM/YYYY");
                    objGuiaRemisionDTO.FechaInicioTraslado = AppUtilidad.stringToDateTime(this.txtFechaTraslado.Text, "DD/MM/YYYY");
                    objGuiaRemisionDTO.RazonSocialDestinatario = this.txtDestinatario.Text;
                    objGuiaRemisionDTO.RucDestinatario = this.txtRucDestinatario.Text;
                    objGuiaRemisionDTO.RazonSocialTransportista = this.txtTransportista.Text;
                    objGuiaRemisionDTO.RucTransportista = this.txtRucTransportista.Text;
                    objGuiaRemisionDTO.Marca = this.txtMarca.Text;
                    objGuiaRemisionDTO.Placa = this.txtPlaca.Text;
                    objGuiaRemisionDTO.Certificado = this.txtCetificado.Text;
                    objGuiaRemisionDTO.Licencia = this.txtLicencia.Text;
                    objGuiaRemisionDTO.NumeroComprobantePago = this.txtComprobante.Text;

                    objGuiaRemisionDTO.Serie = this.txtSerie.Text.PadRight(3, '0');
                    objGuiaRemisionDTO.Numero = this.txtNumero.Text.PadLeft(6, '0');

                    objGuiaRemisionDTO.IdUsuarioModificacion = objUsuarioDTO.IdUsuario;
                    objGuiaRemisionDTO.FechaModificacion = DateTime.Now;

                    objGuiaRemisionDAO.Actualizar(objGuiaRemisionDTO);

                    //--------------------------------
                    SedeDTO objSedeDTO1 = objSedeDAO.ListarPorClave(objGuiaRemisionDTO.IdPuntoPartida);
                    SedeDTO objSedeDTO2 = objSedeDAO.ListarPorClave(objGuiaRemisionDTO.IdPuntoLlegada);

                    dsReportes dsReporte = new dsReportes();

                    dsReportes.GuiaRemisionRow drFilaGuiaRemision = dsReporte.GuiaRemision.NewGuiaRemisionRow();

                    drFilaGuiaRemision.id_guia_remision = Convert.ToInt32(this.lblIdGuiaRemision.Text);
                    drFilaGuiaRemision.punto_partida = objSedeDTO1.Direccion;
                    drFilaGuiaRemision.punto_llegada = objSedeDTO2.Direccion;
                    drFilaGuiaRemision.fecha_emision = objGuiaRemisionDTO.FechaEmision.ToString("dd/MM/yyyy");
                    drFilaGuiaRemision.fecha_inicio_traslado = objGuiaRemisionDTO.FechaInicioTraslado.ToString("dd/MM/yyyy");

                    drFilaGuiaRemision.destinatario = objGuiaRemisionDTO.RazonSocialDestinatario;
                    drFilaGuiaRemision.ruc_destinatario = objGuiaRemisionDTO.RucDestinatario;
                    drFilaGuiaRemision.transportista = objGuiaRemisionDTO.RazonSocialTransportista;
                    drFilaGuiaRemision.ruc_transportista = objGuiaRemisionDTO.RazonSocialTransportista;
                    drFilaGuiaRemision.marca = objGuiaRemisionDTO.Marca;
                    drFilaGuiaRemision.placa = objGuiaRemisionDTO.Placa;
                    drFilaGuiaRemision.certificado = objGuiaRemisionDTO.Certificado;
                    drFilaGuiaRemision.licencia = objGuiaRemisionDTO.Licencia;
                    drFilaGuiaRemision.comprobante = objGuiaRemisionDTO.NumeroComprobantePago;
                    drFilaGuiaRemision.numero = objGuiaRemisionDTO.Serie + "-" + objGuiaRemisionDTO.Numero;

                    dsReporte.GuiaRemision.AddGuiaRemisionRow(drFilaGuiaRemision);

                    List<DespachoLineaDTO> ListaDespachoLinea = objDespachoLineaDAO.ListarPorDespacho(Convert.ToInt32(this.txtIdDespacho.Text));

                    foreach (DespachoLineaDTO item in ListaDespachoLinea)
                    {
                        ArticuloDTO objArticuloDTO = objArticuloDAO.ListarPorClave(item.IdArticulo);
                        dsReportes.GuiaRemisionDetalleRow drFilaGuiaRemisionDetalle = dsReporte.GuiaRemisionDetalle.NewGuiaRemisionDetalleRow();

                        drFilaGuiaRemisionDetalle.id_guia_remision = Convert.ToInt32(this.lblIdGuiaRemision.Text);
                        drFilaGuiaRemisionDetalle.item = item.NumeroLinea;
                        drFilaGuiaRemisionDetalle.cantidad = item.CantidadDespacho; // Convert.ToDecimal("12.33");
                        drFilaGuiaRemisionDetalle.codigo = objArticuloDTO.CodigoArticulo;
                        drFilaGuiaRemisionDetalle.descripcion = objArticuloDTO.Descripcion;
                        drFilaGuiaRemisionDetalle.precio = item.PrecioUnitario; // Convert.ToDecimal("2004.23000");

                        dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle);

                    }
                    //---------------------------------------------
                    CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
                    myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string strRuta = Server.MapPath("rptGuiaRemision.rpt");
                    myReportDocument.Load(strRuta);
                    myReportDocument.SetDataSource(dsReporte);
                    Session.Add("ReporteCrystal", myReportDocument);
                    Session.Add("FormatoReporte", "PDF");

                    string strRutaWeb = Request.ApplicationPath;

                    Response.Write("<script language='javascript'>window.open('frmVisorReporte.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");

                }

            }
            catch (Exception ex)
            {
                this.lblMensaje.Text = ex.ToString();
            }
        }
Пример #52
0
    private void ShowReport()
    {
        #region

        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        try
        {
            string strFileName = "";

            report.Load(Server.MapPath("./REPORT/ALO21/ALO21R01.rpt"));
            strFileName = HttpUtility.UrlEncode("轉門市進貨單明細表.pdf", System.Text.Encoding.UTF8);


            #region 2010/02/11 重新查詢
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(SLP_SLPDate1.Text);//門市進貨日
            ParameterList.Add(SLP_SLPDate2.Text);//轉門市進貨單日
            ParameterList.Add(GetDisTypeSelectedValue());//配本方式
            ParameterList.Add(SLP_SLPNumber1.Text);//理貨批次
            ParameterList.Add(Session["UID"].ToString());//執行者
            ParameterList.Add(DateTime.Now);//執行日期
            ParameterList.Add(string.Format("{0}_{1}", PageTimeStamp.Value, Session["UID"].ToString()));//PageTimeStamp_LoginID :Session_ID
            ParameterList.Add(-1);//最大筆數

            ALOModel.MaintainStAccept BCO = new ALOModel.MaintainStAccept(ConnectionDB);

            string strErrMsg = "";
            DataTable Dt = null;

            if (rbtn_TransStatus1.Checked)//已轉單
            {
                #region
                Dt = BCO.QueryStOutAcceptData(ParameterList, out strErrMsg);
                #endregion
            }
            else//未轉單
            {
                #region
                Dt = BCO.QueryForFind(ParameterList, out strErrMsg);
                #endregion
            }

            #endregion

            report.SetDataSource(Dt);

            string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString();

            report.SetParameterValue("par_Program_ID", "ALO21R01");
            report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
            report.SetParameterValue("par_StAcceptDate", SLP_SLPDate1.Text);
            report.SetParameterValue("par_OutStAcceptDate", SLP_SLPDate2.Text);
            report.SetParameterValue("par_DisType", GetDisTypeSelectedText());

            System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byte[] bytesPDF = new byte[streamPDF.Length];
            streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
            streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally
        {
            report.Close();
        }
        #endregion
    }
Пример #53
0
    //Crystal Report 直接輸出 PDF 檔
    private void ExportReport(DataTable dt)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(Server.MapPath("../REPORT/IVM14/CRIVM14R01.rpt"));
        report.SetDataSource(dt);

        //CrystalReport Parameter 參數設定
        string Program_ID = string.Empty;
        string LoginUser = string.Empty;
        string ChanTransNo = string.Empty;

        Program_ID = this.PageCode.Substring(0, 5) + "R01";
        LoginUser = Session["UID"].ToString();
        ChanTransNo = Session["ForChanTransNo"].ToString();

        report.SetParameterValue("par_Program_ID", this.PageCode);
        report.SetParameterValue("par_LoginUser", LoginUser);
        report.SetParameterValue("par_ChanTransNo", ChanTransNo);

        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("轉入異常資料.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();

    }
Пример #54
0
    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param> 
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source1, DataTable dt_Source2, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source2);
        string par_Vendor = string.Empty;
        string par_VendorName = string.Empty;
        string par_PurDate = string.Empty;
        string par_PurchaseNo = string.Empty;
        string par_PlanAcceptDate = string.Empty;

        par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString();
        par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString();
        par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString();
        par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString();

        if (dt_Source2.Rows.Count != 0)
        {
            par_PlanAcceptDate = dt_Source2.Rows[0]["PLAN_ACCEPT_DATE"].ToString();
        }
        #region 組合查詢條件至ArrayList
        report.SetParameterValue("par_Vendor", par_Vendor);
        report.SetParameterValue("par_VendorName", par_VendorName);
        if (par_PurDate.Trim() != "")
        {
            report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PurDate", "");
        }
        report.SetParameterValue("par_PurchaseNo", par_PurchaseNo);
        if (par_PlanAcceptDate.Trim() != "")
        {
            report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PlanAcceptDate", "");
        }
        #endregion
        #region 判斷輸出檔案型態
        try
        {
            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName); // excel 檔名  

                    Response.ContentType = "application/vnd.ms-excel";

                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":
                    System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    byte[] bytesPDF = new byte[streamPDF.Length];
                    streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                    streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        { 
            this.ErrorMsgLabel.Text = ex.Message; 
        }
        finally 
        {
            report.Close();
        }
        #endregion
    }
Пример #55
0
        protected void InicializaPagina()
        {
            int linea = 0;

            string id = Request.QueryString["id"].ToString();
            string id2 = Request.QueryString["id2"].ToString();

            Decimal dStockArticulo = 0;
            List<InvTransaccionDTO> objTransaccionLista = objTransaccionDAO.ListarPorArticuloProyecto(Convert.ToInt32(id), Convert.ToInt32(id2));
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            ArticuloDTO objArticuloDTO = objArticuloDAO.ListarPorClave(Convert.ToInt32(id));
            InvUnidadMedidaDTO objInvUnidadMedidaDTO = objUnidadMedidaDAO.ListarPorClave(objArticuloDTO.IdUnidadMedida);
            ProyectoDTO objProyectoDTO = objProyectoDAO.ListarPorClave(Convert.ToInt32(id2));

            dsReportes dsReporte = new dsReportes();
            dsReportes.ParametroRow drParametroRow = dsReporte.Parametro.NewParametroRow();
            drParametroRow.id_reporte = 1;
            drParametroRow.empresa = objParametroDTO.RazonSocial;
            drParametroRow.fecha = DateTime.Now.ToString("dd/MM/yyyy");
            dsReporte.Parametro.AddParametroRow(drParametroRow);

            foreach (InvTransaccionDTO fila in objTransaccionLista)
            {
                InvTipoTransaccionDTO objInvTipoTransaccionDTO = objTipoTransaccionDAO.ListarPorClave(fila.IdTipoTransaccion);
                dsReportes.KardexRow drKardexRow = dsReporte.Kardex.NewKardexRow();
                linea = linea + 1;
                drKardexRow.id_reporte = 1;
                drKardexRow.linea = linea;
                drKardexRow.fecha = fila.Fecha.ToString("dd/MM/yyyy");
                drKardexRow.nombre_articulo = objArticuloDTO.Descripcion;
                drKardexRow.codigo_articulo = objArticuloDTO.CodigoArticulo;
                drKardexRow.unidad_medida = objInvUnidadMedidaDTO.NombreUnidadMedida;
                drKardexRow.area = objProyectoDTO.NombreProyecto;
                drKardexRow.observaciones = fila.Descripcion;// objInvTipoTransaccionDTO.NombreTransaccion;

                if (objInvTipoTransaccionDTO.Clase.Equals("I"))
                {
                    dStockArticulo += fila.Cantidad;
                    drKardexRow.entrada = fila.Cantidad;
                    drKardexRow.saldo = dStockArticulo;
                }
                else
                {
                    dStockArticulo -= fila.Cantidad;
                    drKardexRow.salida = fila.Cantidad;
                    drKardexRow.saldo = dStockArticulo;
                }

                dsReporte.Kardex.AddKardexRow(drKardexRow);

            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("KardexArticulo.rpt");
            myReportDocument.Load(strRuta);
            myReportDocument.SetDataSource(dsReporte);
            Session.Add("ReporteCrystal", myReportDocument);
            Session.Add("FormatoReporte", "PDF");

            MemoryStream stream = new MemoryStream();
            stream = (MemoryStream)myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ContentType = "application/pdf";

            myReportDocument.Close();
            myReportDocument.Dispose();

            Response.Clear();
            Response.Buffer = true;

            Response.BinaryWrite(stream.ToArray());
            Response.End();

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
Пример #56
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            DataSet print = new DataSet();
            print.Tables.Add("order");
            print.Tables[0].Columns.Add("number");
            print.Tables[0].Columns.Add("date");
            print.Tables[0].Columns.Add("firstName");
            print.Tables[0].Columns.Add("lastName");
            print.Tables[0].Columns.Add("name");
            print.Tables[0].Columns.Add("pib");
            print.Tables[0].Columns.Add("address");
            print.Tables[0].Columns.Add("city");
            print.Tables[0].Columns.Add("zip");
            print.Tables[0].Columns.Add("email");
            print.Tables[0].Columns.Add("phone");
            print.Tables[0].Columns.Add("comment");
            print.Tables[0].Columns.Add("payment");
            print.Tables[0].Columns.Add("delivery");
            print.Tables[0].Columns.Add("total");
            print.Tables[0].Columns.Add("code");

            print.Tables.Add("orderItem");
            print.Tables[1].Columns.Add("code");
            print.Tables[1].Columns.Add("name");
            print.Tables[1].Columns.Add("webPrice");
            print.Tables[1].Columns.Add("userPrice");
            print.Tables[1].Columns.Add("quantity");
            print.Tables[1].Columns.Add("total");

            DataRow newRow = print.Tables[0].NewRow();
            newRow["number"] = "1";
            newRow["date"] = lblDate.Text;
            newRow["firstName"] = lblFirstname.Text;
            newRow["lastName"] = lblLastname.Text;
            newRow["name"] = lblName.Text;
            newRow["pib"] = lblPib.Text;
            newRow["address"] = lblAddress.Text;
            newRow["city"] = lblCity.Text;
            newRow["zip"] = lblZip.Text;
            newRow["email"] = lblEmail.Text;
            newRow["phone"] = lblPhone.Text;
            newRow["comment"] = lblComment.Text;
            newRow["payment"] = lblPayment.Text;
            newRow["delivery"] = lblDelivery.Text;
            newRow["total"] = lblTotal.Text;
            newRow["code"] = lblCode.Text;
            print.Tables[0].Rows.Add(newRow);

            for (int i = 0; i < dgvItems.Rows.Count; i++)
            {
                newRow = print.Tables[1].NewRow();
                newRow["code"] = ((Label)dgvItems.Rows[i].FindControl("lblProductCode")).Text;
                newRow["name"] = ((Label)dgvItems.Rows[i].FindControl("lblProductName")).Text;
                newRow["webPrice"] = ((Label)dgvItems.Rows[i].FindControl("lblWebPrice")).Text;
                newRow["userPrice"] = ((Label)dgvItems.Rows[i].FindControl("lblPrice")).Text;
                newRow["quantity"] = ((Label)dgvItems.Rows[i].FindControl("lblQuantity")).Text;
                newRow["total"] = ((Label)dgvItems.Rows[i].FindControl("lblTotal")).Text;
                print.Tables[1].Rows.Add(newRow);
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rp = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rp.Load(Server.MapPath("~") + "/administrator/reports/rptOrder.rpt");
            rp.SetDataSource(print);
            Session.Add("orderRp", rp);

            Response.Redirect("/administrator/print.aspx");
        }
Пример #57
0
        private void GenerarCodigoBarras(string code)
        {
            if (code != null)
            {
                Reportes.Code39 c39 = new Reportes.Code39();
                MemoryStream ms = new MemoryStream();
                c39.FontFamilyName = "Free 3 of 9";
                c39.FontFileName = Server.MapPath("FREE3OF9.TTF");
                c39.FontSize = 30;
                c39.ShowCodeString = true;
                System.Drawing.Bitmap objBitmap = c39.GenerateBarcode(code);
                objBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

                codigobarrasRpt = facturaRpt.OpenSubreport("CodigoBarra.rpt");

                CrearTabla();

                DataRow dr = this.dsImages.Tables["images"].NewRow();
                dr["path"] = "ninguno";
                dr["image"] = ms.ToArray();
                this.dsImages.Tables["images"].Rows.Add(dr);

                codigobarrasRpt.SetDataSource(this.dsImages);
            }
        }
Пример #58
0
    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param> 
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source1, DataTable dt_Source2, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source2);
        string par_Vendor = string.Empty;
        string par_VendorName = string.Empty;
        string par_PurDate = string.Empty;
        string par_PurchaseNo = string.Empty;
        string par_FAX = string.Empty;
        string par_TEL = string.Empty;
        string par_BusinessContact = string.Empty;
        double par_Tax = 0;

        par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString();
        par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString();
        par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString();
        par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString();
        par_FAX = dt_Source1.Rows[0]["INV_FAX_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_FAX"].ToString();
        par_TEL = dt_Source1.Rows[0]["INV_TEL_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_TEL"].ToString();
        par_BusinessContact = dt_Source1.Rows[0]["BUSINESS_CONTACT"].ToString();
        if (dt_Source2.Rows.Count == 0)
            par_Tax = 0;
        else
            par_Tax = double.Parse(dt_Source2.Rows[0]["TAXRATE"].ToString());

        #region 組合查詢條件至ArrayList
        report.SetParameterValue("par_Vendor", par_Vendor);
        report.SetParameterValue("par_VendorName", par_VendorName);
        if (par_PurDate.Trim() != "")
        {
            report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date"));
        }
        else
        {
            report.SetParameterValue("par_PurDate", "");
        }
        report.SetParameterValue("par_PurchaseNo", par_PurchaseNo);
        report.SetParameterValue("par_FAX", par_FAX);
        report.SetParameterValue("par_TEL", par_TEL);
        report.SetParameterValue("par_BusinessContact", par_BusinessContact);
        report.SetParameterValue("par_Tax", par_Tax);
        #endregion

        #region 判斷輸出檔案型態
        switch (reportFormatType)
        {
            case "PDF":
                System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                byte[] bytesPDF = new byte[streamPDF.Length];
                streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                //export file  
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                Response.ContentType = "application/pdf";
                Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                Response.Flush();
                Response.Close();
                report.Close();
                break;
            default:

                break;
        }
        #endregion
    }
Пример #59
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source)
    {
        #region
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

        Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        #endregion
    }
Пример #60
0
        /// <summary>
        /// 產生輸出檔案
        /// </summary>
        /// <param name="s_FileName">產生檔案檔名</param>
        /// <param name="s_rptFilePath">RPT報表檔路徑及檔名</param>
        /// <param name="dt_Source">DB抓取的資料集(DataTable)</param>
        /// <param name="RP">報表變數,如無變數請輸入null</param>
        /// <param name="ROF">報表格式</param>        
        public void LoadCrystalReport(string s_FileName,
                                      string s_rptFilePath,
                                      ref DataTable dt_Source,
                                      ReportParameter[] RP,
                                      string ReportOutputFormat
                                      )
        {
            int bytesRead = 0;

            FileStream FS = new FileStream(s_FileName, FileMode.Create, FileAccess.Write);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            try
            {
                report.Load(s_rptFilePath);
                report.SetDataSource(dt_Source);

                //判斷輸出檔案型態
                switch (ReportOutputFormat)
                {
                    case "EXCEL":

                        //如果有報表參數
                        if (RP != null)
                        {
                            for (int i = 0; i < RP.Length; i++)
                            {
                                if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null))
                                {
                                    report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue);
                                }
                            }
                        }

                        Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                        byte[] bytesXLS;

                        try
                        {
                            bytesXLS = new byte[streamXLS.Length];
                            bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                            //export file 
                            while (bytesRead > 0)
                            {
                                FS.Write(bytesXLS, 0, bytesRead);
                                bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            bytesXLS = null;

                            streamXLS.Flush();
                            streamXLS.Close();
                            streamXLS.Dispose();
                        }

                        break;


                    case "PDF":

                        //如果有報表參數
                        if (RP != null)
                        {
                            for (int i = 0; i < RP.Length; i++)
                            {
                                if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null))
                                {
                                    report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue);
                                }
                            }
                        }

                        Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                        byte[] bytesPDF;

                        try
                        {
                            bytesPDF = new byte[streamPDF.Length];
                            bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                            //streamPDF.Seek(0, System.IO.SeekOrigin.Begin);

                            //export file
                            while (bytesRead > 0)
                            {
                                FS.Write(bytesPDF, 0, bytesRead);
                                bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            bytesPDF = null;

                            streamPDF.Flush();
                            streamPDF.Close();
                            streamPDF.Dispose();
                        }

                        break;
                    default:

                        break;
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                FS.Flush();
                FS.Close();
                FS.Dispose();

                report.Close();
                report.Dispose();
                dt_Source.Dispose();
            }
        }