Пример #1
0
        public static void exportarReporte(ReportClass pReporte,
                                           string pNombre,
                                           string pFormula,
                                           ExportFormatType pFormato)
        {
            try
            {
                PrincipalUI.cursorEnEspera();
                ConnectionInfo connInfo = obtenerConexionReporte();
                SetDBLogonForReport(connInfo, pReporte);
                SetDBLogonForSubreports(connInfo, pReporte);
                if (pFormula != null)
                {
                    pReporte.RecordSelectionFormula = pFormula;
                }
                string ruta = System.IO.Path.GetTempPath() +
                              pNombre +
                              DateTime.Now.Ticks +
                              obtenerExtensionReporte(pFormato.ToString());

                pReporte.ExportToDisk(pFormato, ruta);
                pReporte.Load(ruta);
                pReporte.Close();
                Process.Start(ruta);
            }
            catch (Exception ex)
            {
                Mensajes.mensajeError(ex);
            }
            PrincipalUI.cursorPredeterminado();
        }
Пример #2
0
        public string ExportToPdf(string filename)
        {
            filename = filename.Replace(" ", string.Empty).Replace("/", "_");
            var file = System.IO.Path.ChangeExtension(System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename), "pdf");

            myReport.ExportToDisk(ExportFormatType.PortableDocFormat, file);
            return(file);
        }
Пример #3
0
        public string ExportReport(ExportFormatType fileType, string fileName, ReportClass report)
        {
            string fileFullName = Base.GetServiceInstallPath() + "\\Data\\" + (!fileName.Equals("") ? fileName : Security.EncryptWithMD5(DateTime.Now.ToString()));

            switch (fileType)
            {
            case ExportFormatType.PortableDocFormat:
                fileFullName += ".pdf";
                break;

            case ExportFormatType.HTML32:
                fileFullName += ".html";
                break;

            case ExportFormatType.HTML40:
                fileFullName += ".html";
                break;

            case ExportFormatType.Excel:
            case ExportFormatType.ExcelRecord:
                fileFullName += ".xls";
                break;

            case ExportFormatType.WordForWindows:
                fileFullName += ".doc";
                break;

            case ExportFormatType.CrystalReport:
                fileFullName += ".rpt";
                break;

            default:
                fileFullName += ".pdf";
                break;
            }

            try
            {
                report.ExportToDisk(fileType, fileFullName);
                return(fileFullName);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public ActionResult GenerateMemo()
        {
            SqlConnection con = new SqlConnection(Helpers.Helpers.DatabaseConnect);
            DataTable     dt  = new DataTable();

            try
            {
                con.Open();
                SqlCommand     cmd = new SqlCommand("SELECT Description,CurrencySymbol,ActualAmount,CurrencyAbbr FROM vw_PurchasesByCriteria WHERE Reference='" + Convert.ToString(Session["Reference"]) + "'", con);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(dt);
            }
            catch (Exception ex)
            {
                ExceptionLogging.SendErrorToText(ex);
                ViewBag.ErrorMessage = Messages.GENERAL_ERROR;
                return(View());
            }
            var    today          = DateTime.Now.ToShortDateString();
            var    TaskReport     = "Memo";
            string OutputFileName = TaskReport.ToString() + "_" + today + ".pdf";

            ReportClass rptH = new ReportClass();

            rptH.FileName = Server.MapPath(("~/Reports/") + "PurchaseMemo.rpt");

            rptH.Load();
            rptH.SetDataSource(dt);


            string filePath = Server.MapPath("~/TaskReports/");
            string destPath = Path.Combine(filePath, Helpers.Helpers.ToSafeFileName(OutputFileName));

            // if (formatId == parameters.Excel)

            rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            //  Stream stream = rptH.ExportToStream(ExportFormatType.ExcelWorkbook);
            //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

            // else

            // rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);

            return(File(stream, "application/pdf"));
        }
Пример #5
0
        public ActionResult TaskReport()
        {
            SqlConnection con = new SqlConnection(Helpers.Helpers.DatabaseConnect);
            DataTable     dt  = new DataTable();

            try
            {
                con.Open();
                SqlCommand     cmd = new SqlCommand("SELECT CompletedOn,AssignedTo,CreatedOn,FinishBy,CreatedBy,Reference,Priority,FlagText FROM vw_Tasks", con);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(dt);
            }
            catch (Exception ex)
            {
                ExceptionLogging.SendErrorToText(ex);
                ViewBag.ErrorMessage = Messages.GENERAL_ERROR;
                return(View());
            }
            var    today          = DateTime.Now.ToShortDateString();
            var    TaskReport     = "DailyTasks";
            string OutputFileName = TaskReport.ToString() + "_" + today + ".pdf";

            ReportClass rptH = new ReportClass();

            rptH.FileName = Server.MapPath(("~/Reports/") + "DailyTasks.rpt");

            rptH.Load();
            rptH.SetDataSource(dt);


            string filePath = Server.MapPath("~/TaskReports/");
            string destPath = Path.Combine(filePath, Helpers.Helpers.ToSafeFileName(OutputFileName));

            // if (formatId == parameters.Excel)

            rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            //  Stream stream = rptH.ExportToStream(ExportFormatType.ExcelWorkbook);
            //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

            // else

            // rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);

            return(File(stream, "application/pdf"));
        }
Пример #6
0
        public ActionResult GenerateReport()
        {
            SqlConnection con = new SqlConnection(Helpers.DatabaseConnect);
            DataSet       dt  = new DataSet();

            try
            {
                con.Open();
                SqlCommand     cmd = new SqlCommand("SELECT mount, blocks, solarisfreespace, filesystem, capacity, solarisusedspace, totalspace, driveletter, winfreespace, winusedspace,winmemory, wincpu,instanceName,name,receiveHandler,receivePort,transportType,uri,status,msState,msName,msActiveThreadCount,msJvmProcessorLoad,msHeapFreeCurrent,msHeapSizeCurrent,msUsedPhysicalMemory,branchCode,timeLevel,eocStage,gisServiceName,gisServiceStatus,ApplicationName,Task1,ServerIp FROM vw_DailyChecklistt GROUP BY ApplicationName'", con);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(dt);
            }
            catch (Exception ex)
            {
                ExceptionLogger.SendErrorToText(ex);

                //return RedirectToAction("ReportError");
            }
            var    today          = DateTime.Now.ToShortDateString();
            var    TaskReport     = "Checklist";
            string OutputFileName = TaskReport.ToString() + "_" + today + ".pdf";

            ReportClass rptH = new ReportClass();

            rptH.FileName = Server.MapPath(("~/Reports/") + "CheckList.rpt");

            rptH.Load();
            rptH.SetDataSource(dt);


            string filePath = Server.MapPath("~/ChecklistReports/");
            string destPath = Path.Combine(filePath, Helpers.ToSafeFileName(OutputFileName));

            rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);

            return(File(stream, "application/pdf"));
        }
Пример #7
0
        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            HeaderContent = _repo.GetPackOrderByID(HeaderContent.WorkOrderId);

            ReportClass rptH = new ReportClass();
            dsPlanning ds = new dsPlanning();
            string outPath = Application.StartupPath + string.Format(@"\\Out\\{0}.pdf", HeaderContent.WorkOrderNum);
            rptH.FileName = Application.StartupPath + "\\Reports\\Planning\\PackingOrder.rpt";
            ds.PackingOrderHead.AddPackingOrderHeadRow(HeaderContent.Id, HeaderContent.WorkOrderId, HeaderContent.WorkOrderNum
                                          , HeaderContent.DueDate, HeaderContent.IssueDate, HeaderContent.PackOrderNum
                                          , HeaderContent.CompleteFlag, HeaderContent.Remark);
            foreach (var p in HeaderContent.PackStyles)
            {
                ds.PackStyleLines.AddPackStyleLinesRow(p.HeadLineID, p.Id, p.CustId, p.CustomerName, p.ThickMin, p.ThickMax
                                                     , p.WidthMin, p.WidthMax, p.StyleCode, p.Remarks);

                foreach (var k in HeaderContent.SkidPacks.Where(i => i.PackStyleId == p.Id))
                {
                    ds.SkidPackingDesign.AddSkidPackingDesignRow(k.PackStyleId, k.Seq, k.SkidNumber, k.Description, k.Id);
                    foreach (var s in HeaderContent.SerialLines.Where(i => i.PackStyleId == p.Id && i.PackingDesignId == k.Id))
                    {
                        ds.SerialsByPackingStyle.AddSerialsByPackingStyleRow(s.PackStyleId, s.SerialNo, s.Thick, s.Width, s.Length, s.PackingDesignId);
                    }
                }
            }
            rptH.Load();
            ds.AcceptChanges();
            rptH.SetDataSource(ds);
            rptH.Refresh();
            rptH.ExportToDisk(ExportFormatType.PortableDocFormat, outPath);
            OpenPdfFile(outPath);
        }
        private void ExportReports(ReportClass vReportCls,string dtAnalysis)
        {           
            System.Windows.Forms.SaveFileDialog ReportExportDialog;
            string FileName;
            int filterIndex;

            try
            {
                ReportExportDialog = new SaveFileDialog();

                ReportExportDialog.Filter = "PDF Document *.pdf|*.pdf|Excel File *.xls|*.xls|CSV Document *.csv|*.csv";
                ReportExportDialog.Title = "Export Report";
                ReportExportDialog.SupportMultiDottedExtensions = true;
                ReportExportDialog.DefaultExt = ".pdf";
                DialogResult DiaResult = ReportExportDialog.ShowDialog();
                filterIndex = ReportExportDialog.FilterIndex;

                if (DiaResult == DialogResult.OK)
                {
                    FileName = ReportExportDialog.FileName;
                    if (filterIndex!= 3)
                    {
                        switch (filterIndex)
                        {
                            case 1:
                                if (!FileName.ToUpper().EndsWith(".PDF"))
                                    FileName += ".pdf";
                                vReportCls.ExportToDisk(ExportFormatType.PortableDocFormat, FileName);
                                break;
                            case 2:
                                if (!FileName.ToUpper().EndsWith(".XLS"))
                                    FileName += ".xls";
                                vReportCls.ExportToDisk(ExportFormatType.Excel, FileName);
                                break;
                            default:
                                if (!FileName.ToUpper().EndsWith(".PDF"))
                                    FileName += ".pdf";
                                vReportCls.ExportToDisk(ExportFormatType.PortableDocFormat, FileName);
                                break;
                        }
                    }
                    else
                        ExportDatatabletoCSV(dtAnalysis,FileName);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);  
            }
        }
Пример #9
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            var result = HeaderContent.SerialLines.Where(i => i.CutSeq == HeaderContent.CutSeq).Min(i => i.LengthActual);
            if (!timer1.Enabled)
            {
                MessageBox.Show("Pleas start work before calculate weight.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (result == 0)
            {
                MessageBox.Show("Please complete all data in the Grid.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_repo.SaveSerialCutting(epiSession, HeaderContent))
            {
                CuttedLineUpModel cutline = new CuttedLineUpModel();
                var matlineid = (from item in HeaderContent.SerialLines
                                 where item.CutSeq == HeaderContent.CutSeq
                                 select item.MaterialTransLineID).First();

                cutline.ProductionID = HeaderContent.ProductionID;
                cutline.WorkOrderID = HeaderContent.WorkOrderID;
                cutline.CutSeq = HeaderContent.CutSeq;
                cutline.StartTime = DateTime.Now;
                cutline.FinishTime = DateTime.Now;
                cutline.MaterialTransLineID = matlineid;
                HeaderContent.Cutteds = _repo.SaveCuttedLineUp(epiSession, cutline).ToList();
                SetTimeControl("Print");

                ReportClass rptH = new ReportClass();
                dsProduction ds = new dsProduction();
                string outPath = Application.StartupPath + "\\Out\\test.pdf";
                rptH.FileName = Application.StartupPath + "\\Reports\\Production\\ProductionLabel1.rpt";
                foreach (var item in HeaderContent.SerialLines.Where(i => i.CutSeq == HeaderContent.CutSeq))
                {
                    ds.Label.AddLabelRow(item.SerialNo, item.NGFlag.ToString());
                }
                rptH.Load();
                ds.AcceptChanges();
                rptH.SetDataSource(ds);
                rptH.Refresh();
                rptH.ExportToDisk(ExportFormatType.PortableDocFormat, outPath);
                OpenPdfFile(outPath);
            }
        }
Пример #10
0
        public ActionResult PurchasesByCriteria()
        {
            // var unitId = System.Web.HttpContext.Current.Session["ReportName"].ToString();    // Setting ReportName
            //        string strFromDate = System.Web.HttpContext.Current.Session["rptFromDate"].ToString();     // Setting FromDate
            //        string strToDate = System.Web.HttpContext.Current.Session["rptToDate"].ToString();         // Setting ToDate
            //        var rptSource = System.Web.HttpContext.Current.Session["rptSource"];

            //string filetype = Convert.ToString(Session["FormatId"]); ;

            //Rename Processed Batch
            // string newPath = AddSuffix(sourceFile, String.Format("({0})", parameters.IsProcessed));
            //FileInfo fi = new FileInfo(sourceFile);
            //if (fi.Exists)
            //{

            //    fi.MoveTo(newPath);
            //}

            SqlConnection con = new SqlConnection(Helpers.Helpers.DatabaseConnect);
            DataTable     dt  = new DataTable();

            try
            {
                con.Open();
                SqlCommand     cmd = new SqlCommand("SELECT AllocationName,ExpenseName,UnitName,VendorName,ActualAmount,Reference,CreatedOn,CurrencyAbbr,Discount FROM vw_PurchasesByCriteria WHERE AllocationId='" + Convert.ToInt32(Session["AllocationId"]) + "' AND CurrencyId='" + Convert.ToInt32(Session["CurrencyId"]) + "' AND VendorId='" + Convert.ToInt32(Session["VendorId"]) + "' AND ExpId='" + Convert.ToInt32(Session["ExpId"]) + "' AND UnitId='" + Convert.ToInt32(Session["UnitId"]) + "'", con);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                adp.Fill(dt);
            }
            catch (Exception ex)
            {
                ExceptionLogging.SendErrorToText(ex);
                ViewBag.ErrorMessage = Messages.GENERAL_ERROR;
                return(View());
            }


            // string OutputFileName = BatchId + "_" + monthend + ".xlsx";

            ReportClass rptH = new ReportClass();

            rptH.FileName = Server.MapPath(("~/Reports/") + "PurchasesByCriteria.rpt");

            rptH.Load();
            rptH.SetDataSource(dt);

            ExportFormatType efileType = (CrystalDecisions.Shared.ExportFormatType)Enum.Parse(typeof(CrystalDecisions.Shared.ExportFormatType), Convert.ToString(Session["FormatId"]));

            switch (efileType)
            {
            case CrystalDecisions.Shared.ExportFormatType.Excel:
                rptH.ExportToDisk(efileType, "reportExcel.xls");
                break;

            case CrystalDecisions.Shared.ExportFormatType.ExcelRecord:
                rptH.ExportToDisk(efileType, "reportExcel.xls");
                break;

            case CrystalDecisions.Shared.ExportFormatType.HTML32:
                rptH.ExportToDisk(efileType, "reporthtml.html");
                break;

            case CrystalDecisions.Shared.ExportFormatType.HTML40:
                rptH.ExportToDisk(efileType, "reporthtml.html");
                break;

            case CrystalDecisions.Shared.ExportFormatType.NoFormat:
                rptH.ExportToDisk(efileType, "reportExcel.xls");
                break;

            case CrystalDecisions.Shared.ExportFormatType.PortableDocFormat:
                rptH.ExportToDisk(efileType, "reportpdf.pdf");
                break;

            case CrystalDecisions.Shared.ExportFormatType.RichText:
                rptH.ExportToDisk(efileType, "reportrtf.rtf");
                break;

            case CrystalDecisions.Shared.ExportFormatType.WordForWindows:
                rptH.ExportToDisk(efileType, "reportdoc.doc");
                break;
            }
            // string filePath = Server.MapPath("~/BatchOut/");
            // string destPath = Path.Combine(filePath, ToSafeFileName(OutputFileName));
            // if (formatId == parameters.Excel)

            // rptH.ExportToDisk(ExportFormatType.ExcelWorkbook, destPath);
            //  Stream stream = rptH.ExportToStream(ExportFormatType.ExcelWorkbook);
            //return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

            // else

            // rptH.ExportToDisk(ExportFormatType.PortableDocFormat, destPath);
            Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat);

            return(File(stream, "application/pdf"));

            //else if (formatId == parameters.Xml)
            //{
            //    Stream stream = rptH.ExportToStream(ExportFormatType.Xml);
            //    return File(stream, "application/xml");
            //}

            //else if (formatId == parameters.Html)
            //{
            //    Stream streamm = rptH.ExportToStream(ExportFormatType.HTML40);
            //    return File(streamm, "application/html");
            //}
            //else
            //    Stream stream = rptH.ExportToStream(ExportFormatType.CharacterSeparatedValues);
            //    return File(stream, "application/csv");
        }