using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using Extensiones; using Microsoft.Reporting.WebForms; using System.Text; public partial class Inventarios_EntregasPorRealizar : ClsPaginas { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CargarEntregas(); CargarPersonal(); } } protected void BtnAsignar_Click(object sender,EventArgs e) { if (DdlUsuario.SelectedValue.ToEntero() > 0) { bool TieneError = false; ClsGenerales ObjGeneral = new ClsGenerales(); ObjGeneral.IniciaTransacSQL(); GridViewRowCollection Grid = GvPaqueteriasGuias.Rows; int CvePersonal = DdlUsuario.SelectedValue.ToEntero(); long CveAsignacionEntrega = DateTime.Now.Ticks; string Usuario = DdlUsuario.SelectedValue.ToEntero() > 0 ? DdlUsuario.SelectedItem.Text : "Todos"; string LigaPopUpVerFactura = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", ModExtensiones.Encripta(String.Format("OP=ENTREGAS&CVEASIGNACIONENTREGA={0}&USUARIOENTREGA={1}", CveAsignacionEntrega, Usuario))); foreach (GridViewRow row in Grid) { if (row.FCCheckBox("ChkAsigna").Checked) { int CvePaqueteriasGuias = row.DataKey("CvePaqueteriaGuia").ToEntero(); if(!ObjGeneral.AsignarEntregasPorRealizar(CvePaqueteriasGuias, CvePersonal, CveAsignacionEntrega)){ TieneError = true; }else { try { MandarNotificacionCorreo(row); } catch (Exception ex) { TieneError = true; ModExtensiones.GuardaLog(ex.Message); } //string CobranzaCorreo = row.DataKey("CobranzaCorreo"); //string CorreoEntregaAlmacen = row.DataKey("CorreoEntregaAlmacen"); //string CorreoEntregaCompras = row.DataKey("CorreoEntregaCompras"); //string CorreoVendedor = row.DataKey("Correo"); //string CorreoAdicionalNotificacionesVendedor = row.DataKey("CorreoAdicionalNotificaciones"); //string CorreosCC = string.Format("{0};{1};{2};{3}", CorreoVendedor, CorreoAdicionalNotificacionesVendedor, CobranzaCorreo, CorreoEntregaCompras); //string LogCorreo = string.Format("{0} -- {1} --- {2}", "Tipo de entrega", CorreoEntregaAlmacen, CorreosCC); //LogCorreo.GuardaLog(); //ClsSisMail MailCls = new ClsSisMail(); //MailCls.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoVendedor, "Se enviara la compra a su dirección", "Pendiente", CorreosCC); //MailCls = null; } } } if (!TieneError) { ObjGeneral.Commit(); Alert(String.Format("Entregas asignadas correctamente

Imprimir Reporte de Entregas Asignadas", LigaPopUpVerFactura)); CargarEntregas(); UpDatos.Update(); } else { ObjGeneral.RollBack(); } ObjGeneral.Dispose(); } else { Alert("Seleccione a alguien del personal",ModExtensiones.TipoMensaje.MsgAdvertencia); } } private void CargarEntregas() { ClsGenerales ObjGeneral = new ClsGenerales(); if (ObjGeneral.GetEntregasPorRealizar(UsuarioActual.CveEmpresa)) { GvPaqueteriasGuias.DataSource = ObjGeneral.DtResultados; } ObjGeneral.Dispose(); GvPaqueteriasGuias.DataBind(); } private void CargarPersonal() { DataTable UsuariosConRolLogistico = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa).FiltraParametros("CveRol IN (1339,1386,1430,1155)"); DdlUsuario.DataSource = UsuariosConRolLogistico; DdlUsuario.DataBind(); DdlUsuario.Items.Insert(0, new ListItem("Seleccione", "-1")); } //protected void LnkImprimir_Click(object sender, EventArgs e) //{ // List RepParams = new List(); // string Usuario = DdlUsuario.SelectedValue.ToEntero() > 0 ? DdlUsuario.SelectedItem.Text : "Todos"; // RepParams.Add(new ReportParameter("Fecha", DateTime.Today.ToString())); // RepParams.Add(new ReportParameter("AsignadoA", Usuario)); // RepParams.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)); // ImprimirPDF($"Empresas/{UsuarioActual.CveEmpresa}/Formatos/EntregasPorRealizar.rdlc", DtPaqueteriasGuias, RepParams, "Entregas por realizar", "PDF",RDSName:"DsInventarios"); //} private string DocumentoEntregaInterna(GridViewRow row) { string ClienteNombre = row.DataKey("NombreComercial"); string FolioVenta = row.DataKey("SerieFolio"); string Pedido = row.DataKey("PedidoContrato"); string OrdenCompra = row.DataKey("OrdenCompra"); int CveVenta = row.DataKey("CveVenta").ToEntero(); string TipoDocto = row.DataKey("TipoDocto"); DataTable DtDetalle = new DataTable(); ClsVentas ObjVentas = new ClsVentas(); if (ObjVentas.GetVentaDetalle(CveVenta)) { DtDetalle = ObjVentas.DtResultados; } ObjVentas.Dispose(); string DetalleTable = ""; foreach (DataRow dRow in DtDetalle.Rows) { string detalle = string.Format("{0}{1}{2}", dRow["Codigo"], dRow["Cantidad"], dRow["PS"]); DetalleTable += detalle; } 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 ya se encuentra en camino. Le confirmamos los productos que recibirá conforme a la "); strBody.Append($" {TipoDocto}:"); strBody.Append("

"); strBody.Append($"

{FolioVenta} - Pedido {Pedido} - Orden de Compra {OrdenCompra}

"); strBody.Append("
"); strBody.Append(" "); strBody.Append(DetalleTable); strBody.Append("
"); strBody.Append("
"); strBody.Append("

"); strBody.Append(" Solicitamos su apoyo en la verificación del pedido que está próximo a recibir y en caso de presentarse alguno de los siguientes inconvenientes favor de rechazar el paquete y comunicarse de inmediato con su Ejecutivo Comercial:"); strBody.Append("

"); strBody.Append("

"); strBody.Append(" • Empaque violado.
"); strBody.Append("• Daño físico en la caja.
"); strBody.Append("• Producto incompleto o distinto al solicitado.
"); strBody.Append("• Alguna otra situación que se considere que compromete la integridad de la mercancía."); strBody.Append(""); strBody.Append("

"); strBody.Append("
"); strBody.Append("

"); strBody.Append(" Gracias por realizar su pedido
"); //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(""); //List RepParams = new List(); //RepParams.Add(new ReportParameter("Cliente", ClienteNombre)); //RepParams.Add(new ReportParameter("FolioVenta", FolioVenta)); //RepParams.Add(new ReportParameter("Pedido", Pedido)); //RepParams.Add(new ReportParameter("OrdenCompra", OrdenCompra)); //return StreamPDF($"Empresas/{UsuarioActual.CveEmpresa}/Formatos/GuiaInternaAsignada.rdlc", DtDetalle, RepParams, "Notificacion de Envio", "PDF", RDSName: "DsInventarios"); return strBody.ToString(); } private void MandarNotificacionCorreo(GridViewRow row) { string CorreoEntregaAlmacen = row.DataKey("CorreoEntregaAlmacen"); string CorreoEntregaCompras = row.DataKey("CorreoEntregaCompras"); string CorreoVendedor = row.DataKey("Correo"); string CorreoNotificacion = row.DataKey("CorreoNotificacion"); int CveVendedor = row.DataKey("CveVendedor").ToEntero(); string CorreoAsistente = get_GlobalDTVendedores(UsuarioActual.CveEmpresa,VendedorTipo:3).FiltroPrimeroValor("Correo",string.Format("CveSuperior = {0}", CveVendedor)); string Para = string.Format("{0};{1};{2};{3};{4}", CorreoVendedor, CorreoNotificacion, CorreoEntregaCompras,CorreoEntregaAlmacen,CorreoAsistente); string LogCorreo = string.Format("{0} -- {1} --- {2}", "Tipo de entrega", CorreoEntregaAlmacen, Para); LogCorreo.GuardaLog(); //byte[] ArchivoBinario = DocumentoEntregaInterna(row); string body = DocumentoEntregaInterna(row); ClsSisMail MailCls = new ClsSisMail(); //List LSRutasMail = new List(); //ClsSisMail.ArchivoMail itemMail = new ClsSisMail.ArchivoMail(); //{ // var withBlock = itemMail; // itemMail.ArchivoBinario = ArchivoBinario; // itemMail.NombreArchivo = "Notificacion de Envio"; //} //LSRutasMail.Add(itemMail); MailCls.SendMail(ClsPaginas.EmpresaNotificaciones, Para, "Entrega en camino", body, Para); MailCls = null; } }