private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Clases.CrearPDF pdf = new Clases.CrearPDF();

                if (pdf.ToPDF(gridFacturas, Jefas))
                {
                    string     nombre      = pdf.Nombre;
                    PdfReader  reader      = new PdfReader(nombre);
                    string     nombreCopia = Path.GetTempFileName() + ".pdf";
                    PdfStamper stamper     = new PdfStamper(reader, new FileStream(nombreCopia, FileMode.Create));
                    AcroFields fields      = stamper.AcroFields;
                    stamper.JavaScript     = "this.print(true);\r";
                    stamper.FormFlattening = true;
                    stamper.Close();
                    reader.Close();

                    System.Diagnostics.Process.Start(nombreCopia);
                }
                else
                {
                    MessageBox.Show("Error al generar el archivo. \r\n", "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al generar el archivo. \r\n" + ex.Message, "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string _mensajeMail = @"<FONT FACE='arial' SIZE=5>
                                        <H3>FACTURAS PAGADAS EN PRORROGA " + DateTime.Now.ToShortDateString() + @"</H3><BR>
                                         <table BORDER = 1>
                                            <TR>
                                                <TH>FACTURA</TH>
                                                <TH>SALDO EN<br>PRORROGA</TH>
                                                <TH>PAGOS</TH>
                                                <TH>SALDO ACTUAL</TH>
                                            </TR>
                                        ";
                foreach (DataGridViewRow item in dgvDatos.Rows)
                {
                    _mensajeMail += @"<TR>
                                         <TD>" + item.Cells[0].Value + "</TD>" +
                                    "<TD align='right'>" + Convert.ToDecimal(item.Cells[1].Value).ToString("C2") + "</TD>" +
                                    "<TD align='right'>" + Convert.ToDecimal(item.Cells[2].Value).ToString("C2") + "</TD>" +
                                    "<TD align='right'>" + Convert.ToDecimal(item.Cells[3].Value).ToString("C2") + "</TD>"
                                    + "</TR>";
                }

                _mensajeMail += @"</table>";

                SendMail mail = new SendMail();

                string _correosDestinatarios = System.Configuration.ConfigurationSettings.AppSettings["CorreosAtradiusPagos"].ToString();
                if (dgvDatos.Rows.Count > 0)
                {
                    Clases.CrearPDF pdf  = new Clases.CrearPDF();
                    string          ruta = pdf.ToPDFAtradius(dgvDatos, string.Empty, "Facturas pagadas en prorroga " + DateTime.Now.ToShortDateString());
                    if (!string.IsNullOrEmpty(ruta))
                    {
                        mail.EnviarAtradius(ruta, _correosDestinatarios, _mensajeMail, "Facturas pagadas en prorroga");
                        MessageBox.Show("Envio Exitoso", "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void imprimirToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                Cobranza.Clases.CrearPDF pdf = new Clases.CrearPDF();
                pdf.ToPDFDepositos(dataGridView1.DataSource as DataTable, string.Empty);

                string     nombre      = pdf.Nombre;
                PdfReader  reader      = new PdfReader(nombre);
                string     nombreCopia = Path.GetTempFileName() + ".pdf";
                PdfStamper stamper     = new PdfStamper(reader, new FileStream(nombreCopia, FileMode.Create));
                AcroFields fields      = stamper.AcroFields;
                stamper.JavaScript     = "this.print(true);\r";
                stamper.FormFlattening = true;
                stamper.Close();
                reader.Close();

                System.Diagnostics.Process.Start(nombreCopia);
            }
            catch (Exception)
            {
                MessageBox.Show("Error", "HalcoNET", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (dgvFacts.DataSource != null)
            {
                if (Imprimir.Equals("Reporte"))
                {
                    DialogResult dialog = MessageBox.Show("¿Esta seguro que desea imprimir el reporte?", "HalcoNET", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (dialog == System.Windows.Forms.DialogResult.OK)
                    {
                        Clases.CrearPDF pdf   = new Clases.CrearPDF();
                        string          _path = pdf.ToPDFCorchoxCP(dgvFacts.DataSource as DataTable, FechaConsulta);
                        if (!string.IsNullOrEmpty(_path))
                        {
                            //Actualizar U_Impreso = 'Y' PJ_TblCorcho
                            int       _actualizadas = 0;
                            DataTable _datos        = (from item in (dgvFacts.DataSource as DataTable).AsEnumerable()
                                                       where !item.Field <string>("Condicion de pago").ToLower().Contains("total")
                                                       select item).CopyToDataTable();

                            foreach (DataRow item in _datos.Rows)
                            {
                                _actualizadas += this.ActualiarEstatus(item.Field <Int32>("DocEntry"), item.Field <string>("Tipo"));
                            }
                            System.Diagnostics.Process.Start(_path);
                        }
                    }
                }
                if (Imprimir.Equals("Corcho"))
                {
                    Clases.CrearPDF pdf = new Clases.CrearPDF();
                    // pdf.ToPDFCorcho(dgvUSD.DataSource as DataTable);

                    pdf.ToPDFCorcho(dgvFacts.DataSource as DataTable);
                }
            }
        }
Exemple #5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string _CardCode = string.Empty;
                string _Docnum   = string.Empty;
                bool   fist      = false;

                _CardCode = dgvEncabezado.CurrentRow.Cells[(int)ColumasEncabezado.Cliente].Value.ToString();
                _Docnum   = dgvDetalle.CurrentRow.Cells[(int)ColumnasDetalle.Factura].Value.ToString();

                string       _mensaje = string.Empty;
                DialogResult _result  = System.Windows.Forms.DialogResult.No;

                foreach (DataRow item in detalle.Rows)
                {
                    if (item.Field <string>("ExistP1") == "N" && item.Field <bool>("Prorroga1") == true)
                    {
                        string _aux = ExcecuteNonQuery(9, dateTimePicker1.Value, string.Empty, string.Empty, item.Field <int>("DocEntry"), item.Field <int>("Factura"), "P1", DateTime.Now);
                        _mensaje += "Factura: " + item.Field <int>("Factura") + " Estado: " + _aux + "\r\n";
                        _result   = System.Windows.Forms.DialogResult.Yes;
                    }
                    if (item.Field <string>("ExistP2") == "N" && item.Field <bool>("Prorroga2") == true)
                    {
                        string _aux = ExcecuteNonQuery(9, dateTimePicker1.Value, string.Empty, string.Empty, item.Field <int>("DocEntry"), item.Field <int>("Factura"), "P2", DateTime.Now);
                        _mensaje += "Factura: " + item.Field <int>("Factura") + " Estado: " + _aux + "\r\n";
                        _result   = System.Windows.Forms.DialogResult.Yes;
                    }
                    //SI EXISTE ALGUN CLIENTE EN JURIDICO
                    if (item.Field <string>("ExistJ1") == "N" && item.Field <bool>("Juridico") == true)
                    {
                        string _aux = ExcecuteNonQuery(9, dateTimePicker1.Value, string.Empty, string.Empty, item.Field <int>("DocEntry"), item.Field <int>("Factura"), "J1", DateTime.Now);
                        _mensaje += "Factura: " + item.Field <int>("Factura") + " Estado: " + _aux + "\r\n";
                        _result   = System.Windows.Forms.DialogResult.Yes;
                    }

                    if (item.Field <string>("ExistRE") == "N" && item.Field <bool>("Reclamación") == true)
                    {
                        string clientes = string.Empty;

                        int countClientes = 0;
                        if (_result == System.Windows.Forms.DialogResult.No)
                        {
                            var qry = (from fa in detalle.AsEnumerable()
                                       where fa.Field <string>("ExistRE") == "N" && fa.Field <bool>("Reclamación") == true
                                       select fa.Field <string>("CardCode")).Distinct();

                            countClientes = qry.Count();

                            foreach (string r in qry)
                            {
                                clientes += r + "\r\n";
                            }

                            if (!fist)
                            {
                                _result = MessageBox.Show("Se enviarán los siguientes clientes a Reclamación\r\n" + clientes + "¿Desea continuar?", "HalcoNET", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            }
                        }
                        fist = true;

                        if (_result == System.Windows.Forms.DialogResult.Yes)
                        {
                            string _aux = ExcecuteNonQuery(9, dateTimePicker1.Value, string.Empty, string.Empty, item.Field <int>("DocEntry"), item.Field <int>("Factura"), "RE", item.Field <DateTime>("Fecha siniestro"));
                            _mensaje += "Factura: " + item.Field <int>("Factura") + " Estado: " + _aux + "\r\n";
                        }
                    }
                }

                string clientesMail = string.Empty;
                var    qryMail      = (from fa in detalle.AsEnumerable()
                                       where fa.Field <string>("ExistRE") == "N" && fa.Field <bool>("Reclamación") == true
                                       select new
                {
                    CardCode = fa.Field <string>("CardCode"),
                    CardName = fa.Field <string>("CardName")
                }).Distinct();

                foreach (DataRow r in qryMail.ToDataTable().Rows)
                {
                    Clases.CrearPDF pdf  = new Clases.CrearPDF();
                    string          file = pdf.ToPDFAtradius(r.Field <string>("CardCode"), "Cliente a reclamación:\r\n" + r.Field <string>("CardCode") + " - " + r.Field <string>("CardName") + "\r\n\r\nFacturas a reclamación");

                    string subj = "ATRADIUS - Reclamación - " + r.Field <string>("CardCode") + " - " + r.Field <string>("CardName");

                    SendMail mail = new SendMail();
                    string   _correosDestinatarios = System.Configuration.ConfigurationSettings.AppSettings["CorreosAtradius"].ToString();
                    if (file != string.Empty)
                    {
                        mail.Enviar(file, _correosDestinatarios, "*****@*****.**", @"<b>---</b>", subj, true);
                    }
                }

                if (_result == System.Windows.Forms.DialogResult.Yes)
                {
                    var dialogTypeName = "System.Windows.Forms.PropertyGridInternal.GridErrorDlg";
                    var dialogType     = typeof(Form).Assembly.GetType(dialogTypeName);

                    var dialog = (Form)Activator.CreateInstance(dialogType, new PropertyGrid());

                    dialog.Text = "HalcoNET";

                    dialogType.GetProperty("Details").SetValue(dialog, _mensaje, null);
                    dialogType.GetProperty("Message").SetValue(dialog, "Operación completada. De click en el boton 'Detalles' para mayor información.", null);

                    var result = dialog.ShowDialog();

                    button1_Click(sender, e);

                    int indexEncabezado = 0;
                    foreach (DataGridViewRow item in dgvEncabezado.Rows)
                    {
                        if (item.Cells[(int)ColumasEncabezado.Cliente].Value.ToString() == _CardCode)
                        {
                            indexEncabezado = item.Index;
                        }
                    }

                    dgvEncabezado.CurrentCell = dgvEncabezado.Rows[indexEncabezado].Cells[(int)ColumasEncabezado.Cliente];

                    int indexDetalle = 0;
                    foreach (DataGridViewRow item in dgvDetalle.Rows)
                    {
                        if (item.Cells[(int)ColumnasDetalle.Factura].Value.ToString() == _Docnum)
                        {
                            indexDetalle = item.Index;
                        }
                    }

                    dgvDetalle.CurrentCell = dgvDetalle.Rows[indexDetalle].Cells[(int)ColumnasDetalle.Factura];
                }
            }
            catch (Exception ex)
            {
                var dialogTypeName = "System.Windows.Forms.PropertyGridInternal.GridErrorDlg";
                var dialogType     = typeof(Form).Assembly.GetType(dialogTypeName);

                var dialog = (Form)Activator.CreateInstance(dialogType, new PropertyGrid());

                dialog.Text = "HalcoNET";
                dialogType.GetProperty("Details").SetValue(dialog, ex.Message, null);
                dialogType.GetProperty("Message").SetValue(dialog, "Error inesperado", null);

                var result = dialog.ShowDialog();
            }
        }