();
if (File.Exists(RutaArchivoAdjunto))
{
ArchivoAdjunto.ArchivoBinario = File.ReadAllBytes(RutaArchivoAdjunto);
ArchivoAdjunto.Ruta = RutaArchivoAdjunto;
ArchivoAdjunto.NombreArchivo = new FileInfo(RutaArchivoAdjunto).Name;
ListaAdjuntos.Add(ArchivoAdjunto);
}
if ((ListaAdjuntos.Count > 0))
{
MensajeEnviado = Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, body.ToString(), Archivos: ListaAdjuntos);
}
else
{
MensajeEnviado = Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, body.ToString());
}
break;
case 2:
// Tipo 2 Paqueteria Recibida por Cliente - Notifica a Vendedor al actualizar estatus a 4
Cuerpo.AppendLine(String.Format("Le informamos que los productos de la factura {0} con Guía {1} y paquetería {2} han sido confirmados de recibido por el Cliente {3}.
", SerieFolio, Guia, Paqueteria, NombreCliente));
if (tDtMovimientos.Rows.Count > 0)
{
Cuerpo.AppendLine("");
Cuerpo.AppendLine("| Cantidad | Producto | ");
foreach (DataRow Drow in tDtMovimientos.Rows)
{
Cuerpo.AppendLine(String.Format("
| {0} | {1} |
", Drow["Cantidad"].ToString().ToEntero(), Drow["PS"].ToString()));
}
Cuerpo.AppendLine("
");
}
if (Correo.SendMail(UsuarioActual.Empresa, Destinatario, Asunto, Cuerpo.ToString()))
{
MensajeEnviado = true;
}
break;
case 3:
//Tipo 3 Guia reasignada
Cuerpo.AppendLine(String.Format("Motivo:{0}. Tu envío fue reprogramado para el siguiente día hábil.", DdlMotivoRechazoGuia.SelectedItem.Text));
CargaDatosCorreo(this.CveVenta);
if (Correo.SendMail(UsuarioActual.Empresa, this.Destinatario, Asunto, Cuerpo.ToString()))
{
MensajeEnviado = true;
}
break;
}
return MensajeEnviado;
}
protected void CargaDatosCorreo(int CveVenta, Boolean SubirArchivo = false)
{
if (CveVenta > 0)
{
ClsVentas ObjVentas = new ClsVentas();
if (ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa))
{
if (ObjVentas.DtResultados.Rows.Count > 0)
{
DataRow DbRowVenta = ObjVentas.DtResultados.Rows[0];
int CveCliente = DbRowVenta["CveCliente"].ToString().ToEntero();
int CveVendedor = DbRowVenta["CveVendedor"].ToString().ToEntero();
string CorreoNotificacion = DbRowVenta["CorreoNotificacion"] != null ? DbRowVenta["CorreoNotificacion"].ToString():"";
SerieFolio = String.Format("{0}-{1}", DbRowVenta["Serie"].ToString(), DbRowVenta["Folio"].ToString().ToEntero());
NombreCliente = DbRowVenta["ClienteNombre"].ToString();
//Si se subio Archivo
if (!SubirArchivo)
{
//correo de Vendedor
Destinatario = DbRowVenta["CorreoVendedorVenta"].ToString();
}
else
{
//correo del cliente
Destinatario = DbRowVenta["Mail"].ToString();
}
Destinatario = "sig.buzon02@gmail.com"; // CORREO PRUEBA
if (UsuarioActual.Empresa.Funcionalidad(280) == "1" && CveCliente > 0 && CveVendedor > 0)
{
Destinatario = getCorreoNotificacion(CveCliente, CveVendedor,CorreoNotificacion);
}
if (ObjVentas.GetVentaDetalle(CveVenta))
{
DTMovimientos = ObjVentas.DtResultados;
}
}
}
ObjVentas.Dispose();
}
}
private string getCorreoNotificacion(int CveCliente, int CveVendedor,string CorreoNotificacion)
{
DataRow DatosCliente = get_GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimero(string.Format("CveCliente = {0}", CveCliente));
DataRow DatosVendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(string.Format("CveVendedor = {0}", CveVendedor));
string CorreoAsistente = get_GlobalDTVendedores(UsuarioActual.CveEmpresa,VendedorTipo:3).FiltroPrimeroValor("Correo", string.Format("CveSuperior = {0}", CveVendedor));
if (DatosCliente != null && DatosVendedor != null)
{
StringBuilder correos = new StringBuilder("");
if (DatosCliente["CorreoEntregaCompras"].ToString().Length > 0) correos.Append(string.Format("{0};", DatosCliente["CorreoEntregaCompras"].ToString()));
if (DatosCliente["CorreoEntregaAlmacen"].ToString().Length > 0) correos.Append(string.Format("{0};", DatosCliente["CorreoEntregaAlmacen"].ToString()));
if (DatosVendedor["Correo"].ToString().Length > 0) correos.Append(string.Format("{0};", DatosVendedor["Correo"].ToString()));
correos.Append(CorreoNotificacion + ";");
correos.Append(CorreoAsistente + ";");
//if (DatosVendedor["CorreoAdicionalNotificaciones"].ToString().Length > 0) correos.Append(string.Format("{0};", DatosVendedor["CorreoAdicionalNotificaciones"].ToString()));
return correos.ToString();
}
return "";
}
#endregion
protected void Reasignar_Click(object sender, EventArgs e)
{
RegistraScript("$('#ModalMotivoReasignacion').modal('show')", "hidemodal3");
GridViewRow GvRow = (GridViewRow)(((LinkButton)sender).NamingContainer);
CvePaqueteriaGuiaReasignar = GvRow.DataKey("CvePaqueteriaGuia").ToEntero();
CveVenta = GvRow.DataKey("CveAgrupador").ToString().ToEntero();
Folio = GvRow.DataKey("Folio").ToString();
}
protected void BtnReasignar_Click(object sender, EventArgs e)
{
ClsGenerales ObjGeneral = new ClsGenerales();
if (ObjGeneral.AsignarEntregasPorRealizar(CvePaqueteriaGuiaReasignar, -1, CveMotivoRechazoPaqueteria: DdlMotivoRechazoGuia.SelectedValue.ToEntero()))
{
Alert("La guía está lista para volver a ser asignada, disponible en el reporte Entregas Por Realizar");
}
ObjGeneral.Dispose();
CargaDatos();
UPDatos.Update();
CvePaqueteriaGuiaReasignar = -1;
EnviarCorreoNotificacionEntrega(3, Folio, "", "", "", "", "", -1, null);
RegistraScript("$('#ModalMotivoReasignacion').modal('hide')", "hidemodal3");
}
private string DocumentoEntregaInterna(int CveVenta)
{
ClsVentas ObjVentas = new ClsVentas();
if (ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa))
{
DataRow row = ObjVentas.DtResultados.Rows[0];
string ClienteNombre = row["ClienteNombre"].ToString();
string FolioVenta = row["SerieFolio"].ToString();
string Pedido = row["PedidoContrato"].ToString();
string OrdenCompra = row["OrdenCompra"].ToString();
string tipoDocto = row["TipoDocto"].ToString();
DataTable DtDetalle = new DataTable();
if (ObjVentas.GetVentaDetalle(CveVenta))
{
DtDetalle = ObjVentas.DtResultados;
}
string DetalleTable = "";
foreach (DataRow dRow in DtDetalle.Rows)
{
string detalle = string.Format("| {0} | {1} | {2} |
", dRow["Codigo"], dRow["Cantidad"], dRow["PS"]);
DetalleTable += detalle;
}
CargaDatosCorreo(CveVenta);
StringBuilder strBody = new StringBuilder();
strBody.Append("");
strBody.Append("");
strBody.Append("");
strBody.Append("");
strBody.Append(" ");
strBody.Append("");
strBody.Append($"

");
strBody.Append("
");
strBody.Append(" ");
strBody.Append($" Apreciable {ClienteNombre}, su pedido correspondiente a la {tipoDocto}:");
strBody.Append("
");
strBody.Append($" {FolioVenta} - Pedido {Pedido} - Orden de Compra {OrdenCompra}
");
strBody.Append(" Su Pedido:
");
strBody.Append(" ");
strBody.Append("
");
strBody.Append(DetalleTable);
strBody.Append("
");
strBody.Append("
");
strBody.Append("
");
strBody.Append(" ");
strBody.Append(" Agradecemos su preferencia.
");
//strBody.Append(" Compuproveedores");
strBody.Append("
");
strBody.Append(" ");
strBody.Append(" Sigue disfrutando de nuestros productos y servicios
");
//strBody.Append(" www.compuproveedores.com");
strBody.Append("");
strBody.Append("
");
strBody.Append(" ");
strBody.Append("");
return strBody.ToString();
}
ObjVentas.Dispose();
return "";
}
}