881 lines
33 KiB
C#
881 lines
33 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
using System.Text;
|
|
using Microsoft.Reporting.WebForms;
|
|
using System.Activities.Expressions;
|
|
|
|
public partial class General_PopUpPaqueteriasGuias : ClsPaginas
|
|
{
|
|
#region "PROPIEDADES"
|
|
private String OP
|
|
{
|
|
get
|
|
{
|
|
return ViewState["OP"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["OP"] = value;
|
|
}
|
|
}
|
|
//V, OC, MOV
|
|
|
|
private int CveVenta
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveVenta"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveVenta"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveOC
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveOC"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveOC"] = value;
|
|
}
|
|
}
|
|
|
|
private int CveMovimiento
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveMovimiento"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveMovimiento"] = value;
|
|
}
|
|
}
|
|
private int CveCompra
|
|
{
|
|
get
|
|
{
|
|
return ViewState["CveCompra"].ToString().ToEntero();
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["CveCompra"] = value;
|
|
}
|
|
}
|
|
|
|
private DataTable DTGuiasVinculadas
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTGuiasVinculadas"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTGuiasVinculadas"] = value;
|
|
}
|
|
}
|
|
|
|
private String SerieFolio
|
|
{
|
|
get
|
|
{
|
|
return ViewState["SerieFolio"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["SerieFolio"] = value;
|
|
}
|
|
}
|
|
|
|
private String NombreCliente
|
|
{
|
|
get
|
|
{
|
|
return ViewState["NombreCliente"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["NombreCliente"] = value;
|
|
}
|
|
}
|
|
private String Pedido
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Pedido"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Pedido"] = value;
|
|
}
|
|
}
|
|
private String OrdenCompra
|
|
{
|
|
get
|
|
{
|
|
return ViewState["OrdenCompra"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["OrdenCompra"] = value;
|
|
}
|
|
}
|
|
|
|
private String Destinatario
|
|
{
|
|
get
|
|
{
|
|
return ViewState["Destinatario"].ToString();
|
|
}
|
|
set
|
|
{
|
|
ViewState["Destinatario"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
private DataTable DTMovimientos
|
|
{
|
|
get
|
|
{
|
|
return (DataTable)ViewState["DTMovimientos"];
|
|
}
|
|
|
|
set
|
|
{
|
|
ViewState["DTMovimientos"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
((BaseMasterPage)this.Master).EsPopup = true;
|
|
|
|
RecuperaCve();
|
|
|
|
CargaPaqueterias();
|
|
CargaPaqueteriasGuiasTipo();
|
|
CargaSucursales();
|
|
|
|
if (CveVenta > 0 || CveOC > 0 || CveMovimiento > 0 || CveCompra > 0)
|
|
{
|
|
CargaGuiasVinculadas();
|
|
if(CveVenta > 0)
|
|
{
|
|
CondicionesVenta();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ActivaModoGuiaSinVincular();
|
|
}
|
|
|
|
if (!UsuarioActual.TienePermisoProceso(218))
|
|
{
|
|
UPGuiasPorVincular.Visible = false;
|
|
GvGuiasVinculadas.Columns[6].Visible = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#region "CARGA DATOS"
|
|
protected void RecuperaCve()
|
|
{
|
|
//if (Request["OP"] != null && !Request["OP"].ToString().Equals(""))
|
|
//{
|
|
// ViewState["OP"] = Request["OP"];
|
|
//}
|
|
//else
|
|
//{
|
|
// ViewState["OP"] = -1;
|
|
//}
|
|
|
|
if (Request["CveVenta"] != null && !Request["CveVenta"].ToString().Equals("") && Request["CveVenta"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveVenta"] = Request["CveVenta"];
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveVenta"] = -1;
|
|
}
|
|
|
|
if (Request["CveOC"] != null && !Request["CveOC"].ToString().Equals("") && Request["CveOC"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveOC"] = Request["CveOC"];
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveOC"] = -1;
|
|
}
|
|
if (Request["CveMovimiento"] != null && !Request["CveMovimiento"].ToString().Equals("") && Request["CveMovimiento"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveMovimiento"] = Request["CveMovimiento"];
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveMovimiento"] = -1;
|
|
}
|
|
if (Request["CveCompra"] != null && !Request["CveCompra"].ToString().Equals("") && Request["CveCompra"].ToEntero() > 0)
|
|
{
|
|
ViewState["CveCompra"] = Request["CveCompra"];
|
|
}
|
|
else
|
|
{
|
|
ViewState["CveCompra"] = -1;
|
|
}
|
|
}
|
|
protected void CargaGuiasVinculadas()
|
|
{
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
if (ObjGeneral.GetPaqueteriasGuiasDetalles(-1, -1, CveVenta, CveOC, CveMovimiento, CveCompra))
|
|
{
|
|
DTGuiasVinculadas = ObjGeneral.DtResultados;
|
|
GvGuiasVinculadas.DataSource = DTGuiasVinculadas;
|
|
GvGuiasVinculadas.DataBind();
|
|
}
|
|
ObjGeneral.Dispose();
|
|
UPGuiasVinculadas.Update();
|
|
}
|
|
protected void CargaPaqueterias()
|
|
{
|
|
DdlPaqueterias.Items.Clear();
|
|
DdlPaqueterias.DataSource = get_GlobalDTPaqueterias(UsuarioActual.CveEmpresa);
|
|
DdlPaqueterias.DataBind();
|
|
DdlPaqueterias.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
UPGuiasPorVincular.Update();
|
|
}
|
|
protected void CargaPaqueteriasGuiasTipo()
|
|
{
|
|
DdlPaqueteriaGuiaTipo.Items.Clear();
|
|
DdlPaqueteriaGuiaTipo.DataSource = get_GlobalDTPaqueteriaGuiaTipos(UsuarioActual.CveEmpresa);
|
|
DdlPaqueteriaGuiaTipo.DataBind();
|
|
DdlPaqueteriaGuiaTipo.Items.Insert(0, new ListItem("Seleccione ", "-1"));
|
|
if (CveCompra > 0)
|
|
{
|
|
//DdlPaqueteriaGuiaTipo.SelectedValueExist(21);
|
|
DdlPaqueteriaGuiaTipo.SelectedIndex = DdlPaqueteriaGuiaTipo.Items.IndexOf(DdlPaqueteriaGuiaTipo.Items.FindByText("Compra"));
|
|
}
|
|
UPGuiasPorVincular.Update();
|
|
}
|
|
protected void CargaSucursales()
|
|
{
|
|
DdlSucursales.DataSource = get_GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1);
|
|
DdlSucursales.DataBind();
|
|
UPGuiasPorVincular.Update();
|
|
}
|
|
#endregion
|
|
|
|
#region "CAMBIO MODALIDAD"
|
|
protected void RBLVincularGuia_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (RBLVincularGuia.SelectedValue == "1")
|
|
{
|
|
ActivaModoVincularGuia();
|
|
}
|
|
else
|
|
{
|
|
ActivaModoNuevaGuia();
|
|
}
|
|
LimpiaCampos();
|
|
}
|
|
protected void ActivaModoVincularGuia()
|
|
{
|
|
RowPaqueteria.Visible = true;
|
|
RowBtnVincular.Visible = true;
|
|
|
|
RowRastreo.Visible = false;
|
|
RowFechas.Visible = false;
|
|
RowCajas.Visible = false;
|
|
RowDimensiones.Visible = false;
|
|
RowObservaciones.Visible = false;
|
|
TrTipo.Visible = false;
|
|
|
|
BtnCrearGuia.Visible = false;
|
|
BtnLimpiar.Visible = false;
|
|
}
|
|
protected void ActivaModoNuevaGuia()
|
|
{
|
|
RowPaqueteria.Visible = true;
|
|
RowBtnVincular.Visible = false;
|
|
|
|
RowRastreo.Visible = true;
|
|
RowFechas.Visible = true;
|
|
RowCajas.Visible = true;
|
|
RowDimensiones.Visible = true;
|
|
RowObservaciones.Visible = true;
|
|
TrTipo.Visible = true;
|
|
|
|
BtnCrearGuia.Visible = true;
|
|
BtnLimpiar.Visible = true;
|
|
}
|
|
protected void ActivaModoGuiaSinVincular()
|
|
{
|
|
UPGuiasVinculadas.Visible = false;
|
|
RBLVincularGuia.SelectedIndex = 1;
|
|
RBLVincularGuia.Enabled = false;
|
|
|
|
ActivaModoNuevaGuia();
|
|
}
|
|
#endregion
|
|
|
|
#region "REGISTRO Y VINCULACION DE GUIAS"
|
|
|
|
protected void LimpiaCampos()
|
|
{
|
|
TxtGuia.Text = "";
|
|
TxtRastreo.Text = "";
|
|
DdlPaqueterias.SelectedValue = "-1";
|
|
DdlEstatus.SelectedValue = "1";
|
|
DdlSucursales.SelectedValue = "-1";
|
|
TxtFecha.Text = "";
|
|
TxtFechaEstimada.Text = "";
|
|
TxtNoCajas.Text = "";
|
|
TxtPeso.Text = "";
|
|
TxtDimensiones.Text = "";
|
|
TxtObservaciones.Text = "";
|
|
}
|
|
|
|
protected void AgregarNuevaGuia()
|
|
{
|
|
//Crear guia y enviar a detalle con Cve
|
|
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
|
|
Boolean TieneError = false;
|
|
|
|
ObjGeneral.IniciaTransacSQL();
|
|
|
|
int CvePaqueteria = DdlPaqueterias.SelectedValue.ToEntero();
|
|
int CveEstatus = DdlEstatus.SelectedValue.ToEntero();
|
|
int CveSucursal = DdlSucursales.SelectedValue.ToEntero();
|
|
int CvePaqueteriaGuiaTipo = DdlPaqueteriaGuiaTipo.SelectedValue.ToEntero();
|
|
|
|
String Fecha = TxtFecha.Text;
|
|
String FechaEstimada = TxtFechaEstimada.Text == "" ? "-1" : TxtFechaEstimada.Text;
|
|
|
|
String Guia = (TxtGuia.Text == "") ? "-1" : TxtGuia.Text;
|
|
String Rastreo = TxtRastreo.Text;
|
|
String Dimensiones = TxtDimensiones.Text;
|
|
|
|
int NoCajas = TxtNoCajas.Text.ToEntero();
|
|
Double Peso = TxtPeso.Text.ToDouble();
|
|
|
|
String Observaciones = TxtObservaciones.Text;
|
|
Boolean ImplicaCosto = ChkImplicaCosto.Checked;
|
|
|
|
string PolizaSeguro = (tdLblPolizaSeguro.Visible) ? TxtPolizaSeguro.Text : "-1";
|
|
|
|
int CvePaqueteriaGuia = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, CvePaqueteriaGuiaTipo,CveEstatus, CveSucursal, Fecha, Rastreo, Guia, NoCajas, Peso, Dimensiones,
|
|
FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ImplicaCosto,PolizaSeguro: PolizaSeguro);
|
|
|
|
if (CvePaqueteriaGuia > 0)
|
|
{
|
|
if (CveVenta > 0 || CveOC > 0 || CveMovimiento > 0 || CveCompra > 0)
|
|
{
|
|
TieneError = !ObjGeneral.AddPaqueteriasGuiasDetalles(CvePaqueteriaGuia, CveVenta, CveOC, CveMovimiento, CveCompra);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TieneError = true;
|
|
}
|
|
|
|
if (TieneError)
|
|
{
|
|
ObjGeneral.RollBack();
|
|
}
|
|
else
|
|
{
|
|
ObjGeneral.Commit();
|
|
string notificacionCorreos = getCorreoString();
|
|
MandaCorreoNotificacionGuia(notificacionCorreos);
|
|
if (Guia == "-1")
|
|
{
|
|
if (CveVenta > 0 || CveOC > 0 || CveMovimiento > 0 || CveCompra > 0)
|
|
{
|
|
if (CveVenta > 0) { Alert(String.Format("La Guía se ha generado y se se ha vinculado a la Venta correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveOC > 0) { Alert(String.Format("La Guía se ha generado y se se ha vinculado a la Orden de Compra correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveMovimiento > 0) { Alert(String.Format("La Guía se ha generado y se se ha vinculado al Movimiento correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveCompra > 0) { Alert(String.Format("La Guía se ha generado y se se ha vinculado a la Compra correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("La Guía se ha generado correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (CveVenta > 0 || CveOC > 0 || CveMovimiento > 0 || CveCompra > 0)
|
|
{
|
|
if (CveVenta > 0)
|
|
{
|
|
|
|
// 04/04/2018 - Recupera Datos Venta y Envia correo de Notificacion
|
|
CargaDatosVenta(CveVenta);
|
|
//Destinatario = "sig.buzon02@gmail.com"; //vendedor
|
|
Boolean NotificacionEnviada = false;
|
|
|
|
|
|
if (DTGuiasVinculadas.Rows.Count > 1)
|
|
{
|
|
//Mas de dos Guia Vinculada a la Venta
|
|
//Notificacion a cliente
|
|
NotificacionEnviada = EnviarCorreoNotificacionGuias(1, SerieFolio, NombreCliente, Destinatario, DdlPaqueterias.SelectedItem.Text, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos);
|
|
//Notificaciones a correos Fijos
|
|
EnviarCorreoNotificacionGuias(4, SerieFolio, NombreCliente, Destinatario, DdlPaqueterias.SelectedItem.Text, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos, DTGuiasVinculadas.Rows.Count, CvePaqueteriaGuia);
|
|
}
|
|
else
|
|
{
|
|
//Primera Guia Vinculada a la Venta
|
|
//Notifica a cliente
|
|
NotificacionEnviada = EnviarCorreoNotificacionGuias(1, SerieFolio, NombreCliente, Destinatario, DdlPaqueterias.SelectedItem.Text, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos);
|
|
}
|
|
//
|
|
|
|
if (NotificacionEnviada)
|
|
{
|
|
Alert(String.Format("La Guía {0} se ha generado y se se ha vinculado a la Venta correctamente.<br><br>Correo enviado exitosamente a {1}.", Guia, Destinatario), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("La Guía {0} se ha generado y se se ha vinculado a la Venta correctamente.<br><br>Se presentó un Error al enviar el correo a: {1}.", Guia, Destinatario), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
}
|
|
if (CveOC > 0) { Alert(String.Format("La Guía {0} se ha generado y se se ha vinculado a la Orden de Compra correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveMovimiento > 0) { Alert(String.Format("La Guía {0} se ha generado y se se ha vinculado al Movimiento correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("La Guía {0} se ha generado correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
}
|
|
|
|
LimpiaCampos();
|
|
|
|
if ((CveVenta > 0 || CveOC > 0 || CveMovimiento > 0 || CveCompra > 0))
|
|
{
|
|
RBLVincularGuia.SelectedValue = "1";
|
|
ActivaModoVincularGuia();
|
|
}
|
|
}
|
|
ObjGeneral.Dispose();
|
|
}
|
|
|
|
protected void VincularGuia()
|
|
{
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
String Guia = TxtGuia.Text;
|
|
int CvePaqueteria = DdlPaqueterias.SelectedValue.ToEntero();
|
|
|
|
if (ObjGeneral.GetPaqueteriasGuias(-1,-1, CvePaqueteria, -1, -1, UsuarioActual.CveEmpresa, Guia, "-1", "-1") && ObjGeneral.DtResultados.Rows.Count > 0)
|
|
{
|
|
int CvePaqueteriaGuia = ObjGeneral.DtResultados.Rows[0]["CvePaqueteriaGuia"].ToString().ToEntero();
|
|
|
|
String Rastreo = ObjGeneral.DtResultados.Rows[0]["Rastreo"].ToString();
|
|
String Paqueteria = ObjGeneral.DtResultados.Rows[0]["Paqueteria"].ToString();
|
|
|
|
ObjGeneral.IniciaTransacSQL();
|
|
|
|
if (ObjGeneral.AddPaqueteriasGuiasDetalles(CvePaqueteriaGuia, CveVenta, CveOC, CveMovimiento, CveCompra))
|
|
{
|
|
ObjGeneral.Commit();
|
|
|
|
TxtGuia.Text = "";
|
|
DdlPaqueterias.SelectedValue = "-1";
|
|
|
|
if (CveVenta > 0)
|
|
{
|
|
|
|
// 04/04/2018 - Recupera Datos Venta y Envia correo de Notificacion
|
|
CargaDatosVenta(CveVenta);
|
|
|
|
// Destinatario = "sig.buzon02@gmail.com"; //Cliente, correo prueba eliminar esta linea
|
|
Boolean NotificacionEnviada = false;
|
|
|
|
if (DTGuiasVinculadas.Rows.Count > 1)
|
|
{
|
|
//Mas de dos Guia Vinculada a la Venta
|
|
//Notifica a cliente
|
|
NotificacionEnviada = EnviarCorreoNotificacionGuias(1, SerieFolio, NombreCliente, Destinatario, Paqueteria, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos);
|
|
//Notifica a correos fijos
|
|
EnviarCorreoNotificacionGuias(4, SerieFolio, NombreCliente, Destinatario, Paqueteria, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos, DTGuiasVinculadas.Rows.Count, CvePaqueteriaGuia);
|
|
|
|
}
|
|
else
|
|
{
|
|
//Primera Guia Vinculada a la Venta
|
|
//Notifica a cliente
|
|
NotificacionEnviada = EnviarCorreoNotificacionGuias(1, SerieFolio, NombreCliente, Destinatario, Paqueteria, Guia, Rastreo,Pedido,OrdenCompra, CveVenta, DTMovimientos);
|
|
}
|
|
//
|
|
if (NotificacionEnviada)
|
|
{
|
|
Alert(String.Format("La Venta se ha vinculado a la Guía {0} correctamente.<br><br>Correo enviado exitosamente a {1}", Guia, Destinatario), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("La Venta se ha vinculado a la Guía {0} correctamente.<br><br>Se presentó un Error al enviar el correo a: {1}", Guia, Destinatario), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
|
|
}
|
|
if (CveOC > 0) { Alert(String.Format("La Orden de Compra se ha vinculado a la Guía {0} correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveMovimiento > 0) { Alert(String.Format("El Movimiento se ha vinculado a la Guía {0} correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
if (CveCompra > 0) { Alert(String.Format("La Compra se ha vinculado a la Guía {0} correctamente.", Guia), ModExtensiones.TipoMensaje.MsgInformacion); }
|
|
}
|
|
else
|
|
{
|
|
ObjGeneral.RollBack();
|
|
}
|
|
ObjGeneral.Dispose();
|
|
}
|
|
else
|
|
{
|
|
Alert(String.Format("No se encontraron registros de la Guía {0}.", Guia), ModExtensiones.TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
protected void EliminarVinculacion(int CvePaqueteriaGuiaDetalle)
|
|
{
|
|
ClsGenerales ObjGeneral = new ClsGenerales();
|
|
ObjGeneral.IniciaTransacSQL();
|
|
|
|
if (ObjGeneral.RemovePaqueteriasGuiasDetalles(CvePaqueteriaGuiaDetalle, -1))
|
|
{
|
|
ObjGeneral.Commit();
|
|
Alert(String.Format("La vinculación de la Guía se ha Eliminado correctamente."), ModExtensiones.TipoMensaje.MsgInformacion);
|
|
}
|
|
else
|
|
{
|
|
ObjGeneral.RollBack();
|
|
}
|
|
ObjGeneral.Dispose();
|
|
}
|
|
#endregion
|
|
|
|
#region "BOTONES"
|
|
|
|
protected void BtnLimpiar_Click(object sender, EventArgs e)
|
|
{
|
|
LimpiaCampos();
|
|
}
|
|
|
|
protected void BtnCrearGuia_Click(object sender, EventArgs e)
|
|
{
|
|
AgregarNuevaGuia();
|
|
CargaGuiasVinculadas();
|
|
}
|
|
|
|
protected void BtnAgregarGuia_Click(object sender, EventArgs e)
|
|
{
|
|
VincularGuia();
|
|
CargaGuiasVinculadas();
|
|
}
|
|
|
|
protected void GvGuiasVinculadas_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|
{
|
|
|
|
int CvePaqueteriaGuiaDetalle = GvGuiasVinculadas.Rows[e.RowIndex].DataKey("CvePaqueteriaGuiaDetalle").ToEntero();
|
|
EliminarVinculacion(CvePaqueteriaGuiaDetalle);
|
|
CargaGuiasVinculadas();
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region "CORREO DE NOTIFICACION DE GUIA"
|
|
protected Boolean EnviarCorreoNotificacionGuias(int Tipo, String SerieFolio, String NombreCliente, String DestinatarioC, String Paqueteria, String Guia, String Rastreo, String Pedido, String OrdenCompra, int CveVenta, DataTable tDtMovimientos, int CountPaqueteria = 0, int CvePaqueteriaGuia = -1)
|
|
{
|
|
ClsSisMail Correo = new ClsSisMail();
|
|
String Asunto = String.Format("{0} Envio de pedido: {1}", UsuarioActual.Empresa.NombreCorto, SerieFolio);
|
|
StringBuilder Cuerpo = new StringBuilder();
|
|
|
|
Boolean MensajeEnviado = false;
|
|
|
|
switch (Tipo)
|
|
{
|
|
//CORREO NORMAL A CLIENTE
|
|
case 1:
|
|
Cuerpo.AppendLine(String.Format("Estimado {0} le informamos que los productos de la factura {1} han sido enviados mediante la paquetería {2} con Guia {3}, Rastreo {4}, Pedido {5}, Orden de Compra {6}.<br><br>", NombreCliente, SerieFolio, Paqueteria, Guia, Rastreo,Pedido,OrdenCompra));
|
|
|
|
if (tDtMovimientos.Rows.Count > 0)
|
|
{
|
|
Cuerpo.AppendLine("<table><tr>");
|
|
Cuerpo.AppendLine("<th>Cantidad</th><th>Producto</th>");
|
|
|
|
|
|
foreach (DataRow Drow in tDtMovimientos.Rows)
|
|
{
|
|
Cuerpo.AppendLine(String.Format("<tr><td>{0}</td><td>{1}</td></tr>", Drow["Cantidad"].ToString().ToEntero(), Drow["PS"].ToString()));
|
|
}
|
|
|
|
Cuerpo.AppendLine("</tr></table>");
|
|
}
|
|
|
|
Cuerpo.AppendLine("<br><br>Dudas y aclaraciones con su coordinador empresarial.");
|
|
List<ClsSisMail.ArchivoMail> LSRutasMail = new List<ClsSisMail.ArchivoMail>();
|
|
if (UsuarioActual.CveEmpresa.Contiene(1,72, 80))
|
|
{
|
|
string Ruta = String.Format("{0}Formatos\\{1}.docx", UsuarioActual.Empresa.Ruta, "DocumentoEntregasForaneas");
|
|
LSRutasMail.Add(new ClsSisMail.ArchivoMail() { Ruta = Ruta }); ;
|
|
|
|
}
|
|
|
|
|
|
if (Correo.SendMail(UsuarioActual.Empresa, DestinatarioC, Asunto, Cuerpo.ToString(),Archivos: LSRutasMail))
|
|
{
|
|
//Alert("Correo enviado exitosamente a " + DestinatarioC);
|
|
MensajeEnviado = true;
|
|
}
|
|
else
|
|
{
|
|
//Alert("Se presentó un Error al enviar el correo a " + DestinatarioC);
|
|
MensajeEnviado = false;
|
|
}
|
|
|
|
break;
|
|
case 2:
|
|
|
|
break;
|
|
|
|
case 3:
|
|
break;
|
|
|
|
case 4:
|
|
// CORREO FIJO CUANDO SON MAS DE 1 GUIA POR VENTA
|
|
Cuerpo.AppendLine(String.Format("Se informa que la venta {0} cuenta con {1} paqueteria(s), se agrego la paqueteria {2}, usuario {3}.<br><br>", SerieFolio, CountPaqueteria, Paqueteria, UsuarioActual.Nombre));
|
|
|
|
//correo a ramón y a luz
|
|
if (UsuarioActual.CveEmpresa.Contiene(72, 80))
|
|
{
|
|
DestinatarioC = "luzdelmarcoeto@compuproveedores.com;ramonmartinez@compuproveedores.com";
|
|
|
|
if (tDtMovimientos.Rows.Count > 0)
|
|
{
|
|
Cuerpo.AppendLine("<table><tr>");
|
|
Cuerpo.AppendLine("<th>Cantidad</th><th>Producto</th>");
|
|
|
|
foreach (DataRow Drow in tDtMovimientos.Rows)
|
|
{
|
|
Cuerpo.AppendLine(String.Format("<tr><td>{0}</td><td>{1}</td></tr>", Drow["Cantidad"].ToString().ToEntero(), Drow["PS"].ToString()));
|
|
}
|
|
Cuerpo.AppendLine("</tr></table>");
|
|
}
|
|
|
|
if (Correo.SendMail(UsuarioActual.Empresa, DestinatarioC, Asunto, Cuerpo.ToString()))
|
|
{
|
|
//Alert("Correo enviado exitosamente a " + DestinatarioC);
|
|
MensajeEnviado = true;
|
|
}
|
|
else
|
|
{
|
|
//Alert("Se presentó un Error al enviar el correo a " + DestinatarioC);
|
|
MensajeEnviado = false;
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
return MensajeEnviado;
|
|
}
|
|
|
|
protected void CargaDatosVenta(int CveVenta)
|
|
{
|
|
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();
|
|
SerieFolio = String.Format("{0}-{1}", DbRowVenta["Serie"].ToString(), DbRowVenta["Folio"].ToString().ToEntero());
|
|
NombreCliente = DbRowVenta["ClienteNombre"].ToString();
|
|
Pedido = DbRowVenta["PedidoContrato"].ToString();
|
|
OrdenCompra = DbRowVenta["OrdenCompra"].ToString();
|
|
string CorreoAsistente = "";
|
|
if (get_GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo: 3).FiltraParametros($"CveSuperior = {DbRowVenta["CveVendedor"].ToString()}").Rows.Count > 0)
|
|
{
|
|
foreach (DataRow Dr in get_GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo: 3).FiltraParametros($"CveSuperior = {DbRowVenta["CveVendedor"].ToString()}").Rows)
|
|
{
|
|
CorreoAsistente += $";{Dr["Correo"].ToString()}";
|
|
}
|
|
}
|
|
|
|
Destinatario = $"{DbRowVenta["Mail"].ToString()};{DbRowVenta["CorreoVendedorVenta"].ToString()}{CorreoAsistente}";
|
|
if (ObjVentas.GetVentaDetalle(CveVenta))
|
|
{
|
|
DTMovimientos = ObjVentas.DtResultados;
|
|
}
|
|
|
|
}
|
|
}
|
|
ObjVentas.Dispose();
|
|
}
|
|
|
|
private string DocumentoEntregaInterna()
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (ObjVentas.GetVenta(this.CveVenta, UsuarioActual.CveEmpresa) && ObjVentas.DtResultados.Rows.Count> 0)
|
|
{
|
|
string ClienteNombre = ObjVentas.DtResultados.Rows[0]["ClienteNombre"].ToString();
|
|
string FolioVenta = ObjVentas.DtResultados.Rows[0]["SerieFolio"].ToString();
|
|
string Pedido = ObjVentas.DtResultados.Rows[0]["PedidoContrato"].ToString();
|
|
string OrdenCompra = ObjVentas.DtResultados.Rows[0]["OrdenCompra"].ToString();
|
|
string Guia = TxtGuia.Text;
|
|
string Rastreo = TxtRastreo.Text;
|
|
string Paqueteria = DdlPaqueterias.SelectedItem.Text;
|
|
string TipoDocto = ObjVentas.DtResultados.Rows[0]["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("<tr><td style='width:25%'>{0}</td><td style='width:25%'>{1}</td><td style='width:50%'>{2}</td></tr>", dRow["Codigo"], dRow["Cantidad"], dRow["PS"]);
|
|
DetalleTable += detalle;
|
|
}
|
|
|
|
StringBuilder strBody = new StringBuilder();
|
|
strBody.Append("<html>");
|
|
strBody.Append("<head>");
|
|
strBody.Append("<meta charset='UTF-8'>");
|
|
strBody.Append("</head>");
|
|
strBody.Append(" <body style='width:800px;'>");
|
|
strBody.Append("<div>");
|
|
strBody.Append($"<img src='http://sig.adssistemas.mx/Empresas/{UsuarioActual.CveEmpresa}/Logo.png' style='width:200px'></img>");
|
|
strBody.Append("</div>");
|
|
strBody.Append(" <p style='font-family:Segoe UI Semibold;font-size:12pt;width:100%'>");
|
|
strBody.Append($" Apreciable {ClienteNombre}, su pedido ya se encuentra en camino con el número de guía {Guia} y rastreo {Rastreo} de {Paqueteria}. Le confirmamos los productos que recibirá conforme a la {TipoDocto}:");
|
|
strBody.Append(" </p>");
|
|
strBody.Append($" <p style='width:100%;text-align:center;font-family:Segoe UI Semibold;font-size:12pt'>{FolioVenta} - Pedido {Pedido} - Orden de Compra {OrdenCompra}</P>");
|
|
strBody.Append(" <div style='width:100%;text-align:center'>");
|
|
strBody.Append(" <table style='width:100%;font-family:Segoe UI Semibold;font-size:12pt'>");
|
|
strBody.Append(DetalleTable);
|
|
strBody.Append(" </table>");
|
|
strBody.Append(" </div>");
|
|
strBody.Append(" <p style='font-family:Segoe UI Semibold;font-size:12pt;width:100%'>");
|
|
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(" </p>");
|
|
strBody.Append(" <p style='font-family:Segoe UI Semibold;font-size:12pt;width:100%'>");
|
|
strBody.Append(" • Empaque violado.<br/>");
|
|
strBody.Append("• Daño físico en la caja.<br/>");
|
|
strBody.Append("• Producto incompleto o distinto al solicitado.<br/>");
|
|
strBody.Append("• Alguna otra situación que se considere que compromete la integridad de la mercancía.");
|
|
strBody.Append("");
|
|
strBody.Append(" </p>");
|
|
strBody.Append(" <br/>");
|
|
strBody.Append(" <p style='font-family:Segoe UI Semibold;font-size:12pt;width:100%'>");
|
|
strBody.Append(" Gracias por realizar pedido <br/>");
|
|
//strBody.Append(" Compuproveedores");
|
|
strBody.Append(" </p>");
|
|
strBody.Append(" <p style='font-family:Segoe UI Semibold;font-size:12pt;width:100%;text-align:center'>");
|
|
strBody.Append(" Sigue disfrutando de nuestros productos y servicios<br/>");
|
|
//strBody.Append(" <a href='https://www.compuproveedoresti.com/'>www.compuproveedores.com</a>");
|
|
strBody.Append("");
|
|
strBody.Append(" </p>");
|
|
strBody.Append(" </body>");
|
|
strBody.Append("</html>");
|
|
|
|
return strBody.ToString();
|
|
}
|
|
ObjVentas.Dispose();
|
|
return "";
|
|
}
|
|
|
|
private string getCorreoString()
|
|
{
|
|
ClsVentas ObjVentas = new ClsVentas();
|
|
if (ObjVentas.GetVenta(CveVenta,UsuarioActual.CveEmpresa) && ObjVentas.DtResultados.Rows.Count > 0 )
|
|
{
|
|
int CveVendedor = ObjVentas.DtResultados.Rows[0]["CveVendedor"].ToEntero();
|
|
int CveCliente = ObjVentas.DtResultados.Rows[0]["CveCliente"].ToEntero();
|
|
DataRow Vendedor = get_GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltroPrimero(string.Format("CveVendedor = {0}",CveVendedor));
|
|
DataRow VendedorAsistente = get_GlobalDTVendedores(UsuarioActual.CveEmpresa,VendedorTipo:3).FiltroPrimero(string.Format("CveSuperior = {0}", CveVendedor));
|
|
DataRow Cliente = get_GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente : CveCliente).FiltroPrimero("");
|
|
string CorreoEntregaAlmacen = "";
|
|
string CorreoEntregaCompras = "";
|
|
string CorreoVendedor = "";
|
|
string CorreoNotificaciones = ObjVentas.DtResultados.Rows[0]["CorreoNotificacion"] != null ? ObjVentas.DtResultados.Rows[0]["CorreoNotificacion"].ToString():"";
|
|
string CorreoAsistente = "";
|
|
|
|
if (Cliente != null) {
|
|
CorreoEntregaAlmacen=Cliente["CorreoEntregaAlmacen"].ToString();
|
|
CorreoEntregaCompras = Cliente["CorreoEntregaCompras"].ToString();
|
|
}
|
|
if (Vendedor != null)
|
|
{
|
|
CorreoVendedor=Vendedor["Correo"].ToString();
|
|
//CorreoAdicionalNotificacionesVendedor=Vendedor["CorreoAdicionalNotificaciones"].ToString();
|
|
}
|
|
if (VendedorAsistente != null)
|
|
{
|
|
CorreoAsistente = VendedorAsistente["Correo"].ToString();
|
|
}
|
|
string CorreosConcat = String.Format("{0};{1};{2};{3};{4}", CorreoEntregaAlmacen, CorreoEntregaCompras, CorreoVendedor, CorreoNotificaciones, CorreoAsistente);
|
|
return CorreosConcat;
|
|
}
|
|
ObjVentas.Dispose();
|
|
return "";
|
|
}
|
|
|
|
private void MandaCorreoNotificacionGuia(string Correos)
|
|
{
|
|
|
|
string body = DocumentoEntregaInterna();
|
|
|
|
ClsSisMail MailCls = new ClsSisMail();
|
|
|
|
MailCls.SendMail(ClsPaginas.EmpresaNotificaciones, Correos, "Se enviara la compra a su dirección", body, Correos);
|
|
MailCls = null;
|
|
}
|
|
#endregion
|
|
|
|
private void CondicionesVenta()
|
|
{
|
|
|
|
ClsVentas ObjVenta = new ClsVentas();
|
|
if (ObjVenta.GetVenta(CveVenta,UsuarioActual.CveEmpresa))
|
|
{
|
|
if (ObjVenta.DtResultados.Rows.Count > 0)
|
|
{
|
|
DataRow VentasDetalle = ObjVenta.DtResultados.Rows[0];
|
|
double Total = VentasDetalle["Total"].ToString().ToDouble();
|
|
bool Mostrar = (Total >= 50000.00);
|
|
tdLblPolizaSeguro.Visible = Mostrar;
|
|
tdTxtPolizaSeguro.Visible = Mostrar;
|
|
}
|
|
}
|
|
ObjVenta.Dispose();
|
|
}
|
|
|
|
} |