示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        conn = new SqlConnection();
        conn.ConnectionString = ConfigurationManager.ConnectionStrings["kmcConnectionString"].ToString();
        conn.Open();
        DataSet ds  = new DataSet();
        string  qry = "select * from userinfo where Username = '******'";

        sda = new SqlDataAdapter(qry, conn);
        sda.Fill(ds, "user");
        rpt.Load(Server.MapPath("~/CrystalReport.rpt"));
        rpt.FileName       = Server.MapPath("~/CrystalReport.rpt");
        crv.DisplayToolbar = true;
        crv.ToolPanelView  = CrystalDecisions.Web.ToolPanelViewType.None;
        crv.Zoom(100);
        crv.HasExportButton               = false;
        crv.HasPrintButton                = true;
        crv.HasToggleGroupTreeButton      = false;
        crv.HasToggleParameterPanelButton = false;
        crv.HasZoomFactorList             = false;
        crv.HasCrystalLogo                = false;
        crv.Font.Size = 8;
        crv.GroupTreeStyle.Font.Size = 8;
        crv.GroupTreeStyle.ShowLines = false;
        crv.ToolbarStyle.Width       = Unit.Parse("2046px");

        rpt.SetDataSource(ds);
        crv.ReportSource = rpt;
        filepath         = Server.MapPath("~/" + "test.pdf");
        rpt.ExportToDisk(ExportFormatType.PortableDocFormat, filepath);
        //rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "PersonDetails");
        //pdfcontroller();
        conn.Close();
    }
        private void Reporte1()
        {
            string         NameFile      = "Empleados_lista";
            int            n             = 1;
            string         filePath      = @"C:/Users/mfhernandezl/Downloads/" + NameFile + ".pdf";
            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("/Reports/PersonInfo.rpt"));
            bdPersonal dsPersona = ReadAll();

            crystalReport.SetDataSource(dsPersona);
            CrystalReportViewer1.ReportSource = crystalReport;
            CrystalReportViewer1.Visible      = true;
            CrystalReportViewer1.RefreshReport();
            if (!File.Exists(filePath))
            {
                crystalReport.ExportToDisk(ExportFormatType.PortableDocFormat, filePath);
                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.WriteFile(filePath);
            }
            else
            {
                NameFile += "(" + n++ + ")";
                filePath  = @"C:/Users/mfhernandezl/Downloads/" + NameFile + ".pdf";
                crystalReport.ExportToDisk(ExportFormatType.PortableDocFormat, filePath);
                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();
                Response.ContentType = "application/pdf";
                Response.WriteFile(filePath);
            }
        }
        protected void imgbtnPresupuesto_click(object sender, EventArgs e)
        {
            //Parametros del store procedure
            string strID = Cookies.GetCookie("cookieEditarOrdenEstimacion").Value;

            FirmasReportes oFirmas   = FirmasReportesBusiness.ObtenerFirmasReportesPorModulo("Reportes");
            string         strReviso = oFirmas.FirmaReviso;
            //1. Configurar la conexión y el tipo de comando
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);

            try
            {
                using (var comando = new SqlCommand("web_spS_ObtenerREstimacion", conn))
                {
                    using (var adaptador = new SqlDataAdapter(comando))
                    {
                        DataTable dt = new DataTable();
                        adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
                        adaptador.SelectCommand.Parameters.Add(@"IDMovimiento", SqlDbType.Int).Value = Convert.ToInt32(strID);
                        adaptador.Fill(dt);

                        var reporteEstimaciones = new ReportDocument();
                        reporteEstimaciones.Load(Server.MapPath("reportess/rPresupuesto.rpt"));
                        reporteEstimaciones.SetDataSource(dt);
                        reporteEstimaciones.SetParameterValue("reviso", strReviso);

                        string strDireccion = Server.MapPath(" ") + "\\reportess\\Estimaciones\\" + strID;

                        //2. Validar si existe el directorio donde se guardaran
                        if (Directory.Exists(strDireccion))
                        {
                            reporteEstimaciones.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Estimaciones/" + strID + "/rPresupuesto " + strID + ".pdf"));
                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Estimaciones/" + strID + "/rPresupuesto " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                            // reporteFotos.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "rFotos " + strID);
                        }
                        else
                        {
                            Directory.CreateDirectory(strDireccion);
                            reporteEstimaciones.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Estimaciones/" + strID + "/rPresupuesto " + strID + ".pdf"));
                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Estimaciones/" + strID + "/rPresupuesto " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                        }
                    } // end using adaptador
                }     // end using comando
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
                conn.Dispose();
            }
        }
示例#4
0
        /// <summary>
        /// Method IsEmptyReport checks to see if report pulls data or not. This would tell us weather we needed send an email or not.
        /// Users requested to send email with attached empty report regardless of the existence of data.
        /// </summary>
        /// <param name="report"></param>
        /// <param name="p_ReportDocument"></param>
        /// <returns></returns>
        private bool ExportReport(CRPT report, ReportDocument p_ReportDocument)
        {
            try
            {
                string outputDir = ConfigurationManager.AppSettings["OutputPath"].ToString() + report.OutputPath + "\\" + DateTime.Now.ToString("yyyy_MM_dd");
                string fname     = GetGroupLevelFileName(report);
                string strReportExportNamePath = outputDir + "\\" + fname;

                bool IsRFPT = SetParameterValues(report, p_ReportDocument);

                if (IsRFPT)
                {
                    // if (IsEmptyReport(p_ReportDocument)) return false;
                    try
                    {
                        if (!Directory.Exists(outputDir))
                        {
                            Directory.CreateDirectory(outputDir);
                        }

                        if (report.IsPdf())
                        {
                            p_ReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, strReportExportNamePath);
                        }
                        else
                        {
                            p_ReportDocument.ExportToDisk(ExportFormatType.Excel, strReportExportNamePath);
                        }

                        SendMail(strReportExportNamePath, report.Recipients, "Generated Report Attached.", "FreestyleConnect Report");
                    }
                    catch (Exception e)
                    {
                        VMALogger.Log(LogLevel.Error, Environment.NewLine + "Report Name: " + report.ReportName + "Export error message: " + e.Message);
                        return(false);
                    }
                }
                else
                {
                    VMALogger.Log(LogLevel.Error, Environment.NewLine + "Report Name: " + report.ReportName + "Export Parameters not found");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                VMALogger.Log(LogLevel.Error, Environment.NewLine + "Set Parameter Error: " + report.ReportName + " Error Message: " + ex.Message);
                return(false);
            }

            return(true);
        }
        private void VentaTotalxCTC()
        {
            string ctc = string.Empty;

            desde = Convert.ToDateTime(Page.Request["desde"]);
            hasta = Convert.ToDateTime(Page.Request["hasta"]);
            ctc   = Page.Request["ctc"];
            parametros.Add(desde);
            parametros.Add(hasta);
            parametros.Add(ctc);

            ds.tVentaTotalCTC.Merge(conReportes.VentaTotalxCTC(parametros));
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
            rpt.FileName = Server.MapPath("~/RPT/VentaTotalxCTC.rpt");
            rpt.Load(rpt.FileName, OpenReportMethod.OpenReportByDefault);

            rpt.SetDataSource(ds);
            crviewer.ReportSource = rpt;
            //rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ajdsfaklj");
            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("files/asdf.pdf"));

            //ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('files/asdf.pdf');popup.focus();", true);
            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var hidden = open('files/asdf.pdf', 'NewWindow', 'top=25,left=300,width=800, height=600,status=yes,resizable=yes,scrollbars=yes');", true);
            //hidden = open('files/asdf.pdf', 'NewWindow', 'top=25,left=300,width=800, height=600,status=yes,resizable=yes,scrollbars=yes');
        }
        private void ExportReport(ParamReport paramReport)
        {
            var conInfo = new ConnectionInfo
            {
                ServerName   = _builder.DataSource,
                DatabaseName = _builder.InitialCatalog,
                UserID       = _builder.UserID,
                Password     = _builder.Password
            };

            using (var rd = new ReportDocument())
            {
                rd.Load(Path.Combine(Server.MapPath("~/Reports"), paramReport.ReportName));

                rd.DataSourceConnections[0]
                .SetConnection(conInfo.ServerName, conInfo.DatabaseName, conInfo.UserID, conInfo.Password);

                if (paramReport.Parameters.Any())
                {
                    foreach (var param in paramReport.Parameters)
                    {
                        rd.SetParameterValue(param.Key, param.Value);
                    }
                }

                var formatType = GetExportFormatType(paramReport);

                var path = Path.Combine(Server.MapPath("~/Reports/tmp"), GetFileExt(paramReport));

                rd.ExportToDisk(formatType, path);
            }
        }
        public JsonResult GenerateDetailReport(LP_Inv_Report objrprtparam)

        {
            try
            {
                objLP_Inventory_BLL = new LP_Inventory_BLL(objrprtparam);
                DataTable dt = objLP_Inventory_BLL.GetInventoryReport().Tables[0];

                //List<Customer> allCustomer = new List<Customer>();
                //allCustomer = context.Customers.ToList();


                ReportDocument rd = new ReportDocument();
                rd.Load(Path.Combine(Server.MapPath("~/Reports"), "InventoryReport.rpt"));

                rd.SetDataSource(dt);

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


                rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Path.Combine(Server.MapPath("~/Reports"), "InventoryReport.Pdf"));
                //stream.Seek(0, SeekOrigin.Begin);
                //return File(stream, "application/pdf", "CustomerList.pdf");
                return(Json(new { data = "/Reports/InventoryReport.Pdf", success = true, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { data = "/Reports/InventoryReport.Pdf", success = true, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet));
            }
        }
        public string GenerateReport(int ReturnID, string ReportPath)
        {
            ReportDocument rptDoc = null;

            System.IO.MemoryStream objStr = null;
            try
            {
                string Path = "~/Reports/rptCustomerRegistrationBank.rpt";
                rptDoc = new ReportDocument();
                rptDoc.Load(Server.MapPath(Path));
                rptDoc.SetParameterValue("@customerId", ReturnID);
                rptDoc.SetParameterValue("@BankID", ddlBank.SelectedValue);
                objStr = (System.IO.MemoryStream)rptDoc.ExportToStream(ExportFormatType.PortableDocFormat);

                rptDoc.ExportToDisk(ExportFormatType.PortableDocFormat, ReportPath);
                return(ReportPath);
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
                return(string.Empty);
            }
            finally
            {
            }
        }
示例#9
0
        /// <summary>
        /// PDFファイル作成(各請求書毎)
        /// </summary>
        public void PrintOutPDF()
        {
            if (this.targetReportDocument == null)
            {
                throw new ReportException(CommonConst.ErrReportObjectNotReady, new NullReferenceException());
            }
            try
            {
                DirectoryInfo dir = new DirectoryInfo(basedir);
                if (!dir.Exists)
                {
                    dir.Create();
                }

                string filepath = string.Format(basedir + @"\wk_{0:D5}.pdf", this.printfiles.Count);
                this.printfiles.Add(filepath);

                targetReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, filepath);

                targetReportDocument.Close();
                targetReportDocument.Dispose();
                targetReportDocument = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    public void Sentmail_supplier(int PONO, int sup)
    {
        ReportDocument document      = new ReportDocument();
        string         str           = base.Server.MapPath("rptsv/");
        Merchandising  merchandising = new Merchandising();
        string         val           = this._bll.get_Informationdataset("select cCmpName from Smt_Company where Display_AS_Header=1").Tables[0].Rows[0]["cCmpName"].ToString();

        new System.Data.DataTable().TableName = "PO_Printing";
        System.Data.DataTable table = this.blInventory.get_InformationdataTable("Sp_Smt_POPrinting " + ((int)PONO));
        //merchandising.Tables.get_Item("PO_Printing").Merge(table);

        merchandising.Tables["PO_Printing"].Merge(table);

        document.Load(base.Server.MapPath("Report_Merchandising/CrystalReport2.rpt"));
        document.SetDataSource((System.Data.DataSet)merchandising);
        document.SetParameterValue("cCmpName", val);
        System.IO.MemoryStream stream1 = (System.IO.MemoryStream)document.ExportToStream(ExportFormatType.PortableDocFormat);
        base.Response.Clear();
        ContentType type = new ContentType();

        base.Response.Buffer = true;
        type.MediaType       = ("application/pdf");
        string fileName = str + ((int)PONO) + ".pdf";

        document.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);
        this.execmail(this.Session["Uid"].ToString(), PONO, sup, base.Server.MapPath("rptsv/") + ((int)PONO) + ".pdf");
        if (System.IO.File.Exists(fileName))
        {
            System.IO.File.Delete(fileName);
        }
    }
示例#11
0
文件: Core.cs 项目: radtek/InfoPos
        public int ExportToFile(string rptfile, string outfiletype, DataSet tables, string outfilename, ref string error)
        {
            int success = 0;

            try
            {
                ReportDocument rd = new ReportDocument();
                if (tables.Tables.Count == 1)
                {
                    success = Load(rptfile, tables.Tables[0], ref rd, ref error);
                }
                else
                {
                    success = Load(rptfile, tables, ref rd, ref error);
                }

                if (success == 0)
                {
                    string           extention = "";
                    ExportFormatType type      = GetExportType(outfiletype, ref extention);

                    rd.ExportToDisk(type, outfilename);

                    rd.Dispose();
                }
            }
            catch (Exception ex)
            {
                success = 23;
                error   = ex.Message;
            }
            return(success);
        }
示例#12
0
 protected void Page_Load(object Sender, EventArgs e)
 {
     ds      = new DataSet();
     reporte = new ReportDocument();
     if (Session["facs"] != null)
     {
         if (Request.QueryString["tipo"] == "C")
         {
             Utils.MostrarAlerta(Response, "Se ha creado la factura de cliente con prefijo " + Request.QueryString["pre"] + " y número " + Request.QueryString["num"] + "");
             try
             {
                 Imprimir.ImprimirRPT(Response, Request.QueryString["pre"], Convert.ToInt32(Request.QueryString["num"]), true);
             }
             catch
             {
                 lb.Text += "Error al generar la impresión. Detalles : " + formatoRecibo.Mensajes + "<br>";
             }
         }
         else if (Request.QueryString["tipo"] == "P")
         {
             DBFunctions.Request(ds, IncludeSchema.NO, Armar_Select_Pro() + ";" +
                                 "SELECT MNIT.mnit_nit,CEMP.cemp_nombre,CEMP.cemp_direccion,MNIT.mnit_telefono,TREG.treg_nombre CONCAT''CONCAT 'Nº 'CONCAT' 'CONCAT CEMP.cemp_numeregiiva CONCAT' 'CONCAT 'de 'CONCAT''CONCAT CAST(CEMP.cemp_regiiva AS char(10)),MNIT.mnit_web,PCIU.pciu_nombre FROM dbxschema.mnit MNIT,dbxschema.cempresa CEMP,dbxschema.tregimeniva TREG,dbxschema.pciudad PCIU WHERE MNIT.mnit_nit=CEMP.mnit_nit AND CEMP.cemp_indiregiiva=TREG.treg_regiiva AND PCIU.pciu_codigo=CEMP.cemp_ciudad;" +
                                 "SELECT 'Numeración autorizada por la DIAN Resolución Nº ' CONCAT pdoc_numeresofact CONCAT ' Fecha ' CONCAT CAST(pdoc_fechresofact AS char(10)) CONCAT ' Rango con prefijo ' CONCAT pdoc_codigo CONCAT ' Nº ' CONCAT CAST(pdoc_numeinic AS char(10)) CONCAT ' al Nº ' CONCAT CAST(pdoc_numefina AS char(10)) FROM dbxschema.pdocumento WHERE pdoc_codigo='" + (((ArrayList)Session["facs"])[0].ToString().Split('-'))[0].ToString() + "'");
             Sacar_Letras();
             ds.WriteXmlSchema(Path.Combine(Request.PhysicalApplicationPath, "schemas/Finanzas.Cartera.Finanzas.Cartera.rpte_ImpCauAutoPro.xsd"));
             reporte.Load(Path.Combine(Request.PhysicalApplicationPath, "rpt/Finanzas.Cartera.rpte_ImpCauAutoPro.rpt"));
             reporte.SetDataSource(ds);
             visor.ReportSource = reporte;
             visor.DataBind();
             reporte.ExportToDisk(ExportFormatType.WordForWindows, Path.Combine(Request.PhysicalApplicationPath, "rptgen/Finanzas.Cartera.rpte_ImpCauAutoPro.doc"));
         }
     }
 }
        public void Exportar(string key)
        {
            try
            {
                ReportDocument objRpt = new ReportDocument();
                DataSet ds = (DataSet)this.GetDataReport(key);

                string reportPath = "C:\\Reportes\\CRTejTicket_rpt.rpt";
                objRpt.Load(reportPath);

                ExportOptions crExportOptions = new ExportOptions();

                objRpt.SetDataSource(ds.Tables[0]);
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();
                saveFileDialog.Filter = "Document (*.pdf)|*.PDF";
                saveFileDialog.FilterIndex = 1;
                saveFileDialog.FileName = "Etiqueta.pdf";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    objRpt.ExportToDisk(ExportFormatType.PortableDocFormat, saveFileDialog.FileName); ;
                }

                crExportOptions = objRpt.ExportOptions;
                objRpt.Export();

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        private void CustomerTransactionReportForm_Load(object sender, EventArgs e)
        {
            ReportDocument cryRpt;

            using (Devart.Data.SQLite.SQLiteConnection myConn = new Devart.Data.SQLite.SQLiteConnection(myConfig.connstr))
            {
                using (SQLiteCommand myCmd = new SQLiteCommand(sqlcmd, myConn))
                {
                    myConn.Open();
                    using (SQLiteDataReader myReader = myCmd.ExecuteReader())
                    {
                        dataSet2.customer_trans.Load(myReader);
                        myConn.Close();
                    }
                }
            }

            this.customerTableAdapter1.Fill(this.dataSet2.customer);
            this.configurationTableAdapter1.Fill(this.dataSet2.configuration);

            CustomerTransactionReport rpt = new CustomerTransactionReport();
            rpt.SetDataSource(this.dataSet2);

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(this.dataSet2);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\CustomerTransactions.pdf");
        }
示例#15
0
        protected void download_Click(object sender, EventArgs e)
        {
            LinkButton lnk = (LinkButton)sender;
            string     PO  = lnk.CommandArgument.ToString();

            using (var context = new YETIEntities())
            {
                ReportDocument cryRpt = new ReportDocument();
                cryRpt.Load(Server.MapPath("~/Reports/RWO.rpt"));

                cryRpt.SetDataSource(context.cqf_workOrder.Where(w => w.fs_workOrder == PO).ToList());
                crystalReportViewer1.ReportSource = cryRpt;

                crystalReportViewer1.RefreshReport();
                cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath("~/Reports/RWO.pdf"));

                cqf_logActividad log = new cqf_logActividad();
                log.fdt_fecha    = DateTime.Now;
                log.fi_idUsuario = int.Parse(Session["UserID"].ToString());
                log.fs_actividad = "Download Report Work Order:" + PO;

                context.cqf_logActividad.Add(log);
                context.SaveChanges();
            }
        }
        private void CreateReport(ICollection source, string reportName)
        {
            try
            {
                var rd = new ReportDocument();
                rd.Load("Reports\\" + reportName + ".rpt");
                rd.SetDataSource(source);
                var saveFileDlg = new SaveFileDialog
                {
                    FileName         = reportName,
                    DefaultExt       = ".pdf",
                    Filter           = "Pdf documents (.pdf)|*.pdf",
                    InitialDirectory = Environment.CurrentDirectory
                };

                if (saveFileDlg.ShowDialog() == true)
                {
                    rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, saveFileDlg.FileName);
                }
            }
            catch (Exception ex)
            {
                CustomMessage.Show(ex.Message, this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataValidation dv    = new DataValidation();
            string         sPath = dv.CurrentDir(true);

            string sFN = sPath + "pdfs//AgentStockPrices.pdf";

            ReportDocument r = new ReportDocument();

            try
            {
                string sRpt = "AgentStockPrices.rpt";
                r.Load(System.AppDomain.CurrentDomain.BaseDirectory + sRpt);

                sFN = "C:\\MGMQuotation\\pdfs\\AgentStockPrices.rpt";
                r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN);

                System.Web.HttpContext.Current.Response.ClearContent();
                System.Web.HttpContext.Current.Response.ClearHeaders();
                System.Web.HttpContext.Current.Response.ContentType = "application/pdf";
                System.Web.HttpContext.Current.Response.WriteFile(sFN);
            }
            catch (Exception ex)
            {
                Response.Write("Exception occurred: " + ex + ".");
            }
            finally
            {
                r.Dispose();
            }
        }
示例#18
0
        private void cmdExcel_Click(object sender, EventArgs e)
        {
            string sFileName = "";

            try
            {
                var SaveFileDlg = new SaveFileDialog();
                SaveFileDlg.Title  = "VietBaJC-->Save to Excel file";
                SaveFileDlg.Filter = "Excel files|*.XLS";
                if (SaveFileDlg.ShowDialog() == DialogResult.OK)
                {
                    sFileName = SaveFileDlg.FileName;
                    if (sFileName.Contains(".XLS"))
                    {
                    }
                    else
                    {
                        sFileName += ".XLS";
                    }
                    Text = "Đang lưu dữ liệu ra file: " + sFileName;
                    RptDoc.ExportToDisk(ExportFormatType.Excel, sFileName);
                    Text = "In dữ liệu";
                    if (
                        Utility.AcceptQuestion(
                            "Đã xuất dữ liệu thành công ra file Excel ở đường dẫn: " + sFileName + Constants.vbCrLf +
                            "Bạn có muốn mở file Excel ra xem không?", "Thông báo", true))
                    {
                        Process.Start(sFileName);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void GenerateInvoice()
        {
            string path = @"C:\PS Supermarket\Bills\" + txtinvoiceno.Text + ".pdf";

            if (!Directory.Exists(@"C:\PS Supermarket\Bills"))
            {
                Directory.CreateDirectory(@"C:\PS Supermarket\Bills");
            }
            ReportDocument rep = new ReportDocument();

            rep.Load(@"C:\PS Supermarket\Invoice.rpt");
            db.CrystalReportServer(rep);
            rep.SetParameterValue("InvoiceNo", txtinvoiceno.Text);
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            rep.ExportToDisk(ExportFormatType.PortableDocFormat, path);
            DialogResult open = MessageBox.Show("Do you want to Open the Invoice?", "Open Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (open == DialogResult.Yes)
            {
                Process.Start(path);
            }
        }
        // POST api/crystalreports
        public HttpResponseMessage Post([FromBody] ReportInfo report)
        {
            try
            {
                var reportName            = report.ReportName;
                var tenantName            = report.TenantName;
                var crystalReportFileInfo = ObtainReportDefinition(reportName, tenantName);

                ReportDocument doc = new ReportDocument();
                doc.Load(crystalReportFileInfo.localFileInfo);
                var tempFile = Path.GetTempFileName();
                //Export to PDF on temp file
                doc.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, tempFile);

                var resName         = GetReportOutputName(report);
                var url             = new StorageAbstraction().Save(resName, tempFile);
                var responseMessage = new ReportOutputResponse()
                {
                    Url = url
                };
                var response = Request.CreateResponse(responseMessage);
                return(response);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error! " + ex.Message + "--" + ex.StackTrace);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ReportDocument rd;
                rd = new ReportDocument();
            rd.Load(@"C:\Users\PLABON\Documents\Visual Studio 2013\Projects\SalesAndInventorySystem\SalesAndInventorySystemUI\Report\a.rpt");
            List<PersonType> company = companyGateway.GetCompanies();
            var companyX = company.Select(x => new {x.ID, x.Name});
            rd.SetDataSource(companyX);
            crystalReportViewer1.ReportSource = rd;

            crystalReportViewer1.Refresh();
                int a = 10;
            if (File.Exists(@"D:\" + "AAAA" + a  +".pdf"))
                File.Delete(@"D:\" + a++ + ".pdf");
            rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\" + a + ".pdf");

            }
            catch (Exception)
            {

                throw;
            }
        }
    public void Sm_Em_L(int PONO, string Supplieremail, string supname)
    {
        this._bll.get_InformationdataTable("select Email from Smt_Users where cUserName='******'").Rows[0]["Email"].ToString();
        ReportDocument document      = new ReportDocument();
        string         str           = base.Server.MapPath("rptsv/");
        Merchandising  merchandising = new Merchandising();
        string         val           = this._bll.get_Informationdataset("select cCmpName from Smt_Company where Display_AS_Header=1").Tables[0].Rows[0]["cCmpName"].ToString();

        new System.Data.DataTable().TableName = ("PO_Printing");
        System.Data.DataTable table2 = this.blInventory.get_InformationdataTable("Sp_Smt_POPrinting " + ((int)PONO));
        merchandising.Tables["PO_Printing"].Merge(table2);
        document.Load(base.Server.MapPath("Report_Merchandising/CrystalReport2.rpt"));
        document.SetDataSource((System.Data.DataSet)merchandising);
        document.SetParameterValue("cCmpName", val);
        System.IO.MemoryStream stream1 = (System.IO.MemoryStream)document.ExportToStream(ExportFormatType.PortableDocFormat);
        base.Response.Clear();
        ContentType type = new ContentType();

        base.Response.Buffer = true;
        type.MediaType       = ("application/pdf");
        string fileName = string.Concat((object[])new object[] { str, supname, "_", ((int)PONO), ".pdf" });

        if (System.IO.File.Exists(fileName))
        {
            System.IO.File.Delete(fileName);
        }
        document.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);
    }
        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                path = @"C:\PS Supermarket\Sales Report.pdf";
                ReportDocument rep = new ReportDocument();
                rep.Load(@"C:\PS Supermarket\Sales Report.rpt");
                db.CrystalReportServer(rep);
                rep.SetParameterValue("From", txtfrom.Text);
                rep.SetParameterValue("To", txtto.Text);
                rep.SetParameterValue("CustomerID", txtcustomer.Text);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                rep.ExportToDisk(ExportFormatType.PortableDocFormat, path);
                Process.Start(path);
                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;

                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#24
0
        private static void LoadReportTest()
        {
            var rpt = new ReportDocument();

            var reportFilename = @"Reports\SimpleReport.rpt";

            rpt.Load(reportFilename);

            if (rpt.IsLoaded)
            {
                if (rpt.HasSavedData)
                {
                    rpt.Refresh();
                }

                Console.WriteLine("Report was loaded.");

                rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "SimpleReport.pdf");
            }

            rpt.Close();

            rpt.Dispose();

            System.Diagnostics.Process.Start("SimpleReport.pdf");
        }
示例#25
0
        public void GenerateBuilty()
        {
            string         type       = TempData["Type"].ToString();
            var            ReportData = (DataSet)TempData["ReportData"];
            ReportDocument rd         = new ReportDocument();

            if (type == "Company")
            {
                rd.Load(Path.Combine(Server.MapPath("~/Reports/FactoryBuilty.rpt")));
            }
            else if (type == "Factory")
            {
                rd.Load(Path.Combine(Server.MapPath("~/Reports/FactoryBuilty.rpt")));
            }

            rd.SetDataSource(ReportData);
            Response.Clear();
            string filepath = Server.MapPath("~/" + "Builty.rpt");

            rd.ExportToDisk(ExportFormatType.PortableDocFormat, filepath);
            FileInfo fileinfo = new FileInfo(filepath);

            Response.AddHeader("Content-Disposition", "inline;filenam=Builty.pdf");
            Response.ContentType = "application/pdf";
            Response.WriteFile(fileinfo.FullName);
        }
示例#26
0
        private static void LoadReportWithParameterTest()
        {
            var jednostkaId = 3;
            var osobaId     = 1;

            var rpt = new ReportDocument();

            rpt.Load(@"Reports\ReportWithParameter.rpt");

            if (rpt.IsLoaded)
            {
                // Logowanie do bazy danych
                // rpt.SetDatabaseLogon("user", "password");

                // Przekazanie parametru
                rpt.SetParameterValue("Jednostka", jednostkaId);
                rpt.SetParameterValue("Osoba", osobaId);

                if (rpt.HasSavedData)
                {
                    rpt.Refresh();
                }

                rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "ReportWithParameter.pdf");
            }

            rpt.Close();

            rpt.Dispose();

            System.Diagnostics.Process.Start("ReportWithParameter.pdf");
        }
示例#27
0
        private byte[] ExportPDF(ReportDocument rpt)
        {
            string fileName = System.IO.Path.GetTempFileName();

            CrystalDecisions.Shared.ExportFormatType exp = ExportFormatType.PortableDocFormat;
            rpt.ExportToDisk(exp, fileName);

            byte[] myData;
            using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                myData = new byte[Convert.ToInt32(fs.Length - 1) + 1];
                fs.Read(myData, 0, Convert.ToInt32(fs.Length));
                fs.Close();
            }

            try
            {
                System.IO.File.Delete(fileName);
            }
            catch (Exception)
            {
                // fixme: data cleanup
            }

            return(myData);
        }
示例#28
0
        private static void AddImageToReportTest()
        {
            var rpt = new ReportDocument();

            var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

            var filename = path + @"\Images\sulmar.png";

            rpt.Load(@"Reports\SimpleReport.rpt");

            var doc = rpt.ReportClientDocument;

            var section = doc.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];

            var picture = doc.ReportDefController.ReportObjectController.ImportPicture(filename, section, 1, 1);

            rpt.SaveAs(@"Reports\AddImageReport.rpt");

            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "AddImageReport.pdf");

            rpt.Close();

            rpt.Dispose();

            System.Diagnostics.Process.Start("AddImageReport.pdf");
        }
示例#29
0
        private static void LoadReportParameterMultiTest()
        {
            var rpt = new ReportDocument();

            rpt.Load(@"Reports\ReportWithParameterMulti.rpt");

            var departments = new ParameterValues();

            departments.AddValue(1);
            departments.AddValue(3);
            departments.AddValue(4);

            var p1 = new ParameterDiscreteValue {
                Value = 5
            };

            departments.Add(p1);


            rpt.SetParameterValue("Jednostki", departments);

            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, "ReportWithParameterMulti.pdf");

            rpt.Close();

            rpt.Dispose();

            System.Diagnostics.Process.Start("ReportWithParameterMulti.pdf");
        }
示例#30
0
        public string PrintExpense(long Id)
        {
            ReportDocument rd = new ReportDocument();

            Guid   id1        = Guid.NewGuid();
            var    pdfName    = "Expense" + id1 + ".pdf";
            string strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + "Expense" + ".rpt";
            string strPdfPath = System.Web.HttpContext.Current.Server.MapPath("~/") + "Reports\\" + pdfName;

            rd.Load(strRptPath);
            rd.Refresh();

            string connectionString =
                ConfigurationManager.ConnectionStrings["EAharaDB"].ConnectionString;

            SqlConnectionStringBuilder SConn = new SqlConnectionStringBuilder(connectionString);

            rd.DataSourceConnections[0].SetConnection(
                SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);

            foreach (ReportDocument srd in rd.Subreports)
            {
                srd.DataSourceConnections[0].SetConnection(SConn.DataSource, SConn.InitialCatalog, SConn.UserID, SConn.Password);
            }
            rd.SetParameterValue(0, Id);
            System.IO.File.Delete(strPdfPath);
            // rd.PrintOptions.PaperSize = PaperSize.PaperA5;
            rd.ExportToDisk(ExportFormatType.PortableDocFormat, strPdfPath);

            return(pdfName);
        }
示例#31
0
        private static void SetLocationTest()
        {
            var connectionInfo = new ConnectionInfo
            {
                ServerName         = @"DESKTOP-KT89MMD\SQLEXPRESS",
                DatabaseName       = "CrystalReportsDb",
                IntegratedSecurity = true,
                // UserID = "",
                // Password = "",
            };


            var rpt = new ReportDocument();

            rpt.Load(@"Reports\ReportForPeriod.rpt");

            if (rpt.IsLoaded)
            {
                foreach (CrystalDecisions.CrystalReports.Engine.Table table in rpt.Database.Tables)
                {
                    TableLogOnInfo logOnInfo = table.LogOnInfo;

                    logOnInfo.ConnectionInfo = connectionInfo;
                    table.ApplyLogOnInfo(logOnInfo);

                    Console.WriteLine($"{table.Name}");
                }


                rpt.ExportToDisk(ExportFormatType.CrystalReport, "SetLocationTest.rpt");

                //System.Diagnostics.Process.Start("SetLocationTest.pdf");
            }
        }
示例#32
0
        private static void LoadAndExportReportTest()
        {
            var rpt = new ReportDocument();


            rpt.Load(@"Reports\JedenWierszArtykulParagraf.rpt");

            if (rpt.IsLoaded)
            {
                Console.WriteLine("Report was loaded.");

                if (rpt.HasSavedData)
                {
                    rpt.Refresh();
                }

                rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "report.pdf");

                System.Diagnostics.Process.Start("report.pdf");
            }

            rpt.Close();

            rpt.Dispose();
        }
示例#33
0
        private void materialFlatButton1_Click(object sender, EventArgs e)
        {
            try
            {
                ReportDocument rep  = new ReportDocument();
                string         path = @"C:\PS Supermarket\Bank Transactions.pdf";

                rep.Load(@"C:\PS Supermarket\Bank Transactions.rpt");
                db.CrystalReportServer(rep);
                rep.SetParameterValue("From", txtfrom.Text);
                rep.SetParameterValue("To", txtto.Text);
                rep.SetParameterValue("Type", type);
                rep.SetParameterValue("Bank", txtbankidentity.Text);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                rep.ExportToDisk(ExportFormatType.PortableDocFormat, path);
                Process.Start(path);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#34
0
    protected void Button7_Click1(object sender, EventArgs e)
    {
        ReportDocument reporte = new ReportDocument();
        reporte.Load(@"C:\Users\Jorge\Documents\Visual Studio 2013\WebSites\Quetzal\Reporte3.rpt");

        ExportFormatType tipo = ExportFormatType.PortableDocFormat;
        reporte.ExportToDisk(tipo, @"C:\Users\Jorge\EmpleadosSuc.pdf");
    }
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            DateTime desde = new DateTime();
            DateTime hasta = new DateTime();

            //desde = Convert.ToDateTime(pMetodos.ConvertmmddyyyyToyyyymmdd(dpDesde.Text));
            //hasta = Convert.ToDateTime(pMetodos.ConvertmmddyyyyToyyyymmdd(dpHasta.Text));

            desde = Convert.ToDateTime(pMetodos.ConvertddmmyyyyToyyyymmdd(dpDesde.Text));
            hasta = Convert.ToDateTime(pMetodos.ConvertddmmyyyyToyyyymmdd(dpHasta.Text));

            string ctc = ddlCTC.SelectedValue;

            string url = "CrystalViewer.aspx?reporte=VentaTotalxCTCxCliente&ctc=" + ctc + "&desde=" + pMetodos.ConvertddmmyyyyToyyyymmdd(dpDesde.Text) + "&hasta=" + pMetodos.ConvertddmmyyyyToyyyymmdd(dpHasta.Text) +"&cliente=" + ddlClientes.SelectedValue;
            //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "OpenPopUp('" + url + "');", true);

            ArrayList parametros = new ArrayList();
            dsReportes ds = new dsReportes();

            parametros.Add(desde);
            parametros.Add(hasta);
            parametros.Add(ddlClientes.SelectedValue);
            parametros.Add(ctc);

            ds.tVentaTotalCTCxCliente.Merge(conReportes.VentaTotalxCTCxCliente(parametros));
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
            rpt.FileName = Server.MapPath("~/RPT/VentaTotalxCTCxCliente.rpt");
            rpt.Load(rpt.FileName, OpenReportMethod.OpenReportByDefault);

            rpt.SetDataSource(ds);
            crviewer.ReportSource = rpt;
            //rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ajdsfaklj");

            string fileName = ddlCTC.SelectedItem.Text + "xCliente";
            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("files/" + fileName + ".pdf"));

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "desactivarSpinner();", true);

            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var hidden = open('files/" + fileName + ".pdf', 'NewWindow', 'top=25,left=300,width=800, height=600,status=yes,resizable=yes,scrollbars=yes');", true);

            /*DataTable dt = conReportes.VentaTotalxCTCxCliente(parametros);
            gvListadoReporte.DataSource = dt;
            gvListadoReporte.DataBind();

            Chart1.Visible = true;

            string[] x = new string[dt.Rows.Count];
            int[] y = new int[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                x[i] = dt.Rows[i][0].ToString();
                y[i] = Convert.ToInt32(dt.Rows[i][1]);
            }
            Chart1.Series[0].Points.DataBindXY(x, y);
            Chart1.Series[0].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;// SeriesChartType.Pie;
            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            */
        }
示例#36
0
        public static bool exportReport(int type, ReportDocument repd)
        {
            SaveFileDialog f = new SaveFileDialog();
            bool result = false;
            switch (type)
            {
                case 1:

                    f.Filter = "Word file(*.doc)|*.doc";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        repd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.WordForWindows, f.FileName);
                        result = true;
                    }
                    break;
                case 2:

                    f.Filter = "Pdf file(*.pdf)|*.pdf";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        repd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, f.FileName);
                        result = true;
                    }
                    break;
                case 3:

                    f.Filter = "Excel file(*.xls)|*.xls";
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        repd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, f.FileName);
                        result = true;
                    }
                    break;
                default:
                    MessageBox.Show("Không chọn đúng loại.");
                    break;

            }
            return result;
        }
示例#37
0
        /// <summary>
        /// Сохранить отчет
        /// </summary>
        /// <param name="path">Путь к папке, куда надо сохранить отчет</param>
        /// <param name="reportFileName">Имя отчета</param>
        /// <param name="reportFileExtension">Расширение отчета</param>
        public void SaveReportFile(string path, string reportFileName, string reportFileExtension)
        {
            CheckDataSource();

            var pathToFile = Path.Combine(path, reportFileName + "." + reportFileExtension);

            ReportDocument report = new ReportDocument();
            string pathToReportTemplate = Path.Combine(PATH_TO_REPORTS_TEMPLATES, _reportTemplateName + ".rpt");
            report.Load(pathToReportTemplate);

            report.SetDataSource(_dataSource as DataSet);

            report.ExportToDisk(GetExportFormatType(reportFileExtension), pathToFile);
        }
示例#38
0
        private void ATBReportForm_Load(object sender, EventArgs e)
        {
            ReportDocument cryRpt;

            this.debtors_summaryTableAdapter1.Fill(this.dataSet21.debtors_summary);
            this.customerTableAdapter1.Fill(this.dataSet21.customer);
            ATBReport rpt = new ATBReport();
            rpt.SetDataSource(this.dataSet21);
            rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(dataSet21);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\AgedTrialBalance.pdf");
        }
示例#39
0
        private void StatementReportForm_Load(object sender, EventArgs e)
        {
            ReportDocument cryRpt;

            this.customer_transTableAdapter1.FillBy1(this.dataSet2.customer_trans);
            this.customerTableAdapter1.Fill(this.dataSet2.customer);
            this.configurationTableAdapter1.Fill(this.dataSet2.configuration);
            this.debtors_summaryTableAdapter1.Fill(this.dataSet2.debtors_summary);

            StatementsReport rpt = new StatementsReport();
            rpt.SetDataSource(this.dataSet2);

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(dataSet2);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\Statements.pdf");
        }
示例#40
0
        private void SalesProdReportForm_Load(object sender, EventArgs e)
        {
            this.configurationTableAdapter.Fill(this.dataSet2.configuration);
            runCreateSummaryTable();

            ReportDocument cryRpt;

            productSalesReportTableAdapter.Fill(this.dataSet2.ProductSalesReport);

            SalesProdReport rpt = new SalesProdReport();
            rpt.SetDataSource(dataSet2);

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(dataSet2);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\ProductSalesDetails.pdf");
        }
示例#41
0
 public string VietBaoCao()
 {
     ReportDocument rd = new ReportDocument();
     if (Loaibaocao == "Thống kê chi")
     {
         string path = Directory.GetCurrentDirectory() + @"\Thống kê chi";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         try
         {
             rd.Load(Directory.GetCurrentDirectory()+ @"\CrystalReportThongKeDoanhThu.rpt");
             rd.SetDataSource(DALThongKeDoanhThu.ListSachChi(Tungay, Denngay));
             path = path + @"\" + Mota + ".pdf";
             rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);
             return path;
         }
         catch
         {
             return path = "";
         }
     }
     else
     {
         string path = Directory.GetCurrentDirectory() + @"\Thống kê thu";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         try
         {
             rd.Load(Directory.GetCurrentDirectory() + @"\REPORT\CrystalReportThongKeThu.rpt");
             rd.SetDataSource(DALThongKeDoanhThu.ListSachthu(Tungay, Denngay));
             path = path + @"\" + Mota + ".pdf";
             rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);
             return path;
         }
         catch { return path = ""; }
     }
 }
示例#42
0
        private void SalesSummaryReportForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet2.ProductSalesSummary' table. You can move, or remove it, as needed.
               // DataSet2 dataSet2 = new DataSet2();
               // Vectra.DataSet2TableAdapters.configurationTableAdapter configurationTableAdapter1 = new Vectra.DataSet2TableAdapters.configurationTableAdapter();
               // Vectra.DataSet2TableAdapters.ProductSalesSummaryTableAdapter ProductSalesSummaryTableAdapter1 = new Vectra.DataSet2TableAdapters.ProductSalesSummaryTableAdapter();
            runCreateSummaryTable();

            ReportDocument cryRpt;

            configurationTableAdapter1.Fill(this.dataSet2.configuration);
            productSalesSummaryTableAdapter.Fill(this.dataSet2.ProductSalesSummary);

            SalesSummaryReport rpt = new SalesSummaryReport();
            rpt.SetDataSource(dataSet2);

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(dataSet2);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\ProductSalesSummary.pdf");
        }
示例#43
0
        private void ReceiptAndAdjReportForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet2.PaymentAdjustRpt' table. You can move, or remove it, as needed.
            this.paymentAdjustRptTableAdapter.Fill(this.dataSet2.PaymentAdjustRpt);
            // TODO: This line of code loads data into the 'dataSet2.configuration' table. You can move, or remove it, as needed.
            this.configurationTableAdapter.Fill(this.dataSet2.configuration);
            this.configurationTableAdapter.Fill(this.dataSet2.configuration);
            runCreateSummaryTable();

            ReportDocument cryRpt;

            this.paymentAdjustRptTableAdapter.Fill(this.dataSet2.PaymentAdjustRpt);

            ReceiptAndAdjReport rpt = new ReceiptAndAdjReport();
            rpt.SetDataSource(dataSet2);

            cryRpt = new ReportDocument();
            cryRpt.Load(rpt.FileName.ToString());
            cryRpt.SetDataSource(dataSet2);
            cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, ReportFolder.reportFolderName + @"\ReceiptAndAdjustments.pdf");
        }
示例#44
0
 public string VietBaoCao()
 {
     ReportDocument rd = new ReportDocument();
     string path = Directory.GetCurrentDirectory() + @"\Thống kê tồn kho";
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     try
     {
         rd.Load(Directory.GetCurrentDirectory() + @"\REPORT\CrystalReportThongKeTonKho.rpt");
         rd.SetDataSource(DALThongKeTonKho.ThongKe(Tungay, Denngay));
         path = path + @"\" + Mota + ".pdf";
         rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);
         return path;
     }
     catch
     {
         return path = "";
     }
 }
示例#45
0
 public string ThongKeSachBan()
 {
     ReportDocument rd = new ReportDocument();
     string path = Directory.GetCurrentDirectory() + @"\Thống kê sách bán được";
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
     try
     {
         rd.Load(Directory.GetCurrentDirectory() + @"\REPORT\CrystalReportThongKeBanDuoc.rpt");
         rd.SetDataSource(DALThongKeSachBanDuoc.ThongKe(Madaily, Tungay, Denngay));
         path = path + @"\" + Motafile + ".pdf";
         rd.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, path);
         return path;
     }
     catch
     {
         return path = "";
     }
 }
示例#46
0
 protected void btnfile_Click(object sender, EventArgs e)
 {
     string s, m, w;
     DateTime frd, td;
     CultureInfo cf = new CultureInfo("hi-IN");
     frd = Convert.ToDateTime(txtfd.Text, cf);
     td = Convert.ToDateTime(txttd.Text, cf);
     w = txtwc.Text;
     m = txtsc.Text;
     //s = "{{CDOSU.SOC}= '" + m + "' and {CR.WCC}='" + w + "'} and {{cr.regdt}>=#" + frd + "# and {cr.regdt}<=#" + td + "#}";
     s = "{CDOSU.SOC}= '" + m + "' and {CR.WCC}='" + w + "' and {CR.REGDT}>=#" + frd + "# and {CR.REGDT}<=#" + td + "#";
     ReportDocument rpt = new ReportDocument();
     rpt.Load(Server.MapPath("statusWise.rpt"));
     rpt.FileName = Server.MapPath("statusWise.rpt");
     rpt.SetParameterValue("statuscd", m);
     rpt.SetParameterValue("wardcode", w);
     rpt.SetParameterValue("From", frd);
     rpt.SetParameterValue("To", td);
     rpt.RecordSelectionFormula = s;
     rpt.SetDatabaseLogon("scott", "tiger", "ora9i", "");
     rpt.ExportToDisk(ExportFormatType.WordForWindows, "C:/crmsrpts/EIS.doc");
 }
        public static void btnPrint_OnClickStep( IRNReportDetails form,  EventArgs args)
        {
            // TODO: Complete business rule implementation
            IAttachment attachment = null;
              		string pluginid = string.Empty;

               Sage.Entity.Interfaces.IRNReport parentEntity = form.CurrentEntity as Sage.Entity.Interfaces.IRNReport;

              if (ReportsHelper.GetPluginId("RNReport:Irnreport", out pluginid))
              {
              WebReportingClass reporting = new WebReportingClass();

            Sage.Platform.Data.IDataService datasvc = MySlx.Data.CurrentConnection;
              Sage.Entity.Interfaces.IUser user = MySlx.Security.CurrentSalesLogixUser;

              string tempPath = Rules.GetTempAttachmentPath();
            string ConnectionString = datasvc.GetConnectionString();

              string report = reporting.GenerateReport(ConnectionString,datasvc.Server,DatabaseServer.dsMSSQL,tempPath,false,false,"RNREPORT.RNREPORTID", "", pluginid, "", "",  "", "SELECT RNREPORT.RNREPORTID FROM RNREPORT", string.Format("(RNREPORT.RNREPORTID = '{0}')", parentEntity.Id), user.Id.ToString(),  user.UserName.ToString());

                ReportDocument doc = new ReportDocument();

                report = string.Format("{0}run\\{1}", tempPath, report);

                doc.Load(report);

                string filename = string.Format("{0}\\{1}_v{2}.pdf", Rules.GetAttachmentPath(), parentEntity.ReferenceNumber.Replace(" ", "_"), 1);

                doc.ExportToDisk(ExportFormatType.PortableDocFormat,filename);

              		doc.Close();

              attachment = Sage.Platform.EntityFactory.Create<IAttachment>();
              attachment.Description = string.Format("{0} v{1}", parentEntity.ReferenceNumber, 1);
              attachment.InsertFileAttachment(filename);
            attachment.RNREPORTID =Convert.ToString(parentEntity.Id);

              attachment.Save();

             System.IO.File.Delete(report);

              }
        }
        private void btSendConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlDataReader rdr = null;
                string email = "";
                string contact = "";
                string qry = "select co.contact_email, co.contact_name from customer c inner join contact co on co.owner_id = c.id where c.id = '" +
                    cbCustomer.Text + "' and co.contact_name = '" + cbContact.Text + "';";
                rdr = MysqlInterface.DoQuery(qry);
                while (rdr.Read())
                {
                    if (!rdr.IsDBNull(0)) email = rdr.GetString(0);
                    if (!rdr.IsDBNull(1)) contact = rdr.GetString(1);
                }

                string orderid = tbOrderId.Text;
                ReportDocument cryRpt = new ReportDocument();
                string dir = System.IO.Directory.GetCurrentDirectory();
                dir = "Confirmation.rpt";
                cryRpt.Load(dir);
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = orderid;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["orderid"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, "confirmations//confirmation-" + orderid + ".pdf");

                Outlook.Application outlookApp = new Outlook.Application();
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                string directory = Directory.GetCurrentDirectory();
                orderid = tbOrderId.Text;
                string po = tbCustPO.Text;
                directory = directory + "\\confirmations\\confirmation-" + orderid + ".pdf";
                mailItem.Attachments.Add(directory);
                mailItem.Subject = "Pinnacle Glass Doors - Confirmation# " + orderid + " - PO# " + po;
                mailItem.To = email;

                string name = contact;
                if (contact != "")
                {
                    int pos = name.IndexOf(' ');
                    if (pos != -1)
                        name = name.Substring(0, pos);
                }
                mailItem.Body = "Hi " + name + ",\n\n" + "Attached is a confirmation of your purchase order " + po + "." +
                    "\n\nThank You,\n\n" + Globals.USER_NAME;
                mailItem.Importance = Outlook.OlImportance.olImportanceNormal;
                try
                { mailItem.Display(true); }
                catch
                    (Exception) { }

                //crystalReportViewer1.ReportSource = cryRpt;
                //crystalReportViewer1.RefreshReport();

            }
            catch (LogOnException)
            {
                MessageBox.Show("Incorrect Logon Parameters. Check your user name and password.");
            }
            catch (DataSourceException)
            {
                MessageBox.Show("An error has occurred while connecting to the database.");
            }
            catch (EngineException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void SendPO()
        {
            try
            {
                MySqlDataReader rdr = null;
                string email = "";
                string contact = "";
                string qry = "select c.email, c.contact from vendor c where c.ID = '" + cbVendor.Text + "';";
                rdr = MysqlInterface.DoQuery(qry);
                while (rdr.Read())
                {
                    email = rdr.GetString(0);
                    contact = rdr.GetString(1);
                }

                string orderid = tbOrderId.Text;
                ReportDocument cryRpt = new ReportDocument();
                string dir = System.IO.Directory.GetCurrentDirectory();
                dir = "PurchaseOrder.rpt";
                cryRpt.Load(dir);
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = orderid;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["order_id"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, "pos//po-" + orderid + ".pdf");

                Outlook.Application outlookApp = new Outlook.Application();
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                string directory = System.IO.Directory.GetCurrentDirectory();
                orderid = tbOrderId.Text;
                directory = directory + "\\pos\\po-" + orderid + ".pdf";
                mailItem.Attachments.Add(directory);
                mailItem.Subject = "Pinnacle Glass Doors - Purchase Order# " + orderid;
                mailItem.To = email;

                string name = contact;
                if (contact != "")
                {
                    int pos = name.IndexOf(' ');
                    if (pos != -1)
                        name = name.Substring(0, pos);
                }
                mailItem.Body = "Hi " + name + ",\n\n" + "Please see the attached purchase order. Please confirm pricing and ship date." +
                    "\n\nThank You,\n\n" + Globals.USER_NAME;
                mailItem.Importance = Outlook.OlImportance.olImportanceNormal;
                mailItem.Display(true);

            }
            catch (LogOnException)
            {
                MessageBox.Show("Incorrect Logon Parameters. Check your user name and password.");
            }
            catch (DataSourceException)
            {
                MessageBox.Show("An error has occurred while connecting to the database.");
            }
            catch (EngineException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btSendQuote_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlDataReader rdr = null;
                string email = "";
                string contact = "";
                string qry = "select c.email, c.contact from customer c where c.ID = '" + cbCustomer.Text + "';";
                rdr = MysqlInterface.DoQuery(qry);
                while (rdr.Read())
                {
                    email = rdr.GetString(0);
                    contact = rdr.GetString(1);
                }

                string orderid = tbOrderId.Text;
                ReportDocument cryRpt = new ReportDocument();
                string dir = System.IO.Directory.GetCurrentDirectory();
                dir = "Quote.rpt";
                cryRpt.Load(dir);
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

                crParameterDiscreteValue.Value = orderid;
                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions["orderid"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, "quotations//quote-" + orderid + ".pdf");

                Outlook.Application outlookApp = new Outlook.Application();
                Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                string directory = Directory.GetCurrentDirectory();
                orderid = tbOrderId.Text;
                directory = directory + "\\quotations\\quote-" + orderid + ".pdf";
                mailItem.Attachments.Add(directory);
                mailItem.Subject = "Pinnacle Glass Doors - Quote# " + orderid;
                mailItem.To = email;

                string name = contact;
                if (contact != "")
                {
                    int pos = name.IndexOf(' ');
                    if (pos != -1)
                        name = name.Substring(0, pos);
                }
                mailItem.Body = "Hi " + name + ",\n\n" + "Here is the quote you requested. Please let me know if you would like to proceed with the order" +
                    "\n\nThank You,\n\n" + Globals.USER_NAME;
                mailItem.Importance = Outlook.OlImportance.olImportanceNormal;
                mailItem.Display(true);

                //crystalReportViewer1.ReportSource = cryRpt;
                //crystalReportViewer1.RefreshReport();

            }
            catch (LogOnException)
            {
                MessageBox.Show("Incorrect Logon Parameters. Check your user name and password.");
            }
            catch (DataSourceException)
            {
                MessageBox.Show("An error has occurred while connecting to the database.");
            }
            catch (EngineException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    protected string rutaAnexo(String incorporacionID, String consultoraID)
    {
        string nombre = "C:\\Reportes\\solicitud_de_credito_" + DateFormatter.getTimestamp(DateTime.Now) + ".pdf";

        String db_databaseName = connectionBL.getDataBaseName();
        String db_serverName = connectionBL.getServerName();
        String db_userID = connectionBL.getUserID();
        String db_password = connectionBL.getPassword();

        ReportDocument rpt = new ReportDocument();
        rpt.Load(Server.MapPath("../CrystalReports/rcSolicitudCredito.rpt"));
        rpt.SetDatabaseLogon("", "", ".", db_databaseName);
        rpt.SetParameterValue("@incorporacionID", Convert.ToInt32(incorporacionID));

        rpt.ExportToDisk(ExportFormatType.PortableDocFormat, nombre);

        return nombre;
    }
示例#52
0
        public static PayslipDocument ExportStaffPayslip(int payslip, string company)
        {
            string path = Properties.Settings.Default.ExportPath;
            string cString = Properties.Settings.Default.DB;
            SqlConnection objCon = new SqlConnection(cString);
            SqlCommand objCmd = null;
            SqlDataAdapter objAdapter = null;
            DataSet ds = null;
            PayslipDocument meta = new PayslipDocument();
            try
            {
                objCon.Open();
                objCmd = new SqlCommand("GetStaffPayslip", objCon);
                objCmd.CommandType = CommandType.StoredProcedure;
                objCmd.Parameters.Add("@PayslipID", SqlDbType.Int).Value = payslip;
                objCmd.Parameters.Add("@Company", SqlDbType.VarChar, 12).Value = company;

                // Create a SqlDataAdapter.
                objAdapter = new SqlDataAdapter();
                objAdapter.SelectCommand = objCmd;
                ds = new DataSet("PaySlip");
                objAdapter.Fill(ds);
                objCon.Close();
                ds.Tables[0].TableName = "FUNC_DP";
                ds.Tables[1].TableName = "FUNC_VENC";
                ds.Tables[2].TableName = "Recibos";
                ds.Tables[3].TableName = "RecibosDetalhes";
                ds.Tables[4].TableName = "Seguros";
                ds.Tables[5].TableName = "SegurancaSocial";
                if (path[path.Length - 1] != '\\')
                    path += "\\GRH\\";
                else
                    path += "GRH\\";
                path += ds.Tables[2].Rows[0].ItemArray[1] + "-" + Convert.ToString(ds.Tables[2].Rows[0].ItemArray[2]).PadLeft(2, '0') + "\\";

                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);

                meta.NIF = ds.Tables["FUNC_DP"].Rows[0].ItemArray[1].ToString();
                meta.RecordID = Convert.ToInt32(ds.Tables["Recibos"].Rows[0].ItemArray[5]);
                meta.Date = new DateTime(Convert.ToInt32(ds.Tables["Recibos"].Rows[0].ItemArray[1]), Convert.ToInt32(ds.Tables["Recibos"].Rows[0].ItemArray[2]), 1);
                meta.Description = ds.Tables["Recibos"].Rows[0].ItemArray[1].ToString() + '/' +
                                            ds.Tables["Recibos"].Rows[0].ItemArray[2].ToString().PadLeft(2, '0') + ' ' +
                                            ds.Tables["Recibos"].Rows[0].ItemArray[3].ToString();
                meta.SystemName = "GRH";
                meta.MetaPath = path + payslip + ".xml";
                meta.DocumentPath = path + payslip + ".pdf";

                if (File.Exists(meta.MetaPath))
                    File.Delete(meta.MetaPath);

                if (File.Exists(meta.DocumentPath))
                    File.Delete(meta.DocumentPath);

                using (ReportDocument cryRpt = new ReportDocument())
                {
                    cryRpt.Load(Properties.Settings.Default.PayslipStaff);
                    // Show corporate image
                    cryRpt.ReportDefinition.ReportObjects["Picture1"].ObjectFormat.EnableSuppress = false;
                    cryRpt.ReportDefinition.ReportObjects["Text1"].ObjectFormat.EnableSuppress = false;
                    cryRpt.ReportDefinition.ReportObjects["Text19"].ObjectFormat.EnableSuppress = false;
                    // set the data source of the report
                    cryRpt.SetDataSource(ds);
                    cryRpt.ExportToDisk(ExportFormatType.PortableDocFormat, meta.DocumentPath);
                }
                meta.SaveMetadata(meta.MetaPath);
                return meta;
            }
            finally
            {
                if (ds != null)
                    ds.Dispose();
                if (objAdapter != null)
                    objAdapter.Dispose();
                if (objCmd != null)
                    objCmd.Dispose();
                if (objCon != null)
                {
                    if(objCon.State != ConnectionState.Closed)
                        objCon.Close();
                    objCon.Dispose();
                }
            }
        }
示例#53
0
        public string ExportReportToPDF(string reportName)
        {
            string pdfFile = string.Empty;

            if (reportName.Equals(string.Empty))
            {
                Log("ExportReportToPDF - Param [reportName] must have a value.");
            }
            else
            {
                ReportDocument reportDocument = new ReportDocument();
                try
                {
                    reportDocument.Load(Settings.LocalReportFolder + reportName);
                    SetCrystalReportLogon(reportDocument);

                    pdfFile = GetNewPDFFileName();

                    if (HasParameterSetNameArg)
                        CreateParameterCollection(reportDocument.ParameterFields);

                    reportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, pdfFile);
                }
                catch (Exception ex)
                {
                    Log(ex.ToString());
                }
                finally
                {
                    reportDocument.Dispose();
                }
            }

            return pdfFile;
        }
示例#54
0
    protected string rutaAnexoReingreso(int reingresoID)
    {
        ConnectionBL connectionBL = new ConnectionBL();

        string nombre = "C:\\Reportes\\Reingreso_" + DateFormatter.getTimestamp(DateTime.Now) + ".pdf";

        String db_databaseName = connectionBL.getDataBaseName();
        String db_serverName = connectionBL.getServerName();
        String db_userID = connectionBL.getUserID();
        String db_password = connectionBL.getPassword();

        ReportDocument rpt = new ReportDocument();
        rpt.Load(Server.MapPath("../CrystalReports/crReingreso.rpt"));
        rpt.SetDatabaseLogon("", "", ".", db_databaseName);
        rpt.SetParameterValue("@reingresoID", reingresoID);
        rpt.ExportToDisk(ExportFormatType.PortableDocFormat, nombre);

        return nombre;
    }
        private void VentaTotalxCTC()
        {
            string ctc = string.Empty;
            desde = Convert.ToDateTime(Page.Request["desde"]);
            hasta = Convert.ToDateTime(Page.Request["hasta"]);
            ctc = Page.Request["ctc"];
            parametros.Add(desde);
            parametros.Add(hasta);
            parametros.Add(ctc);

            ds.tVentaTotalCTC.Merge(conReportes.VentaTotalxCTC(parametros));
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new ReportDocument();
            rpt.FileName = Server.MapPath("~/RPT/VentaTotalxCTC.rpt");
            rpt.Load(rpt.FileName, OpenReportMethod.OpenReportByDefault);

            rpt.SetDataSource(ds);
            crviewer.ReportSource = rpt;
            //rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ajdsfaklj");
            rpt.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("files/asdf.pdf"));

            //ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('files/asdf.pdf');popup.focus();", true);
            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var hidden = open('files/asdf.pdf', 'NewWindow', 'top=25,left=300,width=800, height=600,status=yes,resizable=yes,scrollbars=yes');", true);
            //hidden = open('files/asdf.pdf', 'NewWindow', 'top=25,left=300,width=800, height=600,status=yes,resizable=yes,scrollbars=yes');
        }
        public string GenerateInvoice(int id)
        {
            string exportFilePath = null;

            #region Get System Parameters
            string Comp_68_Title = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_name_68").Select(sp => sp.value).FirstOrDefault();
            string Comp_28_Title = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_name_28").Select(sp => sp.value).FirstOrDefault();
            string Comp_68_CTitle = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_name_68").Select(sp => sp.value).FirstOrDefault();
            string Comp_28_CTitle = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_name_28").Select(sp => sp.value).FirstOrDefault();
            string Comp_Address = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_address").Select(sp => sp.value).FirstOrDefault();
            string Comp_CAddress = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_address").Select(sp => sp.value).FirstOrDefault();
            string Comp_Tel = this._db.recsys_system_parameter.Where(sp => sp.name == "company_tel").Select(sp => sp.value).FirstOrDefault();
            string Comp_Fax = this._db.recsys_system_parameter.Where(sp => sp.name == "company_fax").Select(sp => sp.value).FirstOrDefault();
            string Comp_Hotline = this._db.recsys_system_parameter.Where(sp => sp.name == "company_service_hotline").Select(sp => sp.value).FirstOrDefault();
            string Comp_Subsidiary = "(A wholly-owned subsidiary of Yau Lee Holding Limited)";
            #endregion Get System Parameters

            #region Get Quotation
            double? quotationItemAmountTotal = (from qi in this._db.recsys_quotation_items
                                                join r in this._db.recsys_relate on qi.id equals r.id2
                                                where r.table1 == "quotation" && r.table2 == "quotation_items" && r.id1 == id && qi.price != null
                                                select qi.price).Sum();
            var quotationItems = (from q in this._db.recsys_quotation
                                  join rc in this._db.recsys_relate_customers on q.customer_id equals rc.id into subrc
                                  from rc2 in subrc.DefaultIfEmpty()
                                  join qi in
                                      (from r in this._db.recsys_relate
                                       join qi in this._db.recsys_quotation_items on r.id2 equals qi.id into subqi
                                       from qi2 in subqi.DefaultIfEmpty()
                                       where r.table1 == "quotation" && r.table2 == "quotation_items" && r.id1 == id
                                       select new
                                       {
                                           q_id = r.id1,
                                           nSequence = qi2.nSequence,
                                           id = qi2.id,
                                           code = qi2.code,
                                           detail = qi2.detail,
                                           detail2 = qi2.detail2,
                                           price = qi2.price
                                       }) on q.id equals qi.q_id
                                  where q.id == id
                                  select new
                                  {
                                      center = rc2.center,
                                      tender_number = q.tender_number,
                                      minor_work = q.minor_work,
                                      invoice = q.invoice,
                                      invoice_date = q.invoice_date,
                                      dummy_date = q.dummy_date,
                                      dummy = q.dummy,
                                      initial = q.initial,
                                      customer_name = rc2.name,
                                      address1 = rc2.address1,
                                      address2 = rc2.address2,
                                      contact = rc2.contact,
                                      email = rc2.email,
                                      tel1 = rc2.tel1,
                                      tel2 = rc2.tel2,
                                      fax1 = rc2.fax1,
                                      fax2 = rc2.fax2,
                                      sequence = qi.nSequence,
                                      detail = q.lang == 1 ? qi.detail : qi.detail2,
                                      price = qi.price.HasValue ? qi.price.Value : 0,
                                      lang = q.lang
                                  }).ToList();

            ArrayList rptSource = new ArrayList();
            foreach (var quotationItem in quotationItems)
            {
                InvoiceCrystalReportModel model = new InvoiceCrystalReportModel
                {
                    Comp_Title = quotationItem.center == "28" ? Comp_28_Title : Comp_68_Title,
                    Comp_CTitle = quotationItem.center == "28" ? Comp_28_CTitle : Comp_68_CTitle,
                    Comp_Address = Comp_Address,
                    Comp_CAddress = Comp_CAddress,
                    Comp_Tel = ": " + Comp_Tel,
                    Comp_Fax = ": " + Comp_Fax,
                    Comp_Hotline = ": " + Comp_Hotline,
                    Comp_Subsidiary = Comp_Subsidiary,
                    invoice_no = string.Format("{0}{1}", quotationItem.dummy == 1 ? "INV-Q" + id : quotationItem.invoice, (string.IsNullOrEmpty(quotationItem.minor_work) ? string.Empty : " /E" + quotationItem.minor_work)),
                    nSeq = quotationItem.sequence.HasValue ? quotationItem.sequence.Value.ToString().PadLeft(2, '0') : string.Empty,
                    invoice_date = quotationItem.invoice_date.HasValue ? quotationItem.invoice_date.Value.ToString("dd-MMM-yy", CultureInfo.CreateSpecificCulture("en-US")) : string.Empty,
                    dummy_date = quotationItem.dummy_date.HasValue ? quotationItem.dummy_date.Value.ToString("dd-MMM-yy", CultureInfo.CreateSpecificCulture("en-US")) : string.Empty,
                    customer_name = quotationItem.customer_name,
                    address1 = quotationItem.address1,
                    address2 = quotationItem.address2 + (string.IsNullOrEmpty(quotationItem.tender_number) ? string.Empty : " (" + quotationItem.tender_number + ")"),
                    contact = quotationItem.contact,
                    tel1 = string.IsNullOrEmpty(quotationItem.tel1) ? string.IsNullOrEmpty(quotationItem.tel2) ? string.Empty
                                                                                                               : quotationItem.tel2
                                                                    : string.IsNullOrEmpty(quotationItem.tel2) ? quotationItem.tel1
                                                                                                               : quotationItem.tel1 + " / " + quotationItem.tel2,
                    fax1 = string.IsNullOrEmpty(quotationItem.fax1) ? string.IsNullOrEmpty(quotationItem.fax2) ? string.Empty
                                                                                                               : quotationItem.fax2
                                                                    : string.IsNullOrEmpty(quotationItem.fax2) ? quotationItem.fax1
                                                                                                               : quotationItem.fax1 + " / " + quotationItem.fax2,
                    detail = quotationItem.detail,
                    price = quotationItem.price,
                    price_total = quotationItemAmountTotal.HasValue ? quotationItemAmountTotal.Value : 0,
                    email = quotationItem.email,
                    initial = quotationItem.initial,
                    lang = quotationItem.lang
                };
                rptSource.Add(model);
            }
            #endregion Get Quotation

            if (quotationItems != null && quotationItems.Count() > 0)
            {
                ReportDocument rd = new ReportDocument();
                try
                {
                    string strRptPath = Server.MapPath("~/Report/Invoice.rpt");
                    string shareDriveRootFolderPath = ConfigurationManager.AppSettings["ShareRootFolderPath"].ToString();
                    string invoiceTempFolder = shareDriveRootFolderPath + @"\Invoice\Temp\";
                    if (!Directory.Exists(invoiceTempFolder))
                    {
                        Directory.CreateDirectory(invoiceTempFolder);
                    }
                    exportFilePath = invoiceTempFolder + Guid.NewGuid() + ".pdf";
                    rd.Load(strRptPath);
                    rd.SetDataSource(rptSource);
                    //Stream stream = rd.ExportToStream(ExportFormatType.PortableDocFormat);
                    rd.ExportToDisk(ExportFormatType.PortableDocFormat, exportFilePath);
                }
                catch
                {
                    exportFilePath = null;
                }
                finally
                {
                    rd.Dispose();
                }
            }

            return exportFilePath;
        }
示例#57
0
    protected void ddlTerm_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlGrade.SelectedIndex == 0)
        {
            lblError.ForeColor = Color.Red;
            lblError.Text = "Please Select Grade";
        }
        else if (ddlClass.SelectedIndex == 0)
        {
            lblError.ForeColor = Color.Red;
            lblError.Text = "Please Select Class";
        }
        else if (ddlStudentName.SelectedIndex == 0)
        {
            lblError.ForeColor = Color.Red;
            lblError.Text = "Please Select Student";
        }
        else if (ddlTerm.SelectedIndex == 0)
        {
            lblError.ForeColor = Color.Red;
            lblError.Text = "Please Select Term";
        }
        else
        {
            lblError.Text = "";  //if error Fixed remove error Messege

            ParameterDiscreteValue crtparamDiscValue;
            ParameterField crtParamField;
            ParameterFields crtParamFields;

            crtparamDiscValue = new ParameterDiscreteValue();
            crtParamField = new ParameterField();
            crtParamFields = new ParameterFields();

            crtparamDiscValue.Value = adNo;
            crtParamField.ParameterFieldName = "adno";
            crtParamField.CurrentValues.Add(crtparamDiscValue);
            crtParamFields.Add(crtParamField);

            crtparamDiscValue.Value = ddlGrade.SelectedIndex;
            crtParamField.ParameterFieldName = "grade";
            crtParamField.CurrentValues.Add(crtparamDiscValue);
            crtParamFields.Add(crtParamField);

            crtparamDiscValue.Value = ddlTerm.SelectedIndex;
            crtParamField.ParameterFieldName = "term";
            crtParamField.CurrentValues.Add(crtparamDiscValue);
            crtParamFields.Add(crtParamField);

            crtparamDiscValue.Value = ddlClass.SelectedValue;
            crtParamField.ParameterFieldName = "class";
            crtParamField.CurrentValues.Add(crtparamDiscValue);
            crtParamFields.Add(crtParamField);

            crvReportViewer.ParameterFieldInfo = crtParamFields;

            //Create report document
            ReportDocument crystalReport = new ReportDocument();

            //Load crystal report made in design view
            crystalReport.Load(Server.MapPath("Reports/NewStudentAcaPerf.rpt"));

            //Set DataBase Login Info
            crystalReport.SetDatabaseLogon("root", "123", @"localhost", "nsis");

            //Provide parameter values
            crystalReport.SetParameterValue("adno", adNo);
            crystalReport.SetParameterValue("grade", ddlGrade.SelectedIndex);
            crystalReport.SetParameterValue("term", ddlTerm.SelectedIndex);
            crystalReport.SetParameterValue("class", ddlClass.SelectedIndex);
            crystalReport.SetParameterValue("padno", adNo);
            crystalReport.SetParameterValue("pgrade", ddlGrade.SelectedIndex);
            crystalReport.SetParameterValue("pterm", ddlTerm.SelectedIndex);
            crystalReport.SetParameterValue("pclass", ddlClass.SelectedValue);
            crystalReport.SetParameterValue("mgrade", ddlGrade.SelectedIndex);
            crystalReport.SetParameterValue("mterm", ddlTerm.SelectedIndex);
            crystalReport.SetParameterValue("mclass", ddlClass.SelectedValue);

            //Guid.NewGuid().ToString()
            string filename = System.IO.Path.GetTempPath() + adNo + ".pdf";
            crystalReport.ExportToDisk(ExportFormatType.PortableDocFormat, filename);

            crvReportViewer.ReportSource = crystalReport;
        }
    }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string cliente = txtCliente.Text;
           
            if(cliente.Equals(""))
            {
                MessageBox.Show("Falta datos del Cliente", "Mensaje de advertencia");
            }
            else
            {
                for (int count = 0; count < dataGridViewFactura.Rows.Count; count++)
                {
                    string codigo = (string)dataGridViewFactura.Rows[count].Cells["columnProducto"].Value;
                    contador = contador + 1;

                }
                if(contador >=1)
                {
                    Console.Write("contador es " + contador);
                    if (consumidorF == true)
                    {
                        txtCliente.Text = "";
                        txtRUC.Text = "";
                        txtDireccion.Text = "";
                        txtTelefono.Text = "";
                        dataGridViewProducto.ClearSelection();
                        dataGridViewFactura.Rows.Clear();
                        txtSubTotal.Text = "";
                        txtIva.Text = "";
                        txtTotal.Text = "";


                        rbFactura.Enabled = false;
                        rbConsumidorFinal.Enabled = false;
                        rbCodigo.Enabled = false;
                        rbProducto.Enabled = false;
                        txtBusqueda.Enabled = false;
                        dataGridViewProducto.Enabled = false;
                        btnGuardar.Enabled = false;
                        btnAgregarProducto.Enabled = false;
                        txtCantidad.Enabled = false;
                        txtEmpleado.Text = Login.ROL;
                        consumidorF = false;


                    }
                    else
                    {
                        contador = 0;
                        // es una factura
                        ced = txtRUC.Text;
                        numFactura = num;
                        Console.Write("num fact "+numFactura);
                        cedEmpleado = MetodosBD.retornaCedulaEmpleado(txtEmpleado.Text);
                        subT = Convert.ToDouble(txtSubTotal.Text);
                        I = Convert.ToDouble(txtIva.Text);
                        T = Convert.ToDouble(txtTotal.Text);
                         string cod="";
                        string prod="";
                        int cant =0;
                        double  precio=0;
                        double total=0;


                        MetodosBD.InsertarFacturaC(numFactura, ced, cedEmpleado, fechaActual, subT, I, T, false);
                        for (int count = 0; count < dataGridViewFactura.Rows.Count; count++)
                        {
                             cod = (string)dataGridViewFactura.Rows[count].Cells["columnProducto"].Value;
                            prod= MetodosBD.buscarCodigoProducto(cod);
                              cant = (int)dataGridViewFactura.Rows[count].Cells["columnCantidad"].Value;
                             precio = (double)dataGridViewFactura.Rows[count].Cells["columnPrecioUnit"].Value;
                            total = (double)dataGridViewFactura.Rows[count].Cells["columnTotal"].Value;


                            MetodosBD.InsertarDetalleFactura(numFactura, prod, cant, precio, total);
                            
                        }

                        string n = lblNumFact.Text; // aqui obtengo el numero de factura


                                           




                        
                        FormFacturaC form = new FormFacturaC();
                        ReportDocument oRep = new ReportDocument();
                        ParameterField pf = new ParameterField();
                        ParameterFields pfs = new ParameterFields();
                        ParameterDiscreteValue pdv = new ParameterDiscreteValue();
                        pf.Name = "@numFact";
                        pdv.Value = n;
                        pf.CurrentValues.Add(pdv);
                        pfs.Add(pf);
                        form.crystalReportViewer1.ParameterFieldInfo = pfs;
                        oRep.Load(@"C:\Users\Usuario\Documents\GitHub\ProyectoProgramacion5\ProyectoProgV\ProyectoProgV\Presentacion\reporteFacturaCliente2.rpt");
                        oRep.ExportToDisk(ExportFormatType.PortableDocFormat, @"C:\Users\Usuario\Documents\GitHub\ProyectoProgramacion5\Facturas\Factura Nro."+ n +".pdf");
                        

                       
                        
                         
                        
                        
                        form.crystalReportViewer1.ReportSource = oRep;

                        form.Show();
                        



                        txtCliente.Text = "";
                        txtRUC.Text = "";
                        txtDireccion.Text = "";
                        txtTelefono.Text = "";
                        lblNumFact.Text = "";
                        dataGridViewProducto.ClearSelection();
                        dataGridViewFactura.Rows.Clear();
                        txtSubTotal.Text = "";
                        txtIva.Text = "";
                        txtTotal.Text = "";
                      

                        rbFactura.Enabled = false;
                        rbConsumidorFinal.Enabled = false;
                        rbCodigo.Enabled = false;
                        rbProducto.Enabled = false;
                        txtBusqueda.Enabled = false;
                        dataGridViewProducto.Enabled = false;
                        btnGuardar.Enabled = false;
                        btnAgregarProducto.Enabled = false;
                        txtCantidad.Enabled = false;
                        txtEmpleado.Text = Login.ROL;
                        consumidorF = false;

                        
                        urlEnvio = "C:\\Users\\Usuario\\Documents\\GitHub\\ProyectoProgramacion5\\Facturas\\Factura Nro." + n + ".pdf";
                        //creamos nuestro objeto de la clase que hicimos
                        email = MetodosBD.buscarEmailCliente(txtRUC.Text);
                        btnEnviar.Enabled = true;
                        EnviarMail oMail = new EnviarMail();


                        bool resultado = oMail.enviarCorreo("Gracias por comprar Att. Code Enterprise ", "Facturacion", email, urlEnvio);
                        if (resultado)
                        {
                            MessageBox.Show("Mensaje enviado");
                        }
                        else
                        {
                            MessageBox.Show("Mensaje no enviado");
                        }
                      
                       
           

                    }
                }
                else
                {
                    MessageBox.Show("Falta datos de Productos", "Mensaje de advertencia");
                }
               
            }
        }
示例#59
0
    protected string rutaAnexoSeguimiento(String ConsultoraCodigo)
    {
        ConnectionBL connectionBL = new ConnectionBL();

         string nombre = "C:\\Reportes\\Seguimiento_" + DateFormatter.getTimestamp(DateTime.Now) + ".pdf";

         String db_databaseName = connectionBL.getDataBaseName();
         String db_serverName = connectionBL.getServerName();
         String db_userID = connectionBL.getUserID();
         String db_password = connectionBL.getPassword();

         ReportDocument rpt = new ReportDocument();
         rpt.Load(Server.MapPath("../CrystalReports/crSeguimiento.rpt"));
         rpt.SetDatabaseLogon("", "", ".", db_databaseName);
         rpt.SetParameterValue("@ConsultoraCodigo", Convert.ToInt32(ConsultoraCodigo));
         rpt.ExportToDisk(ExportFormatType.PortableDocFormat, nombre);

         return nombre;
    }
        protected void imgbtnVistaPreviaReporteVolumetrias_Click(object sender, EventArgs e)
        {
            //Parametros del store procedure
            string strID = Cookies.GetCookie("cookieEditarVolumetria").Value;
            string strPreciario = Cookies.GetCookie("cookiePreciario").Value;

            string path = AppDomain.CurrentDomain.BaseDirectory;
            //1. Configurar la conexión y el tipo de comando
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
            try
            {
                using (var comando = new SqlCommand("web_spS_ObtenerCambiosPreciarioPorVolumetria", conn))
                {
                    using (var adaptador = new SqlDataAdapter(comando))
                    {
                        DataTable dt = new DataTable();
                        adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
                        adaptador.SelectCommand.Parameters.Add(@"idpreciario", SqlDbType.NVarChar).Value = strPreciario;
                        adaptador.SelectCommand.Parameters.Add(@"Volumetria", SqlDbType.Int).Value = Convert.ToInt32(strID);
                        adaptador.Fill(dt);

                        var reporte = new ReportDocument();
                        reporte.Load(Server.MapPath("reportess/CPreciarioV.rpt"));
                        reporte.SetDataSource(dt);
                        reporte.SetParameterValue("path", path);
                        reporte.SetParameterValue("pathlogo", path + "\\images\\clientes\\");
                        reporte.SetParameterValue("pathlogopro", path + "\\images\\proveedores\\");

                        string strDireccion = Server.MapPath(" ") + "\\reportess\\Volumetrias\\" + strID;

                        //2. Validar si existe el directorio donde se guardaran
                        if (Directory.Exists(strDireccion))
                        {
                            reporte.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf"));

                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                           // reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "Resumen de OC: ");

                        }
                        else
                        {
                            Directory.CreateDirectory(strDireccion);
                            reporte.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf"));
                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                        }
                        reporte.Dispose();
                        reporte.Close();
                    } // end using adaptador
                } // end using comando

            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                    conn.Close();
                conn.Dispose();
            }
        }