Ejemplo n.º 1
1
        protected void btnpdf_Click(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("ListadoArticulos1.rpt");
            myReportDocument.Load(strRuta);

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

            myReportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Listado");
        }
Ejemplo n.º 2
0
        protected void btnReporte_Click(object sender, EventArgs e)
        {
            PedidoDAO objPedidoDAO = new PedidoDAO();
            ParametroDAO objParametroDAO  = new ParametroDAO();
            ParametroDTO objParametroDTO = objParametroDAO.ListarPorClave(1);
            dsReportes dsReporte = new dsReportes();

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

            this.lblMensaje.Text = "";

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

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

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

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

                    dsReporte.Pedido.AddPedidoRow(drPedidoRow);
                }

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

                string strRutaWeb = Request.ApplicationPath;

                Response.Write("<script language='javascript'>window.open('ReportePedido.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            }
            else
            {
                this.lblMensaje.Text = "Noy registros con los parametros indicados";
            }
        }
Ejemplo n.º 3
0
 private void crystalReportViewer1_Load(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     reportDocument.Load(_crystalReportFilePath);
     reportDocument.SetDataSource(_reportSourceTable);  // C:\VisualStudio2008_SVN\MyPlayground\MyPlayground\FieldLabel1.rpt
     crystalReportViewer1.ReportSource = reportDocument;
 }
Ejemplo n.º 4
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Error al generar el reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Caja caja = new Caja((int)cbxCaja.SelectedValue);
            string logo = string.Empty;
            if (!caja.IsNull())
                logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
            caja = null;
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rpt.Load("Reportes\\CorteCaja.rpt");
            rpt.Subreports[0].SetDataSource((DataTable)dgvCheques.DataSource);
            rpt.SetDataSource((DataTable)dgvTransacciones.DataSource);
            rpt.SetParameterValue("Caja", cbxCaja.Text);
            rpt.SetParameterValue("PesosR", tbxPesos.Value);
            rpt.SetParameterValue("PesosS", tbxCantidad.Value);
            rpt.SetParameterValue("DolaresR", tbxDolares.Value);
            rpt.SetParameterValue("DolaresS", tbxCantidad2.Value);
            rpt.SetParameterValue("PB1000",tbxPB1000.Text);
            rpt.SetParameterValue("PB500", tbxPB500.Text);
            rpt.SetParameterValue("PB200", tbxPB200.Text);
            rpt.SetParameterValue("PB100", tbxPB100.Text);
            rpt.SetParameterValue("PB50", tbxPB50.Text);
            rpt.SetParameterValue("PB20", tbxPB20.Text);
            rpt.SetParameterValue("PM100", tbxPM100.Text);
            rpt.SetParameterValue("PM20", tbxPM20.Text);
            rpt.SetParameterValue("PM10", tbxPM10.Text);
            rpt.SetParameterValue("PM5", tbxPM5.Text);
            rpt.SetParameterValue("PM2", tbxPM2.Text);
            rpt.SetParameterValue("PM1", tbxPM1.Text);
            rpt.SetParameterValue("PM50C", tbxPC50.Text);
            rpt.SetParameterValue("PM20C", tbxPC20.Text);
            rpt.SetParameterValue("PM10C", tbxPC10.Text);
            rpt.SetParameterValue("PM5C", tbxPC5.Text);

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

            rpt.SetParameterValue("Logo", logo);

            frmReporte frm = new frmReporte(rpt);
            frm.ShowDialog();
            rpt.Dispose();
            rpt = null;
            frm.Dispose();
            frm = null;
        }
Ejemplo n.º 5
0
    private void BindReport(string reportName)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        string reportPath = Server.MapPath(Constz.HomeFolder + "Reports/" + reportName + ".rpt");
        rpt.Load(reportPath);
        CrystalDecisions.Shared.TableLogOnInfo logonInfo = new CrystalDecisions.Shared.TableLogOnInfo();
        logonInfo = rpt.Database.Tables[0].LogOnInfo;
        logonInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["DB_SERVER"].ToString().Trim();
        logonInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["DB_USER"].ToString().Trim();
        logonInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["DB_PASSWORD"].ToString();
        rpt.Database.Tables[0].ApplyLogOnInfo(logonInfo);

        CrystalDecisions.Shared.ParameterValues curValue = new CrystalDecisions.Shared.ParameterValues();
        CrystalDecisions.Shared.ParameterDiscreteValue paraValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
        for (int i = 0; i < Request.QueryString.Count; ++i)
        {
            string field = Request["paramfield" + (i + 1).ToString()];
            string value = Request["paramvalue" + (i + 1).ToString()];
            if (field != null && value != null)
            {
                paraValue.Value = value;
                curValue = rpt.ParameterFields[field].CurrentValues;
                curValue.Add(paraValue);
                rpt.ParameterFields[field].CurrentValues = curValue;
            }
            else
                break;
        }
        //paraValue.Value = reportKey;
        //curValue = rpt.ParameterFields["LOID"].CurrentValues;
        //curValue.Add(paraValue);
        //rpt.ParameterFields["LOID"].CurrentValues = curValue;

        rpt.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto;

        if (Request["landscape"] != null)
        {
            if (Request["landscape"] == "1") rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
        }
        Page.Cache["rpt"] = rpt;
        ctlReportViewer.ReportSource = Page.Cache["rpt"];
        //ctlReportViewer.DataBind();
    }
Ejemplo n.º 6
0
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     Caja caja = new Caja((int)cbxCaja.SelectedValue);
     string logo = string.Empty;
     if (!caja.IsNull())
         logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
     caja = null;
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpt.Load("Reportes\\Inventarios.rpt");
     rpt.SetDataSource(((DataView)dgvTransacciones.DataSource).Table);
     rpt.SetParameterValue("Sucursal", cbxSucursal.Text);
     rpt.SetParameterValue("Caja", cbxCaja.Text);
     rpt.SetParameterValue("Usuario", cbxUsuarios.Text);
     rpt.SetParameterValue("Tipo", cbxTipos.Text);
     rpt.SetParameterValue("FechaIni", dtpFechaIni.Text);
     rpt.SetParameterValue("FechaFin", dtpFechaFin.Text);
     rpt.SetParameterValue("Logo", logo);
     frmReporte frm = new frmReporte(rpt);
     frm.ShowDialog();
     rpt.Dispose();
     rpt = null;
     frm.Dispose();
     frm = null;
 }
Ejemplo n.º 7
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex > 0)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptUserRegister.rpt"))
                    {
                        //dtblUser.TableName = "UserRegister";
                        //dtblUser.WriteXmlSchema(@"D:\Project_Info\Report\UserRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblUser.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptUserRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "User Register", true, true, true, true, false, true, true, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "User Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("User - Register", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
        }
Ejemplo n.º 8
0
        private CrystalDecisions.Windows.Forms.CrystalReportViewer CreateViewer()
        {
            CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
            crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();

            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc =
                new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            //this.m_objViewer.m_dataGridViewRs.DataSource;
            rptDoc.Load(@".\Report\rptPrepay.rpt");
            //rptDoc.DataDefinition.FormulaFields["operatorname"].Text = "'"+this.m_objViewer.LoginInfo.m_strEmpName+"'";
            //rptDoc.DataDefinition.FormulaFields["areaname"].Text = "'" + this.m_objViewer.m_txtAREAID_CHR.Text + "'";
            //rptDoc.DataDefinition.FormulaFields["statdate"].Text = "'";

            //排序
            ColumnSortModeChanged();

            rptDoc.SetDataSource(this.m_rptView);


            //rptDoc.SetDataSource(m_dtPrint);
            //rptDoc.SetDataSource(this.m_objViewer.m_dataGridViewRs.DataSource);
            crystalReportViewer1.ReportSource = rptDoc;
            return(crystalReportViewer1);
        }
Ejemplo n.º 9
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         CrystalDecisions.CrystalReports.Engine.ReportDocument doc
             = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
         doc.Load(HttpContext.Current.Server.MapPath("~/Reporting/sample.rpt"));
         ExportOptions options = new ExportOptions();
         options.ExportFormatType = ExportFormatType.PortableDocFormat;
         string contentType = "application/pdf";
         String fileName    = "InterplanReport"; //use for infoXpert upload file name
                                                 //export report
         doc.ExportToHttpResponse(
             options,
             context.Response,
             false,
             null
             );
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 10
0
        private void reports(string sql, string rptname)
        {
            try
            {
                config.loadReports(sql);

                string reportname = rptname;


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

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


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

                crystalReportViewer1.ReportSource = reportdoc;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "No crystal reports installed. Pls. contact administrator.");
            }
        }
Ejemplo n.º 11
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemStockRegister.rpt"))
                    {
                        //dtblItemStock .TableName = "ItemStockRegister";
                        //dtblItemStock.WriteXmlSchema(@"D:\ItemStockRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblItemStock.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptItemStockRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Stock Register", true, true, true, true, false, true, true, false, false, false, false);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Item Stock Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("ItemStock - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    if (dgvItemStock.CurrentRow != null)
                    {
                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();

                        para.Add("@i_StockID", dgvItemStock.CurrentRow.Cells["StockID"].Value.ToString());
                        dtReport = objList.ListOfRecord("rpt_ItemBeanCard", para, "ItemStock - Bean Card report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemBeanCard.rpt"))
                            {
                                //dtReport .TableName = "ItemBeanCard";
                                //dtReport.WriteXmlSchema(@"D:\Report\ItemBeanCard.xsd");

                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptItemBeanCard.rpt");

                                CurrentUser.AddReportParameters(rptDoc, dtReport, "Item Bean Card", true, true, true, true, false, true, true, false, false, false, false);

                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Item Bean Card - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("File is not exist...");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("ItemStock - Bean Card Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 3)
            {
                try
                {
                    DataTable dt = new DataTable();
                    LogoBind(dt);
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemStockValuationRegister.rpt"))
                    {
                        //dtblItemStock .TableName = "ItemStockValuationRegister";
                        //dtblItemStock.WriteXmlSchema(@"D:\ItemStockValuationRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblItemStock.DefaultView;
                        DVReport.RowFilter = filter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptItemStockValuationRegister.rpt");
                        rptDoc.Database.Tables[1].SetDataSource(dt);
                        rptDoc.Refresh();
                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Stock Valuation Register", true, true, true, true, false, true, true, false, false, false, false);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Item Stock Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("ItemStock - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 12
0
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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



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

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

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


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


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

                break;
            case "PDF":

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

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


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

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

                break;
        }

    }
Ejemplo n.º 13
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (cmbreports.SelectedIndex == 1)
                {
                    DataTable dt = new DataTable();
                    LogoBind(dt);
                    if (dgvDebitNote.CurrentRow != null)
                    {

                        DataTable dtTNC = new DataTable();
                        //NameValueCollection para2 = new NameValueCollection();
                        //para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString());
                        //para2.Add("@i_TNC_Sub", "SALES");

                        //dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC");

                        DataTable dtReport = new DataTable();

                        NameValueCollection para = new NameValueCollection();
                        para.Add("@i_RecID", Convert.ToInt64(dgvDebitNote.CurrentRow.Cells["DNID"].Value).ToString());
                        dtReport = objList.ListOfRecord("rpt_DebitNote", para, "DebitNote - Report");

                        //NameValueCollection para2 = new NameValueCollection();
                        //_CompId = CurrentCompany.CompId;
                        //para2.Add("@i_CompId", _CompId.ToString());
                        //dtCompany = objList.ListOfRecord("rpt_Company", para2, "Quotation - Report");
                        dtReport.TableName = "DebitNote";
                        dtReport.WriteXmlSchema(@"D:\DebitNote.xsd");

                        dtReport = objList.ListOfRecord("rpt_DebitNote", para, "DebitNote - Report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptDebitNote.rpt"))
                            {
                                //dtReport.TableName = "PurchaseOrder";
                                //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptDebitNote.rpt");
                                rptDoc.Subreports[0].DataSourceConnections.Clear();
                                //rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC);
                                rptDoc.Database.Tables[1].SetDataSource(dt);
                                //rptDoc.Database.Tables[2].SetDataSource(dtCompany);

                                rptDoc.Refresh();
                                CurrentUser.AddReportParameters(rptDoc, dtReport, "", true, false, false, false, false, false, false, false, false, false, false);
                                CurrentUser.AddExtraParameter(rptDoc);
                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Debit Note - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
                MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception");
            }
            
            
            
            }
Ejemplo n.º 14
0
        public override Result ShowReport()
        {
            try
            {
                var crystalReportViewer = new CrystalReportsViewer();
                var myReport            = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myReport.Load(ReportPath);
                var crSections = myReport.ReportDefinition.Sections;

                if (myReport.Subreports.Count > 0)
                {
                    foreach (CrystalDecisions.CrystalReports.Engine.Section crSection in crSections)
                    {
                        //The subreports
                        var crReportObjects = crSection.ReportObjects;
                        foreach (CrystalDecisions.CrystalReports.Engine.ReportObject crReportObject in crReportObjects)
                        {
                            if (crReportObject.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
                            {
                                var crSubreportObject   = (CrystalDecisions.CrystalReports.Engine.SubreportObject)crReportObject;
                                var crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);
                                var crTables            = crSubreportDocument.Database.Tables;

                                foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
                                {
                                    //The report header subreport.
                                    if (aTable.Name == "Report_Header")
                                    {
                                        crSubreportDocument.SetDataSource(Header);
                                    }
                                    else if (aTable.Name == "LoanPaymentDetails")
                                    {
                                        crSubreportDocument.SetDataSource(LoanPaymentDetails);
                                    }
                                }
                            }
                        }
                    }
                }


                foreach (
                    CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition ff in
                    myReport.DataDefinition.FormulaFields)
                {
                    //The formula fields
                    if (ff.Kind == CrystalDecisions.Shared.FieldKind.FormulaField)
                    {
                        if (ff.Name.Contains("Report_Title"))
                        {
                            ff.Text = "'" + ReportTitle + "'";
                        }
                        else if (ff.Name.Contains("cCriteria1"))
                        {
                            ff.Text = "'" + Criteria1 + "'";
                        }
                        else if (ff.Name.Contains("cCriteria2"))
                        {
                            ff.Text = "'" + Criteria2 + "'";
                        }
                        else if (ff.Name.Contains("cCriteria3"))
                        {
                            ff.Text = "'" + Criteria3 + "'";
                        }
                    }
                }

                myReport.SetDataSource(Details);
                crystalReportViewer.ViewerCore.ReportSource = myReport;
                return(ReportWindowForm.AddControl(crystalReportViewer));
            }
            catch (Exception e)
            {
                return(new Result(false, e.Message));
            }
        }
        public void GenerateReport()
        {
            try
            {
                string filepart = @"file:\";

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

                CrystalDecisions.Shared.TableLogOnInfos crtableLogoninfos = new CrystalDecisions.Shared.TableLogOnInfos();

                CrystalDecisions.Shared.TableLogOnInfo ConInfo = new CrystalDecisions.Shared.TableLogOnInfo();

                CrystalDecisions.Shared.ConnectionInfo crConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();

                CrystalDecisions.CrystalReports.Engine.Tables CrTables;

                CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions crParameterFieldDefinitions;

                CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition crParameterFieldDefinition;

                CrystalDecisions.Shared.ParameterValues crParameterValues = new CrystalDecisions.Shared.ParameterValues();

                CrystalDecisions.Shared.ParameterDiscreteValue crParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue();


                if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace(filepart, "") + @"\PEZA_REPORTS\rpt_PEZA_8106_BoatNote.rpt"))
                {
                    objReport1.Load(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Replace(filepart, "") + @"\PEZA_REPORTS\rpt_PEZA_8106_BoatNote.rpt");
                }
                else
                {
                    objReport1.Load(ClsConfig.PEZAReportPath_Trial + "rpt_PEZA_8106_BoatNote.rpt");
                }

                crParameterDiscreteValue.Value = _formNo.ToString().Trim();//recDate.SelectedDate.Value;
                crParameterFieldDefinitions    = objReport1.DataDefinition.ParameterFields;
                crParameterFieldDefinition     = crParameterFieldDefinitions["@8106FormNo"];
                crParameterValues = crParameterFieldDefinition.CurrentValues;

                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

                //objReport1.SetParameterValue("@8106FormNo", "14176560");

                string sUserID       = ClsConfig.ReportUser;
                string sPassword     = ClsConfig.ReportPassword;
                string sServerName   = ClsConfig.ReportServer;
                string sDatabaseName = ClsConfig.ReportDatabase_PEZA;


                crConnectionInfo.ServerName   = sServerName;
                crConnectionInfo.DatabaseName = sDatabaseName;
                //crConnectionInfo.IntegratedSecurity = true;
                crConnectionInfo.UserID   = sUserID;
                crConnectionInfo.Password = sPassword;

                CrTables = objReport1.Database.Tables;

                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                {
                    ConInfo = CrTable.LogOnInfo;
                    ConInfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(ConInfo);
                }

                reportViewer.ViewerCore.ReportSource = objReport1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 16
0
        protected void InicializaPagina()
        {
            int linea = 0;

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

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

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

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

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

                dsReporte.Kardex.AddKardexRow(drKardexRow);

            }

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

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

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

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

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

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
Ejemplo n.º 17
0
    protected void RaporOlustur(string Format)
    {
        EFDal ed = new EFDal();
        report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        string RaporAdi = Request["RaporAdi"].ToString() + ".rpt";
        //string RaporAd = Server.MapPath("..\\..\\Rapor\\" + RaporAdi);
        string RaporAd = Server.MapPath("Rapor\\" + RaporAdi);
        report.Load(RaporAd);

        if (RaporAdi == "SertifikaKapak.rpt")//turkak
        {
            //100476479
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString());
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            //report.SetParameterValue("Url", "Url");

            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
        }

        if (RaporAdi == "SertifikaKapakTSE.rpt")//tse
        {
            //100476479
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            //report.SetParameterValue("Url", "Url");
        }

        if (RaporAdi == "SertifikaKapakEImza.rpt")//turkak
        {
            //100476479
            QRCodeOlustur();
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString());
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            report.SetParameterValue("Url", Session["qrCodeURL"].ToString());

            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
        }

        if (RaporAdi == "SertifikaKapakTSEEImza.rpt")//tse
        {
            //100476479
            QRCodeOlustur();
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            report.SetParameterValue("Url", Session["qrCodeURL"].ToString());
        }

        if (RaporAdi == "CihazKayit.rpt")
        {
            //report.SetParameterValue("Sifre", "bakalim");
            string IstekNo = Request["IstekNo"].ToString();
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            int Yil = int.Parse(Request["Yil"].ToString());
            int FirmaId = int.Parse(Request["FirmaId"].ToString());

            report.RecordSelectionFormula = "{vCihazKabul.SILINDI}=false and {vCihazKabul.ISTEKNO}=" + IstekNo + " and {vCihazKabul.BOLGEKODU}=" + BolgeKodu.ToString() + " and {vCihazKabul.YIL}=" + Yil.ToString() + " and {vCihazKabul.FIRMAID}=" + FirmaId.ToString();
            //report.RecordSelectionFormula = "{vCihazKabul.YIL}=9 and {vCihazKabul.ISTEKNO}=549 and {vCihazKabul.BOLGEKODU}=2";
        }

        if (RaporAdi == "GorevOluru.rpt")
        {
            string GorevId = Request["GorevId"].ToString();
            //report.RecordSelectionFormula = "{GorevPersonel.GorevID}=" + GorevId ;
            report.SetParameterValue("AracPlakasi", Session["RaporIcinAracPlakasi"].ToString());
            report.SetParameterValue("GorevId", GorevId);
            Session.Remove("RaporIcinAracPlakasi");
        }
        if (RaporAdi == "TeklifYeni.rpt")
        {
            lblUyari.Visible = false;
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string TeklifNo = Request["TeklifNo"].ToString();
            string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);
            if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis
            {
                lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz..";
                lblUyari.Visible = true;
                return;
            }
            else
            {
                report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
                //report.SetParameterValue("KurumTipi", "Kamu");
                //report.SetParameterValue("Telefon", "4545");
            }
        }
        if (RaporAdi == "TeklifYeniIndirimli.rpt")
        {
            lblUyari.Visible = false;
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string TeklifNo = Request["TeklifNo"].ToString();
            string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);
            decimal IndirimOrani = 0;
            if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis
            {
                lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz..";
                lblUyari.Visible = true;
                return;
            }
            else
            {
                report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
                using (Service1Client client = new Service1Client())
                {
                    IndirimOrani = client.TeklifNodanIndirimOraniniDon(BolgeKodu, TeklifNo);
                }
                report.SetParameterValue("IndirimOrani", IndirimOrani);
                //report.SetParameterValue("Telefon", "4545");
            }
        }
        if (RaporAdi == "TeklifYeniOnYazisiz.rpt")
        {
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string TeklifNo = Request["TeklifNo"].ToString();
            string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);

            report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
            report.SetParameterValue("KurumTipi", "Kamu");
            report.SetParameterValue("Telefon", Telefon);
        }

        if (RaporAdi == "FaturaOnYaziDetayli.rpt")
        {
            report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString());
            report.SetParameterValue("PaketNolari", Session["FaturaOnYaziIcinVirgulleAyrilmisPaketNolar"].ToString());
            report.SetParameterValue("PaketBedelleri", decimal.Parse(Session["PaketBedelleri"].ToString()));
            report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "H");
            if (Session["PaketKapsamindaOlmayanlariGizle"] == "E")
            {
                report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "E");
                Session["PaketKapsamindaOlmayanlariGizle"] = null;
            }
        }
        if (RaporAdi == "FaturaOnYazi.rpt")
        {
            report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString());
            report.SetParameterValue("MasrafIncelemeUcreti", Session["DetaysizMasrafIncelemeUcreti"].ToString());
            report.SetParameterValue("PostaHavale", Session["DetaysizPostaBedeli"].ToString());
            /*
            DataSet ds=new DataSet();
            ds=ed.Sorgula("SELECT  top 1   dbo.firma.MUSTNO, dbo.firma.FIRMAADI, dbo.firma.ADRESI, dbo.firma.ADRESII, dbo.firma.IL_ILCE, dbo.firma.TELEFON, dbo.firma.FAX, dbo.firma.ILGILI, "+
                      " dbo.firma.EMAIL, dbo.firma.NOTLAR, dbo.firma.FATADRES, dbo.firma.VERGIDAIRESI, dbo.firma.VERGINO, dbo.firma.BOLGEKODU, dbo.firma.SILINDI, "+
                      " dbo.istek.FIRMAID, dbo.istek.YIL, dbo.istek.ISTEKNO, dbo.istek.ALTISTNO, dbo.istek.CIHAZADI, dbo.istek.IMALATCI, dbo.istek.MODEL, dbo.istek.SERINO, "+
                      " dbo.istek.OLCUMARALIGI, dbo.istek.ILGLAB, dbo.istek.SORUMLU, dbo.istek.FATBEDEL, dbo.istek.IPTAL, dbo.istek.BOLGEKODU AS isBolgeKodu, dbo.istek.SILINDI AS isSilindi, "+
                      " dbo.istek.FATURASIRA, dbo.istek.CIHAZKAPSAMAYRINTITABLOSU, dbo.FaturaOnYazi.ID, dbo.FaturaOnYazi.ISTID, dbo.FaturaOnYazi.BOLGEKODU AS FoyBolgeKodu, "+
                      " dbo.FaturaOnYazi.Silindi AS foySilindi, dbo.FaturaOnYazi.FATURANO, dbo.FaturaOnYazi.GUNLUKSIRA,dbo.FaturaOnYazi.EkBolgemi "+
                        " FROM         dbo.istek INNER JOIN "+
                      " dbo.firma ON dbo.istek.FIRMAID = dbo.firma.FIRMAID INNER JOIN "+
                      " dbo.FaturaOnYazi ON dbo.istek.ISTID = dbo.FaturaOnYazi.ISTID "+
                      " where FaturaOnYazi.ISTID in ("+Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString() +")");

            report.SetDataSource(ds);
             */
        }
        if (RaporAdi == "FaturaOnYaziYeni.rpt")
        {
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
            report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
            using (Service1Client proxy = new Service1Client())
            {
                decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
                report.SetParameterValue("PostaBedeli", PostaBedeli);
                report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);
                /*
                //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise
                if (EkBolgeUcretiToplami == 0)
                {
                    report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false);
                }
                 */
                Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null;
            }
        }
        //if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        //{
        //    int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);

        //    using (Service1Client proxy = new Service1Client())
        //    {
        //        decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString());

        //        report.SetParameterValue("YurtDisindanmi", false);
        //        report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
        //        report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());

        //        report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);
        //        report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
        //        report.SetParameterValue("PostaBedeli", PostaBedeli);

        //        report.SetParameterValue("IndirimOrani", IndirimOrani);

        //        /*
        //        //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise
        //        if (EkBolgeUcretiToplami == 0)
        //        {
        //            report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false);
        //        }
        //         */

        //    }
        //}

        if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        {
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);

            using (Service1Client proxy = new Service1Client())
            {
                //decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal MasrafIncelemeUcreti = ed.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal PostaBedeli = ed.FaturaNoIcinIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString());
                report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString());
                report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
                report.SetParameterValue("PostaBedeli", PostaBedeli);
                report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);
                report.SetParameterValue("IndirimOrani", IndirimOrani);
                report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString(), "MasrafveInceleme");
                report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString(), "MasrafveInceleme");
             }
        }

        if (RaporAdi == "FirmaEtiketi.rpt")
        {
            report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
            report.SetParameterValue("FirmaId", Request["FirmaId"].ToString());
        }
        if (RaporAdi == "EgitimSertifikasi.rpt")
        {
            int EgtBolgeKodu = 0;
            report.SetParameterValue("@EgitimId", Request["EgitimId"].ToString());
            using (Service1Client proxy = new Service1Client())
            {

                //report.SetParameterValue("EgitimiVerenler", proxy.EgitimiVerenlerinIsimleriniVirgulleAyrilmisOlarakDon(int.Parse(Request["EgitimId"].ToString())));
                report.SetParameterValue("EgitimiVerenler", ed.kal_BelirliEgitimiVerenListesiDon2(int.Parse(Request["EgitimId"].ToString())));

                report.SetParameterValue("EgitimAdi", proxy.EgitimIddenEgitimAdiDon(int.Parse(Request["EgitimId"].ToString())));
                using (Service1Client proxyy = new Service1Client())
                {
                    EgtBolgeKodu = proxyy.BolgeKoduDon(Context.User.Identity.Name);
                }
                if (EgtBolgeKodu == 1)//Gebze
                {
                    report.SetParameterValue("ImzaAd", "Ali Can Kuyrukluyıldız");
                    report.SetParameterValue("ImzaStatu", "Gebze Kalibrasyon Müdürü");
                }
                if (EgtBolgeKodu == 2)//Ankara
                {
                    report.SetParameterValue("ImzaAd", "Abdulmuttalip Aktoğ");
                    report.SetParameterValue("ImzaStatu", "Kalibrasyon Grup Başkanı");
                }
                if (EgtBolgeKodu == 3)//Bursa
                {
                    report.SetParameterValue("ImzaAd", "Ömer EYYUPOĞLU");
                    report.SetParameterValue("ImzaStatu", "Bursa İl Koordinatörü");
                }
            }

        }
        SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();
        sb.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["KalData"].ToString();
        CrystalDecisions.Shared.TableLogOnInfo tliCurrent;
        foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in report.Database.Tables)
        {
            tliCurrent = tbl.LogOnInfo;
            tliCurrent.ConnectionInfo.ServerName = sb.DataSource;
            tliCurrent.ConnectionInfo.UserID = sb.UserID;
            tliCurrent.ConnectionInfo.Password = sb.Password;
            tliCurrent.ConnectionInfo.DatabaseName = sb.InitialCatalog;
            tbl.ApplyLogOnInfo(tliCurrent);
        }
        if (Format == "PDF")
        {
            if (Session["eImzaliOlacak"] == null)
            {
                this.ExportReportPdfEImzaYok();
            }
            else
            {
                this.ExportReportPdf();
            }

        }
        if (Format == "Word")
        {
            this.ExportReportWord();
        }

        CrystalReportViewer1.ReportSource = report;

        //Rapor üretildikten hemen sonra faturalandırılan istekler tablosuna yaz
        if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        {
            using (Service1Client proxy = new Service1Client())
            {
                Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null;
                string[] IstIdler = (string[])Session["FaturalandirildiOlarakIsaretlenecekIstIdler"];
                foreach (var item in IstIdler)
                {
                    try
                    {
                        proxy.FaturalandirilanIsteklereEkle(int.Parse(item));
                    }
                    catch
                    {
                        //RadNotification1.Text = " <font color='red'> "+item +" istekId li cihaz faturası yazılanlar tablosuna eklenemedi! Bu, cihazın birden fazla faturalandırılmasına yol acabilir. Lütfen istekId sini not alip sistem yöneticisine bildiriniz.</font>"; ;
                        // RadNotification1.Show();
                    }
                }
            }
        }
    }
Ejemplo n.º 18
0
        public ActionResult ExportData_IU(ApplicationHeaderInfo pInfo, App_Detail_PLB02_CGD_Info pDetail,
                                          List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();

                // Fill export_header
                string fileName     = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B02_VI_" + TradeMarkAppCode.AppCode_TM_3C_PLB_02_CGD + ".docx");
                string fileName_pdf = "";

                AppsCommon.Prepare_Data_Export_B02(ref pDetail, pInfo, pAppDocumentInfo);

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

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLB02_CGD_Info>(_lst, false);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile    = "TM_PLB02_CGD.rpt";
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B02_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B02_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    _tempfile    = "TM_PLB02_CGD_EN.rpt"; // tiếng anh
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B02_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B02_EN_" + _datetimenow + ".pdf";
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));
                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table_3c";

                    //_ds_all.WriteXml(@"E:\Working\Legaltech\Application\WebApps\Content\XML\TM_PLB02CGD.xml", XmlWriteMode.WriteSchema);

                    oRpt.Database.Tables["Table_3c"].SetDataSource(_ds_all.Tables[0]);

                    //oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

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

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

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Ejemplo n.º 19
0
        void GenerarArchivo(Int32 Id_evento, Boolean GenerarArchivo)
        {
            try
            {
                pSeleccionarParametros_Result p = new pSeleccionarParametros_Result();
                Programa e = new Programa();
                pSeleccionarReportes_Result            r = new pSeleccionarReportes_Result();
                List <pSeleccionarValores_prog_Result> v = new List <pSeleccionarValores_prog_Result>();
                string returnValue = null;

                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    p = context.pSeleccionarParametros().FirstOrDefault();
                    e = context.Programas.Where(ev => ev.id_evento == Id_evento).FirstOrDefault();
                    r = context.pSeleccionarReportes(e.cod_rep.Trim()).FirstOrDefault();
                    v = context.pSeleccionarValores_prog(e.id_evento).ToList();
                }

                ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                SqlConnection sqlConn = new SqlConnection(returnValue);

                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = r.funcion.Trim();

                foreach (var item in v)
                {
                    switch (item.tipo.Trim())
                    {
                    case "Char":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Char);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_char;
                        break;

                    case "Int":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Int);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_int;
                        break;

                    case "Decimal":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Decimal);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_dec;
                        break;

                    case "DateTime":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.DateTime);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_date;
                        break;

                    case "Time":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Time);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_time;
                        break;

                    case "Bit":
                        comd.Parameters.Add(item.parametro.Trim(), SqlDbType.Bit);
                        comd.Parameters[comd.Parameters.Count - 1].Value = item.valor_bit;
                        break;
                    }
                }

                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, r.funcion.Trim());

                if (ds.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("Sin datos para mostrar.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    string Filename = r.ruta + @"\" + r.Archivo;
                    CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    oRpt.Load(@Filename);
                    oRpt.SetDataSource(ds);

                    if (GenerarArchivo == false)
                    {
                        FrmRep Fr = new FrmRep(ds, r.Archivo, false);
                        Fr.ShowDialog();
                    }
                    else
                    {
                        Archivo = "";

                        //string Fecha = ((DateTime.Now.Day < 10) ? "0" : "") + DateTime.Now.Day.ToString() +
                        //      ((DateTime.Now.Month < 10) ? "0" : "") + DateTime.Now.Month.ToString() +
                        //      (DateTime.Now.Year.ToString());

                        //string Hora = ((DateTime.Now.Hour < 10) ? "0" : "") + DateTime.Now.Hour.ToString() +
                        //              ((DateTime.Now.Minute < 10) ? "0" : "") + DateTime.Now.Minute.ToString() +
                        //              ((DateTime.Now.Second < 10) ? "0" : "") + DateTime.Now.Second.ToString();

                        switch (e.Tipo.Trim())
                        {
                        case "PDF":
                            //Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + " F[" + Fecha + "] H[" + Hora + "].pdf";
                            Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + ".pdf";
                            oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Archivo.TrimEnd());
                            break;

                        case "XLS":
                            Archivo = @p.ruta_pdf + @"\" + e.descrip.Trim() + ".xls";
                            oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.ExcelRecord, Archivo.TrimEnd());
                            break;
                        }
                    }
                    oRpt.Close();
                    oRpt.Dispose();
                }
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SqlException ex0)
            {
                MessageBox.Show(ex0.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 20
0
        public void Print()
        {
            try
            {
                string strReportPath;
                string strParm1 = "";

                string strParm2 = "";

                string strParm3 = "";

                string strValue1 = Request.QueryString["value1"];

                string[] parms = strValue1.Split(',');

                int intNumParms = parms.Count();

                string strRpt = parms[0];

                string strSP = parms[1];

                if (intNumParms >= 3)
                {
                    strParm1 = parms[2];
                }

                if (intNumParms >= 4)
                {
                    strParm2 = parms[3];
                }

                if (intNumParms >= 5)
                {
                    strParm3 = parms[4];
                }


                System.Data.DataSet ds = new System.Data.DataSet();
                //                System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection("Data Source=sql394.mysite4now.com;Initial Catalog=ULS_db1;User ID=uls2008;Password=2008uls");
                System.Data.SqlClient.SqlConnection sqlcon = new System.Data.SqlClient.SqlConnection("Data Source=(local);Initial Catalog=ULS_db1;User ID=uls2008;Password=uls2008");
                System.Data.SqlClient.SqlCommand    comand = new System.Data.SqlClient.SqlCommand();
                comand.Connection  = sqlcon;
                comand.CommandText = strSP;
                comand.CommandType = System.Data.CommandType.StoredProcedure;

                switch (strRpt)
                {
                case "EmployeeListByCertification":
                    strReportPath = Server.MapPath("~/Reports/QualEmpListByCert.rpt");
                    comand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@companyId", System.Data.SqlDbType.VarChar, 25));
                    comand.Parameters["@companyId"].Value = strParm1;
                    comand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@qualId", System.Data.SqlDbType.VarChar, 25));
                    comand.Parameters["@qualId"].Value = strParm2;
                    break;

                case "EmployeeListByCompany":
                    strReportPath = Server.MapPath("~/Reports/QualEmpListByCompany.rpt");
                    comand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@companyId", System.Data.SqlDbType.VarChar, 25));
                    comand.Parameters["@companyId"].Value = strParm1;
                    break;

                case "CertListByEmployee":
                    strReportPath = Server.MapPath("~/Reports/CertListByEmployee.rpt");
                    comand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@employeeId", System.Data.SqlDbType.Int));
                    comand.Parameters["@employeeId"].Value = strParm1;
                    break;

                case "EmpListExpiredCerts":
                    strReportPath = Server.MapPath("~/Reports/EmployeeListExpiredCerts.rpt");
                    break;

                case "EmpListDueToExpire90Days":
                    strReportPath = Server.MapPath("~/Reports/EmployeeListDueToExpireCerts.rpt");
                    break;

                default:
                    strReportPath = Server.MapPath("~/Reports/EquipAssinedTo.rpt");
                    break;
                }


                System.Data.SqlClient.SqlDataAdapter sqladp = new System.Data.SqlClient.SqlDataAdapter(comand);

                sqlcon.Open();
                sqladp.Fill(ds, "myDataSet");

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

                oRpt.Load(strReportPath);

                oRpt.SetDataSource(ds.Tables[0]);

                CrystalReportViewer1.ReportSource = oRpt;

                sqlcon.Close();
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
        }
Ejemplo n.º 21
0
    //匯出Excel
    private void ShowReportB(DataTable dt)
    {
        #region 利用CrystalReport匯出Excel

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

        //檔案匯出
        System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        byte[] bytesXLS = new byte[streamXLS.Length];
        streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
        streamXLS.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表_" + System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + ".XLS", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/xls";
        Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
Ejemplo n.º 22
0
    //列印報表
    private void ShowReport(DataSet ds)
    {
        #region 利用CrystalReport列印報表

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

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

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

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

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

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

        //檔案匯出
        System.IO.Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytesPDF = new byte[streamPDF.Length];
        streamPDF.Read(bytesPDF, 0, bytesPDF.Length);
        streamPDF.Seek(0, System.IO.SeekOrigin.Begin);
        //Export File  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode("商品期別異動表.PDF", System.Text.Encoding.UTF8));//匯出檔名  
        Response.ContentType = "application/pdf";
        Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
        Response.Flush();
        Response.Close();
        report.Close();
        #endregion
    }
Ejemplo n.º 23
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    DataTable           dtReport = new DataTable();
                    NameValueCollection para     = new NameValueCollection();
                    para.Add("@i_FYID", CurrentUser.FYID.ToString());

                    dtReport = objList.ListOfRecord("rpt_SalesInvoiceRegister", para, "SalesInvoice - Report");
                    DataView DVReport;
                    DVReport           = dtReport.DefaultView;
                    DVReport.RowFilter = StrFilter;


                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoiceRegister.rpt"))
                        {
                            //dtblSalesInvoice .TableName = "PORegister";
                            //dtblSalesInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoiceRegister.rpt");
                            //rptDoc.BlankRecords.Height -= (ds.tblItems.Count * 136);
                            CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Sales Invoice Register", true, true, true, true, false, true, true, false, false, false, true);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Sales Invoice Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            else if (cmbreports.SelectedIndex == 2)
            {
                rptSalesInvoice_Click(sender, e);
            }
            else if (cmbreports.SelectedIndex == 3)
            {
                if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "RI")
                {
                    salesInvoiceToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Retail Invoice not generated for this sale.");
                }
            }
            else if (cmbreports.SelectedIndex == 4)
            {
                if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "TI")
                {
                    taxInvoiceToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Tax Invoice not generated for this sale.");
                }
            }
            ////////////////////////

            else if (cmbreports.SelectedIndex == 5)
            {
                if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "ES")
                {
                    try
                    {
                        DataTable dt = new DataTable();
                        LogoBind(dt);

                        if (dgvSalesInvoice.CurrentRow != null)
                        {
                            DataTable           dtTNC = new DataTable();
                            NameValueCollection para2 = new NameValueCollection();
                            para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString());
                            para2.Add("@i_TNC_Sub", "SALES");

                            dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC");


                            DataTable           dtReport = new DataTable();
                            NameValueCollection para     = new NameValueCollection();
                            para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString());

                            dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report");
                            if (objList.Exception == null)
                            {
                                if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoice.rpt"))
                                {
                                    //dtReport.TableName = "PurchaseOrder";
                                    //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd");
                                    CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                    rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoice.rpt");
                                    rptDoc.Subreports[0].DataSourceConnections.Clear();
                                    rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC);
                                    rptDoc.Database.Tables[1].SetDataSource(dt);
                                    rptDoc.Refresh();
                                    CurrentUser.AddReportParameters(rptDoc, dtReport, "Estimate", true, true, true, true, true, true, true, true, true, true, true);
                                    CurrentUser.AddExtraParameter(rptDoc);
                                    Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                    fRptView.Text = "Estimate - [Page Size: A4]";
                                    fRptView.crViewer.ReportSource = rptDoc;
                                    fRptView.ShowDialog();
                                }
                                else
                                {
                                    MessageBox.Show("File is not exist...");
                                }
                            }
                            else
                            {
                                MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
                        MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                    }
                }
                else
                {
                    MessageBox.Show("Estimate not generated for this sale.");
                }
            }

            ///////////////////


            //else if (cmbreports.SelectedIndex == 6)
            //{
            //    try
            //    {
            //        DataTable dt = new DataTable();
            //        LogoBind(dt);
            //        if (dgvSalesInvoice.CurrentRow != null)
            //        {

            //            DataTable dtTNC = new DataTable();
            //            NameValueCollection para2 = new NameValueCollection();
            //            para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString());
            //            para2.Add("@i_TNC_Sub", "SALES");

            //            dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC");

            //            DataTable dtReport = new DataTable();
            //            NameValueCollection para = new NameValueCollection();
            //            para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString());

            //            dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report");
            //            if (objList.Exception == null)
            //            {
            //                if (System.IO.File.Exists(CurrentUser.ReportPath + "rptDeliveryChallan.rpt"))
            //                {
            //                    //dtReport.TableName = "Logo";
            //                    //dtReport.WriteXmlSchema(@"D:\ERP-CRM\CRM_ICON\Logo.xsd");
            //                    CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            //                    rptDoc.Load(CurrentUser.ReportPath + "rptDeliveryChallan.rpt");
            //                    rptDoc.Subreports[0].DataSourceConnections.Clear();
            //                    rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC);
            //                    //rptDoc.Refresh();
            //                    rptDoc.Database.Tables[1].SetDataSource(dt);
            //                    rptDoc.Refresh();
            //                    CurrentUser.AddReportParameters(rptDoc, dtReport, "Delivery Challan", true, true, true, true, true, true, true, true, true, true, true);
            //                    CurrentUser.AddExtraParameter(rptDoc);
            //                    Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
            //                    fRptView.Text = "Delivery Challan - [Page Size: A4]";
            //                    fRptView.crViewer.ReportSource = rptDoc;
            //                    fRptView.ShowDialog();
            //                }
            //                else
            //                {
            //                    MessageBox.Show("File is not exist...");
            //                }
            //            }
            //            else
            //            {
            //                MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //            }
            //        }
            //    }
            //    catch (Exception exc)
            //    {
            //        Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
            //        MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
            //    }
            //}

            else if (cmbreports.SelectedIndex == 6)
            {
                try
                {
                    DataTable dt = new DataTable();
                    LogoBind(dt);
                    if (dgvSalesInvoice.CurrentRow != null)
                    {
                        DataTable           dtTNC = new DataTable();
                        NameValueCollection para2 = new NameValueCollection();
                        para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString());
                        para2.Add("@i_TNC_Sub", "SALES");

                        dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC");


                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();
                        para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString());

                        dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoice.rpt"))
                            {
                                //dtReport.TableName = "PurchaseOrder";
                                //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoice.rpt");
                                rptDoc.Subreports[0].DataSourceConnections.Clear();
                                rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC);
                                rptDoc.Database.Tables[1].SetDataSource(dt);
                                rptDoc.Refresh();
                                CurrentUser.AddReportParameters(rptDoc, dtReport, "Proforma Invoice", true, true, true, true, true, true, true, true, true, true, true);
                                CurrentUser.AddExtraParameter(rptDoc);
                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Proforma Invoice - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("File is not exist...");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 7)
            {
                try
                {
                    if (dgvSalesInvoice.CurrentRow != null)
                    {
                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();
                        para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString());

                        dtReport = objList.ListOfRecord("rpt_ChallanCumTaxInvoice", para, "SalesInvoice - Report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptChallanCumTaxInvoice.rpt"))
                            {
                                //dtReport.TableName = "ChallanCumTaxInvoice";
                                //dtReport.WriteXmlSchema(@"D:\ChallanCumTaxInvoice.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptChallanCumTaxInvoice.rpt");
                                CurrentUser.AddReportParameters(rptDoc, dtReport, "Challan Cum Tax Invoice", true, true, true, true, true, true, true, true, true, true, true);
                                CurrentUser.AddExtraParameter(rptDoc);
                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Challan Cum Tax Invoice - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("File is not exist...");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
            culture.NumberFormat.CurrencySymbol = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            base.InitializeCulture();

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

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

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

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

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

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

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

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

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

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

                    CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: " + ex.Message + " " + ex.StackTrace);
                    throw new Exception(ex.Message); 
                    //WebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepciones.aspx");
                }
            }
        }
Ejemplo n.º 25
0
        protected void InicializaPagina()
        {
            int IdOrdenCompra;

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

            IdOrdenCompra = Convert.ToInt32(id);

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

            dsReportes dsReporte = new dsReportes();

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

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

            dsReporte.Parametro.AddParametroRow(drParametroRow);

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

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

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

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

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

            drOrdenCompraRow.Subtotal = objOrdenCompraDTO.ImporteOrdenCompra;

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

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

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

            drOrdenCompraRow.Proyecto = objOrdenCompraDTO.NombreProyecto;

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

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

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

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

            dsReporte.OrdenCompra.AddOrdenCompraRow(drOrdenCompraRow);

            foreach (OrdenCompraLineaDTO linea in objOrdenCompraLinea)
            {

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

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

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

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

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

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

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

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

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

            stream.Flush();
            stream.Close();
            stream.Dispose();
        }
Ejemplo n.º 26
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    DataTable           dtReport = new DataTable();
                    NameValueCollection para     = new NameValueCollection();
                    para.Add("@i_FYID", CurrentUser.FYID.ToString());
                    para.Add("@i_UserId", CurrentUser.UserID.ToString());
                    para.Add("@i_CompId", CurrentCompany.CompId.ToString());

                    dtReport = objList.ListOfRecord("rpt_IndentRegister", para, "Indent - Report");
                    DataView DVReport;
                    DVReport           = dtReport.DefaultView;
                    DVReport.RowFilter = StrFilter;

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptGRNRegister.rpt"))
                        {
                            //dtblPurchaseInvoice .TableName = "PORegister";
                            //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptGRNRegister.rpt");

                            CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Register", true, true, true, true, false, true, true, false, false, false, false);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Indent Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Indent - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    if (dgvPurchaseInvoice.CurrentRow != null)
                    {
                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();
                        para.Add("@i_PIID", Convert.ToInt64(dgvPurchaseInvoice.CurrentRow.Cells["PIID"].Value).ToString());
                        dtReport = objList.ListOfRecord("rpt_IndentDetail", para, "Indent - Report");
                        DataView DVReport;
                        DVReport           = dtReport.DefaultView;
                        DVReport.RowFilter = StrFilter;

                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptPurchaseInvoiceRegisterWithDetail.rpt"))
                            {
                                //dtblPurchaseInvoice .TableName = "PORegister";
                                //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptPurchaseInvoiceRegisterWithDetail.rpt");
                                CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Detail", true, true, true, true, false, true, true, false, false, false, false);
                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Indent Detail - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("File is not exist...");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Indent - Detail Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 3)
            {
                try
                {
                    DataTable dt = new DataTable();
                    LogoBind(dt);
                    if (dgvPurchaseInvoice.CurrentRow != null)
                    {
                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();
                        para.Add("@i_RecID", Convert.ToInt64(dgvPurchaseInvoice.CurrentRow.Cells["PIID"].Value).ToString());

                        dtReport = objList.ListOfRecord("rpt_Indent", para, "Indent - Report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptIndent.rpt"))
                            {
                                //dtblPurchaseInvoice .TableName = "PORegister";
                                //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptIndent.rpt");
                                rptDoc.Database.Tables[1].SetDataSource(dt);
                                rptDoc.Refresh();
                                CurrentUser.AddReportParameters(rptDoc, dtReport, "Indent", true, true, true, true, true, true, true, true, true, true, false);

                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Indent - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("File is not exist...");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Indent", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 4)
            {
                try
                {
                    DataTable           dtReport = new DataTable();
                    NameValueCollection para     = new NameValueCollection();
                    para.Add("@i_FYID", CurrentUser.FYID.ToString());
                    para.Add("@i_UserId", CurrentUser.UserID.ToString());
                    para.Add("@i_CompId", CurrentCompany.CompId.ToString());

                    dtReport = objList.ListOfRecord("rpt_IndentRegister", para, "Indent - Report");
                    DataView DVReport;
                    DVReport           = dtReport.DefaultView;
                    DVReport.RowFilter = StrFilter;

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptGRNRegister.rpt"))
                        {
                            //dtblPurchaseInvoice .TableName = "PORegister";
                            //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptGRNRegister.rpt");

                            CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Register", true, true, true, true, false, true, true, false, false, false, false);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Indent Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Indent - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 27
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptCustomerRegister.rpt"))
                    {
                        //dtblCustomer.TableName = "CustomerRegister";
                        //dtblCustomer.WriteXmlSchema(@"D:\report\CustomerRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblLead.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptCustomerRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Customer Register", true, true, true, true, false, true, false, false, false, false, false);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Customer Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }

                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Customer- Register", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptCustomerMailingLabel.rpt"))
                    {
                        //dtblCustomer.TableName = "CustomerRegister";
                        //dtblCustomer.WriteXmlSchema(@"D:\report\CustomerRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblLead.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptCustomerMailingLabel.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Customer Mailing Label", true, true, true, true, false, true, false, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Customer Mailing Label - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }

                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Customer- Mailing Label", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            //------------------------
            //try
            //{

            //    if (cmbreports.SelectedIndex > 0)
            //    {

            //        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptLeadRegister.rpt"))
            //        {
            //            //dtblLead.TableName = "LeadRegister";
            //            //dtblLead.WriteXmlSchema(@"E:\SharedFile\LeadRegister.xsd");

            //            DataView DVReport;
            //            DVReport = dtblLead.DefaultView;
            //            DVReport.RowFilter = StrFilter;
            //            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            //            rptDoc.Load(CurrentUser.ReportPath + "rptLeadRegister.rpt");

            //            CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Inquiry Register", true, true, true, true, false, true, true, false, false, false, true);

            //            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
            //            fRptView.Text = "Inquiry Register - [Page Size: A4]";
            //            fRptView.crViewer.ReportSource = rptDoc;
            //            fRptView.ShowDialog();


            //        }
            //        else
            //        {
            //            MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
            //        }
            //    }

            //    cmbreports.SelectedIndex = 0;

            //}
            //catch (Exception exc)
            //{
            //    Utill.Common.ExceptionLogger.writeException("User - Register", exc.StackTrace);
            //    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
            //}
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //this takes request parameters only from the query string
        string SalesOrderID = Request.QueryString["salesorderid"];
        if (SalesOrderID == null)
        {
            //SalesOrderID = "QDEMOA0019C7"; //FOR Testing
        }
        if (SalesOrderID == null)
        {
            Response.Write("No Valid SalesOrderID provided");
        }
        else
        {

            try
            {
                Sage.Entity.Interfaces.ISalesOrder salesOrder = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ISalesOrder>(SalesOrderID);

                string reportPath = Server.MapPath("CrystalReports\\PickingListDetail.rpt");
                CrystalDecisions.CrystalReports.Engine.ReportDocument crReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                crReport.Load(reportPath);
                crReport.RecordSelectionFormula = "{SALESORDER.SALESORDERID} = '" + salesOrder.Id.ToString() + "'";

                //Retrieve connection string information
                // get the DataService to get a connection string to the database
                Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>();

                string connectionString = datasvc.GetConnectionString();

                System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();
                builder.ConnectionString = connectionString;

                string password = builder["Password"].ToString();
                string username = builder["User ID"].ToString();
                string dataSource = datasvc.Server;
                string initialCatalog = datasvc.Alias;

                //Define new connection for Crystal Report
                CrystalDecisions.Shared.ConnectionInfo connectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
                connectionInfo.DatabaseName = initialCatalog;
                connectionInfo.UserID = username;
                connectionInfo.Password = password;
                connectionInfo.ServerName = dataSource;

                // set report connection for main report
                SetDBLogonForReport(connectionInfo, crReport);
                // set report connection for any subreports
                SetDBLogonForSubreports(connectionInfo, crReport);
                //System.IO.MemoryStream ms = (System.IO.MemoryStream)crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                //Response.BinaryWrite(ms.ToArray());
                String filename = "exportedPDF/PickingList" + salesOrder.AlternateKeyPrefix + "-" + salesOrder.AlternateKeySuffix + ".pdf";
                crReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Server.MapPath(filename));

                //string popupScript = "<script language='javascript'>" + "window.open('C:/BiWeeklyReport.pdf'); <//script>";
                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popupOpener", "var popup=window.open('" + filename + "');popup.focus();", true);

                //string jsScript = "window.close();";
                //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "AlertJS", jsScript, true);
                //Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();");
                Response.Redirect(filename);

            }
            catch (System.Threading.ThreadAbortException ex)
            {

            }
            finally
            {
                //Response.End();
            }
        }
    }
Ejemplo n.º 29
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
                culture.NumberFormat.CurrencySymbol = string.Empty;
                System.Threading.Thread.CurrentThread.CurrentCulture   = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                base.InitializeCulture();

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

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

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

                    if (formatoRptExportar == "PDF")
                    {
                        CrystalDecisions.Shared.ExportOptions           exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                        exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                    }
                    if (formatoRptExportar == "Excel")
                    {
                        CrystalDecisions.Shared.ExportOptions      exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.ExcelFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions();
                        exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, Server.MapPath("~/TempExcel/") + sb.ToString() + ".xls");

                        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                        response.ClearContent();
                        response.Clear();
                        response.ContentType = "application/vnd.ms-excel";
                        response.AddHeader("Content-Disposition", "attachment; filename=" + sb.ToString() + ".xls" + ";");
                        response.TransmitFile(Server.MapPath("~/TempExcel/" + sb.ToString() + ".xls"));
                        response.Flush();
                        response.End();
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Trace.Warn("Thread abortado");
            }
            catch (Exception ex)
            {
                WebForms.Excepciones.Redireccionar(ex, "~/NotificacionDeExcepcion.aspx");
            }
        }
Ejemplo n.º 30
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

        #region 前置檢查與參數過濾

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

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

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


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


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

        #endregion

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

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

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

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

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

                break;
        }
        #endregion

    }
Ejemplo n.º 31
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataSet dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

        #region 前置檢查與參數過濾

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

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

        #endregion

        #region 組合查詢條件至Report ArrayList

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

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

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

        report.SetParameterValue("Vendor", sTemp);

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

        report.SetParameterValue("RootNo", sTemp);

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

        report.SetParameterValue("PMA", sTemp);

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

        report.SetParameterValue("CATEGORY", sTemp);

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

        #endregion

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

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

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


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

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

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

                break;
            default:

                break;
        }

    }
Ejemplo n.º 32
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptVendorRegister.rpt"))
                    {
                        //dtblVendor.TableName = "VendorRegister";
                        //dtblVendor.WriteXmlSchema(@"D:\Report\VendorRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblVendor.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptVendorRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Vendor Register", true, true, true, true, false, true, true, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Vendor Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                        // DataTable dt = new DataTable();
                        //// dt = dgvVendor.DataSource();
                        // for (int i = 0; i < dgvVendor.Rows.Count; i++)
                        // {
                        //     DataRow dr = dt.NewRow();
                        //     dr["Col1"] = dgvVendor.rows[i]["Col1"].text;
                        //     dt.Rows.Add(dr);
                        // }
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Vendor - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptVendorMailingLabel.rpt"))
                    {
                        //dtblVendor.TableName = "VendorRegister";
                        //dtblVendor.WriteXmlSchema(@"D:\Report\VendorRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblVendor.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptVendorMailingLabel.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Vendor Mailing Label", true, true, true, true, false, true, false, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Vendor Mailing Label - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Vendor - Mailing Label Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 33
0
        /// <summary>
        /// 產生輸出檔案
        /// </summary>
        /// <param name="s_FileName">產生檔案檔名</param>
        /// <param name="s_rptFilePath">RPT報表檔路徑及檔名</param>
        /// <param name="dt_Source">DB抓取的資料集(DataTable)</param>
        /// <param name="RP">報表變數,如無變數請輸入null</param>
        /// <param name="ROF">報表格式</param>        
        public void LoadCrystalReport(string s_FileName,
                                      string s_rptFilePath,
                                      ref DataTable dt_Source,
                                      ReportParameter[] RP,
                                      string ReportOutputFormat
                                      )
        {
            int bytesRead = 0;

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

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

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

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

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

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

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

                        break;


                    case "PDF":

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

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

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

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

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

                        break;
                    default:

                        break;
                }

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

                report.Close();
                report.Dispose();
                dt_Source.Dispose();
            }
        }
        static string _scanPath; //Repertoire de recherche

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            try
            {

                #region validation

                //Parametre sur la ligne de commande est obligatoire
                if (args.Length < 2)
                {
                    throw new ArgumentException(Resource1.ERR_ARG);
                }

                if (!Directory.Exists(args[0]))
                {
                    throw new System.IO.DirectoryNotFoundException(Resource1.ERR_NO_SOURCE_PATH);
                }

                if (!Directory.Exists(args[1]))
                {
                    throw new System.IO.DirectoryNotFoundException(Resource1.ERR_NO_DEST_PATH);
                }

                #endregion

                _scanPath = args[0];
                _ouputReportFile = args[1] + ((args[1].EndsWith("\\")) ? "" : "\\") + "report.csv";

                //Filtre pour les fichier rpt dans le répertoire et les sous-répertoires
                string[] filePaths = Directory.GetFiles(_scanPath, "*.rpt", SearchOption.AllDirectories);

                // Delete the file if it exists.
                if (File.Exists(_ouputReportFile))
                {
                    File.Delete(_ouputReportFile);
                }

                //Creation du fichier de rapport
                using (TextWriter tw = new StreamWriter(_ouputReportFile))
                {
                    tw.WriteLine("Create on : " + DateTime.Now);
                    tw.WriteLine("FileName;Version");

                    using (CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument())
                    {
                        //pour chaque fichier trouvé on lit la version du rapport et on l'inscrit dans le fichier
                        foreach (string file in filePaths)
                        {
                            //CrystalDecisions.Shared.ExportOptions t;
                            //t.ExportFormatType = (CrystalDecisions.Shared.ExportFormatType)34;

                            rpt.Load(file);

                            int majVer = rpt.ReportClientDocument.MajorVersion;
                            int minVer = rpt.ReportClientDocument.MinorVersion;
                            tw.WriteLine(file + ';' + majVer + '.' + minVer); //inscription au fichier
                            rpt.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("");
                Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Console.WriteLine("ERREUR : " + ex.Message);
                Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                Console.WriteLine("");
            }
        }
Ejemplo n.º 35
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemRegister.rpt"))
                    {
                        dtblItem.TableName = "ItemRegister";
                        dtblItem.WriteXmlSchema(@"D:\ItemRegister.xsd");

                        DataView DVReport;
                        DVReport           = dtblItem.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptItemRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Register", true, true, true, true, false, true, true, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Item Register - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Item Register", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    DataTable dtReport = new DataTable();
                    dtReport = objList.ListOfRecord("rpt_Sales_Service_Quotation", null, "Item - Report");

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemSales.rpt"))
                        {
                            //dtReport.TableName = "ItemSales";
                            //dtReport.WriteXmlSchema(@"D:\ItemSales.xsd");

                            DataView DVReport;               //rooja
                            DVReport = dtReport.DefaultView; //rooja

                            if (StrFilter != "")
                            {
                                StrFilter = StrFilter + " And ";
                                StrFilter = StrFilter + " TYPE = 'QUOTATION' And ";


                                if (StrFilter != "")
                                {
                                    StrFilter = StrFilter.Substring(0, StrFilter.Length - 4);
                                }

                                DVReport.RowFilter = StrFilter;//rooja

                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptItemSales.rpt");

                                CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Quotation Report", true, true, true, true, false, true, true, false, false, false, true);

                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Item Sales Report - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Please filter data with Customer name and/or Item name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                btnfilter.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            else if (cmbreports.SelectedIndex == 3)
            {
                try
                {
                    DataTable dtReport = new DataTable();
                    dtReport = objList.ListOfRecord("rpt_Sales_Service_Quotation", null, "Item - Report");

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemSales.rpt"))
                        {
                            //dtReport.TableName = "ItemSales";
                            //dtReport.WriteXmlSchema(@"D:\ItemSales.xsd");

                            DataView DVReport;               //rooja
                            DVReport = dtReport.DefaultView; //rooja
                            if (StrFilter != "")
                            {
                                StrFilter = StrFilter + " And ";
                                StrFilter = StrFilter + " TYPE = 'Sales' And ";


                                if (StrFilter != "")
                                {
                                    StrFilter = StrFilter.Substring(0, StrFilter.Length - 4);
                                }

                                DVReport.RowFilter = StrFilter;//rooja

                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptItemSales.rpt");

                                CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Quotation Report", true, true, true, true, false, true, true, false, false, false, true);

                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Item Sales Report - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Please filter data with Customer name and/or Item name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                btnfilter.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 4)
            {
                try
                {
                    DataTable dtReport = new DataTable();
                    dtReport = objList.ListOfRecord("rpt_Sales_Service_Quotation", null, "Item - Report");

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemSales.rpt"))
                        {
                            //dtReport.TableName = "ItemSales";
                            //dtReport.WriteXmlSchema(@"D:\ItemSales.xsd");

                            DataView DVReport;               //rooja
                            DVReport = dtReport.DefaultView; //rooja
                            if (StrFilter != "")
                            {
                                StrFilter = StrFilter + " And ";
                                StrFilter = StrFilter + " TYPE = 'Service' And ";


                                if (StrFilter != "")
                                {
                                    StrFilter = StrFilter.Substring(0, StrFilter.Length - 4);
                                }

                                DVReport.RowFilter = StrFilter;//rooja

                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptItemSales.rpt");

                                CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Quotation Report", true, true, true, true, false, true, true, false, false, false, true);

                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Item Sales Report - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Please filter data with Customer name and/or Item name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                btnfilter.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 36
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    if (dgvServiceModule.CurrentRow == null)
                    {
                        return;
                    }

                    DataTable           dtReport = new DataTable();
                    NameValueCollection Paralist = new NameValueCollection();
                    Paralist.Add("@i_ServiceId", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString());
                    dtReport = objList.ListOfRecord("rpt_ServiceModule", Paralist, "ServiceModule - Report");
                    //if (objList.Exception == null)
                    //{
                    //dtReport.TableName = "ServiceModuleRegister";
                    //dtReport.WriteXmlSchema(@"D:\ServiceModuleRegister.xsd");
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceModuleRegister.rpt"))
                    {
                        DataView DVReport;
                        DVReport           = dtblItem.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptServiceModuleRegister.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Service Module", true, true, true, true, false, true, true, false, false, false, true);
                        //CurrentUser.AddExtraParameter(rptDoc);
                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Service Module - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                    }
                    //}
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Service Module", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    if (dgvServiceModule.CurrentRow == null)
                    {
                        return;
                    }

                    DataTable dt = new DataTable();
                    // LogoBind(dt);
                    DataSet             dtReport = new DataSet();
                    NameValueCollection Paralist = new NameValueCollection();
                    Paralist.Add("@i_RecID", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString());
                    dtReport = objList.ListOfDataSetRecordwithPara("rpt_Service_Order", Paralist, "Service Invoice - Report");
                    if (objList.Exception == null)
                    {
                        //dtReport.Tables[0].TableName = "ServiceOrder";
                        //dtReport.Tables[0].WriteXmlSchema(@"D:\ServiceOrder.xsd");
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceOrder.rpt"))
                        {
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptServiceOrder.rpt");
                            //  rptDoc.Database.Tables[1].SetDataSource(dt);
                            rptDoc.Refresh();
                            CurrentUser.AddReportParameters(rptDoc, dtReport.Tables[0], "Service Order", true, true, true, true, false, true, true, false, false, false, true);


                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Service Order - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Service Invoice", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 3)
            {
                try
                {
                    DataTable dt = new DataTable();
                    LogoBind(dt);
                    if (dgvServiceModule.CurrentRow != null)
                    {
                        DataTable           dtTNC = new DataTable();
                        NameValueCollection para2 = new NameValueCollection();
                        para2.Add("@i_Code", dgvServiceModule.CurrentRow.Cells["RequestNo"].Value.ToString());
                        para2.Add("@i_TNC_Sub", "SERVICE");
                        para2.Add("@i_CompId", CurrentCompany.CompId.ToString());
                        dtTNC = objDA.ExecuteDataTableSP("rpt_Service_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC");



                        DataTable           dtReport = new DataTable();
                        NameValueCollection para     = new NameValueCollection();
                        para.Add("@i_RecID", Convert.ToInt64(dgvServiceModule.CurrentRow.Cells["ServiceId"].Value).ToString());

                        dtReport = objList.ListOfRecord("rpt_ServiceInvoice", para, "ServiceInvoice - Report");
                        if (objList.Exception == null)
                        {
                            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceInvoice.rpt"))
                            {
                                //dtReport.TableName = "ServiceInvoice";
                                //dtReport.WriteXmlSchema(@"D:\ServiceInvoice.xsd");
                                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                                rptDoc.Load(CurrentUser.ReportPath + "rptServiceInvoice.rpt");
                                rptDoc.Subreports[0].DataSourceConnections.Clear();
                                rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC);
                                rptDoc.Database.Tables[1].SetDataSource(dt);
                                rptDoc.Refresh();
                                CurrentUser.AddReportParameters(rptDoc, dtReport, "Service Invoice", true, true, true, true, true, true, true, true, true, true, true);
                                CurrentUser.AddExtraParameter(rptDoc);
                                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                                fRptView.Text = "Labour Invoice - [Page Size: A4]";
                                fRptView.crViewer.ReportSource = rptDoc;
                                fRptView.ShowDialog();
                            }
                            else
                            {
                                MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath.");
                            }
                        }
                        else
                        {
                            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 4)
            {
                try
                {
                    if (dgvServiceModule.CurrentRow == null)
                    {
                        return;
                    }

                    DataTable           dtReport = new DataTable();
                    NameValueCollection Paralist = new NameValueCollection();
                    Paralist.Add("@i_ServiceId", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString());
                    dtReport = objList.ListOfRecord("rpt_ServiceModule", Paralist, "ServiceModule - Report");
                    //if (objList.Exception == null)
                    //{
                    //dtReport.TableName = "ServiceModuleRegister";
                    //dtReport.WriteXmlSchema(@"D:\ServiceModuleRegister.xsd");
                    if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceVouchar.rpt"))
                    {
                        DataView DVReport;
                        DVReport           = dtblItem.DefaultView;
                        DVReport.RowFilter = StrFilter;
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptServiceVouchar.rpt");

                        CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Service Module", true, true, true, true, false, true, true, false, false, false, true);

                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Service Module - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("File is not exist...");
                    }
                    //}
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Service Module", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }

            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 37
0
        public byte[] RunReport(String reportName, String fileName, string travelRequestId)
        {
            byte[]         response         = null;
            ConnectionInfo crConnectionInFo = new ConnectionInfo();

            CrystalDecisions.CrystalReports.Engine.Tables crTables;
            TableLogOnInfo             crTableLogonInfo             = new TableLogOnInfo();
            DiskFileDestinationOptions crDiskFileDestinationOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions();
            ExportOptions crExportOptions = new CrystalDecisions.Shared.ExportOptions();

            CrystalDecisions.CrystalReports.Engine.ReportDocument dReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            String rptPath = System.Web.Hosting.HostingEnvironment.MapPath(System.Configuration.ConfigurationManager.AppSettings["rptPath"]);
            String fName   = fileName;

            dReport.Load(rptPath + reportName);

            dReport.SetParameterValue("p_travelrequestID", travelRequestId);
            if (reportName == "Travel_Business_Expense.rpt")
            {
                dReport.SetParameterValue("p_travelrequestID", travelRequestId);
            }


            string defaultConnectionString = ConfigurationManager.ConnectionStrings["CrystalReport"].ConnectionString;
            var    builder = new DbConnectionStringBuilder();

            builder.ConnectionString = defaultConnectionString;

            crConnectionInFo.DatabaseName = "";
            crConnectionInFo.ServerName   = builder["SERVICE_NAME"].ToString();
            crConnectionInFo.UserID       = builder["User ID"].ToString();
            crConnectionInFo.Password     = builder["Password"].ToString();



            crTables = dReport.Database.Tables;
            crTableLogonInfo.ConnectionInfo = crConnectionInFo;

            foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in crTables)
            {
                rTable.ApplyLogOnInfo(crTableLogonInfo);
            }
            foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subrpt in dReport.Subreports)
            {
                foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in subrpt.Database.Tables)
                {
                    rTable.ApplyLogOnInfo(crTableLogonInfo);
                }
            }

            try
            {
                var memoryStream = new MemoryStream();
                var data         = dReport.ExportToStream(ExportFormatType.PortableDocFormat);
                data.CopyTo(memoryStream);
                response = memoryStream.ToArray();


                if (File.Exists(rptPath + "Exported/" + fileName + ".pdf"))
                {
                    File.Delete(rptPath + "Exported/" + fileName + ".pdf");
                }
                FileStream file = new FileStream(rptPath + "Exported/" + fileName + ".pdf", FileMode.Create, FileAccess.ReadWrite);
                memoryStream.WriteTo(file);
                file.Close();
                file.Dispose();
                memoryStream.Close();
                memoryStream.Dispose();

                //File.WriteAllBytes(rptPath+"Exported/"+fileName+".pdf", response);
            }
            catch (Exception ex)
            {
                LogMessage.Log("Error generating crystal report : " + ex.Message);
                throw new Exception(ex.Message);
            }
            finally
            {
                dReport.Close();
                dReport.Dispose();
            }
            return(response);
        }
Ejemplo n.º 38
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
                culture.NumberFormat.CurrencySymbol = string.Empty;
                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                base.InitializeCulture();
                
                string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/Iva_Ventas.xsd");
                System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "Iva_Ventas.xsd", true);

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

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

                    if (formatoRptExportar == "PDF")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                    }
                    if (formatoRptExportar == "Excel")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.ExcelFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, Server.MapPath("~/TempExcel/") + sb.ToString() + ".xls");
                        
                        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                        response.ClearContent();
                        response.Clear();
                        response.ContentType = "application/vnd.ms-excel";
                        response.AddHeader("Content-Disposition", "attachment; filename=" + sb.ToString() + ".xls" + ";");
                        response.TransmitFile(Server.MapPath("~/TempExcel/" + sb.ToString() + ".xls"));
                        response.Flush();
                        response.End();  
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Trace.Warn("Thread abortado");
            }
            catch (Exception ex)
            {
                WebForms.Excepciones.Redireccionar(ex, "~/NotificacionDeExcepcion.aspx");
            }
        }
Ejemplo n.º 39
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// /// <param name="reportFormatType">檔案型態</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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


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

        #region 前置檢查與參數過濾

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

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

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

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

        #endregion


        #region 組合查詢條件至ArrayList

        ArrayList returnList = new ArrayList();

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

        #endregion

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

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

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


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


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


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

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

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

                break;
        }

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

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

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

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

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

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

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

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

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

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

                    dsReportes dsReporte = new dsReportes();

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

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

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

                    dsReporte.GuiaRemision.AddGuiaRemisionRow(drFilaGuiaRemision);

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

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

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

                        dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle);

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

                    string strRutaWeb = Request.ApplicationPath;

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

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

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

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

                    objGuiaRemisionDAO.Actualizar(objGuiaRemisionDTO);

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

                    dsReportes dsReporte = new dsReportes();

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

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

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

                    dsReporte.GuiaRemision.AddGuiaRemisionRow(drFilaGuiaRemision);

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

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

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

                        dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle);

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

                    string strRutaWeb = Request.ApplicationPath;

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

                }

            }
            catch (Exception ex)
            {
                this.lblMensaje.Text = ex.ToString();
            }
        }
Ejemplo n.º 41
0
        public static CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReportDocument(string documentName)
        {
            try
            {
                CrystalDecisions.CrystalReports.Engine.ReportDocument ret =
                   Feng.Utils.ReflectionHelper.CreateInstanceFromName(documentName) as CrystalDecisions.CrystalReports.Engine.ReportDocument;
                if (ret != null)
                    return ret;
            }
            catch (Exception)
            {
            }

            ResourceContent res = ResourceInfoHelper.ResolveResource(documentName, ResourceType.Report);
            if (res != null)
            {
                switch (res.Type)
                {
                    case ResourceContentType.File:
                        {
                            CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            reportDocument.Load(res.Content.ToString());
                            return reportDocument;
                        }
                    case ResourceContentType.Binary:
                        {
                            byte[] data = (byte[])res.Content;
                            string fileName = System.IO.Path.GetTempFileName();
                            using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create))
                            {
                                fs.Write(data, 0, data.Length);
                            }
                            CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            reportDocument.Load(fileName);
                            return reportDocument;
                        }
                    default:
                        throw new ArgumentException("Invalid Resource Content Type!");
                }
            }
            else
            {
                throw new ArgumentException(string.Format("Can't find resouce of {0}!", documentName));
            }
        }
Ejemplo n.º 42
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, App_Detail_C01_Info pDetail,
                                               List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppDocumentOthersInfo> pLstImagePublic)
        {
            try
            {
                string _datetimenow             = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language                 = AppsCommon.GetCurrentLang();
                List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>();

                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                }

                AppsCommon.Prepare_Data_Export_C01(ref pDetail, pInfo, pAppDocumentInfo, pLstImagePublic);
                if (pAppDocOtherInfo != null)
                {
                    foreach (var item in pAppDocOtherInfo)
                    {
                        pDetail.Note += item.Documentname + " ; ";
                    }

                    if (pAppDocOtherInfo.Count > 0)
                    {
                        pDetail.Note = pDetail.Note.Substring(0, pDetail.Note.Length - 2);
                    }
                }
                _lst.Add(pDetail);

                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false);
                //_ds_all.WriteXml(@"C:\inetpub\A01.xml", XmlWriteMode.WriteSchema);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "C01.rpt";
                if (language == Language.LangEN)
                {
                    _tempfile = "C01_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

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

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

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

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Ejemplo n.º 43
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="PickNo">揀貨單號</param>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="reportFormatType">檔案型態</param>
    /// <param name="ReportOrderOption">排序類型 "item":品項 "locate":儲位 </param>
    private void LoadCrystalReport(string PickNo, string s_FileName, string s_rptFilePath, string reportFormatType, string ReportOrderOption)
    {

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

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

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

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

                DataTable dtResult = new DataTable();

                string ProgName = "";

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

                DataView dv = new DataView(dtResult);

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

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

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

                report.SetDataSource(dv.ToTable());

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

            }
            else
            {
                DataTable dtResult = new DataTable();

                dtResult = BCO.GetPrintRpt03(ParameterList);

                report.SetDataSource(dtResult);

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

            switch (reportFormatType)
            {
                case "EXCEL":

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

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


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


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

                    break;
                case "PDF":


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

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

                    break;
            }

            report.Close();

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

    }
Ejemplo n.º 44
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            string strConnect = cn.GetConnectString();
            int    stt        = 0;

            //if (dgvPacking.Rows.Count > 0 && dgvPacking.Rows.Count <= 12 && txtNumber.Text != "") // && txtNgayXX.Text != "" ) // Kiểm tra điều kiện in
            if (dgvPacking.Rows.Count > 0 && dgvPacking.Rows.Count <= 12 && txtNumber.Text != "" && txtNgayXX.Text != "")  // Kiểm tra điều kiện in
            {
                if (pc.checkSplit(dgvPacking))
                {
                    string wh = this.getWarehouse();
                    if (pc.checkUser(Environment.UserName, wh)) //Check user have permission on warehouse
                    {
                        if (dp.isUserWHInvoiceMandatoryValid(Environment.UserName, wh, this.getSalesOrder(), strConnect))
                        {
                            //MessageBox.Show(dgvPacking.Rows[0].Cells["Date"].Value.ToString());
                            //string cmd;
                            DataSet   ds = new DataSet();
                            DataTable tb = new DataTable();
                            int       id;
                            string    SalesId;
                            string    cust = dgvPacking.Rows[0].Cells["CUST"].Value.ToString();
                            //int num = 0;
                            string PackingId = pc.getPackingByList(pc.getPackingByDatagridview(dgvPacking));
                            //MessageBox.Show(PackingId);
                            tb.Columns.Add("STT");      //Số thứ tự
                            tb.Columns.Add("ITEM");     //Mã Item
                            tb.Columns.Add("NAME");     //Tên Item
                            tb.Columns.Add("QTY");      //Số lượng
                            tb.Columns.Add("UOM");      //Don vi
                            tb.Columns.Add("BATCH");    //Số lô
                            //tb.Columns.Add("DATE");   //Ngày giao
                            foreach (DataGridViewRow dr in dgvPacking.Rows)
                            {
                                string batchStr = "";
                                string Qty      = dr.Cells["QTY"].Value.ToString();
                                stt += 1;
                                string[] qty   = pc.processQty(dr.Cells["EDITQTY"].Value.ToString());
                                string[] batch = pc.processBatch(dr.Cells["BATCH"].Value.ToString());
                                //Neu tach so luong
                                //if (dr.Cells["BATCH"].Value.ToString() != "" &&  batch.Length ==  qty.Length)
                                if (dr.Cells["EDITQTY"].Value.ToString() != "" && batch.Length == qty.Length)
                                {
                                    for (int i = 0; i < qty.Length; i++)
                                    {
                                        if (batchStr.Length != 0)
                                        {
                                            batchStr += ",Số lượng:" + qty[i] + "-" + "Số lô:" + batch[i];
                                        }
                                        else
                                        {
                                            batchStr += "Số lượng:" + qty[i] + "-" + "Số lô:" + batch[i];
                                        }
                                    }
                                }
                                if (dr.Cells["EDITQTY"].Value.ToString() == "" && batch.Length == qty.Length)
                                {
                                    batchStr = dr.Cells["BATCH"].Value.ToString();
                                }

                                //tb.Rows.Add(stt, dr.Cells["ITEMID"].Value, dr.Cells["NAME"].Value, Qty, dr.Cells["UNIT"].Value, batchStr, dr.Cells["DATE"].Value);
                                tb.Rows.Add(stt, dr.Cells["ITEMID"].Value, dr.Cells["NAME"].Value, Qty, dr.Cells["UNIT"].Value, batchStr);// Bỏ ngày giao
                            }
                            ds.Tables.Add(tb);
                            id      = dp.getId(strConnect) + 1;
                            SalesId = dgvPacking.Rows[0].Cells["SALESID"].Value.ToString();
                            //INSERT HEADER
                            dp.InsertNumberByStore("InsertNumber_VTIREPORT", id, strConnect, SalesId, PackingId, wh, txtNumber.Text, txtCTrinh.Text, txtDonVi.Text, txtDiaChi.Text, txtNgayXX.Text);
                            //INSERT LINE
                            foreach (DataGridViewRow dr in dgvPacking.Rows)
                            {
                                dp.InsertNumberLinesByStore("InsertNumberLines_VTIREPORT", strConnect, id, SalesId, dr.Cells["PACKINGSLIPID"].Value.ToString(), dr.Cells["WAREHOUSE"].Value.ToString()
                                                            , dr.Cells["ItemId"].Value.ToString(), dr.Cells["Name"].Value.ToString(), dr.Cells["ORDERQTY"].Value.ToString()
                                                            , Double.Parse(dr.Cells["QTY"].Value.ToString()), dr.Cells["UNIT"].Value.ToString(), dr.Cells["EDITQTY"].Value.ToString(), dr.Cells["BATCH"].Value.ToString()
                                                            , dr.Cells["DATE"].Value.ToString(), "", dr.Cells["INVOICEACCOUNT"].Value.ToString(), dr.Cells["CUST"].Value.ToString());
                            }
                            cryCNXX cnxx = new cryCNXX();

                            //USER PATTERN
                            CrystalDecisions.CrystalReports.Engine.ReportDocument crys = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            string path = Application.StartupPath + "\\Report\\cryCNXX.rpt";
                            ////MessageBox.Show(path);
                            crys.Load(path);
                            //cryCNXX cnn2 =
                            crys.SetDataSource(ds);
                            crys.SetParameterValue("SoPhieu", txtNumber.Text);
                            crys.SetParameterValue("Cust", cust);
                            crys.SetParameterValue("CTrinh", txtCTrinh.Text);
                            crys.SetParameterValue("DiaChi", txtDiaChi.Text);
                            crys.SetParameterValue("DVThiCong", txtDonVi.Text);
                            //crys.SetParameterValue("Date", DateTime.Now.ToString("dd/MM/yyyy"));
                            crys.SetParameterValue("Date", txtNgayXX.Text);   //Ngày xuất xưởng

                            //crys.SetParameterValue("Num", num.ToString() + "/" + DateTime.Now.ToString("MM") + DateTime.Now.ToString("yy") + "-HT");
                            // crys.SetParameterValue("PackingId", txtPackId.Text);
                            //crys.SetParameterValue("PackingId", PackingId);
                            //
                            frCNXXView view = new frCNXXView(crys);

                            view.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("User " + Environment.UserName + " không có quyền in Sales Order chưa Invoiced." + this.getSalesOrder());
                        }
                    }
                    else
                    {
                        MessageBox.Show("User " + Environment.UserName + " không có quyền in Chứng Nhận Xuất Xưởng trên kho. " + wh);
                    }
                }
                else
                {
                    MessageBox.Show("Kiểm tra lại tổng số lượng trên cột EditQty");
                }
            }
            else
            {
                MessageBox.Show("Kiểm tra lại dữ liệu, số dòng phải < 12 ,nhập số phiếu  và ngày cấp CNXX !");
            }
        }
Ejemplo n.º 45
0
    //Crystal Report 直接輸出 PDF 檔
    private void ExportReport(DataTable dt)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

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

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

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

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

    }
Ejemplo n.º 46
0
        private void Guia()
        {
            dsReportes dsReporte = new dsReportes();

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

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

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

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

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

            dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle1);

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

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

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

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

                dsReporte.GuiaRemisionDetalle.AddGuiaRemisionDetalleRow(drFilaGuiaRemisionDetalle3);
            }

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

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

            //dsReporte.OrdenCompra.AddOrdenCompraRow(dsFilaOrdenCompra);

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

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

            //    dsReporte.OrdenCompraLineas.AddOrdenCompraLineasRow(drFilaOrdenCompraLinea);

            //}

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

            string strRutaWeb = Request.ApplicationPath;

            Response.Write("<script language='javascript'>window.open('frmVisorReporte.aspx" + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            //Response.Write("<script language='javascript'>window.open('" + strRutaWeb + "frmOrdenCompraImpresion.aspx?id=" + IdOrdenCompra.ToString() + "','ventana','scrollbars=1,resizable=1,width=800,height=600,left=20,top=0');</script>");
            //Response.Write("<script language='javascript'>JS_openWindow('" + strRutaWeb + "frmOrdenCompraImpresion.aspx?id=" + IdOrdenCompra.ToString() + "','Reporte','600','300','no', 'no', 'no', 'no', 'no');</script>");
        }
Ejemplo n.º 47
0
        public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate)
        {
            try
            {
                string language = AppsCommon.GetCurrentLang();

                App_Detail_C01_BL            objBL = new App_Detail_C01_BL();
                ApplicationHeaderInfo        applicationHeaderInfo  = new ApplicationHeaderInfo();
                App_Detail_C01_Info          app_Detail             = new App_Detail_C01_Info();
                List <AppFeeFixInfo>         appFeeFixInfos         = new List <AppFeeFixInfo>();
                List <AppDocumentInfo>       appDocumentInfos       = new List <AppDocumentInfo>();
                List <AppDocumentOthersInfo> _LstDocumentOthersInfo = new List <AppDocumentOthersInfo>();
                List <AppDocumentOthersInfo> pLstImagePublic        = new List <AppDocumentOthersInfo>();

                app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos, ref _LstDocumentOthersInfo, ref pLstImagePublic);

                AppsCommon.Prepare_Data_Export_C01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, pLstImagePublic);

                if (_LstDocumentOthersInfo != null)
                {
                    foreach (var item in _LstDocumentOthersInfo)
                    {
                        app_Detail.Note += item.Documentname + " ; ";
                    }

                    if (_LstDocumentOthersInfo.Count > 0)
                    {
                        app_Detail.Note = app_Detail.Note.Substring(0, app_Detail.Note.Length - 2);
                    }
                }

                List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>();
                _lst.Add(app_Detail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string _tempfile    = "C01.rpt";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                if (p_View_Translate == 1)
                {
                    // nếu là tiếng việt thì xem bản tiếng anh và ngược lại
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        _tempfile    = "C01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                    }
                }
                else
                {
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "C01_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf";
                    }
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table";
                    //_ds_all.WriteXml(@"C:\inetpub\C01.xml", XmlWriteMode.WriteSchema);

                    // đè các bản dịch lên
                    if (p_View_Translate == 1)
                    {
                        // nếu là bản xem của thằng dịch
                        App_Translate_BL          _App_Translate_BL = new App_Translate_BL();
                        List <App_Translate_Info> _lst_translate    = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId);

                        AppsCommon.Overwrite_DataSouce_Export(ref _ds_all, _lst_translate);
                    }

                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

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


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

                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Ejemplo n.º 48
0
    private string generatefiles(DataSet ds, string FirstPath, DataTable mailsetting)
    {
        try
        {
            DataView dvmaster        = new DataView(ds.Tables[0]);
            DataView dv              = new DataView(ds.Tables[1]);
            string   strAttachFirst  = string.Empty;
            string   strAttachSecond = string.Empty;


            bool isSendData = false;
            System.Collections.ArrayList objList = new ArrayList();
            CrystalDecisions.CrystalReports.Engine.ReportDocument crystalReport;
            objList.Add(MailSetting(mailsetting));
            XmlDocument doc   = new XmlDocument();
            XmlNode     inode = doc.CreateElement("f");
            XmlNode     fnode = doc.CreateElement("r");

            foreach (DataRow Row in ds.Tables[0].Rows)
            {
                MailDetails objMails = new MailDetails();
                dv.RowFilter       = "SubDocId = " + Row["subdocno"].ToString();
                dvmaster.RowFilter = "subdocno = " + Row["subdocno"].ToString();
                crystalReport      = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                crystalReport.Load(Server.MapPath("../Report/PrintInvoiceMM.rpt"));
                crystalReport.SetDataSource(dv);
                isSendData     = dv.ToTable().Rows.Count > 0 ? true : false;
                strAttachFirst = Server.MapPath(FirstPath + dvmaster[0]["CustCode"] + "-" + dvmaster[0]["subdocno"] + ".pdf");
                crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, strAttachFirst);
                crystalReport.Close();
                crystalReport.Dispose();
                crystalReport       = null;
                objMails.Attachment = strAttachSecond != "" ? strAttachFirst + "," + strAttachSecond : strAttachFirst;
                objMails.Name       = dvmaster[0]["CustName"].ToString();
                objMails.EmailId    = Row["EmailID"].ToString();
                string makesubject = dvmaster[0]["subject"].ToString();
                objMails.Subject = makesubject;
                objMails.Desc    = Row["msg"].ToString();

                XmlNode element = doc.CreateElement("i");

                inode           = doc.CreateElement("subdoc");
                inode.InnerText = Row["subdocno"].ToString();
                element.AppendChild(inode);

                inode           = doc.CreateElement("fyu");
                inode.InnerText = Row["FY"].ToString();
                element.AppendChild(inode);

                inode           = doc.CreateElement("mod");
                inode.InnerText = Row["module"].ToString();
                element.AppendChild(inode);

                fnode.AppendChild(element);

                if (isSendData)
                {
                    objList.Add(objMails);
                }
                objMails = null;
            }
            Other_Z.OtherBAL ObjBal = new Other_Z.OtherBAL();
            ObjBal.UpdateEmailLog(fnode.OuterXml, "", "", "");
            return(JsonConvert.SerializeObject(objList));
        }
        catch (Exception ex)
        {
            throw;
        }
    }
Ejemplo n.º 49
0
    protected void RaporOlustur(string Format)
    {
        EFDal ed = new EFDal();

        report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        string RaporAdi = Request["RaporAdi"].ToString() + ".rpt";
        //string RaporAd = Server.MapPath("..\\..\\Rapor\\" + RaporAdi);
        string RaporAd = Server.MapPath("Rapor\\" + RaporAdi);

        report.Load(RaporAd);


        if (RaporAdi == "SertifikaKapak.rpt")//turkak
        {
            //100476479
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString());
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            //report.SetParameterValue("Url", "Url");

            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
        }

        if (RaporAdi == "SertifikaKapakTSE.rpt")//tse
        {
            //100476479
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            //report.SetParameterValue("Url", "Url");
        }



        if (RaporAdi == "SertifikaKapakEImza.rpt")//turkak
        {
            //100476479
            QRCodeOlustur();
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString());
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            report.SetParameterValue("Url", Session["qrCodeURL"].ToString());

            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
        }

        if (RaporAdi == "SertifikaKapakTSEEImza.rpt")//tse
        {
            //100476479
            QRCodeOlustur();
            report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString());
            report.SetParameterValue("@IstID", Request["IstId"].ToString());
            report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", ""));
            report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString());
            Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString();
            //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur());
            report.SetParameterValue("Url", Session["qrCodeURL"].ToString());
        }

        if (RaporAdi == "CihazKayit.rpt")
        {
            //report.SetParameterValue("Sifre", "bakalim");
            string IstekNo   = Request["IstekNo"].ToString();
            int    BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            int    Yil       = int.Parse(Request["Yil"].ToString());
            int    FirmaId   = int.Parse(Request["FirmaId"].ToString());

            report.RecordSelectionFormula = "{vCihazKabul.SILINDI}=false and {vCihazKabul.ISTEKNO}=" + IstekNo + " and {vCihazKabul.BOLGEKODU}=" + BolgeKodu.ToString() + " and {vCihazKabul.YIL}=" + Yil.ToString() + " and {vCihazKabul.FIRMAID}=" + FirmaId.ToString();
            //report.RecordSelectionFormula = "{vCihazKabul.YIL}=9 and {vCihazKabul.ISTEKNO}=549 and {vCihazKabul.BOLGEKODU}=2";
        }

        if (RaporAdi == "GorevOluru.rpt")
        {
            string GorevId = Request["GorevId"].ToString();
            //report.RecordSelectionFormula = "{GorevPersonel.GorevID}=" + GorevId ;
            report.SetParameterValue("AracPlakasi", Session["RaporIcinAracPlakasi"].ToString());
            report.SetParameterValue("GorevId", GorevId);
            Session.Remove("RaporIcinAracPlakasi");
        }
        if (RaporAdi == "TeklifYeni.rpt")
        {
            lblUyari.Visible = false;
            int    BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string TeklifNo  = Request["TeklifNo"].ToString();
            string Telefon   = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);
            if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis
            {
                lblUyari.Text    = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz..";
                lblUyari.Visible = true;
                return;
            }
            else
            {
                report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
                //report.SetParameterValue("KurumTipi", "Kamu");
                //report.SetParameterValue("Telefon", "4545");
            }
        }
        if (RaporAdi == "TeklifYeniIndirimli.rpt")
        {
            lblUyari.Visible = false;
            int     BolgeKodu    = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string  TeklifNo     = Request["TeklifNo"].ToString();
            string  Telefon      = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);
            decimal IndirimOrani = 0;
            if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis
            {
                lblUyari.Text    = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz..";
                lblUyari.Visible = true;
                return;
            }
            else
            {
                report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
                using (Service1Client client = new Service1Client())
                {
                    IndirimOrani = client.TeklifNodanIndirimOraniniDon(BolgeKodu, TeklifNo);
                }
                report.SetParameterValue("IndirimOrani", IndirimOrani);
                //report.SetParameterValue("Telefon", "4545");
            }
        }
        if (RaporAdi == "TeklifYeniOnYazisiz.rpt")
        {
            int    BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            string TeklifNo  = Request["TeklifNo"].ToString();
            string Telefon   = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu);

            report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + "  and {birim.NEICIN}='teklif'";
            report.SetParameterValue("KurumTipi", "Kamu");
            report.SetParameterValue("Telefon", Telefon);
        }

        if (RaporAdi == "FaturaOnYaziDetayli.rpt")
        {
            report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString());
            report.SetParameterValue("PaketNolari", Session["FaturaOnYaziIcinVirgulleAyrilmisPaketNolar"].ToString());
            report.SetParameterValue("PaketBedelleri", decimal.Parse(Session["PaketBedelleri"].ToString()));
            report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "H");
            if (Session["PaketKapsamindaOlmayanlariGizle"] == "E")
            {
                report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "E");
                Session["PaketKapsamindaOlmayanlariGizle"] = null;
            }
        }
        if (RaporAdi == "FaturaOnYazi.rpt")
        {
            report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString());
            report.SetParameterValue("MasrafIncelemeUcreti", Session["DetaysizMasrafIncelemeUcreti"].ToString());
            report.SetParameterValue("PostaHavale", Session["DetaysizPostaBedeli"].ToString());

            /*
             * DataSet ds=new DataSet();
             * ds=ed.Sorgula("SELECT  top 1   dbo.firma.MUSTNO, dbo.firma.FIRMAADI, dbo.firma.ADRESI, dbo.firma.ADRESII, dbo.firma.IL_ILCE, dbo.firma.TELEFON, dbo.firma.FAX, dbo.firma.ILGILI, "+
             *        " dbo.firma.EMAIL, dbo.firma.NOTLAR, dbo.firma.FATADRES, dbo.firma.VERGIDAIRESI, dbo.firma.VERGINO, dbo.firma.BOLGEKODU, dbo.firma.SILINDI, "+
             *        " dbo.istek.FIRMAID, dbo.istek.YIL, dbo.istek.ISTEKNO, dbo.istek.ALTISTNO, dbo.istek.CIHAZADI, dbo.istek.IMALATCI, dbo.istek.MODEL, dbo.istek.SERINO, "+
             *        " dbo.istek.OLCUMARALIGI, dbo.istek.ILGLAB, dbo.istek.SORUMLU, dbo.istek.FATBEDEL, dbo.istek.IPTAL, dbo.istek.BOLGEKODU AS isBolgeKodu, dbo.istek.SILINDI AS isSilindi, "+
             *        " dbo.istek.FATURASIRA, dbo.istek.CIHAZKAPSAMAYRINTITABLOSU, dbo.FaturaOnYazi.ID, dbo.FaturaOnYazi.ISTID, dbo.FaturaOnYazi.BOLGEKODU AS FoyBolgeKodu, "+
             *        " dbo.FaturaOnYazi.Silindi AS foySilindi, dbo.FaturaOnYazi.FATURANO, dbo.FaturaOnYazi.GUNLUKSIRA,dbo.FaturaOnYazi.EkBolgemi "+
             *          " FROM         dbo.istek INNER JOIN "+
             *        " dbo.firma ON dbo.istek.FIRMAID = dbo.firma.FIRMAID INNER JOIN "+
             *        " dbo.FaturaOnYazi ON dbo.istek.ISTID = dbo.FaturaOnYazi.ISTID "+
             *        " where FaturaOnYazi.ISTID in ("+Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString() +")");
             *
             * report.SetDataSource(ds);
             */
        }
        if (RaporAdi == "FaturaOnYaziYeni.rpt")
        {
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);
            report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
            report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
            using (Service1Client proxy = new Service1Client())
            {
                decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal PostaBedeli          = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
                report.SetParameterValue("PostaBedeli", PostaBedeli);
                report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);

                /*
                 * //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise
                 * if (EkBolgeUcretiToplami == 0)
                 * {
                 *  report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false);
                 * }
                 */
                Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null;
            }
        }
        //if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        //{
        //    int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);

        //    using (Service1Client proxy = new Service1Client())
        //    {
        //        decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
        //        decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString());

        //        report.SetParameterValue("YurtDisindanmi", false);
        //        report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
        //        report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());

        //        report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);
        //        report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
        //        report.SetParameterValue("PostaBedeli", PostaBedeli);

        //        report.SetParameterValue("IndirimOrani", IndirimOrani);

        //        /*
        //        //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise
        //        if (EkBolgeUcretiToplami == 0)
        //        {
        //            report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false);
        //        }
        //         */

        //    }
        //}


        if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        {
            int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name);


            using (Service1Client proxy = new Service1Client())
            {
                //decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal MasrafIncelemeUcreti = ed.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal PostaBedeli          = ed.FaturaNoIcinIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                decimal IndirimOrani         = decimal.Parse(Request["IndirimOrani"].ToString());
                report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString());
                report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString());
                report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti);
                report.SetParameterValue("PostaBedeli", PostaBedeli);
                report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami);
                report.SetParameterValue("IndirimOrani", IndirimOrani);
                report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString(), "MasrafveInceleme");
                report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString(), "MasrafveInceleme");
            }
        }


        if (RaporAdi == "FirmaEtiketi.rpt")
        {
            report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString());
            report.SetParameterValue("FirmaId", Request["FirmaId"].ToString());
        }
        if (RaporAdi == "EgitimSertifikasi.rpt")
        {
            int EgtBolgeKodu = 0;
            report.SetParameterValue("@EgitimId", Request["EgitimId"].ToString());
            using (Service1Client proxy = new Service1Client())
            {
                //report.SetParameterValue("EgitimiVerenler", proxy.EgitimiVerenlerinIsimleriniVirgulleAyrilmisOlarakDon(int.Parse(Request["EgitimId"].ToString())));
                report.SetParameterValue("EgitimiVerenler", ed.kal_BelirliEgitimiVerenListesiDon2(int.Parse(Request["EgitimId"].ToString())));


                report.SetParameterValue("EgitimAdi", proxy.EgitimIddenEgitimAdiDon(int.Parse(Request["EgitimId"].ToString())));
                using (Service1Client proxyy = new Service1Client())
                {
                    EgtBolgeKodu = proxyy.BolgeKoduDon(Context.User.Identity.Name);
                }
                if (EgtBolgeKodu == 1)//Gebze
                {
                    report.SetParameterValue("ImzaAd", "Ali Can Kuyrukluyıldız");
                    report.SetParameterValue("ImzaStatu", "Gebze Kalibrasyon Müdürü");
                }
                if (EgtBolgeKodu == 2)//Ankara
                {
                    report.SetParameterValue("ImzaAd", "Abdulmuttalip Aktoğ");
                    report.SetParameterValue("ImzaStatu", "Kalibrasyon Grup Başkanı");
                }
                if (EgtBolgeKodu == 3)//Bursa
                {
                    report.SetParameterValue("ImzaAd", "Ömer EYYUPOĞLU");
                    report.SetParameterValue("ImzaStatu", "Bursa İl Koordinatörü");
                }
            }
        }
        SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();

        sb.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["KalData"].ToString();
        CrystalDecisions.Shared.TableLogOnInfo tliCurrent;
        foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in report.Database.Tables)
        {
            tliCurrent = tbl.LogOnInfo;
            tliCurrent.ConnectionInfo.ServerName   = sb.DataSource;
            tliCurrent.ConnectionInfo.UserID       = sb.UserID;
            tliCurrent.ConnectionInfo.Password     = sb.Password;
            tliCurrent.ConnectionInfo.DatabaseName = sb.InitialCatalog;
            tbl.ApplyLogOnInfo(tliCurrent);
        }
        if (Format == "PDF")
        {
            if (Session["eImzaliOlacak"] == null)
            {
                this.ExportReportPdfEImzaYok();
            }
            else
            {
                this.ExportReportPdf();
            }
        }
        if (Format == "Word")
        {
            this.ExportReportWord();
        }

        CrystalReportViewer1.ReportSource = report;

        //Rapor üretildikten hemen sonra faturalandırılan istekler tablosuna yaz
        if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt")
        {
            using (Service1Client proxy = new Service1Client())
            {
                Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null;
                string[] IstIdler = (string[])Session["FaturalandirildiOlarakIsaretlenecekIstIdler"];
                foreach (var item in IstIdler)
                {
                    try
                    {
                        proxy.FaturalandirilanIsteklereEkle(int.Parse(item));
                    }
                    catch
                    {
                        //RadNotification1.Text = " <font color='red'> "+item +" istekId li cihaz faturası yazılanlar tablosuna eklenemedi! Bu, cihazın birden fazla faturalandırılmasına yol acabilir. Lütfen istekId sini not alip sistem yöneticisine bildiriniz.</font>"; ;
                        // RadNotification1.Show();
                    }
                }
            }
        }
    }
Ejemplo n.º 50
0
    /// <summary>
    /// 利用 CrystalReport 列印報表
    /// </summary>
    /// <param name="s_FileName">報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="reportFormatType">檔案型態</param> 
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source1, DataTable dt_Source2, string reportFormatType)
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

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

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

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

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

                break;
        }
        #endregion
    }
Ejemplo n.º 51
0
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     Caja caja = new Caja(Globales.IdCaja);
     string logo=string.Empty;
     if (!caja.IsNull())
         logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
     caja = null;
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpt.Load("Reportes\\Historial.rpt");
     rpt.SetDataSource((DataTable)this.dgvPrestamos.DataSource);
     rpt.SetParameterValue("NoPrestamo", cbxPrestamo.SelectedValue.ToString());
     rpt.SetParameterValue("Cliente", cbxCliente.Text);
     rpt.SetParameterValue("Capital", tbxCapital.Value);
     rpt.SetParameterValue("PagoMinimo", tbxPago.Value);
     rpt.SetParameterValue("FechaCorte", dtpFecha.Value);
     rpt.SetParameterValue("Estatus", cbxEstatus.Text);
     rpt.SetParameterValue("Logo", logo);
     frmReporte frm = new frmReporte(rpt);
     frm.ShowDialog();
     rpt.Dispose();
     rpt = null;
     frm.Dispose();
     frm = null;
 }
        public ActionResult ExportDataNew(ApplicationHeaderInfo pInfo, AppTM06DKQTInfoExport pDetail, List <AppDocumentInfo> pAppDocumentInfo,
                                          List <AppClassDetailInfo> pAppClassInfo)
        {
            try
            {
                //  AppTM06DKQTInfoExport pDetail= new AppTM06DKQTInfoExport();
                string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/C06_Request for_international_trademark_registration_vi_exp.doc");

                // Fill export_header
                string fileName = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C06_Request_for_international_trademark_registration_vi_exp_" + pInfo.Appcode + ".pdf");
                // Fill export_detail
                pDetail.Status        = 254;
                pDetail.Status_Form   = 252;
                pDetail.Relationship  = "11";
                pDetail.strNgayNopDon = pDetail.NGAYNOPDON.ToDateStringN0();
                if (pDetail.REF_APPNO_TEXT != null)
                {
                    pDetail.REF_APPNO_TEXT = pDetail.REF_APPNO_TEXT.Trim();
                }
                pDetail = CreateInstanceTM06DKQT.CopyAppHeaderInfo(pDetail, pInfo);

                if (pAppClassInfo != null)
                {
                    Hashtable _hsGroupclass = new Hashtable();
                    foreach (var item in pAppClassInfo)
                    {
                        AppClassDetailInfo _newinfo = new AppClassDetailInfo();
                        _newinfo.CloneObj();
                        if (_hsGroupclass.ContainsKey(item.Code.Substring(0, 2)))
                        {
                            _newinfo = (AppClassDetailInfo)_hsGroupclass[item.Code.Substring(0, 2)];
                        }
                        _newinfo.Code       = item.Code;
                        _newinfo.Textinput += item.Textinput + ", ";
                        _newinfo.IntTongSanPham++;
                        _hsGroupclass[item.Code.Substring(0, 2)] = _newinfo;
                    }
                    List <AppClassDetailInfo> _listApp = new List <AppClassDetailInfo>();
                    foreach (DictionaryEntry item in _hsGroupclass)
                    {
                        _listApp.Add((AppClassDetailInfo)item.Value);
                    }
                    foreach (AppClassDetailInfo item in _listApp.OrderBy(m => m.Code))
                    {
                        pDetail.strListClass += "Nhóm " + item.Code.Substring(0, 2) + ": " + item.Textinput.Trim().Trim(',') + " (" + (item.IntTongSanPham < 10 ? "0" + item.IntTongSanPham.ToString() : item.IntTongSanPham.ToString()) + " sản phẩm)" + "\n";
                    }
                }

                // đẩy file lên server
                if (pDetail.pfileLogo != null)
                {
                    pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo);
                }

                if (!string.IsNullOrEmpty(pDetail.LOGOURL))
                {
                    //Kết xuất ảnh
                }

                #region hiển thị tài liệu đính kèm
                if (pAppDocumentInfo == null)
                {
                    pAppDocumentInfo = new List <AppDocumentInfo>();
                }
                foreach (AppDocumentInfo item in pAppDocumentInfo)
                {
                    if (item.Document_Id == "C06DKQT_D_01")
                    {
                        pDetail.TOKHAI_USED    = item.Isuse.ToString();
                        pDetail.TOKHAI_SOTRANG = item.CHAR01;
                        pDetail.TOKHAI_SOBAN   = item.CHAR02;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_02")
                    {
                        pDetail.MAUDK_VPQT_USED    = item.Isuse.ToString();
                        pDetail.MAUDK_VPQT_SO      = item.CHAR01;
                        pDetail.MAUDK_VPQT_NGONNGU = item.CHAR02;
                        pDetail.MAUDK_VPQT_SOTRANG = item.CHAR03;
                        pDetail.MAUDK_VPQT_SOBAN   = item.CHAR04;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_03")
                    {
                        pDetail.MAUNDH_USED  = item.Isuse.ToString();
                        pDetail.MAUNDH_SOMAU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_04")
                    {
                        pDetail.BANSAO_TOKHAI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_05")
                    {
                        pDetail.BANSAO_GIAYDK_NHCS_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_06")
                    {
                        pDetail.BAN_CK_SD_NGANHANG_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_07")
                    {
                        pDetail.GIAY_UQ_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_NGONNGU = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_08")
                    {
                        pDetail.GIAY_UQ_BANDICH_USED    = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANDICH_SOTRANG = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_09")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANGOC_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_010")
                    {
                        pDetail.GIAY_UQ_BANDICH_BANSAO_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_011")
                    {
                        pDetail.GIAY_UQ_BANGOCNOPSAU_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_012")
                    {
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO_USED = item.Isuse.ToString();
                        pDetail.GIAY_UQ_BANGOCNOP_THEOSO      = item.CHAR01;
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_013")
                    {
                        pDetail.CHUNGTU_LEPHI_USED = item.Isuse.ToString();
                        continue;
                    }
                    if (item.Document_Id == "C06DKQT_D_014")
                    {
                        pDetail.TAILIEUBOSUNG_USED = item.Isuse.ToString();
                        pDetail.TAILIEUBOSUNG      = item.CHAR01;
                        continue;
                    }
                }

                #endregion
                List <AppFeeFixInfo> pFeeFixInfo = CommonFunction.Call_Fee.CallFee_C06(pDetail);
                pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount;
                if (pInfo.Languague_Code == Language.LangEN)
                {
                    pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount_Usd;
                }
                List <AppTM06DKQTInfoExport> _lst = new List <AppTM06DKQTInfoExport>();
                pDetail.LOGOURL = Server.MapPath(pDetail.LOGOURL);
                _lst.Add(pDetail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <AppTM06DKQTInfoExport>(_lst, false);

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                string _tempfile = "C06.rpt";
                //if(AppsCommon.GetCurrentLang() == Language.LangEN)
                if (pInfo.Languague_Code != Language.LangVI)
                {
                    _tempfile = "C06.rpt";
                }

                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile), OpenReportMethod.OpenReportByTempCopy);

                //   _ds_all.WriteXmlSchema(@"C:\Users\user\Desktop\LEGALTECH\XMLFILE\TM06DKQT.xml");
                //Logger.LogInfo("b3: ");
                CrystalDecisions.CrystalReports.Engine.PictureObject _pic01;
                _pic01        = (CrystalDecisions.CrystalReports.Engine.PictureObject)oRpt.ReportDefinition.Sections[0].ReportObjects["Picture1"];
                _pic01.Width  = 200;
                _pic01.Height = 200;

                System.IO.FileInfo file = new System.IO.FileInfo(pDetail.LOGOURL);
                Bitmap             img  = new Bitmap(pDetail.LOGOURL);
                try
                {
                    double _Const = 6.666666666666 / 2;
                    int    _left = 0, _top = 0, _marginleft = 225, _margintop = 5580;
                    int    _h  = 600;
                    double _d1 = (_h - img.Width) / 2;
                    _d1   = _Const * _d1;
                    _left = _marginleft + Convert.ToInt32(_d1);
                    if (_left < 0)
                    {
                        _left = _marginleft;
                    }
                    _pic01.Left = _left;
                    // top

                    _d1  = (_h - img.Height) / 2;
                    _d1  = _Const * _d1;
                    _top = _margintop + Convert.ToInt32(_d1);
                    if (_top < 0)
                    {
                        _top = _margintop;
                    }
                    _pic01.Top = _top;
                }
                catch (Exception)
                {
                }
                finally
                {
                    img.Dispose();
                }

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

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

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


                return(Json(new { success = 0 }));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(Json(new { success = 0 }));
            }
        }
Ejemplo n.º 53
0
    //Crystal Report 直接輸出 PDF 檔
    private void ExportReport(DataTable dt, ReportType RType)
    {
        string strFileName = string.Empty;
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

        report.SetDataSource(dt);

        //CrystalReport Parameter 參數設定        

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

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

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

        strFileName = "在途單";

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

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

    }
Ejemplo n.º 54
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");

            culture.NumberFormat.CurrencySymbol = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture   = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            base.InitializeCulture();

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

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

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

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

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

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

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

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

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

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

                    CrystalDecisions.Shared.ExportOptions           exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: " + ex.Message + " " + ex.StackTrace);
                    throw new Exception(ex.Message);
                    //WebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepciones.aspx");
                }
            }
        }
Ejemplo n.º 55
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    DataTable dtReport = new DataTable();
                    dtReport = objList.ListOfRecord("rpt_CustomerReceipt", null, "CustomerPayment - Report");

                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptCustomerPaymentRegister.rpt"))
                        {
                            //ObjDataTable.TableName = "PaymentRegister";
                            //ObjDataTable.WriteXmlSchema(@"D:\PaymentRegister.xsd");
                            DataView DVReport;
                            DVReport           = ObjDataTable.DefaultView;
                            DVReport.RowFilter = StrFilter;
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptCustomerPaymentRegister.rpt");

                            CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Customer Payment Register", true, true, true, true, false, true, true, false, false, false, true);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Customer Payment Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Customer Payment - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            else if (cmbreports.SelectedIndex == 2)
            {
                try
                {
                    DataTable           dtReport = new DataTable();
                    NameValueCollection PARA1    = new NameValueCollection();
                    PARA1.Add("@i_ReceiptID", dgvCustomerPayment.CurrentRow.Cells["ReceiptID"].Value.ToString());
                    dtReport = objList.ListOfRecord("rpt_Customer_Payment_Receipt", PARA1, "CustomerPayment - Report");
                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptCustomerPendingPaymentReceipt.rpt"))
                        {
                            //dtReport.TableName = "PaymentReceipt";
                            //dtReport.WriteXmlSchema(@"D:\PaymentReceipt.xsd");
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptCustomerPendingPaymentReceipt.rpt");

                            CurrentUser.AddReportParameters(rptDoc, dtReport, "Payment Receipt", true, true, true, true, false, true, true, false, false, false, true);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Payment Receipt - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Customer Payment - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 56
0
        private void cmbreports_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbreports.SelectedIndex == 1)
            {
                try
                {
                    NameValueCollection para = new NameValueCollection();
                    para.Add("@i_CompId", CurrentCompany.CompId.ToString());
                    para.Add("@i_UserID", CurrentUser.UserID.ToString());
                    DataTable dtReport = new DataTable();

                    dtReport = objList.ListOfRecord("rpt_VendorPayment", para, "VendorPayment - Report");
                    if (objList.Exception == null)
                    {
                        if (System.IO.File.Exists(CurrentUser.ReportPath + "rptVendorPaymentRegister.rpt"))
                        {
                            //dtblPurchaseInvoice .TableName = "PORegister";
                            //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd");
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptVendorPaymentRegister.rpt");

                            CurrentUser.AddReportParameters(rptDoc, dtReport, "Vendor Payment Register", true, true, true, true, false, true, true, false, false, false, false);

                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Vendor Payment Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("File is not exist...");
                        }
                    }
                    else
                    {
                        MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception exc)
                {
                    Utill.Common.ExceptionLogger.writeException("Customer Payment - Register Report", exc.StackTrace);
                    MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
                }
            }
            //else if (cmbreports.SelectedIndex == 2)
            //{
            //    try
            //    {
            //        DataTable dtReport = new DataTable();
            //        NameValueCollection PARA1 = new NameValueCollection();
            //        PARA1.Add("@i_ReceiptID", dgvContacts.CurrentRow.Cells["ReceiptID"].Value.ToString());
            //        dtReport = objList.ListOfRecord("rpt_Customer_Payment_Receipt", PARA1, "CustomerPayment - Report");
            //        if (objList.Exception == null)
            //        {
            //            if (System.IO.File.Exists(CurrentUser.ReportPath + "rptCustomerPendingPaymentReceipt.rpt"))
            //            {
            //                //dtReport.TableName = "PaymentReceipt";
            //                //dtReport.WriteXmlSchema(@"D:\PaymentReceipt.xsd");
            //                CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            //                rptDoc.Load(CurrentUser.ReportPath + "rptCustomerPendingPaymentReceipt.rpt");

            //                CurrentUser.AddReportParameters(rptDoc, dtReport, "Payment Receipt", true, true, true, true, false, true, true, false, false, false, true);

            //                Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
            //                fRptView.Text = "Payment Receipt - [Page Size: A4]";
            //                fRptView.crViewer.ReportSource = rptDoc;
            //                fRptView.ShowDialog();
            //            }
            //            else
            //            {
            //                MessageBox.Show("File is not exist...");
            //            }
            //        }
            //        else
            //        {
            //            MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //        }
            //    }
            //    catch (Exception exc)
            //    {
            //        Utill.Common.ExceptionLogger.writeException("Customer Payment - Register Report", exc.StackTrace);
            //        MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception");
            //    }
            //}
            cmbreports.SelectedIndex = 0;
        }
Ejemplo n.º 57
0
        void GenerarArchivo(Boolean GenerarArchivo)
        {
            try
            {
                string Co_lin   = cboLinea.SelectedIndex == -1 ? null : cboLinea.SelectedValue.ToString().Trim();
                string Co_subl  = cboSub_lin.SelectedIndex == -1 ? null : cboSub_lin.SelectedValue.ToString().Trim();
                string Co_col   = cboColores.SelectedIndex == -1 ? null : cboColores.SelectedValue.ToString().Trim();
                string Co_cat   = cboCat_art.SelectedIndex == -1 ? null : cboCat_art.SelectedValue.ToString().Trim();
                string Cod_proc = cboProce.SelectedIndex == -1 ? null : cboProce.SelectedValue.ToString().Trim();
                string Grupo;
                string Archivo;

                pSeleccionarParametros_Result p = new pSeleccionarParametros_Result();
                //Programa e = new Programa();
                pSeleccionarReportes_Result r = new pSeleccionarReportes_Result();
                //List<pSeleccionarValores_prog_Result> v = new List<pSeleccionarValores_prog_Result>();
                //string returnValue = null;

                using (Profit_RGEntities context = new Profit_RGEntities())
                {
                    p     = context.pSeleccionarParametros().FirstOrDefault();
                    r     = context.pSeleccionarReportes("006").FirstOrDefault();
                    Grupo = context.pObtenerGrupo(txtCo_empresa.Text.Trim()).AsParallel().FirstOrDefault().grupo.Trim();
                }

                DataSet ds = new DataSet();
                ds.Tables.Add("pAnalisisCompras");
                ds.Tables[0].Columns.Add("A", typeof(string));
                ds.Tables[0].Columns.Add("co_art", typeof(string));
                ds.Tables[0].Columns.Add("art_des", typeof(string));
                ds.Tables[0].Columns.Add("referencia", typeof(string));
                ds.Tables[0].Columns.Add("comentario", typeof(string));
                ds.Tables[0].Columns.Add("lc_descrip2", typeof(string));
                ds.Tables[0].Columns.Add("ene", typeof(decimal));
                ds.Tables[0].Columns.Add("feb", typeof(decimal));
                ds.Tables[0].Columns.Add("mar", typeof(decimal));
                ds.Tables[0].Columns.Add("abr", typeof(decimal));
                ds.Tables[0].Columns.Add("may", typeof(decimal));
                ds.Tables[0].Columns.Add("jun", typeof(decimal));
                ds.Tables[0].Columns.Add("jul", typeof(decimal));
                ds.Tables[0].Columns.Add("ago", typeof(decimal));
                ds.Tables[0].Columns.Add("sep", typeof(decimal));
                ds.Tables[0].Columns.Add("oct", typeof(decimal));
                ds.Tables[0].Columns.Add("nov", typeof(decimal));
                ds.Tables[0].Columns.Add("dic", typeof(decimal));
                ds.Tables[0].Columns.Add("uni_ventas", typeof(decimal));
                ds.Tables[0].Columns.Add("sugerido", typeof(decimal));
                ds.Tables[0].Columns.Add("orden", typeof(Int32));
                ds.Tables[0].Columns.Add("costo", typeof(decimal));
                ds.Tables[0].Columns.Add("comprar", typeof(decimal));
                ds.Tables[0].Columns.Add("total", typeof(decimal));

                ds.Tables[0].Clear();

                List <Acom> ListaAc = Ac.Where(a => a.comprar > 0).ToList();

                if (ListaAc.Count == 0)
                {
                    MessageBox.Show("Sin datos para mostrar.", "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    for (int i = 0; i < ListaAc.Count; i++)
                    {
                        DataRow row = ds.Tables[0].NewRow();
                        row["co_art"]      = ListaAc[i].co_art;
                        row["art_des"]     = ListaAc[i].art_des;
                        row["referencia"]  = ListaAc[i].referencia;
                        row["comentario"]  = ListaAc[i].comentario;
                        row["LC_DESCRIP2"] = ListaAc[i].lc_descrip2;
                        row["Costo"]       = ListaAc[i].costo;
                        row["Comprar"]     = ListaAc[i].comprar;
                        row["Total"]       = ListaAc[i].costo * ListaAc[i].comprar;

                        ds.Tables[0].Rows.Add(row);
                        ds.Tables[0].AcceptChanges();
                    }

                    string Filename = r.ruta + @"\" + r.Archivo;
                    CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    oRpt.Load(@Filename);
                    oRpt.SetDataSource(ds);

                    if (GenerarArchivo == false)
                    {
                        FrmRep Fr = new FrmRep(ds, r.Archivo, false);
                        Fr.ShowDialog();
                    }
                    else
                    {
                        Archivo = "";
                        Archivo = @p.ruta_pdf + @"\" + r.Archivo.Replace(".rpt", "").Trim() + " " + System.DateTime.Now.ToFileTime() + ".pdf";
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Archivo.TrimEnd());
                    }
                    oRpt.Close();
                    oRpt.Dispose();
                }
            }
            catch (EntitySqlException ex)
            {
                MessageBox.Show(ex.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (SqlException ex0)
            {
                MessageBox.Show(ex0.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 58
0
        private void btnSaveExit_Click(object sender, EventArgs e)
        {
            if (_RptType == 2)
            {
                lblErrorMessage.Text = "";
                if (System.IO.File.Exists(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt"))
                {
                    DataTable dt = new DataTable();

                    NameValueCollection Para = new NameValueCollection();
                    // Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString());
                    Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy"));
                    Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy"));

                    dt = CommList.ListOfRecord("rpt_ProfitLossStatement", Para, "Profit Loss Statement");

                    //dt.TableName = "ProfitnLossStatement";
                    //dt.WriteXmlSchema(@"D:\ProfitnLossStatement.xsd");

                    if (CommList.Exception == null)
                    {
                        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                        rptDoc.Load(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt");

                        CurrentUser.AddReportParameters(rptDoc, dt, "Profit Loss Statement", true, true, true, true, false, true, true, false, false, false, false);
                        rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date);
                        rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date);
                        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                        fRptView.Text = "Profit n Loss Statement - [Page Size: A4]";
                        fRptView.crViewer.ReportSource = rptDoc;
                        fRptView.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }


                    //if (cmbAccount.SelectedIndex > 0)
                    //{
                    //    DataTable dt = new DataTable();

                    //    NameValueCollection Para = new NameValueCollection();
                    //   // Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString());
                    //    Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy"));
                    //    Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy"));

                    //    dt = CommList.ListOfRecord("rpt_ProfitLossStatement", Para, "Profit Loss Statement");

                    //    //dt.TableName = "ProfitnLossStatement";
                    //    //dt.WriteXmlSchema(@"D:\ProfitnLossStatement.xsd");

                    //    if (CommList.Exception == null)
                    //    {
                    //        CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    //        rptDoc.Load(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt");

                    //        CurrentUser.AddReportParameters(rptDoc, dt, "Profit Loss Statement", true, true, true, true, false, true, true, false, false, false, false);
                    //        rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date);
                    //        rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date);
                    //        Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                    //        fRptView.Text = "Profit n Loss Statement - [Page Size: A4]";
                    //        fRptView.crViewer.ReportSource = rptDoc;
                    //        fRptView.ShowDialog();
                    //    }
                    //    else
                    //    {
                    //        MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //    }
                    //}
                    //else
                    //{
                    //    lblErrorMessage.Text = "Please select Account";
                    //    return;
                    //}
                }
                else
                {
                    MessageBox.Show("File is not exist...");
                }
            }
            else
            {
                //---------------------------------------
                lblErrorMessage.Text = "";
                if (System.IO.File.Exists(CurrentUser.ReportPath + "rptLedger.rpt"))
                {
                    if (cmbAccount.SelectedIndex > 0)
                    {
                        DataTable dt = new DataTable();

                        NameValueCollection Para = new NameValueCollection();
                        Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString());
                        Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy"));
                        Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy"));

                        dt = CommList.ListOfRecord("rpt_AccountLedger", Para, "Ledger Report");



                        if (CommList.Exception == null)
                        {
                            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                            rptDoc.Load(CurrentUser.ReportPath + "rptLedger.rpt");

                            CurrentUser.AddReportParameters(rptDoc, dt, "Ledger Register", true, true, true, true, false, true, true, false, false, false, false);
                            rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date);
                            rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date);
                            Reports.frmReportViewer fRptView = new Reports.frmReportViewer();
                            fRptView.Text = "Ledger Register - [Page Size: A4]";
                            fRptView.crViewer.ReportSource = rptDoc;
                            fRptView.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        lblErrorMessage.Text = "Please select Account";
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("File is not exist...");
                }
            }
        }
Ejemplo n.º 59
0
    /// <summary>
    /// 利用 CrystalReport 列印 Excel 報表
    /// </summary>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source)
    {
        #region
        CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

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

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

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

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

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        #endregion
    }
Ejemplo n.º 60
0
    // show報表
    private void ShowReport(DataSet ds)
    {
        try
        {
            string strFileName = "";
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            report.Load(Server.MapPath("./REPORT/MKT05/CRMKT05R01.rpt"));
            strFileName = HttpUtility.UrlEncode("採購卡.PDF", System.Text.Encoding.UTF8);

            report.SetDataSource(ds);

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

            //export file  
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);//pdf檔名  
            Response.ContentType = "application/pdf";
            Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
            Response.Flush();
            Response.Close();
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
            UpdatePanel_ErrMsg.Update();
        }
    }