diff --git a/App_Code/ClsClientes.vb b/App_Code/ClsClientes.vb index 7a14674f8..9435c83d1 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -525,7 +525,7 @@ Public Class ClsClientes 'SqlAdapter.Dispose() Return Retorno End Function - Public Function GetHistorialVentas(CveCliente As Integer, Optional SelectTop As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional TipoDocto As String = "-1") As Boolean + Public Function GetHistorialVentas(CveCliente As Integer, Optional SelectTop As Integer = -1, Optional CveClienteSucursal As Integer = -1, Optional TipoDocto As String = "-1", Optional CveEstatusFactura As Integer = -1, Optional FechaI As DateTime = ModExtensiones.MinFecha, Optional FechaF As DateTime = ModExtensiones.MaxFecha) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_ClienteHistorialVentas") @@ -533,6 +533,9 @@ Public Class ClsClientes SqlAdapter.SelectCommand.Parameters.Add("@SelectTop", SqlDbType.Int).Value = SelectTop SqlAdapter.SelectCommand.Parameters.Add("@CveClienteSucursal", SqlDbType.Int).Value = CveClienteSucursal SqlAdapter.SelectCommand.Parameters.Add("@TipoDocto", SqlDbType.VarChar).Value = TipoDocto + SqlAdapter.SelectCommand.Parameters.Add("@CveEstatusFactura", SqlDbType.Int).Value = CveEstatusFactura + SqlAdapter.SelectCommand.Parameters.Add("@FechaI", SqlDbType.DateTime).Value = FechaI + SqlAdapter.SelectCommand.Parameters.Add("@FechaF", SqlDbType.DateTime).Value = FechaF Try SqlAdapter.Fill(Data) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 5d28a3a5a..2157dedef 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -4265,6 +4265,14 @@ Namespace Modelos Return Retorno End If + 'VALIDACION DE PEDIDOS: SI ESTA ENTEGADO NO SE PUEDA CANCELAR + If ObjFactura.TipoDocto = "Pd2" AndAlso TieneAlmacen AndAlso ObjFactura.SaldoAlmacen <> 0 Then + Retorno.Mensaje = "El pedido no se puede cancelar debido ha que ya fue entregado." + Retorno.TipoMensaje = TipoMensaje.MsgAdvertencia + + Return Retorno + End If + Dim CveEstatusRefacturacion As Integer = If(ObjFactura.CveEstatusRefacturacion <= 0, 0, ObjFactura.CveEstatusRefacturacion) diff --git a/PortalCliente/PortalCliente.aspx b/PortalCliente/PortalCliente.aspx index bd846d0b1..cf82c513a 100644 --- a/PortalCliente/PortalCliente.aspx +++ b/PortalCliente/PortalCliente.aspx @@ -1,600 +1,657 @@ -<%@ Page Title="Portal Cliente" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PortalCliente.aspx.vb" Inherits="Ventas_PortalCliente" %> - -<%@ Register Assembly="eWorld.UI, Version=2.0.6.2393, Culture=neutral, PublicKeyToken=24d65337282035f2" Namespace="eWorld.UI" TagPrefix="ew" %> - - - - - - -
  • - Descargar todos los PDF -
  • -
  • - Descargar todos los XML -
  • - - -
  • - Agregar Concepto -
  • -
    -
    -
    - -   - - - - - - - - - + +
    - - - - - - - - - - - - - - - - - - -
    -
    -
    - Resumen - - - - - - - - - - - - - - - - - - - - - -
    Cantidad de Compras:  -
    Total Comprado:  -
    Compra Mínima:  -
    Promedio de Compras:  -
    Compra Máxima:  -
    -
    -
    -
    -
    -
    - - - - - - - - -
    -
    -
    - -
    -
    - Historial de Compras - - - - - - - - - - -
    - - - - - - - - - - - Tipo - - - - - - - - - Factura - - - - - - - - Fecha - - - - - - - Sub Total - - - - - - - Descuento - - - - - - - Amortización - - - - - - - Total - - - - - - - - Moneda - - - - - - - Estatus - - - - - - - Se Timbró - - - - - - - Envío Mail - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    -
    -
    -
    -
    - - - - - - + +
    -
    -
    - Cuentas por Pagar Activas - - - - - - - - - + + + + +
    - - - - - - - - - - Factura - - - - - - Fecha Compra - - - - - - Fecha Vencimiento - - - - - - - Días Vencidos - +<%@ Page Title="Portal Cliente" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PortalCliente.aspx.vb" EnableEventValidation="false" Inherits="Ventas_PortalCliente" %> + +<%@ Register Assembly="eWorld.UI, Version=2.0.6.2393, Culture=neutral, PublicKeyToken=24d65337282035f2" Namespace="eWorld.UI" TagPrefix="ew" %> + + + + + + +
  • + Descargar todos los PDF +
  • +
  • + Descargar todos los XML +
  • +
    + +   + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    +
    + Resumen + + + + + + + + + + + + + + + + + + + + + +
    Cantidad de Compras:  +
    Total Comprado:  +
    Compra Mínima:  +
    Promedio de Compras:  +
    Compra Máxima:  +
    +
    +
    +
    +
    +
    + + + + + + + + +
    +
    +
    + +
    +
    + Historial de Compras + + + + + + + + + + +
    + + + + + + + + + + + Tipo + + + + + + + + + Factura + + + + + + + + Fecha + + + + + + + Sub Total + + + + + + + Descuento + + + + + + + Amortización + + + + + + + Total + + + + + + + + Moneda + + + + + + + Estatus + + + + + + + Se Timbró + + + + + + + Envío Mail + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    +
    +
    +
    + + + + + + - - - - - - + + + + + + - -
    +
    +
    + Cuentas por Pagar Activas + + + + + + + + + - + + + + + Pagar + + + <%----%> + + + + Bitácora + + + + + + + + + + <%-- - --%> -
    + + + + + + + + + + Factura + + + + + + Fecha Compra + + + + + + Fecha Vencimiento + + + + + + + Días Vencidos +   - - - - Monto Compra (Saldo Orig) - + + + + + Monto Compra (Saldo Orig) +   - - - - $ Abonado - + + + + + $ Abonado +   - - - - % Abonado - + + + + + % Abonado +   - - - - Saldo - + + + + + Saldo +   - - - - % A Pagar - + + + + + % A Pagar + %  - - - - Pagar - - - <%----%> - - - - Bitácora - - - - - - - - -
    -
    -
    -
     
    -
    -
    - Historial de Cuentas por Pagar - - - - - - --%> +
    - - - - - - - - - - Factura - - - - - - Fecha Compra - - - - - - Fecha Vencimiento - - - - - - Días Vencidos - +
    +
    +
    +
     
    +
    +
    + Historial de Cuentas por Pagar + + + + + + - + + + + + + + + + + + + <%-- - --%> -
    + + + + + + + + + + Factura + + + + + + Fecha Compra + + + + + + Fecha Vencimiento + + + + + + Días Vencidos +   - - - - Monto Compra (Saldo Orig) - + + + + + Monto Compra (Saldo Orig) +   - - - - $ Abonado - + + + + + $ Abonado +   - - - - % Abonado - + + + + + % Abonado +   - - - - Saldo - + + + + + Saldo +   - - - - % A Pagar - + + + + + % A Pagar +   - - - - - - - - - -
    -
    -
    -
    -
    -
    - - - - - - -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    -
    -
    - - Anticipo del Cliente -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - -
    -
    -
    - - Anticipo del Cliente Historial -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - -
    - -
    - -
    -
    -
    -
    -
    - -
    -
    - - - - -
    -
    - Datos del Orden de Servicio - - - - - - - - - - - - - --%> +
    Persona que Solicitó: - -
    Descripción: - -
    Fecha Cita: +
    +
    +
    +
    +
    + + + + + + + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    +
    + + Anticipo del Cliente +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + +
    +
    +
    + + Anticipo del Cliente Historial +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    +
    + +
    +
    + + + + +
    +
    + Datos del Orden de Servicio + + + + + + + + + + + + + - - - - -
    Persona que Solicitó: + +
    Descripción: + +
    Fecha Cita:   - - - - - - + + + + + + +   - + +   Hora:  - - - - - - -
    - Agregar
    -
    -
    - + + + + + + + +
    + Agregar
    +
    +
    + <%-- -
    @@ -850,880 +907,1089 @@
    --%> - - - - - - - - - -
    - - - + +
    -
    -
    - Datos del Reporte - - +
    --%> + + + + + + + + - -
    + + + - + - -
    +
    +
    + Datos del Reporte + + - - - + + + + - - - + + + + - + + + - - -
    Tipo de Buzón: - - - - - - - -
    + + + + + + +
    Sucursal: - - - - - - -
    + + + + + +
    Fecha : - - - - + - - - + + + + + + + + + +
    + + + + - -
      - - - - - - + + + + + + +   - + +   Hora:  - - - - - - -
    -
    +
    Descripción: - - -
    -
    -
    -
    -
    - Reportó - - + + + +
    + +
    +
    +
    +
    +
    + Reportó + + - - - + + + + - - - + + + + - - - + + + + - - -
    Nombre: - - -
    + +
    Teléfono: - - -
    + +
    Mail: - - -
    + +
    Observaciones: - - -
    -
    -
    -
    - -
    -
    -
    -
    - Personal - - - - - + +
    -   - + + + +
    +
    +
    +
    + +
    +
    +
    +
    + Personal + + + + + - - - -
    +   + Nombre - -
    - - - - - - <%----%> - - - - - - - - - - - -
    - <%----%> - <%----%> - -
    - -
    - -
    -
    -
    - - -
    -
    -
    -
    -
    -
    -
    - - <%-- - - - --%> - - - - - - - - + +
    -
    -
    - Usuarios - - - + + + + + + +
    + + + + + + <%----%> + + + + + + + + + + + +
    + <%----%> + <%----%> + +
    + +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    + + + + + + + + + + --%> + + + + + + + + + + + + + + + + + +
    +
    +
    + Usuarios + + + <%-- --%> - --%> + - + - - - - - - - - - - - + + + + + + + + + + + - + - + - - - - - + + + + + + + + <%-- --%> - - - - - - - - - - - - - - - - - -
    Usuario - - + + Nombre - - - + + + + Correo/Usuario - - - Compras - CxP - Anticip - R.H. - O.S. - Cotiza--- - Sist - + + + + Compras + CxP + Anticip + R.H. + O.S. + Cotiza--- + Sist + Est - - - + + + + Fecha - - - + + + + Usuario - - Comandos
    Comandos
    - - - - - - - - - - - - - - - - - - -     -
    - - +
    + + + + + + + + + + + + + + + + + +     +
    + + <%-- - --%> - - - - - - - - - - - - - - - - - - <%----%> - - - - <%----%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + --%> + + + + + + + + + + + + + + + + + + <%----%> + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      -
    -
    - - -   -   - -
    -
    - - -
    - - -
    -
    - - -
    - - - - - -
    -
    -
    -
    -
    - - Cambio Contraseña -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - -
    - -
    -
    -
    -
    - -
    - - -
    - -
    -
    -
    -
    - -
    - - -
    - - -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - - -
    - -
    - -
    -
    -
    -
    -
    - - - <%--0--%> - - <%--1--%> - - <%--2--%> - - <%--3--%> - - - - - -
    - -
    -
    - <%--4--%> - - <%--5--%> - <%-- + + + + +   +   + + +
    + + +
    + +
    +
    +
    +
    + + + + + + + + + + + +
    +
    +
    + + +
    +
    +
    + +
    + + + +
    +
    + Fecha Inicio: +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: +
    +
    +
    + + + + +
    + + + + + + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + Historial de Pedidos +   Agregar Pedido  +   Descarga Excel  + + + + + + + + +
    + + + + Pedido + + + + + + Fecha + + + + + + Sub Total + + + + + + Descuento + + + + + + Amortización + + + + + + Total + + + + + + Moneda + + + + + + Estatus + + + + + + + + + + + + + + + + + + + +
    + +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    +
    + + + + + +
    +
    +
    +
    +
    + + Cambio Contraseña +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + + +
    + +
    +
    +
    +
    + +
    + + +
    + +
    +
    +
    +
    + +
    + + +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + +
    + + + + + + + + + + <%-- IxC --%> + + +
    + + - + + diff --git a/PortalCliente/PortalCliente.aspx.vb b/PortalCliente/PortalCliente.aspx.vb index cf9b3414e..5a2946392 100644 --- a/PortalCliente/PortalCliente.aspx.vb +++ b/PortalCliente/PortalCliente.aspx.vb @@ -8,13 +8,14 @@ Imports System.Xml Imports System.IO.Compression Imports System.Net Imports Microsoft.Reporting.WebForms - +Imports System.Net.Http + Partial Class Ventas_PortalCliente Inherits ClsPaginas - Const TopRegistros = 20 - - + Const TopRegistros = 20 + + #Region " PROPIEDADES " Private Property CveCliente As Integer Get @@ -177,10 +178,10 @@ Partial Class Ventas_PortalCliente Set(value As Modelos.Factura) ViewState("ObjFactura") = value End Set - End Property - + End Property + #End Region - + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Destino = String.Format("{0}\Compras\", UsuarioActual.Empresa.Ruta) @@ -223,7 +224,10 @@ Partial Class Ventas_PortalCliente CargarClienteSucursal() End If - '??ESTE TAB VA DESAPARECER - PARA QUE SOLO LA EMPRESA GESTIONE A LOS USUARIOS POR CLIENTE?? + CargaPedidos() + CargaCuentasDepositos() + + '??ESTE TAB VA DESAPARECER - PARA QUE SOLO LA EMPRESA GESTIONE A LOS USUARIOS POR CLIENTE?? If UsuarioActual.TienePermisoProceso(234) Then ' CARGA TAB SISTEMA TabSistema.Visible = False 'CargaUsuariosPortal() @@ -245,8 +249,8 @@ Partial Class Ventas_PortalCliente InicializaTabPedido() End If - End Sub - + End Sub + #Region "DATOS DEL CLIENTE" Private Sub CargaDatosCliente() LtlTitulo.Text = "Portal del Cliente:" @@ -261,11 +265,11 @@ Partial Class Ventas_PortalCliente End If End If ObjClientes.Dispose() - End Sub + End Sub #End Region - + #Region "TAB HISTORIAL DE VENTAS" - + Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) Dim ObjClientes As New ClsClientes() If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=CveClienteSucursal) Then @@ -400,9 +404,9 @@ Partial Class Ventas_PortalCliente ObjVentas.UpdateVentaMail(3, HdnCveVenta.Value.ToEntero) ObjVentas.Dispose() End Try - End Sub + End Sub #End Region - + #Region "TAB CUENTAS X PAGAR" Private Sub CargaCxP(Optional VerMas As Integer = -1) If TabCxP.Visible = True Then @@ -539,8 +543,8 @@ Partial Class Ventas_PortalCliente End If ObjEventoBitacora.Dispose() UPAddEventoBitacora.Update() - End Sub - + End Sub + #Region " PAGO PROSEPAGO " Private Sub InicializaProsepago() If Not UsuarioActual.CveEmpresa.Contiene(1, 4, 7, 11, 12, 145) Then @@ -1231,12 +1235,12 @@ Partial Class Ventas_PortalCliente Dim Mail As New ClsSisMail() Mail.SendMail(ClsPaginas.EmpresaNotificaciones, CorreoDestino, Asunto, Body) - End Sub + End Sub #End Region - - + + #End Region - + #Region "TAB ANTICIPOS" Private Sub CargaAnticipos(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) Dim ObjMovtos As New ClsMovimientos() @@ -1290,9 +1294,9 @@ Partial Class Ventas_PortalCliente CargaAnticipos(21) BtnVerMasAnticipos.Text = "Ver Más" End If - End Sub + End Sub #End Region - + #Region "TAB BUZON DE CALIDAD" Private Sub CargarTipoBuzon() If TabBuzonCalidad.Visible = True Then @@ -1378,9 +1382,9 @@ Partial Class Ventas_PortalCliente End If Next ObjQueja.Dispose() - End Sub + End Sub #End Region - + #Region "TAB SISTEMA" Private Sub CargaUsuariosPortal() Dim ObjUsuario As New ClsSisUsuarios() @@ -1424,11 +1428,11 @@ Partial Class Ventas_PortalCliente End If ObjUsuario.Dispose() GvUsuariosPortal.DataBind() - End Sub - - + End Sub + + #Region "GESTION DE USUARIOS DEL PORTAL" - + Protected Sub LnkAgregarUsuario_Click(sender As Object, e As EventArgs) Handles LnkAgregarUsuario.Click Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL) Dim ObjUsuario As New ClsSisUsuarios @@ -1673,13 +1677,13 @@ Partial Class Ventas_PortalCliente a.GuardaLog() Dim Mail As New ClsSisMail() Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - End Sub + End Sub #End Region - + #End Region - + #Region "TAB CONTRASENIA" - + Protected Sub BtnGuardarContraseña_Click(sender As Object, e As EventArgs) Handles BtnGuardarContraseña.Click If Decripta(UsuarioActual.Contraseña) = TxtContraseniaActual.Text Then @@ -1702,9 +1706,459 @@ Partial Class Ventas_PortalCliente Alert("La Contraseña Actual es incorrecta.", TipoMensaje.MsgAdvertencia) End If - End Sub + End Sub #End Region + +#Region "TAB PEDIDOS" + + Private Sub CargaCuentasDepositos() + + 'CargaEstatus + DdlEstatus.DataSource = GlobalDTEstatusFactura.FiltraParametros(" CveEstatusFactura IN (2, 5, 21) ") + DdlEstatus.DataBind() + + DdlCuenta.Items.Clear() + + 'Dim ObjGral As New ClsGenerales + 'If ObjGral.GetCuentasDepositos(CveProveedor:=-1, CveCliente:=CveCliente, CvePersonal:=-1) Then + ' DdlCuentaDeposito.DataSource = ObjGral.DtResultados.FiltraParametros("Estatus ='True'") + ' If ObjGral.DtResultados.Rows.Count > 0 Then + ' DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1")) + ' End If + 'End If + 'ObjGral.Dispose() + + 'DdlCuentaDeposito.DataBind() + + + Dim dt As DataTable + If UsuarioActual.Empresa.Funcionalidad(127) = "1" Then + dt = GlobalDTBancosCuentas(-1) + Else + dt = GlobalDTBancosCuentas(-1).FiltraParametros("CveTipoCuenta <> 1") ' quito las cajas chicas + End If + + + DdlCuenta.DataSource = dt + DdlCuenta.DataBind() + + UpIxC.Update() + End Sub + Private Sub CargaPedidos(Optional TopPedidos As Integer = 21) + 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, TopPedidos, CveClienteSucursal:=-1, TipoDocto:="Pd2", CveEstatusFactura:=DdlEstatus.SelectedValue.ToEntero(), FechaI:=FechaI, FechaF:=FechaF) Then + GvPedidos.DataSource = ObjClientes.DtResultados + If ObjClientes.DtResultados.Rows.Count < 21 Then + LnkVerMasPedidos.Visible = False + End If + End If + ObjClientes.Dispose() + GvPedidos.DataBind() + + UpTabPedidos.Update() + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaPedidos() + End Sub + + Protected Sub BtnVerMasPedidos_Click(sender As Object, e As EventArgs) + If BtnVerMasVentas.Text = "Ver Más" Then + CargaPedidos(-1) + BtnVerMasVentas.Text = "Ver Menos" + Else + CargaPedidos(21) + BtnVerMasVentas.Text = "Ver Más" + End If + End Sub + + Protected Sub GvPedidos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveVenta") <> "" Then + 'e.Row.FCHyperLink("ImgAbonar").NavigateUrl = String.Format("/Bancos/PopIEVentas.aspx?CveVenta={0}&TB_iframe=true&height=550&width=700", e.Row.DBCampo("CveVenta")) + If e.Row.DBCampo("CveEstatusFactura").ToEntero().Contiene(4, 5) Then + e.Row.FCLinkButton("ImgAbonar").Visible = False + e.Row.FCLinkButton("ImgCancelar").Visible = False + End If + Else + e.Row.FCLinkButton("ImgAbonar").Visible = False + e.Row.FCLinkButton("ImgCancelar").Visible = False + e.Row.CssClass = "Totales" + End If + End If + End Sub + + Protected Sub ImgCancelar_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = (DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)) + If GvRow.DataKey("CveVenta").ToEntero() > 0 Then + Dim ObjFactura As New Modelos.Factura(UsuarioActual, GvRow.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) + If ObjFactura IsNot Nothing Then + Dim Resp = ObjFactura.CancelarFactura(RealizarDevolucionAlmacen:=False, ListaRemisionesCancelar:=New List(Of Integer)) + Alert(Resp.Mensaje, If(Resp.HuboError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion)) + End If + Else + Alert("No se encontro pedido para cancelar", TipoMensaje.MsgAdvertencia) + End If + End Sub + + Protected Sub ImgAbonar_Click(sender As Object, e As EventArgs) + + TxtTotalPedido.Text = "" + TxtFolio.Text = "" + + Me.CveVenta = -1 + Dim GvRow As GridViewRow = (DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)) + If GvRow.DataKey("CveVenta").ToEntero() > 0 Then + + LblPedido.Text = GvRow.DataKey("SerieFolio") + TxtTotalPedido.Text = GvRow.DataKey("Total").ToDecimal().FormatoNumero(2) + RVPedido.MaximumValue = GvRow.DataKey("Total").ToDecimal().FormatoNumero(2) + Me.CveVenta = GvRow.DataKey("CveVenta").ToEntero() + + RegistraScript("$('#DivIxC').modal({backdrop: 'static',keyboard: false});") + End If + UpIxC.Update() + End Sub + + Protected Sub BtnPagarPedido_Click(sender As Object, e As EventArgs) + GuargarIxC(CveCliente, TxtTotalPedido.Text.ToDecimal(), New Modelos.Factura(UsuarioActual, Me.CveVenta, UsuarioActual.CveEmpresa)) + End Sub + + Private Sub GuargarIxC(CveCliente As Integer, ImportePagado As Decimal, ObjFactura As Modelos.Factura) + + Dim MsgError As String = "" + Dim CveConceptoContable As Integer = 30 + Dim CveConceptoCompra As Integer = 10 + Dim CveCreditoDetalle As Integer = -1 + Dim CIF As Decimal = 0 + Dim CvePlantillaPoliza As Integer = 3 + Dim CvePrePoliza As Integer = 0 + Dim ComprobanteIE As String = "" + Dim CveIE As Integer = -1 + Dim CveTipoTransaccion As Integer = 11 + Dim FechaDoc As DateTime = Now + + Dim ConceptoContable As Integer + Dim TipoMovimiento As Boolean + Dim importeMovimiento As Decimal + Dim FechaMovimiento As Date = Now + Dim Concepto As String = "" + + Dim Importe As Decimal = ImportePagado + + Dim Msg As New StringBuilder + + Dim ObjIE As New ClsBancos() + Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL) + Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL) + + Try + Dim CveCuentaDeposito As Integer = 0 + 'If DdlCuentaDeposito.Items.Count > 0 Then + ' CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero + 'End If + + '*****-_- INICIA: CONFIGURACION REGISTRO -_-***** + Dim AgregaPolizaSaldoInicial As Boolean = False + + 'INGPC + CvePlantillaPoliza = 6 + If CveCliente > 0 Then + CveConceptoCompra = 66 'Anticipo doc por pagar + CveConceptoContable = 30 'Bancos + End If + + Dim FolioFijo As Integer = 0 + Dim tCveMoneda As Integer = ObjFactura.CveMoneda + Dim tImporteMonedaExtranjera As Decimal = 0 + If tCveMoneda <> 1 Then tImporteMonedaExtranjera = TxtImporte.Text.ToDecimal * GlobalTipoCambio(Now).ToString.ToDecimal + Dim PagueseA = ObjFactura.Cliente.Nombre + + If MsgError = "" Then + + CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, CveTipoTransaccion, FechaDoc, TxtFolio.Text.Trim, PagueseA, Importe, ObjFactura.CveMoneda, + TxtTipoCambio.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePoliza, ComprobanteIE, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, + CveCuentaDeposito:=CveCuentaDeposito, CveEstatusIE:=1, Referencia:="-1", CveCuentaTarjeta:=-1, ConceptoCIE:="-1") + + If CveIE > 0 Then + + If CveTipoTransaccion = 1 AndAlso UsuarioActual.CveEmpresa <> 119 Then FolioFijo = ObjIE.Folio.ToEntero 'cheque + CvePrePoliza = ObjMov.AddPrePolizas("PortalCliente/IE " + "INGPC", CvePlantillaPoliza, Importe, Importe, tCveMoneda, FechaDoc, PagueseA, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FolioFijo:=FolioFijo, ReglaFolioPoliza:=ObjComp.ObtenerReglaFolio(CveTipoTransaccion.ToString(), Nothing, UsuarioActual.CveEmpresa), CveTipoPoliza:=ObjMov.ObtenerTipoPoliza(CveTipoTransaccion.ToString(), "-1", UsuarioActual.CveEmpresa)) + + 'valida prepoliza + If CvePrePoliza > 0 Then + + If Not ObjIE.UpdateIEPrePoliza(MinFecha, "", -1, CvePrePoliza, CveIE, -1) Then + MsgError = "Ocurrio un error al agregar la prepoliza al IE." + End If + + Dim Conc As String = ObjIE.Folio + Dim Ref As String = ObjIE.Folio + + ComprobanteIE = $"{CveIE}" + + 'GUARDA PREPOLIZAS DETALLE [PRIMERO SON LOS CASOS ESPECIALES, AL FINAL (ELSE) LOS CASOS NORMALES] --REEMPLAZA IFs + + Dim importeMX As Decimal + Dim Multiplicador As Integer + + If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantillaPoliza) Then + + For Each Row As DataRow In ObjMov.DtResultados.Rows + + ConceptoContable = Row("CveConcepto").ToString.ToEntero + TipoMovimiento = If(Row("TipoMovto").ToString = "True", True, False) + importeMovimiento = 0 + Multiplicador = (Row("Multiplicador").ToString.ToEntero) + Concepto = ObjMov.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, ConceptoContable, PagueseA, "", ObjIE.Folio) + + Select Case ConceptoContable + Case 66 + importeMovimiento = Importe '- TxtIvaIxC.Text.ToDecimal + importeMX = importeMovimiento + Case 30 + importeMovimiento = Importe + importeMX = importeMovimiento + End Select + + If importeMovimiento <> 0 Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, importeMovimiento, Concepto, ConceptoContable, Concepto, FechaMovimiento, If(ConceptoContable = 30, ObjFactura.Cliente.IdCtaContClientes, ObjFactura.Cliente.IdCtaContAnticipos), -1, CveIE:=CveIE, CveCompra:=-1, CveProveedor:=-1, CvePersonal:=-1, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=importeMovimiento, ImporteME:=tImporteMonedaExtranjera, TipoCambio:=TxtTipoCambio.Text.ToDecimal, CveCuenta:=If(ConceptoContable = 30, ObjFactura.Cliente.CveCuentaClientes, ObjFactura.Cliente.CveCuentaAnticipos)) Then + MsgError = "Ocurrió un error al registrar el asiento del ingreso." + End If + End If + + Next + End If + + If MsgError = "" Then + If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then + If ObjMov.ValorPolizaDescuadre > 0 Then + GuardaLogAD($"Bancos/IE | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas") + End If + Else + MsgError = "No se pudo validar la prepoliza de cuadre." + End If + End If + + 'El movimiento 1 es el de Venta + + 'Conta ContPAQ + 'If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then + ' If IDCtaBeneficiario > 0 And IDCtaContable > 0 Then + ' If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then + ' IDPoliza = ObjMov.ContaIdPoliza + ' 'Alert(alertaContabilizacion & ObjMov.AlertaMensaje, ModExtensiones.TipoMensaje.MsgInformacion) + ' Else + ' Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError) + ' End If + ' Else + ' If IDCtaContable < 1 Then + ' Alert("No se puede contabilizar la Prepoliza debido a que la cuenta de Bancos es invalida", TipoMensaje.MsgAdvertencia) + ' End If + ' If IDCtaBeneficiario < 1 Then + ' Alert("No se puede contabilizar la Prepoliza debido a que las cuenta del Beneficiario es invalida", TipoMensaje.MsgAdvertencia) + ' End If + ' End If + 'End If + + 'If UsuarioActual.Empresa.UsaAC Then + ' Dim ConceptoRenglon, Referencia As String + ' Dim FolioPoliza As Integer + ' Dim Fecha As Date = FechaDoc + ' Dim TipoChq As String = "" + ' Dim Total As Double = TxtImporte.Text.ToDouble + + ' Dim Conta As New ClsContPAQi(UsuarioActual.Empresa) + ' Conta.IniciaTransacSQL() + + ' If CveTipoTransaccion = 1 Then TipoChq = "CHQ" + ' ConceptoRenglon = String.Format("Anticipo {0}", PagueseA) + + ' Dim IDPoliza = Conta.AddPoliza(2, ConceptoRenglon, Total, Total, UsuarioActual.CveUsuario, Fecha, ObjIE.Folio, TipoChq) + + ' If IDPoliza > 0 Then + ' FolioPoliza = Conta.Folio + ' Referencia = ObjIE.Folio + ' ConceptoRenglon = String.Format("Anticipo {0} {1}", PagueseA, TxtObservaciones.Text) + + ' Total = TxtImporte.Text.ToDouble + + ' If Not Conta.AddMovimiento(IDPoliza, IDCtaContable, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento" + + ' If Not Conta.AddMovimiento(IDPoliza, IDCtaBeneficiario, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento" + + ' Else + ' MsgError = "No se insertó el encabezado" + ' End If + + ' If MsgError = "" Then + ' Conta.Commit() + + ' Conta.AjustaPoliza(IDPoliza) + ' 'actualizar la conta del IE + ' ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0) + ' Else + ' Conta.RollBack() + ' IDPoliza = 0 + ' End If + + ' Conta.Dispose() + 'End If + + 'Notificación de Pago + 'If TxtNotificarA.Text.Trim <> "" And MsgError = "" Then + ' 'NotificacionPago(CveIE, TxtNotificarA.Text.Trim) + ' EnviarCorreoNotificacion(CveIE, TxtNotificarA.Text.Trim, "", UsuarioActual, False) + 'End If + Else + MsgError = "No se pudo insertar la póliza" + End If + + Else + MsgError = "No se insertó el encabezado" + End If + + End If + + Catch ex As Exception + MsgError = ex.ToString() + End Try + + If MsgError = "" Then + 'IMPRIME CHEQUE + 'GeneraChequePDF(CveIE, UsuarioActual.Empresa, IDPoliza) + If Msg.ToString = "" Then + ObjIE.Commit() + Msg.Append("El Documento se guardo correctamente: Folio:" + ObjIE.Folio) + Alert(Msg.ToString(), TipoMensaje.MsgInformacion) + End If + 'Dim Archivo As System.IO.FileInfo = Nothing + ''VERIFICA SI EXISTE EL FORMATO + ''If DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(2, 8, 9) Then + '' Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/Transferencia.rdlc", UsuarioActual.Empresa.Ruta)) + ''ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(1) Then + '' Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/CHQ-{1}.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero)) + '' If Not Archivo.Exists Then + '' Archivo = New System.IO.FileInfo(String.Format("{0}\Empresas\Grales\Formatos\CHQ.rdlc", ModExtensiones.DirectorioBaseEmpresas)) + '' End If + ''ElseIf DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(6) And UsuarioActual.CveEmpresa = 72 Then + '' Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/ComprobanteEgreso.rdlc", UsuarioActual.Empresa.Ruta, DdlCuenta.SelectedValue.ToEntero)) + ''End If + + 'If Archivo IsNot Nothing Then + ' If Archivo.Exists Then + ' Msg.AppendFormat("

    {1} ", Encripta(String.Format("OP=IECHEQUE&CVEIE={0}", CveIE)), "Imprimir Ingre") + ' End If + 'End If + + Else + ObjIE.RollBack() + Alert(MsgError, TipoMensaje.MsgAdvertencia) + End If + + ObjIE.Dispose() + ObjMov.Dispose() + ObjComp.Dispose() + + End Sub + + Private Function DescargarFactura(CveVenta As Integer, CveEmpresa As Integer) As Byte() + Dim Url = New Uri(String.Format("{0}Compras/PopUpVerFactura.aspx?P={1}", "http://localhost:85/", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1", CveVenta)))) + Dim File As Byte() = Nothing + Try + Using httpClient = New HttpClient() + httpClient.Timeout = New TimeSpan(0, 15, 0) + Using request = New HttpRequestMessage(HttpMethod.Get, Url) + request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO=100", CveEmpresa, DateTime.UtcNow.Ticks))) + Dim response = httpClient.SendAsync(request).Result + If response.StatusCode = Net.HttpStatusCode.OK Then + File = response.Content.ReadAsByteArrayAsync().Result + End If + End Using + End Using + Catch ex As Exception + File = Nothing + OnError("Ocurrió un error al descargar la factura", ex) + End Try + + Return File + End Function + + Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, EnviarFactura As Boolean, ObjFactura As Modelos.Factura) + + Dim ObjMail As New ClsSisMail() + Dim ObjVentas As New ClsVentas + + Dim ArchivoPDF As String = "" + Dim ArchivoPDFBytes As Byte() = Nothing + Dim ExistePDF As Boolean = False + + Try + + Dim Asunto As String = String.Empty + Dim Cuerpo As String = String.Empty + Dim ResultadoMail As Integer = 0 + + Dim TipoComprobante = "Pedido" + + If UsuarioActual.Empresa.PlantillaMailVenta.Trim.Length > 0 Then + Cuerpo = UsuarioActual.Empresa.PlantillaMailVenta + Cuerpo = Cuerpo.Replace("{""NombreEmpresa""}", UsuarioActual.Empresa.Empresa) + Cuerpo = Cuerpo.Replace("{""NombreCliente""}", ObjFactura.Cliente.Nombre) + Cuerpo = Cuerpo.Replace("{""TipoDocumento""}", TipoComprobante) + Cuerpo = Cuerpo.Replace("{""Fecha""}", ObjFactura.Fecha.ToString("dd/MM/yyyy")) + Cuerpo = Cuerpo.Replace("{""Total""}", ObjFactura.Total.FormatoNumero(2)) + Cuerpo = Cuerpo.Replace("{""FechaVencimiento""}", ObjFactura.FechaVencimiento.ToString("dd/MM/yyyy")) + Cuerpo = Cuerpo.Replace("{""SerieFolio""}", ObjFactura.SerieFolio) + End If + + If UsuarioActual.Empresa.AsuntoPlantillaMailVenta.Trim.Length > 0 Then + Asunto = UsuarioActual.Empresa.AsuntoPlantillaMailVenta + Asunto = Asunto.Replace("{""TipoDocumento""}", TipoComprobante) + Asunto = Asunto.Replace("{""Sucursal""}", ObjFactura.SubProyecto.SubProyecto) + Asunto = Asunto.Replace("{""SerieFolio""}", ObjFactura.SerieFolio) + End If + + If Not EnviarFactura Then + ObjVentas.UpdateVentaMail(0, CveVenta) + End If + + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + + ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, ObjFactura.TipoDocto, ObjFactura.SerieFolio) + + If Not File.Exists(ArchivoPDF) Then + ArchivoPDFBytes = DescargarFactura(ObjFactura.CveVenta, ObjFactura.CveEmpresa) + Else + ExistePDF = True + End If + + If ExistePDF Then + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = ArchivoPDF}) + Else + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = ArchivoPDFBytes, .NombreArchivo = String.Format("{0}.pdf", ObjFactura.SerieFolio)}) + End If + + If ObjMail.SendMail(UsuarioActual.Empresa, ObjFactura.Cliente.Mail, Asunto, Cuerpo, "japmx95@gmail.com", LSRutasMail, Displayname:="") Then + ResultadoMail = 1 + Else + ResultadoMail = 3 + End If + ObjVentas.UpdateVentaMail(ResultadoMail, CveVenta) + + Catch ex As Exception + OnError("Ocurrió error al mandar el Mail", ex) + ObjVentas.UpdateVentaMail(3, CveVenta) + Finally + ObjVentas.Dispose() + End Try + + End Sub +#End Region + #Region "O R D E N A M I E N T O" Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs) Dim Orden As String = "" @@ -1739,12 +2193,12 @@ Partial Class Ventas_PortalCliente ElseIf gvi = 1 Then CargaGridUsuarios(Orden) End If - End Sub + End Sub #End Region - + #Region "DESCARGA Todos los Archivos" - - + + Private Sub BtnDescargarPDF_Click(sender As Object, e As EventArgs) Handles BtnDescargarPDF.Click If Not Directory.Exists(AppDomain.CurrentDomain.BaseDirectory & "Temp") Then Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory & "Temp") @@ -1827,14 +2281,14 @@ Partial Class Ventas_PortalCliente 'Elimine el .zip que se genero If File.Exists(RutaArchivo) Then File.Delete(RutaArchivo) - End Sub - + End Sub + #End Region - - + + #Region "IMPRIMIR GVHistorial" - - + + Protected Sub BtnExcelHistorial_Click(sender As Object, e As EventArgs) Dim retorno As Byte() = Nothing Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) @@ -1870,6 +2324,10 @@ Partial Class Ventas_PortalCliente End Sub + Protected Sub BtnExcelHistorialPedidos_Click(sender As Object, e As EventArgs) + GvPedidos.ExportToExcel("Pedidos") + End Sub + Protected Sub BtnPDFHistorial_Click(sender As Object, e As EventArgs) Dim retorno As Byte() = ImprimirReporteHistorial() @@ -1913,12 +2371,12 @@ Partial Class Ventas_PortalCliente ObjClientes.Dispose() Return retorno - End Function - - + End Function + + #End Region - - + + #Region "IMPRIMIR CxC Activas" Protected Sub LbExcelCxCActivas_Click(sender As Object, e As EventArgs) Dim retorno As Byte() = Nothing @@ -1984,13 +2442,13 @@ Partial Class Ventas_PortalCliente End If ObjMovtos.Dispose() Return retorno - End Function - + End Function + #End Region - - + + #Region "IMPRIMIR CxCHistorial" - + Protected Sub LbExcelCxCHistorial_Click(sender As Object, e As EventArgs) Dim retorno As Byte() = Nothing Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) @@ -2055,34 +2513,34 @@ Partial Class Ventas_PortalCliente End If ObjMovtos.Dispose() Return retorno - End Function - + End Function + #End Region - - 'Protected Sub BtnCxPActivas_Click(sender As Object, e As EventArgs) - ' If BtnCxPActivas.Text = "Ver Más " Then - ' BtnCxPActivas.Text = "Ver Menos " - ' CargaCxP() - ' Else - ' BtnCxPActivas.Text = "Ver Más " - ' CargaCxP(1) - ' End If - 'End Sub - - 'Protected Sub BtnHistorialCxP_Click(sender As Object, e As EventArgs) - ' If BtnHistorialCxP.Text = "Ver Más " Then - ' BtnHistorialCxP.Text = "Ver Menos " - ' CargaCxP(2) - ' Else - ' BtnHistorialCxP.Text = "Ver Más " - ' CargaCxP(2) - ' End If - 'End Sub - + + 'Protected Sub BtnCxPActivas_Click(sender As Object, e As EventArgs) + ' If BtnCxPActivas.Text = "Ver Más " Then + ' BtnCxPActivas.Text = "Ver Menos " + ' CargaCxP() + ' Else + ' BtnCxPActivas.Text = "Ver Más " + ' CargaCxP(1) + ' End If + 'End Sub + + 'Protected Sub BtnHistorialCxP_Click(sender As Object, e As EventArgs) + ' If BtnHistorialCxP.Text = "Ver Más " Then + ' BtnHistorialCxP.Text = "Ver Menos " + ' CargaCxP(2) + ' Else + ' BtnHistorialCxP.Text = "Ver Más " + ' CargaCxP(2) + ' End If + 'End Sub + #Region "TAB PEDIDO" - + #Region "CARGAS" - + Private Sub CargaFolios() If CveSubProyecto <= 0 Then @@ -2280,11 +2738,11 @@ Partial Class Ventas_PortalCliente TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - End Sub - - + End Sub + + #End Region - + #Region "SELECTED INDEX CHANGE" Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) TrConversionTipoCambio.Visible = False @@ -2364,13 +2822,15 @@ Partial Class Ventas_PortalCliente Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) CargaPS(DdlClasificacion.SelectedValue.ToEntero, DdlPS) UpClasificacion.Update() - End Sub - + End Sub + #End Region - + #Region "AGREGAR/EDITAR/ELIMINAR" - Protected Sub LnkAddVenta_Click(sender As Object, e As EventArgs) - + Protected Sub LnkAddPedido_Click(sender As Object, e As EventArgs) + RegistraScript("$('#DivVenta').modal({backdrop: 'static',keyboard: false});") + End Sub + Protected Sub LnkAddPSVenta_Click(sender As Object, e As EventArgs) Modalidad = "A" LnkAgregar.Text = "Agregar" TxtCantidad.Text = "" @@ -2386,9 +2846,9 @@ Partial Class Ventas_PortalCliente DdlClasificacion.SelectedIndex = -1 DdlUM.Items.Clear() ChkAgregar.Checked = True - UpVenta.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddVenta")) + UpAddPedido.Update() + RegistraScript("$('#DivAddVenta').modal({backdrop: 'static',keyboard: false});") End Sub Protected Sub LnkEditar_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) @@ -2411,17 +2871,22 @@ Partial Class Ventas_PortalCliente TxtPrecio.Text = GvRow.DataKey("PU") LblTotal.Text = GvRow.DataKey("Total") ChkAgregar.Checked = False - UpVenta.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddVenta"), "EdicionVenta") + UpAddPedido.Update() + + RegistraScript("$('#DivAddVenta').modal('show');", "EdicionVenta") End Sub Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim DbRow As DataRow = Nothing + DbRow = TmpDT.Rows(GvRow.RowIndex) TmpDT.Rows.Remove(DbRow) + GvPS.DataSource = TmpDT GvPS.DataBind() + CalculaTotalesVenta() + Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion) End Sub @@ -2442,22 +2907,15 @@ Partial Class Ventas_PortalCliente End If DdlClasificacion.SelectedIndex = -1 DdlUM.Items.Clear() - UpVenta.Update() Else RegistraScript("ClosePopup();", "AddUpdatePS") - End If + End If + + UpAddPedido.Update() End Sub Private Sub AgregarPS() - If Modalidad = "A" Then - AgregarProductoServicio(TxtCantidad.Text.ToDecimal, DdlUM.SelectedValue.ToEntero, DdlUM.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, - DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, TxtObs.Text, TxtPrecio.Text.ToDecimal, 0, -1, "", CveSubProyecto, "") - - CalculaTotalesVenta() - - - - ElseIf Modalidad = "U" Then + If Modalidad = "U" Then Dim ErrorEdit As Boolean = True Dim Contador As Integer = 0 @@ -2475,7 +2933,12 @@ Partial Class Ventas_PortalCliente TmpDT.Rows.RemoveAt(Contador) TmpDT.AcceptChanges() End If - End If + End If + + AgregarProductoServicio(TxtCantidad.Text.ToDecimal, DdlUM.SelectedValue.ToEntero, DdlUM.SelectedItem.Text, DdlClasificacion.SelectedValue.ToEntero, DdlClasificacion.SelectedItem.Text, + DdlPS.SelectedValue.ToEntero, DdlPS.SelectedText, TxtObs.Text, TxtPrecio.Text.ToDecimal, 0, -1, "", CveSubProyecto, "") + + CalculaTotalesVenta() End Sub @@ -2616,13 +3079,13 @@ Partial Class Ventas_PortalCliente GvPS.DataSource = view GvPS.DataBind() - UpTabPedidos.Update() - End Sub - + UpAddPedido.Update() + End Sub + #End Region - + #Region "GUARDAR VENTA" - + Private Sub CreaObjetosVenta(Optional VistaPrevia As Boolean = False) ObjFactura = New Modelos.Factura ObjFactura.Version = "3.3" @@ -2911,6 +3374,10 @@ Partial Class Ventas_PortalCliente ViewState("CveVenta") = ObjFactura.CveVenta + If ObjFactura.CveVenta > 0 Then + EnviarCorreoPedido(ObjFactura) + End If + 'MENSAJE PRINCIPAL MensajeAlert.AppendFormat(String.Format("
    El {0}: {1} se generó correctamente.

    ", ObjFactura.TipoDocumento, ObjFactura.SerieFolio)) @@ -2970,6 +3437,10 @@ Partial Class Ventas_PortalCliente 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() + End Sub Private Sub GuardarVenta(ByRef ObjVentas As ClsVentas, ByRef ObjConta As ClsContabilidad, ByRef ObjInventario As ClsInventarios, ByRef ObjContr As ClsContratos, factura As Modelos.Factura, TmpDTDetalle As DataTable, CveNCaVincular As Integer, ByRef objContPaqi As ClsContPAQi, Optional ByRef ObjBancos As ClsBancos = Nothing, Optional ByRef ObjOS As ClsOS = Nothing, ByRef Optional ObjEventos As ClsOIEventos = Nothing, ByRef Optional ObjCGame As ClsCGame = Nothing, ByRef Optional ObjCliente As ClsClientes = Nothing) @@ -3067,11 +3538,12 @@ Partial Class Ventas_PortalCliente TxtObs.Text = "" CalculaTotalesVenta() UpTabPedidos.Update() - End Sub - + End Sub + #End Region - -#End Region - - + +#End Region + + End Class +