E143. Generar remisiones en portal del cliente
This commit is contained in:
@@ -1432,7 +1432,7 @@
|
||||
<table border="0" id="Table1" runat="server" style="width: 100%">
|
||||
<tr>
|
||||
<td>
|
||||
<asp:GridView ID="GvPedidos" runat="server" Width="100%" OnRowDataBound="GvPedidos_RowDataBound" DataKeyNames="CveVenta,Total,SerieFolio" AutoGenerateColumns="False" EmptyDataText="No se encontraron pedidos en el cliente" ToolTip="Listado de pedidos" CssClass="table table-striped table-advance table-hover " Style="margin-top: -10px; text-align: center;" GridLines="None">
|
||||
<asp:GridView ID="GvPedidos" runat="server" Width="100%" OnRowDataBound="GvPedidos_RowDataBound" DataKeyNames="CveVenta,Total,SerieFolio" AutoGenerateColumns="False" EmptyDataText="No se encontraron pedidos en el cliente" ToolTip="Listado de pedidos" CssClass="table table-striped table-advance table-hover" Style="margin-top: -10px; text-align: center;" GridLines="None">
|
||||
<Columns>
|
||||
<asp:TemplateField>
|
||||
<HeaderTemplate>Pedido</HeaderTemplate>
|
||||
@@ -2071,6 +2071,13 @@
|
||||
catch (e) { alert(e); }
|
||||
}
|
||||
|
||||
function CerrarModalVenta() {
|
||||
try {
|
||||
$('#DivVenta').modal('hide');
|
||||
}
|
||||
catch (e) { alert(e); }
|
||||
}
|
||||
|
||||
//VALIDA QUE LA CANTIDAD DE T (TXT) NO SEA MAYOR A C
|
||||
function ValidarCantidad(t, c) {
|
||||
t.value = (ToDouble(t.value) > ToDouble(c) ? c : t.value)
|
||||
|
||||
@@ -9,6 +9,7 @@ Imports System.IO.Compression
|
||||
Imports System.Net
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
Imports System.Net.Http
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Partial Class Ventas_PortalCliente
|
||||
Inherits ClsPaginas
|
||||
@@ -26,6 +27,15 @@ Partial Class Ventas_PortalCliente
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CvePrecioLista As Integer
|
||||
Get
|
||||
Return IfNull(ViewState("CvePrecioLista"), "-1", ViewState("CvePrecioLista")).ToString().ToEntero()
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CvePrecioLista") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property Destino As String
|
||||
Set(value As String)
|
||||
ViewState("Destino") = value
|
||||
@@ -223,8 +233,13 @@ Partial Class Ventas_PortalCliente
|
||||
CargarTipoBuzon()
|
||||
CargarClienteSucursal()
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
TabPedidos.Visible = True
|
||||
CargaPedidos(TipoDocto:="Rem")
|
||||
Else
|
||||
CargaPedidos()
|
||||
End If
|
||||
|
||||
CargaCuentasDepositos()
|
||||
|
||||
'??ESTE TAB VA DESAPARECER - PARA QUE SOLO LA EMPRESA GESTIONE A LOS USUARIOS POR CLIENTE??
|
||||
@@ -260,6 +275,7 @@ Partial Class Ventas_PortalCliente
|
||||
If ObjClientes.DtResultados.Rows.Count > 0 Then
|
||||
'Campos para Modificación
|
||||
LtlCliente.Text = ObjClientes.Nombre
|
||||
CvePrecioLista = ObjClientes.CvePrecioLista
|
||||
Else
|
||||
Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
@@ -1736,11 +1752,11 @@ Partial Class Ventas_PortalCliente
|
||||
|
||||
UpIxC.Update()
|
||||
End Sub
|
||||
Private Sub CargaPedidos(Optional TopPedidos As Integer = 21)
|
||||
Private Sub CargaPedidos(Optional TopPedidos As Integer = 21, Optional TipoDocto As String = "Pd2")
|
||||
Dim FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim.ToDate, MinFecha)
|
||||
Dim FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim.ToDate, MaxFecha)
|
||||
Dim ObjClientes As New ClsClientes
|
||||
If ObjClientes.GetHistorialVentas(CveCliente, UsuarioActual.CveEmpresa, TopPedidos, CveClienteSucursal:=-1, TipoDocto:="Pd2", CveEstatusFactura:=DdlEstatus.SelectedValue.ToEntero(), FechaI:=FechaI, FechaF:=FechaF) Then
|
||||
If ObjClientes.GetHistorialVentas(CveCliente, UsuarioActual.CveEmpresa, TopPedidos, CveClienteSucursal:=-1, TipoDocto:=TipoDocto, CveEstatusFactura:=DdlEstatus.SelectedValue.ToEntero(), FechaI:=FechaI, FechaF:=FechaF) Then
|
||||
GvPedidos.DataSource = ObjClientes.DtResultados
|
||||
If ObjClientes.DtResultados.Rows.Count < 21 Then
|
||||
LnkVerMasPedidos.Visible = False
|
||||
@@ -1753,15 +1769,24 @@ Partial Class Ventas_PortalCliente
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaPedidos()
|
||||
Dim TipoDocto As String = "Pd2"
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
TipoDocto = "Rem"
|
||||
End If
|
||||
CargaPedidos(TipoDocto:=TipoDocto)
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnVerMasPedidos_Click(sender As Object, e As EventArgs)
|
||||
Dim TipoDocto As String = "Pd2"
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
TipoDocto = "Rem"
|
||||
End If
|
||||
|
||||
If BtnVerMasVentas.Text = "Ver Más" Then
|
||||
CargaPedidos(-1)
|
||||
CargaPedidos(-1, TipoDocto:=TipoDocto)
|
||||
BtnVerMasVentas.Text = "Ver Menos"
|
||||
Else
|
||||
CargaPedidos(21)
|
||||
CargaPedidos(21, TipoDocto:=TipoDocto)
|
||||
BtnVerMasVentas.Text = "Ver Más"
|
||||
End If
|
||||
End Sub
|
||||
@@ -2532,7 +2557,7 @@ Partial Class Ventas_PortalCliente
|
||||
|
||||
#Region "CARGAS"
|
||||
|
||||
Private Sub CargaFolios()
|
||||
Private Sub CargaFolios(Optional TipoDocto As String = "Pd2")
|
||||
|
||||
If CveSubProyecto <= 0 Then
|
||||
Alert("No se tienen asignadas sucursales", TipoMensaje.MsgError)
|
||||
@@ -2540,7 +2565,7 @@ Partial Class Ventas_PortalCliente
|
||||
End If
|
||||
|
||||
Dim ObjFolios As New ClsGralFolios()
|
||||
If ObjFolios.GetFolios("Pd2", UsuarioActual.CveEmpresa) Then
|
||||
If ObjFolios.GetFolios(TipoDocto, UsuarioActual.CveEmpresa) Then
|
||||
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format("CveSubProyecto = {0} And Estado = 'Activo'", CveSubProyecto))
|
||||
If DT.Rows.Count > 0 Then
|
||||
ViewState("CveFolio") = DT.Rows(0)("CveFolio").ToString.ToEntero
|
||||
@@ -2593,7 +2618,12 @@ Partial Class Ventas_PortalCliente
|
||||
TxtPrecio.Attributes.Add("onKeyUp ", "Recalcula();")
|
||||
TxtCantidad.Attributes.Add("onKeyUp ", "Recalcula();")
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
CargaFolios("Rem")
|
||||
Else
|
||||
CargaFolios()
|
||||
End If
|
||||
|
||||
|
||||
Dim Dt = New DataSet
|
||||
Dt.Tables.Add("Datos")
|
||||
@@ -2751,6 +2781,7 @@ Partial Class Ventas_PortalCliente
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlPS_selectedindexchange(sender As Object, e As EventArgs)
|
||||
TxtPrecio.Text = ""
|
||||
DdlPSIndexChange()
|
||||
End Sub
|
||||
|
||||
@@ -2771,8 +2802,21 @@ Partial Class Ventas_PortalCliente
|
||||
DdlUM.DataBind()
|
||||
DdlUM.SelectedValueExist(drPS("CveUnidadMedida").ToString)
|
||||
|
||||
TxtPrecio.Text = drPS("Precio").ToString.FormatoNumero(2).Replace(","c, "")
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
If CvePrecioLista > 0 Then
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioLista, CvePS:=DdlPS.SelectedValue.ToEntero()) Then
|
||||
If ObjPS.DtResultados.Rows.Count > 0 Then
|
||||
TxtPrecio.Text = ObjPS.DtResultados.Rows(0)("PrecioLista").ToString().ToDecimal().FormatoNumero()
|
||||
Else
|
||||
TxtPrecio.Text = ""
|
||||
End If
|
||||
Else
|
||||
TxtPrecio.Text = ""
|
||||
End If
|
||||
ObjPS.Dispose()
|
||||
End If
|
||||
Else
|
||||
If UsuarioActual.CveEmpresa = 80 Then
|
||||
'busca el precio de la sucursal
|
||||
Dim ObjPS As New ClsProductosServicios
|
||||
@@ -2787,6 +2831,13 @@ Partial Class Ventas_PortalCliente
|
||||
End If
|
||||
|
||||
ObjPS.Dispose()
|
||||
Else
|
||||
TxtPrecio.Text = drPS("Precio").ToString.FormatoNumero(2).Replace(","c, "")
|
||||
End If
|
||||
End If
|
||||
|
||||
If TxtPrecio.Text.ToDecimal() <= 0 Then
|
||||
Alert("No se encontro un precio para el producto seleccionado", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
If DdlClasificacion.SelectedIndex = 0 Then
|
||||
@@ -2804,6 +2855,7 @@ Partial Class Ventas_PortalCliente
|
||||
Else
|
||||
Alert("Es necesario seleccionar el cliente al cual se le va a facturar.", TipoMensaje.MsgAdvertencia, "AbrirVentana(""/Ventas/PopUpBuscarClientes.aspx?Opt=Fact"", 800, 547, ""N"", ""PopUpBuscar"")")
|
||||
End If
|
||||
|
||||
RegistraScript("Recalcula();")
|
||||
UpVenta.Update()
|
||||
|
||||
@@ -2819,6 +2871,21 @@ Partial Class Ventas_PortalCliente
|
||||
|
||||
#Region "AGREGAR/EDITAR/ELIMINAR"
|
||||
Protected Sub LnkAddPedido_Click(sender As Object, e As EventArgs)
|
||||
If TmpDT IsNot Nothing Then
|
||||
TmpDT.Rows.Clear()
|
||||
TxtObsFact.Text = ""
|
||||
|
||||
GvPS.DataSource = TmpDT
|
||||
GvPS.DataBind()
|
||||
|
||||
CalculaTotalesVenta()
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
DdlMoneda.SelectedValueExist(1)
|
||||
DdlMoneda.Enabled = False
|
||||
End If
|
||||
|
||||
RegistraScript("$('#DivVenta').modal({backdrop: 'static',keyboard: false});")
|
||||
End Sub
|
||||
Protected Sub LnkAddPSVenta_Click(sender As Object, e As EventArgs)
|
||||
@@ -2837,6 +2904,12 @@ Partial Class Ventas_PortalCliente
|
||||
DdlClasificacion.SelectedIndex = -1
|
||||
DdlUM.Items.Clear()
|
||||
ChkAgregar.Checked = True
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
TxtPrecio.Enabled = False
|
||||
End If
|
||||
|
||||
UpVenta.Update()
|
||||
UpAddPedido.Update()
|
||||
|
||||
RegistraScript("$('#DivAddVenta').modal({backdrop: 'static',keyboard: false});")
|
||||
@@ -2850,7 +2923,7 @@ Partial Class Ventas_PortalCliente
|
||||
CargaPS(DdlClasificacion.SelectedValue.ToEntero, DdlPS)
|
||||
UpClasificacion.Update()
|
||||
If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then
|
||||
DdlPS.SelectedValue = GvRow.DataKey("CvePS")
|
||||
DdlPS.ddl.SelectedValueExist(GvRow.DataKey("CvePS"))
|
||||
Else
|
||||
DdlPS.SelectedValue = GvRow.DataKey("CvePS")
|
||||
DdlPS.SelectedText = GvRow.DataKey("PS")
|
||||
@@ -2906,6 +2979,20 @@ Partial Class Ventas_PortalCliente
|
||||
End Sub
|
||||
|
||||
Private Sub AgregarPS()
|
||||
If TxtPrecio.Text.ToDecimal() <= 0 Then
|
||||
Alert("El precio del producto debe ser mayor a cero", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
For Each Row As DataRow In TmpDT.FiltraParametros("", DistinctColumns:={"CveClasificacion", "Clasificacion"}).Rows
|
||||
If DdlClasificacion.SelectedValue.ToEntero <> Row("CveClasificacion").ToString().ToEntero() Then
|
||||
Alert($"El pedido actual solo es para la clasificación '{Row("Clasificacion")}'. Debe seleccionar productos de la misma clasificación", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If Modalidad = "U" Then
|
||||
|
||||
Dim ErrorEdit As Boolean = True
|
||||
@@ -3181,7 +3268,7 @@ Partial Class Ventas_PortalCliente
|
||||
Timbre.Comprobante.FormadePago = Obj.FormaPagoSAT33
|
||||
Timbre.Comprobante.CondicionesdePago = Obj.FormaPago33
|
||||
Timbre.Comprobante.MetodoPago = Obj.ClaveMetodoPagoSAT
|
||||
Timbre.Comprobante.Subtotal = Obj.SubTotal
|
||||
Timbre.Comprobante.SubTotal = Obj.SubTotal
|
||||
Timbre.Comprobante.Descuentos = Obj.Descuento
|
||||
Timbre.Comprobante.Moneda = Obj.MonedaSAT
|
||||
Timbre.Comprobante.TipoCambio = If(Obj.CveMoneda = 1, "1", Obj.TipoCambio.ToString)
|
||||
@@ -3287,8 +3374,136 @@ Partial Class Ventas_PortalCliente
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
|
||||
|
||||
If UsuarioActual.CveEmpresa = 143 Then
|
||||
GuardarWS()
|
||||
Else
|
||||
Guardar()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function SubProyectosClasificaciones() As Hashtable
|
||||
Dim retorno As New Hashtable()
|
||||
|
||||
'CVECLASIFICACION/CVESUBPROYECTO
|
||||
retorno.Add(20331, 11713)
|
||||
retorno.Add(20332, 11761)
|
||||
retorno.Add(20333, 11714)
|
||||
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
Private Sub GuardarWS()
|
||||
|
||||
Dim DtClasificaciones As DataTable = TmpDT.FiltraParametros("", DistinctColumns:={"CveClasificacion", "Clasificacion"})
|
||||
|
||||
If DtClasificaciones IsNot Nothing AndAlso DtClasificaciones.Rows.Count > 1 Then
|
||||
Alert("El pedido debe tener productos de una misma clasificación", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim CveSubProyectoPedido As Integer = -1
|
||||
|
||||
Dim CveClasificacion As Integer = TmpDT.FiltroPrimeroValor("CveClasificacion").ToEntero()
|
||||
|
||||
Dim SubProyectos = SubProyectosClasificaciones()
|
||||
|
||||
'VERIFICA SI LA CLASIFICACION PERTENECE AL SUBPROYECTO
|
||||
If SubProyectos.ContainsKey(CveClasificacion) Then
|
||||
CveSubProyectoPedido = SubProyectos(CveClasificacion).ToString().ToEntero()
|
||||
Else
|
||||
CveSubProyectoPedido = Me.CveSubProyecto
|
||||
End If
|
||||
|
||||
Dim productos As New JArray()
|
||||
For Each Row As DataRow In TmpDT.Rows
|
||||
productos.Add(New JObject(
|
||||
New JProperty("CvePS", Row("CvePS").ToString().ToEntero()),
|
||||
New JProperty("Cantidad", Row("Cantidad").ToString().ToDecimal()),
|
||||
New JProperty("Obs", Row("Obs").ToString()),
|
||||
New JProperty("Precio", Row("PU").ToString().ToDecimal()),
|
||||
New JProperty("Descuento", Row("Descuento").ToString().ToDecimal())
|
||||
)
|
||||
)
|
||||
Next
|
||||
|
||||
Dim URLAPI As String = "https://sig.adssistemas.mx/asmx/WSApp.asmx?WSDL"
|
||||
|
||||
If Not EsProduccion Then
|
||||
URLAPI = "http://localhost:85/asmx/WSApp.asmx?WSDL"
|
||||
End If
|
||||
|
||||
Dim jsonResp = EnviarPedidoWS(URLAPI, CveCliente, CveSubProyectoPedido, UsuarioActual.CveUsuario, TxtObsFact.Text, productos.ToString())
|
||||
|
||||
If Not String.IsNullOrEmpty(jsonResp) Then
|
||||
Dim resp As JObject = JObject.Parse(jsonResp)
|
||||
Dim TieneError As Boolean = CBool(resp("TieneError"))
|
||||
If Not TieneError Then
|
||||
Alert($"La remisión <b>'{resp("SerieFolio")}'</b> se genero correctamente.", JSBtnAceptar:="CerrarModalVenta();", ShowCloseButton:=False)
|
||||
CargaPedidos(TipoDocto:="Rem")
|
||||
Else
|
||||
Alert($"Ocurrió un error al generar el pedido.", TipoMensaje.MsgError)
|
||||
End If
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function EnviarPedidoWS(ByVal url As String, CveCliente As Integer, CveSubProyecto As Integer, CveUsuario As Integer, Observaciones As String, Productos As String) As String
|
||||
Dim retorno = ""
|
||||
|
||||
Try
|
||||
Dim request As HttpWebRequest = CType(WebRequest.Create($"{url}"), HttpWebRequest)
|
||||
request.ContentType = "text/xml;charset=""utf-8"""
|
||||
request.Accept = "text/xml"
|
||||
request.Method = "POST"
|
||||
Dim XMLString As String = $"<Envelope xmlns=""http://schemas.xmlsoap.org/soap/envelope/"">
|
||||
<Body>
|
||||
<AddPedido xmlns=""http://ADSistemas.org/"">
|
||||
<CveCliente>{CveCliente}</CveCliente>
|
||||
<CveSubProyecto>{CveSubProyecto}</CveSubProyecto>
|
||||
<CveUsuario>{CveUsuario}</CveUsuario>
|
||||
<Observaciones>{Observaciones}</Observaciones>
|
||||
<Productos>{Productos}</Productos>
|
||||
</AddPedido>
|
||||
</Body>
|
||||
</Envelope>"
|
||||
Dim SOAPReqBody As XmlDocument = New XmlDocument()
|
||||
SOAPReqBody.LoadXml(XMLString)
|
||||
|
||||
Using stream As Stream = request.GetRequestStream()
|
||||
SOAPReqBody.Save(stream)
|
||||
End Using
|
||||
|
||||
Dim response As String = ""
|
||||
|
||||
Using Serviceres As WebResponse = request.GetResponse()
|
||||
Using rd As StreamReader = New StreamReader(Serviceres.GetResponseStream())
|
||||
response = rd.ReadToEnd()
|
||||
End Using
|
||||
End Using
|
||||
|
||||
If Not String.IsNullOrEmpty(response) Then
|
||||
Dim xmlRetorno = New XmlDocument()
|
||||
xmlRetorno.LoadXml(response)
|
||||
retorno = xmlRetorno.InnerText
|
||||
Else
|
||||
Alert($"Ocurrió un error al leer la respuesta.", TipoMensaje.MsgError)
|
||||
retorno = ""
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
retorno = ""
|
||||
OnError("Ocurrió un error al guardar el pedido", ex)
|
||||
End Try
|
||||
|
||||
Return retorno
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub Guardar()
|
||||
If TmpDT Is Nothing OrElse TmpDT.Rows.Count = 0 Then
|
||||
Alert("Es necesario tener al menos un concepto registrado.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
@@ -3424,8 +3639,8 @@ Partial Class Ventas_PortalCliente
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub EnviarCorreoPedido(ObjFactura As Modelos.Factura)
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, ObjFactura.CveVenta, True, ObjFactura))
|
||||
Hilo.Start()
|
||||
|
||||
Reference in New Issue
Block a user