Subir archivo Adjunto
This commit is contained in:
@@ -1308,6 +1308,15 @@ Partial Class Ventas
|
||||
ViewState("RFCReceptorVenta") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property Adjunto As String
|
||||
Get
|
||||
Return If(IsNothing(ViewState("Adjunto")), "", ViewState("Adjunto").ToString())
|
||||
End Get
|
||||
|
||||
Set(value As String)
|
||||
ViewState("Adjunto") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
#Region "Propiedades PuntoVenta"
|
||||
@@ -3994,6 +4003,21 @@ Partial Class Ventas
|
||||
End If
|
||||
|
||||
RFCReceptorVenta = DbRowVenta("RFCReceptor").ToString()
|
||||
'Adjuntar archivo
|
||||
Adjunto = DbRowVenta("Adjunto").ToString()
|
||||
If Adjunto <> "" Then
|
||||
BtnArchivoAdjunto.Text = Adjunto
|
||||
BtnArchivoAdjunto.Visible = True
|
||||
BtnEliminarAdjunto.Visible = False
|
||||
BtnAdjuntar.Visible = False
|
||||
|
||||
tdAdjuntar.Style.Item("display") = "none"
|
||||
tdAdjunto.Style.Item("display") = "block"
|
||||
|
||||
Else
|
||||
DivAdjuntar.Visible = False
|
||||
|
||||
End If
|
||||
|
||||
ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero()
|
||||
|
||||
@@ -10980,7 +11004,7 @@ Partial Class Ventas
|
||||
CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM,
|
||||
DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False),
|
||||
Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text,
|
||||
FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor) Then
|
||||
FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS, RFCReceptor:=RFCReceptor, Adjunto:=Adjunto) Then
|
||||
ErrorList.Add("Ocurrió un error al Generar la Venta.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
|
||||
Else
|
||||
If factura.TipoDocto.Contiene("Dev", "Egs") Or DtVentasNC IsNot Nothing Or CveEstatusRefacturacion = 1 Then
|
||||
@@ -13748,13 +13772,16 @@ Partial Class Ventas
|
||||
|
||||
'MANDA CORREO
|
||||
If EnviaCorreo Then
|
||||
|
||||
Dim ArchivoAdjunto As String = ""
|
||||
Dim ArchivoXML = String.Format("{0}XML\{1}\{2}.xml", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio)
|
||||
Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio)
|
||||
If Adjunto <> "" Then
|
||||
ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto)
|
||||
End If
|
||||
|
||||
Try
|
||||
' BytesPdfCotizacion(CveVenta)
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF))
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto))
|
||||
Hilo.Start()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar Mail", ex)
|
||||
@@ -13792,13 +13819,16 @@ Partial Class Ventas
|
||||
|
||||
'MANDA CORREO
|
||||
If EnviaCorreo Then
|
||||
|
||||
Dim ArchivoAdjunto As String = ""
|
||||
Dim ArchivoXML = ""
|
||||
Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio)
|
||||
If Adjunto <> "" Then
|
||||
ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto)
|
||||
End If
|
||||
|
||||
Try
|
||||
' BytesPdfCotizacion(CveVenta)
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF))
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto))
|
||||
Hilo.Start()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar Mail", ex)
|
||||
@@ -13835,13 +13865,17 @@ Partial Class Ventas
|
||||
|
||||
LocalSerieFolio = ObjFactura.SerieFolio
|
||||
LocalTipoDocto = ObjFactura.TipoDocto
|
||||
Dim ArchivoAdjunto As String = ""
|
||||
|
||||
Dim ArchivoXML = String.Format("{0}XML\{1}\{2}.xml", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio)
|
||||
Dim ArchivoPDF = String.Format("{0}PDF\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, LocalTipoDocto, LocalSerieFolio)
|
||||
If Adjunto <> "" Then
|
||||
ArchivoAdjunto = String.Format("{0}Ventas\{1}", UsuarioActual.Empresa.Ruta, Adjunto)
|
||||
End If
|
||||
|
||||
Try
|
||||
' BytesPdfCotizacion(CveVenta)
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF))
|
||||
Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto))
|
||||
Hilo.Start()
|
||||
Catch ex As Exception
|
||||
OnError("Ocurrió error al mandar Mail", ex)
|
||||
@@ -19464,7 +19498,7 @@ Partial Class Ventas
|
||||
#End Region
|
||||
|
||||
#Region " MANDA CORREO "
|
||||
Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String)
|
||||
Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String, Adjunto As String)
|
||||
|
||||
Dim ObjMail As New ClsSisMail()
|
||||
Dim ObjVentas As New ClsVentas
|
||||
@@ -19514,6 +19548,10 @@ Partial Class Ventas
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML})
|
||||
End If
|
||||
|
||||
If Adjunto <> "" Then
|
||||
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = Adjunto})
|
||||
End If
|
||||
|
||||
Dim DisplayName As String = ""
|
||||
If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM"
|
||||
|
||||
@@ -31416,5 +31454,101 @@ Partial Class Ventas
|
||||
|
||||
RegistraScript("$('#ModalAplicaRNCDevolucion').modal('hide');")
|
||||
End Sub
|
||||
|
||||
Protected Sub btnGuardarAdjunto_Click(sender As Object, e As System.EventArgs) Handles btnGuardarAdjunto.Click
|
||||
If Not txtAdjuntar.getfiles().Archivos.Count > 0 Then
|
||||
Alert("Tiene que cargar un archivo.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If LblSerie.Text = "" Or TxtFolio.Text = "" Then
|
||||
Alert("Debe asignar una serie un folio antes de subir el archivo.", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
Dim FileExtension As String = "-1"
|
||||
Dim Filesgral As List(Of Archivo) = txtAdjuntar.getfiles().Archivos
|
||||
Dim Filename As String = ""
|
||||
Dim fileItem As Archivo = Filesgral(0)
|
||||
Try
|
||||
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
||||
Adjunto = String.Format("{0}-{1}.{2}", LblSerie.Text, TxtFolio.Text, FileExtension)
|
||||
Dim objVentas As New ClsVentas
|
||||
Dim Path As String
|
||||
Path = Extensiones.DirectorioBaseEmpresas
|
||||
Path += String.Format("Empresas/{0}/Ventas", UsuarioActual.CveEmpresa)
|
||||
If Not Directory.Exists(Path) Then
|
||||
Directory.CreateDirectory(Path)
|
||||
End If
|
||||
Path += $"/{Adjunto}"
|
||||
If File.Exists(Path) Then
|
||||
File.Delete(Path)
|
||||
End If
|
||||
My.Computer.FileSystem.MoveFile(fileItem.FileUrl, Path)
|
||||
BtnAdjuntar.Visible = False
|
||||
BtnArchivoAdjunto.Text = Adjunto
|
||||
BtnArchivoAdjunto.Visible = True
|
||||
BtnEliminarAdjunto.Visible = True
|
||||
tdAdjuntar.Style.Item("display") = "none"
|
||||
tdAdjunto.Style.Item("display") = "block"
|
||||
UpAdjuntar.Update()
|
||||
Alert("Documento cargado", TipoMensaje.MsgInformacion)
|
||||
objVentas.Dispose()
|
||||
|
||||
Catch ex As Exception
|
||||
OnError("Error al cargar archivo", ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnArchivoAdjunto_Click(sender As Object, e As System.EventArgs) Handles BtnArchivoAdjunto.Click
|
||||
Dim ruta As String = HttpContext.Current.Request.ApplicationPath
|
||||
ruta = Extensiones.DirectorioBaseEmpresas
|
||||
ruta += String.Format("Empresas/{0}/Ventas", UsuarioActual.CveEmpresa)
|
||||
ruta += $"/{Adjunto}"
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(ruta)
|
||||
|
||||
Try
|
||||
If Archivo IsNot Nothing Then
|
||||
If Archivo.Exists Then
|
||||
|
||||
HttpContext.Current.Response.Clear()
|
||||
HttpContext.Current.Response.ClearContent()
|
||||
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
||||
HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name))
|
||||
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
||||
HttpContext.Current.Response.TransmitFile(ruta)
|
||||
Response.Flush() ' send it to the client to download
|
||||
HttpContext.Current.Response.SuppressContent = True
|
||||
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
||||
Response.End()
|
||||
|
||||
Else
|
||||
Alert("El archivo no existe", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnEliminarAdjunto_Click(sender As Object, e As System.EventArgs) Handles BtnEliminarAdjunto.Click
|
||||
Dim objVentas As New ClsVentas
|
||||
Dim Path As String
|
||||
Path = String.Format("{0}Empresas/{1}/Ventas/{2}", Extensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, Adjunto)
|
||||
If File.Exists(Path) Then
|
||||
File.Delete(Path)
|
||||
End If
|
||||
BtnAdjuntar.Visible = True
|
||||
tdAdjuntar.Style.Item("display") = "block"
|
||||
BtnArchivoAdjunto.Text = ""
|
||||
BtnArchivoAdjunto.Visible = False
|
||||
tdAdjunto.Style.Item("display") = "none"
|
||||
BtnEliminarAdjunto.Visible = False
|
||||
UpAdjuntar.Update()
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user