Exemple #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            this.lblCount.Text = "Plase wait...";
            this.Enabled = false;
            ReportingClass _Reporte = new ReportingClass();
             /*           String server = GetRegistry.Registry.read(Program.RegKey, "server");
            String database = GetRegistry.Registry.read(Program.RegKey, "database");
            String uid = encryptQueryString.Encrypt.DecryptText(GetRegistry.Registry.read(Program.RegKey, "uid"));
            String password = encryptQueryString.Encrypt.DecryptText(GetRegistry.Registry.read(Program.RegKey, "password"));
            */
            try
            {
                // Titulo
                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", this.Text, "Titulo");

                /*                    switch (this.Text)
                                    {
                                        case "MMM 837I":
                                            _tbl = GetRegistry.Registry.read(Program.RegKey, "Table_MMM_837I");
                                            //"tblmmm837";
                                            break;
                                        case "PMC 837I":
                                            // _tbl = "tblPMC837I"; //"tblmmm837_PMC";
                                            _tbl = GetRegistry.Registry.read(Program.RegKey, "Table_PMC_837I");
                                            break;
                                        case "MMM 837P":
                                            //                            _tbl = "tblMMM837P";
                                            _tbl = GetRegistry.Registry.read(Program.RegKey, "Table_MMM_837P");
                                            break;
                                        case "PMC 837P":
                                            //                            _tbl = "tblPMC837P";
                                            _tbl = GetRegistry.Registry.read(Program.RegKey, "Table_PMC_837P");
                                            break;

                                    }*/
                //  DataSet DS = null;
                //_sql = "select * from mydbMMM." + _tbl + " order by V0DOCUMENT";

                DataTable T = Program.getTotales(txtFoxFile.Text.Trim());

                T.DefaultView.Sort = "V0DOCUMENT";

                //var sortData = from myData in T.AsEnumerable() orderby myData.Field<string>("V0DOCUMENT")  select myData;

                //foreach (var s in sortData)
                //{
                //    foreach (DataRow r in s.Table.Rows)
                //    {
                //        Console.WriteLine(r["V0BATCHNUM"].ToString());
                //    }

                //}

                String _tmpBach = null;
                int _totalBach = 0;
                int _totalimg = 0;
                int _totalreclamaciones = 0;
                int _CountImg = 0;
                int _CountRec = 0;
                String _Out = null;

                //Data para el detalle del documento
                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();

                foreach (DataRow R in T.Rows)
                {
                    if (_tmpBach != R["V0BATCHNUM"].ToString())
                    {
                        if (_tmpBach != null)
                        {
                            _Out = _tmpBach;
                            String OutTotalimg = String.Format("{0:0,0}", _totalimg);
                            String OutTotalRec = String.Format("{0:0,0}", _totalreclamaciones);
                            _Out += String.Format("{0,72}", OutTotalimg);
                            _Out += String.Format("{0,56}", OutTotalRec);
                            _totalreclamaciones = 0;
                            _totalimg = 0;

                            _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", _Out, "Data");

                        }
                        _tmpBach = R["V0BATCHNUM"].ToString();
                        _totalBach++;
                    }
                    _totalimg++;
                    _CountImg++;
                    if (R["V1PAGINA"].ToString().Trim() != "99")
                    {
                        _totalreclamaciones++;
                        _CountRec++;
                    }
                }

                { // El ultimo
                    _Out = _tmpBach;
                    String OutTotalimg = String.Format("{0:0,0}", _totalimg);
                    String OutTotalRec = String.Format("{0:0,0}", _totalreclamaciones);

                    _Out += String.Format("{0,72}", OutTotalimg);
                    _Out += String.Format("{0,56}", OutTotalRec);
                    _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", _Out, "Data");
                }

                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                String OutCounImg = String.Format("{0:0,0}", _CountImg);
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", OutCounImg, "TotalImg");

                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                String OutCounRec = String.Format("{0:0,0}", _CountRec);
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", OutCounRec, "TotalesRec");

                //MessageBox.Show(_totalBach.ToString());

                //Save Pdf
                _Reporte.myLocalReporte.Export();
                MessageBox.Show("Done...", "ImageData,Inc.", MessageBoxButtons.OK, MessageBoxIcon.Information);

                System.Diagnostics.Process.Start("C:\\prueba-kk.pdf");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.lblCount.Text = "0";
                this.Enabled = true;
            }
        }
Exemple #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            this.lblCount.Text = "Plase wait...";
            this.Enabled = false;
            ReportingClass _Reporte = new ReportingClass();

            try
            {
                // Titulo
                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", this.Text, "Titulo");

                DataTable T = Program.getTotales(txtFox.Text.Trim());
                T.DefaultView.Sort = "V0DOCUMENT";

                String _tmpBach = null;
                int _totalBach = 0;
                int _totalimg = 0;
                int _totalreclamaciones = 0;
                int _CountImg = 0;
                int _CountRec = 0;
                String _Out = null;

                //Data para el detalle del documento
                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();

                foreach (DataRow R in T.Rows)
                {
                    if (_tmpBach != R["V0BATCHNUM"].ToString())
                    {
                        if (_tmpBach != null)
                        {
                            _Out = _tmpBach;
                            String OutTotalimg = String.Format("{0:0,0}", _totalimg);
                            String OutTotalRec = String.Format("{0:0,0}", _totalreclamaciones);
                            _Out += String.Format("{0,72}", OutTotalimg);
                            _Out += String.Format("{0,56}", OutTotalRec);
                            _totalreclamaciones = 0;
                            _totalimg = 0;

                            _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", _Out, "Data");

                        }
                        _tmpBach = R["V0BATCHNUM"].ToString();
                        _totalBach++;
                    }
                    _totalimg++;
                    _CountImg++;
                    if (R["V1PAGINA"].ToString().Trim() != "99")
                    {
                        _totalreclamaciones++;
                        _CountRec++;
                    }
                }

                { // El ultimo
                    _Out = _tmpBach;
                    String OutTotalimg = String.Format("{0:0,0}", _totalimg);
                    String OutTotalRec = String.Format("{0:0,0}", _totalreclamaciones);

                    _Out += String.Format("{0,72}", OutTotalimg);
                    _Out += String.Format("{0,56}", OutTotalRec);
                    _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", _Out, "Data");
                }

                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                String OutCounImg = String.Format("{0:0,0}", _CountImg);
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", OutCounImg, "TotalImg");

                _Reporte.values = new CrystalDecisions.Shared.ParameterValues();
                String OutCounRec = String.Format("{0:0,0}", _CountRec);
                _Reporte.ExporTOPdf(@"c:\prueba-kk.pdf", OutCounRec, "TotalesRec");

                //Save Pdf
                _Reporte.myLocalReporte.Export();
                MessageBox.Show("Done...", "ImageData,Inc.", MessageBoxButtons.OK, MessageBoxIcon.Information);

                System.Diagnostics.Process.Start("C:\\prueba-kk.pdf");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.lblCount.Text = "0";
                this.Enabled = true;
            }
        }