178 lines
7.5 KiB
C#
178 lines
7.5 KiB
C#
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;
|
|
|
|
public partial class Inventarios_EntregasPorRealizar : ClsPaginas
|
|
{
|
|
private DataTable DtPaqueteriasGuias
|
|
{
|
|
get
|
|
{
|
|
return (ViewState["DtPaqueteriasGuias"] == null) ? null : (DataTable)ViewState["DtPaqueteriasGuias"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["DtPaqueteriasGuias"] = value;
|
|
}
|
|
}
|
|
|
|
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
|
|
{
|
|
MandarNotificacionCorreo(row);
|
|
//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 <br/><br/><a style='color:#23527c' href='{0}'>Imprimir Reporte de Entregas Asignadas</a>", 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;
|
|
DtPaqueteriasGuias = ObjGeneral.DtResultados;
|
|
GvPaqueteriasGuias.DataBind();
|
|
}
|
|
ObjGeneral.Dispose();
|
|
}
|
|
|
|
private void CargarPersonal()
|
|
{
|
|
DataTable UsuariosConRolLogistico = get_GlobalDTUsuarios(CveEmpresa: UsuarioActual.CveEmpresa).FiltraParametros("CveRol IN (1339,1386,1430)");
|
|
DdlUsuario.DataSource = UsuariosConRolLogistico;
|
|
DdlUsuario.DataBind();
|
|
DdlUsuario.Items.Insert(0, new ListItem("Seleccione", "-1"));
|
|
}
|
|
|
|
protected void LnkImprimir_Click(object sender, EventArgs e)
|
|
{
|
|
List<ReportParameter> RepParams = new List<ReportParameter>();
|
|
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 byte[] DocumentoEntregaInterna(GridViewRow row)
|
|
{
|
|
string ClienteNombre = row.DataKey("NombreComercial");
|
|
string FolioVenta = row.DataKey("Folio");
|
|
string Pedido = row.DataKey("PedidoContrato");
|
|
string OrdenCompra = row.DataKey("OrdenCompra");
|
|
int CveVenta = row.DataKey("CveVenta").ToEntero();
|
|
|
|
DataTable DtDetalle = new DataTable();
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (ObjVentas.GetVentaDetalle(CveVenta))
|
|
{
|
|
DtDetalle = ObjVentas.DtResultados;
|
|
}
|
|
ObjVentas.Dispose();
|
|
|
|
List<ReportParameter> RepParams = new List<ReportParameter>();
|
|
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");
|
|
}
|
|
|
|
private void MandarNotificacionCorreo(GridViewRow row)
|
|
{
|
|
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 Para = string.Format("{0};{1};{2};{3}", CorreoVendedor, CorreoAdicionalNotificacionesVendedor, CobranzaCorreo, CorreoEntregaCompras);
|
|
string LogCorreo = string.Format("{0} -- {1} --- {2}", "Tipo de entrega", CorreoEntregaAlmacen, Para);
|
|
LogCorreo.GuardaLog();
|
|
|
|
byte[] ArchivoBinario = DocumentoEntregaInterna(row);
|
|
|
|
ClsSisMail MailCls = new ClsSisMail();
|
|
List<ClsSisMail.ArchivoMail> LSRutasMail = new List<ClsSisMail.ArchivoMail>();
|
|
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, "Se enviara la compra a su dirección", "Pendiente", Para);
|
|
MailCls = null;
|
|
}
|
|
} |