private void btnEnviar_Click(object sender, EventArgs e) { try { if (dgvCotizaciones.CurrentRow != null && cmbVigente.SelectedIndex == 1) { DialogResult dlgResult = MessageBox.Show("Esta seguro que desea enviar la Cotización", "Cotización", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.No) { return; } else { PdfRtfWordFormatOptions crformattype = new PdfRtfWordFormatOptions(); DiskFileDestinationOptions dfoption = new DiskFileDestinationOptions(); ExportOptions objexport; dfoption.DiskFileName = @"C:\Cotizaciones\Cotizacion_" + cotizacion.CodCotizacion + ".pdf"; ReportDocument document = new ReportDocument(); CRCotizacion cot = new CRCotizacion(); cot.SetDataSource(ds.Cotizacion(Convert.ToInt32(cotizacion.CodCotizacion))); objexport = cot.ExportOptions; objexport.ExportDestinationType = ExportDestinationType.DiskFile; objexport.ExportFormatType = ExportFormatType.PortableDocFormat; objexport.DestinationOptions = dfoption; objexport.FormatOptions = crformattype; cot.Export(); DirectoryInfo Dir = new DirectoryInfo(@"C:\Cotizaciones"); foreach (FileInfo Fi in Dir.GetFiles()) { //Dt.Rows.Add(idfile, Fi.Name.ToString()); //idfile++; if (Fi.Name.Contains(cotizacion.CodCotizacion)) { nombreArchivo = Fi.Name; } } if (Application.OpenForms["frmCorreoElectronico"] != null) { Application.OpenForms["frmCorreoElectronico"].Activate(); } else { frmCorreoElectronico form = new frmCorreoElectronico(); form.link_adjunto.Text = nombreArchivo; form.txtcuerpo.Text = "ESTIMADOS SRs.: " + cotizacion.RazonSocialCliente + Environment.NewLine + Environment.NewLine + "\t LES ADJUNTO LA COTIZACIÓN. N- " + cotizacion.CodCotizacion + "." + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "\t\t\t \t\t ATT. " + Environment.NewLine + "\t\t\t\t" + frmLogin.sApellidoUSer + ", " + frmLogin.sNombreUser; form.tipo = 2; form.ShowDialog(); if (form.enviado == 1) { MessageBox.Show("La Cotización ha envio correctamente", "Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information); consultar(); } else { MessageBox.Show("La Cotización, No se Pudo enviar, Verifique!", "Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information); consultar(); } } } } } catch (Exception ex) { MessageBox.Show("No se Pudo Enviar la Cotización", "Cotización", MessageBoxButtons.OK, MessageBoxIcon.Information); consultar(); } }
private void btnEnviar_Click(object sender, EventArgs e) { try { if (dgvOrdenes.CurrentRow != null) { DialogResult dlgResult = MessageBox.Show("Esta seguro que desea enviar el Borrador Orden seleccionado", "Orden Compra", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlgResult == DialogResult.No) { return; } else { PdfRtfWordFormatOptions crformattype = new PdfRtfWordFormatOptions(); DiskFileDestinationOptions dfoption = new DiskFileDestinationOptions(); ExportOptions objexport; dfoption.DiskFileName = @"C:\Ordenes de Compra\Orden de Compra_" + Docum+ ".pdf"; ReportDocument document = new ReportDocument(); CROrdenCompra orden = new CROrdenCompra(); orden.SetDataSource(ds.RptOrdenCompra(Ord.CodOrdenCompra)); objexport = orden.ExportOptions; objexport.ExportDestinationType = ExportDestinationType.DiskFile; objexport.ExportFormatType = ExportFormatType.PortableDocFormat; objexport.DestinationOptions = dfoption; objexport.FormatOptions = crformattype; orden.Export(); DirectoryInfo Dir = new DirectoryInfo(@"C:\Ordenes de Compra"); foreach (FileInfo Fi in Dir.GetFiles()) { //Dt.Rows.Add(idfile, Fi.Name.ToString()); //idfile++; if (Fi.Name.Contains(Docum)) { nombreArchivo = Fi.Name; } } if (Proce == 0) { if (Application.OpenForms["frmCorreoElectronico"] != null) { Application.OpenForms["frmCorreoElectronico"].Activate(); } else { frmCorreoElectronico form = new frmCorreoElectronico(); form.link_adjunto.Text = nombreArchivo; form.txtcuerpo.Text = "ESTIMADOS SRs.: " + Ord.RazonSocialProveedor + Environment.NewLine + Environment.NewLine + "\t LES ADJUNTO MI ORDEN DE COMPRA. N- " + Docum + "." + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine+ "\t\t\t \t\t ATT. " + Environment.NewLine + "\t\t\t\t" + frmLogin.sApellidoUSer + ", " + frmLogin.sNombreUser; form.codpro=Ord.CodProveedor; form.tipo = 1; form.ShowDialog(); if (form.enviado == 1) { MessageBox.Show("La Orden ha envio correctamente", "Orden Compra", MessageBoxButtons.OK, MessageBoxIcon.Information); //AdmOrden.Envio(Ord.CodOrdenCompra); CargaLista(); } else { MessageBox.Show("La Orden de Compra, No se Pudo enviar, Verifique!", "Orden Compra", MessageBoxButtons.OK, MessageBoxIcon.Information); CargaLista(); } } } } } } catch (Exception ex) { MessageBox.Show("No se Pudo Enviar la Orden Compra", "Orden Compra", MessageBoxButtons.OK, MessageBoxIcon.Information); CargaLista(); } }