Commit inicial Ventas Productivo
This commit is contained in:
732
General/PopUpPaqueteriasGuias.aspx.cs
Normal file
732
General/PopUpPaqueteriasGuias.aspx.cs
Normal file
@@ -0,0 +1,732 @@
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
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 = GlobalDTPaqueterias;
|
||||
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;
|
||||
|
||||
int CvePaqueteriaGuia = ObjGeneral.AddPaqueteriasGuias(CvePaqueteria, CvePaqueteriaGuiaTipo,CveEstatus, CveSucursal, Fecha, Rastreo, Guia, NoCajas, Peso, Dimensiones, FechaEstimada, Observaciones, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, ImplicaCosto);
|
||||
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user