1023 lines
46 KiB
VB.net
1023 lines
46 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
|
|
Partial Class Sistemas_Empresa
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES "
|
|
Private ReadOnly Property CveEmpresa As Integer
|
|
Get
|
|
Return ViewState("CveEmpresa").ToString.ToEntero
|
|
End Get
|
|
End Property
|
|
|
|
Private Property EmpresaEditar As Empresa
|
|
Get
|
|
Return CType(ViewState("EmpresaEditar"), Empresa)
|
|
End Get
|
|
Set(value As Empresa)
|
|
ViewState("EmpresaEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DtFuncionalidades As Data.DataTable
|
|
Get
|
|
Return CType(ViewState("DtFuncionalidades"), DataTable)
|
|
End Get
|
|
Set(value As Data.DataTable)
|
|
ViewState("DtFuncionalidades") = value
|
|
End Set
|
|
End Property
|
|
Private Property BDContPAQ As String
|
|
Get
|
|
BDContPAQ = ViewState("BDContPAQ").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("BDContPAQ") = value
|
|
End Set
|
|
End Property
|
|
Private Property ServerContPAQ As String
|
|
Get
|
|
ServerContPAQ = ViewState("ServerContPAQ").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ServerContPAQ") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtCuentas As DataTable
|
|
Get
|
|
Return CType((ViewState("DtCuentas")), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtCuentas") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtClasificacionIVA As DataTable
|
|
Get
|
|
If ViewState("DtClasificacionIVA") Is Nothing Then
|
|
ViewState("DtClasificacionIVA") = New DataTable
|
|
End If
|
|
Return CType((ViewState("DtClasificacionIVA")), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtClasificacionIVA") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveClasificacionPorcentaje As Integer
|
|
Get
|
|
Return CType((ViewState("CveClasificacionPorcentaje")), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClasificacionPorcentaje") = value
|
|
End Set
|
|
End Property
|
|
Public Property Modalidad As String
|
|
Get
|
|
Return CType((ViewState("Modalidad")), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Modalidad") = value
|
|
End Set
|
|
End Property
|
|
Public Property Index As Integer
|
|
Get
|
|
Return CType((ViewState("Index")), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("Index") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property TipoContabilidad As Integer
|
|
Get
|
|
If ViewState("TipoContabilidad") Is Nothing Then
|
|
ViewState("TipoContabilidad") = -1
|
|
End If
|
|
|
|
Return CType((ViewState("TipoContabilidad")), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoContabilidad") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Enum EnumOpActualizaArchivosCer
|
|
SinOpcion
|
|
KEY
|
|
CER
|
|
PFX
|
|
End Enum
|
|
|
|
|
|
Property OpActualizaArchivosCer As EnumOpActualizaArchivosCer
|
|
|
|
Get
|
|
If ViewState("OpActualizaArchivosCer") Is Nothing Then
|
|
ViewState("OpActualizaArchivosCer") = EnumOpActualizaArchivosCer.SinOpcion
|
|
End If
|
|
|
|
Return DirectCast(ViewState("OpActualizaArchivosCer"), EnumOpActualizaArchivosCer)
|
|
|
|
End Get
|
|
Set(value As EnumOpActualizaArchivosCer)
|
|
ViewState("OpActualizaArchivosCer") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
If UsuarioActual.CveRol <> 1 AndAlso (Request("CveEmpresa") IsNot Nothing AndAlso Request("CveEmpresa").ToEntero > 0) Then
|
|
|
|
If Not ValidaCveEmpresaUsaurio(UsuarioActual.CveUsuario, Request("CveEmpresa").ToEntero) Then
|
|
'Response.Redirect("../Inicio.aspx")
|
|
Alert("No tiene acceso a esta empresa.", TipoMensaje.MsgAdvertencia, "document.location.href = ""../Inicio.aspx""")
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
DdlEmpresa.DataSource = GlobalDTEmpresas
|
|
DdlEmpresa.DataBind()
|
|
CargaDdlPac()
|
|
CargaRegimenFiscal()
|
|
CargaGridIndicadores()
|
|
CargaZonasHorarias()
|
|
|
|
DtFuncionalidades = Nothing
|
|
DtCuentas = Nothing
|
|
CveClasificacionPorcentaje = 0
|
|
|
|
If (Request("CveEmpresa") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresa")) AndAlso Request("CveEmpresa").ToEntero > 0 AndAlso UsuarioActual.CveRol = 1) OrElse UsuarioActual.CveRol <> 1 Then
|
|
ViewState("CveEmpresa") = If(UsuarioActual.CveRol <> 1, UsuarioActual.Empresa.CveEmpresa.ToString, Request("CveEmpresa")) ' Request("CveEmpresa")
|
|
' Session("FileUpload") = CveEmpresa
|
|
CargaTareasProgramadas()
|
|
CargaDatos()
|
|
|
|
'Configuración de Modalidad Update
|
|
TxtTimbres.Enabled = False
|
|
LbArchivoKeyDescarga.Visible = True
|
|
LbArchivoCerDescarga.Visible = True
|
|
LbArchivoPfxDescarga.Visible = True
|
|
|
|
'If LnkArchivoKey.InnerText = "" Then
|
|
' LnkArchivoKey.InnerText = "Reemplazar Archivo Key"
|
|
'End If
|
|
'If LnkArchivoCer.InnerText = "" Then
|
|
' LnkArchivoCer.InnerText = "Reemplazar Archivo Cer"
|
|
'End If
|
|
|
|
'If LnkArchivoPfx.InnerText = "" Then
|
|
' LnkArchivoPfx.InnerText = "Reemplazar Archivo Pfx"
|
|
'End If
|
|
BtnGuardar.Text = "Guardar Cambios"
|
|
|
|
'Plantilla Correo
|
|
|
|
|
|
Else
|
|
'Configuración de Modalidad Insert
|
|
ViewState("CveEmpresa") = -1
|
|
'TAB.ActiveTabIndex = 1
|
|
BtnEliminar.Visible = False
|
|
|
|
End If
|
|
ConfiguracionEmpresa()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ValidaCveEmpresaUsaurio(CveUsuario As Integer, CveEmpresaValidar As Integer) As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
Using ObjEmpresas As New ClsSisEmpresas()
|
|
If ObjEmpresas.GetEmpresas(-1, "-1", "-1", "-1", "-1", UsuarioActual.CveUsuario) Then
|
|
If ObjEmpresas.DtResultados.FiltraParametros($"CveEmpresa = {CveEmpresaValidar}").Rows.Count = 1 Then
|
|
Respuesta = True
|
|
End If
|
|
End If
|
|
End Using
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
Private Sub CargaDatos()
|
|
|
|
Dim ObjEmpresas As New ClsSisEmpresas()
|
|
If ObjEmpresas.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
If ObjEmpresas.DtResultados.Rows.Count > 0 Then
|
|
Me.EmpresaEditar = ObjEmpresas.Empresa
|
|
With ObjEmpresas.Empresa
|
|
|
|
'Campos para Modificación
|
|
TxtCveEmpresa.Text = .CveEmpresa.ToString
|
|
TxtEmpresa.Text = .Empresa : LtlTitulo.Text = "Consulta de Empresa: " & .Empresa
|
|
TxtNombreCorto.Text = .NombreCorto
|
|
TxtDireccion.Text = .Direccion
|
|
TxtNoExt.Text = .NoExt
|
|
TxtNoInt.Text = .NoInt
|
|
TxtColonia.Text = .Colonia
|
|
TxtCiudad.Text = .Ciudad
|
|
TxtEstado.Text = .Estado
|
|
TxtCP.Text = .CP.ToString
|
|
TxtRFC.Text = .RFC
|
|
TxtTelefono.Text = .Telefono
|
|
TxtContacto.Text = .Contacto 'Representante legal
|
|
TxtMail.Text = .Mail
|
|
DdlTipoFacturacion.SelectedValue = .TipoFacturacion
|
|
TxtBIUsuario.Text = .BIUsuario
|
|
TxtBIContraseña.Text = .BIContraseña
|
|
TxtContraseñaKey.Text = .ContraseñaKey
|
|
TxtArchivoKey.Text = .ArchivoKey
|
|
TxtArchivoCer.Text = .ArchivoCer
|
|
TxtArchivoPfx.Text = .ArchivoPfx
|
|
ChkEstatus.Checked = .Estatus
|
|
TxtFecha.Text = .FechaIng.ToString
|
|
TxtCveUsuario.Text = .Usuario
|
|
ChkFacturaProduccion.Checked = .FacturaProduccion
|
|
TxtSendMail.Text = .SendMail
|
|
TxtSendMailPassword.Text = .SendMailPassword
|
|
TxtSendMailServer.Text = .SendMailServer
|
|
TxtSendMailPort.Text = .SendMailPuerto.ToString
|
|
ChkSendMailSSL.Checked = .SendMailSSL
|
|
ChkMostrarRetIVA.Checked = .MostrarRetIVA
|
|
ChkMostrarRetISR.Checked = .MostrarRetISR
|
|
'TxtRegimen.Text = .Regimen
|
|
TxtTimbres.Text = .Timbres.ToString
|
|
ChkUsaContabilidad.Checked = .UsaContabilidad
|
|
ChkUsaBancos.Checked = .UsaBancos
|
|
ChkUsaVentas.Checked = .UsaVentas
|
|
ChkUsaCxC.Checked = .UsaCxC
|
|
ChkUsaCompras.Checked = .UsaCompras
|
|
ChkUsaInventarios.Checked = .UsaInventarios
|
|
ChkUsaRH.Checked = .UsaRH
|
|
ChkUsaNomina.Checked = .UsaNomina
|
|
ChkUsaOS.Checked = .UsaOS
|
|
TxtBDContPAQi.Text = .BDContPAQi
|
|
TxtServerContPAQi.Text = .ServerContPAQi
|
|
TxtUsrContPAQi.Text = .UsrContPAQi
|
|
TxtPwdContPAQi.Text = .PwdContPAQi
|
|
TxtBuzon_Mail.Text = .Buzon_Mail
|
|
TxtBuzon_Server.Text = .Buzon_Server
|
|
TxtBuzon_Puerto.Text = .Buzon_Puerto.ToString
|
|
ChkBuzon_SSL.Checked = .Buzon_SSL
|
|
TxtBuzon_USR.Text = .Buzon_USR
|
|
TxtBuzon_PWD.Text = .Buzon_PWD
|
|
TxtMailSoporte.Text = .Soporte_Mail
|
|
TxtServidorSoporte.Text = .Soporte_Server
|
|
TxtPuertoSoporte.Text = .Soporte_Puerto.ToString
|
|
DdlProtocolo.Text = .Buzon_Tipo
|
|
ChkSSLSoporte.Checked = .Soporte_SSL
|
|
TxtUsuarioSoporte.Text = .Soporte_USR
|
|
DdlProtocoloSoporte.SelectedValue = .Soporte_Tipo
|
|
TxtContraseñaSoporte.Text = .Soporte_PWD
|
|
DdlCvePac.SelectedValueExist(.CvePAC.ToString)
|
|
DdlRegimen.SelectedValue = .CveRegimenFiscal.ToString
|
|
TxtCURP.Text = .CURP
|
|
TxtImporte.Text.ToDecimal
|
|
TxtCIEC.Text = .CIEC
|
|
DdlPlataforma.SelectedValue = .CvePlataforma.ToString
|
|
ChkUsaAC.Checked = .UsaAC
|
|
TxtPorDepreciacion.Text = .PorDepreciacion.ToString
|
|
TxtExtension.Text = .Extension
|
|
TxtLocalidad.Text = .Localidad
|
|
DdlMetodoInventario.SelectedValue = .CveMetodoInventario.ToString
|
|
TxtPeriodoActual.Text = .PeriodoActual.ToString
|
|
TxtEjercicioActual.Text = .EjercicioActual.ToString
|
|
ChkDefaultAsistencias.Checked = .DefaultAsistencias
|
|
TxtDiasPermitidos.Text = .DiasPermitidos.ToString
|
|
DdlTipoCentroDeCostos.SelectedValue = .Tipo_CentroCosto.ToString
|
|
ChkReqCentroCostos.Checked = .RequiereCentroCostos
|
|
DdlTerminalTipo.SelectedValue = .PV_TerminalTipo.ToString
|
|
TxtImporte.Text = .Importe.ToString
|
|
TipoContabilidad = .TipoContabilidad
|
|
DdlZonaHoraria.SelectedValueExist(.CveZonaHoraria)
|
|
|
|
TxtPlantillaVenta.Text = .PlantillaMailVenta
|
|
TxtAsunto.Text = .AsuntoPlantillaMailVenta
|
|
|
|
TxtPlantillaCotizacion.Text = .PlantillaMailVentaCotizacion
|
|
TxtAsuntoCotizacion.Text = .AsuntoPlantillaMailVentaCotizacion
|
|
|
|
'NUEVOS
|
|
TxtAreaGeografica.Text = .AreaGeografica
|
|
|
|
|
|
'Fiel
|
|
LblPfx.Text = .FielPFX
|
|
lblPassFiel.Text = .FielPassword
|
|
|
|
'PARA PROPIEDAD - TRIGGER
|
|
BDContPAQ = .BDContPAQi
|
|
ServerContPAQ = .ServerContPAQi
|
|
|
|
'CUENTAS PADRES
|
|
ObjEmpresas.GetEmpresasFuncionalidades(CveEmpresa)
|
|
DtFuncionalidades = ObjEmpresas.DtResultados
|
|
|
|
|
|
Session("FileUpload") = .Banner
|
|
Session("FileUpload") = .ArchivoKey
|
|
Session("FileUpload") = .ArchivoCer
|
|
Session("FileUpload") = .ArchivoPfx
|
|
End With
|
|
Else
|
|
Alert("La Empresa Solicitada no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
|
|
End If
|
|
End If
|
|
|
|
ObjEmpresas.Dispose()
|
|
CargarGrupoEmpresas()
|
|
UpDatos.Update()
|
|
End Sub
|
|
Protected Sub CargarGrupoEmpresas()
|
|
Dim ObjEmpresas As New ClsSisEmpresas()
|
|
|
|
'Gridview
|
|
ObjEmpresas.GetEmpresasGrupos(CveEmpresa)
|
|
GVGrupoEmpresas.DataSource = ObjEmpresas.DtResultados
|
|
GVGrupoEmpresas.DataBind()
|
|
|
|
'DropdownList Empresas
|
|
ObjEmpresas.GetEmpresasGruposNot(CveEmpresa)
|
|
DdlEmpresas.Items.Clear()
|
|
DdlEmpresas.DataSource = ObjEmpresas.DtResultados
|
|
DdlEmpresas.DataBind()
|
|
|
|
ObjEmpresas.Dispose()
|
|
|
|
updategrupoempresa.Update()
|
|
End Sub
|
|
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) Handles AddGrupoEmpresa.Click
|
|
|
|
Dim ObjEmpresas As New ClsSisEmpresas()
|
|
ObjEmpresas.AddEmpresasGrupos(CveEmpresa, DdlEmpresas.SelectedValue.ToEntero)
|
|
ObjEmpresas.Dispose()
|
|
CargarGrupoEmpresas()
|
|
End Sub
|
|
Protected Sub GrupoEmpresas_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GVGrupoEmpresas.RowDeleting
|
|
Dim ObjEmpresas As New ClsSisEmpresas()
|
|
ObjEmpresas.RemoveEmpresasGrupos(CveEmpresa, CType(GVGrupoEmpresas.Rows(e.RowIndex).FindControl("GVColCVeEmpresa"), HiddenField).Value.ToEntero())
|
|
ObjEmpresas.Dispose()
|
|
CargarGrupoEmpresas()
|
|
End Sub
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
Dim ObjGral As New ClsGenerales()
|
|
Dim ObjContPAQ As ClsContPAQi = Nothing
|
|
Dim Indicador As New ClsIndicadores(ObjEmpresas.IniciaTransacSQL())
|
|
|
|
Dim TextoError As String = ""
|
|
Dim TextoOK As String = ""
|
|
|
|
If CveEmpresa = -1 Then
|
|
If ObjEmpresas.AddEmpresa(TxtCveEmpresa.Text.Trim.ToEntero, TxtEmpresa.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim,
|
|
TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, TxtTelefono.Text.Trim, TxtContacto.Text.Trim, TxtMail.Text.Trim,
|
|
DdlTipoFacturacion.SelectedValue, TxtBIUsuario.Text.Trim, TxtBIContraseña.Text.Trim, TxtContraseñaKey.Text.Trim, TxtArchivoKey.Text.Trim,
|
|
TxtArchivoCer.Text.Trim, TxtArchivoPfx.Text.Trim, "", UsuarioActual.CveUsuario, ChkFacturaProduccion.Checked, ChkMostrarRetIVA.Checked,
|
|
ChkMostrarRetISR.Checked, "-1", TxtSendMail.Text.Trim, TxtSendMailPassword.Text.Trim, TxtSendMailServer.Text.Trim,
|
|
TxtSendMailPort.Text.Trim.ToEntero, ChkSendMailSSL.Checked, ChkUsaContabilidad.Checked, ChkUsaBancos.Checked, ChkUsaVentas.Checked, ChkUsaCxC.Checked,
|
|
ChkUsaCompras.Checked, ChkUsaInventarios.Checked, ChkUsaRH.Checked, ChkUsaNomina.Checked, ChkUsaOS.Checked, TxtBDContPAQi.Text.Trim, TxtServerContPAQi.Text.Trim,
|
|
TxtUsrContPAQi.Text.Trim, TxtPwdContPAQi.Text.Trim, TxtBuzon_Mail.Text.Trim, TxtBuzon_Server.Text.Trim, TxtBuzon_Puerto.Text.Trim.ToEntero, ChkBuzon_SSL.Checked,
|
|
TxtBuzon_USR.Text.Trim, TxtBuzon_PWD.Text.Trim, DdlProtocolo.SelectedValue, TxtMailSoporte.Text.Trim, TxtServidorSoporte.Text.Trim, TxtPuertoSoporte.Text.Trim.ToEntero, ChkSSLSoporte.Checked,
|
|
TxtUsuarioSoporte.Text.Trim, TxtContraseñaSoporte.Text.Trim, DdlProtocoloSoporte.SelectedValue,
|
|
"".Trim, TxtAreaGeografica.Text.Trim,
|
|
TxtNombreCorto.Text, TxtCURP.Text.Trim, DdlRegimen.SelectedValue.ToEntero, TxtImporte.Text.ToDecimal, TxtCIEC.Text, DdlPlataforma.SelectedValue.ToEntero, ChkUsaAC.Checked,
|
|
TxtPorDepreciacion.Text.ToDecimal, TxtExtension.Text, TxtLocalidad.Text, DdlMetodoInventario.SelectedValue.ToEntero, TxtPeriodoActual.Text.ToEntero,
|
|
TxtEjercicioActual.Text.ToEntero, ChkDefaultAsistencias.Checked, TxtDiasPermitidos.Text.ToEntero, DdlTipoCentroDeCostos.SelectedValue.ToEntero, ChkReqCentroCostos.Checked, DdlTerminalTipo.SelectedValue.ToEntero,
|
|
CvePAC:=DdlCvePac.SelectedValue.ToEntero, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero
|
|
) Then
|
|
|
|
'Movemos el Archivo Fisicamente
|
|
If Session("FileUpload") IsNot Nothing AndAlso Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString) Then
|
|
Dim Extension As String = Path.GetExtension(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString)
|
|
File.Move(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString, Request.PhysicalApplicationPath + "Banners\" & ObjEmpresas.CveEmpresa.ToString & Extension)
|
|
|
|
End If
|
|
ViewState("CveEmpresa") = ObjEmpresas.CveEmpresa
|
|
'InicializaClasificacionIVA(ObjEmpresas)
|
|
TextoOK = "La nueva Empresa se guardó correctamente."
|
|
Else
|
|
TextoError = "Ocurrió un error al agregar la empresa"
|
|
End If
|
|
|
|
|
|
|
|
'Agregar Indicadores
|
|
For Each Row As GridViewRow In GvIndicadores.Rows
|
|
If Row.DataKey("CveIndicador") <> "" And Row.DataKey("CveEmpresa") = "" Then
|
|
If Row.FCCheckBox("chkIndicador").Checked Then
|
|
If Not Indicador.AddIndicadorEmpresa(Row.DataKey("CveIndicador").ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
|
|
|
|
Else
|
|
If ObjEmpresas.UpdateEmpresa(TxtEmpresa.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtRFC.Text.Trim,
|
|
TxtCP.Text.Trim, TxtTelefono.Text.Trim, TxtContacto.Text.Trim, TxtMail.Text.Trim, DdlTipoFacturacion.SelectedItem.ToString, TxtBIUsuario.Text.Trim,
|
|
TxtBIContraseña.Text.Trim, TxtContraseñaKey.Text, TxtArchivoKey.Text.Trim, TxtArchivoCer.Text.Trim, TxtArchivoPfx.Text.Trim, "", ChkEstatus.Checked,
|
|
ChkFacturaProduccion.Checked, ChkMostrarRetIVA.Checked, ChkMostrarRetISR.Checked, "", TxtSendMail.Text.Trim,
|
|
TxtSendMailPassword.Text.Trim, TxtSendMailServer.Text.Trim, TxtSendMailPort.Text.Trim.ToEntero, ChkSendMailSSL.Checked, ChkUsaContabilidad.Checked, ChkUsaBancos.Checked,
|
|
ChkUsaVentas.Checked, ChkUsaCxC.Checked, ChkUsaCompras.Checked, ChkUsaInventarios.Checked, ChkUsaRH.Checked, ChkUsaNomina.Checked, ChkUsaOS.Checked, TxtBDContPAQi.Text.Trim,
|
|
TxtServerContPAQi.Text.Trim, TxtUsrContPAQi.Text.Trim, TxtPwdContPAQi.Text.Trim, TxtBuzon_Mail.Text.Trim, TxtBuzon_Server.Text.Trim, TxtBuzon_Puerto.Text.Trim.ToEntero,
|
|
ChkBuzon_SSL.Checked, TxtBuzon_USR.Text.Trim, TxtBuzon_PWD.Text.Trim, TxtCveEmpresa.Text.Trim.ToEntero, DdlProtocolo.SelectedValue,
|
|
TxtMailSoporte.Text.Trim, TxtServidorSoporte.Text.Trim, TxtPuertoSoporte.Text.Trim.ToEntero, ChkSSLSoporte.Checked,
|
|
TxtUsuarioSoporte.Text.Trim, TxtContraseñaSoporte.Text.Trim, DdlProtocoloSoporte.SelectedValue, "", TxtAreaGeografica.Text.Trim,
|
|
TxtNombreCorto.Text, TxtCURP.Text.Trim, DdlRegimen.SelectedValue.ToEntero, DdlCvePac.SelectedValue.ToEntero,
|
|
TxtImporte.Text.ToDecimal, TxtCIEC.Text, DdlPlataforma.SelectedValue.ToEntero, ChkUsaAC.Checked,
|
|
TxtPorDepreciacion.Text.ToDecimal, TxtExtension.Text, TxtLocalidad.Text, DdlMetodoInventario.SelectedValue.ToEntero, TxtPeriodoActual.Text.ToEntero,
|
|
TxtEjercicioActual.Text.ToEntero, ChkDefaultAsistencias.Checked, TxtDiasPermitidos.Text.ToEntero, DdlTipoCentroDeCostos.SelectedValue.ToEntero, ChkReqCentroCostos.Checked,
|
|
DdlTerminalTipo.SelectedValue.ToEntero, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero) Then
|
|
|
|
'Movemos el Archivo Fisicamente
|
|
If Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString) Then
|
|
Dim Extension As String = Path.GetExtension(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString)
|
|
If File.Exists(Request.PhysicalApplicationPath + "Banners\" & CveEmpresa & Extension) Then
|
|
File.Delete(Request.PhysicalApplicationPath + "Banners\" & CveEmpresa & Extension)
|
|
File.Move(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString, Request.PhysicalApplicationPath + "Banners\" & CveEmpresa & Extension)
|
|
Else
|
|
File.Move(Request.PhysicalApplicationPath + "Banners\Temp\" & Session("FileUpload").ToString, Request.PhysicalApplicationPath + "Banners\" & CveEmpresa & Extension)
|
|
End If
|
|
End If
|
|
|
|
TextoOK = "Los cambios de guardaron correctamente."
|
|
Else
|
|
TextoError = "Ocurrió un error al guardar los cambios de la empresa"
|
|
End If
|
|
|
|
'Agregar Indicadores
|
|
For Each Row As GridViewRow In GvIndicadores.Rows
|
|
If Row.DataKey("CveIndicador") <> "" AndAlso Row.DataKey("CveEmpresa") <> "" And Row.FCCheckBox("chkIndicador").Checked = False Then
|
|
If Not Indicador.RemoveIndicadoresEmpresas(Row.DataKey("CveIndicador").ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
If Row.DataKey("CveIndicador") <> "" And Row.DataKey("CveEmpresa") = "" Then
|
|
If Row.FCCheckBox("chkIndicador").Checked Then
|
|
If Not Indicador.AddIndicadorEmpresa(Row.DataKey("CveIndicador").ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Exit For
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
'RECARGA EMPRESA
|
|
If TextoError = "" Then
|
|
If ObjEmpresas.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") Then
|
|
GlobalDTEmpresas(CveEmpresa) = Nothing
|
|
|
|
'verifico si existe la carpeta de la empresa, sino la crea
|
|
For Each dr As Data.DataRow In ObjEmpresas.DtResultados.Rows
|
|
If Not IO.Directory.Exists(String.Format("{0}\{1}", ModExtensiones.DirectorioBaseEmpresas, dr("CveEmpresa"))) Then
|
|
IO.Directory.CreateDirectory(String.Format("{0}Empresas\{1}", ModExtensiones.DirectorioBaseEmpresas, dr("CveEmpresa")))
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
'TRIGGER
|
|
If TextoError = "" And TxtBDContPAQi.Text.Trim <> "" And TxtBDContPAQi.Text.Trim <> "" And TxtBDContPAQi.Text.Trim <> "" And TxtBDContPAQi.Text.Trim <> "" Then
|
|
|
|
If UsuarioActual.Empresa.UsaContabilidad Then
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
'CREA OBJETO EMPRESA
|
|
If ObjEmpresas.GetEmpresas(TxtCveEmpresa.Text.ToEntero, "-1", "-1", "-1", "-1") Then
|
|
Dim Empresa As New Empresa
|
|
Empresa = ObjEmpresas.Empresa
|
|
|
|
ObjContPAQ = New ClsContPAQi(Empresa)
|
|
|
|
If ObjContPAQ.Conectado Then
|
|
'ADD
|
|
If BDContPAQ = "" Then
|
|
If Not ObjContPAQ.TRIGGER(TxtBDContPAQi.Text.Trim) Then
|
|
TextoError = "Los datos de conexion al servidor de contabilidad son incorrectos"
|
|
End If
|
|
End If
|
|
|
|
'UPDATE
|
|
If BDContPAQ <> "" And (BDContPAQ <> TxtBDContPAQi.Text.Trim Or ServerContPAQ <> TxtServerContPAQi.Text.Trim) Then
|
|
If Not ObjContPAQ.TRIGGER(TxtBDContPAQi.Text.Trim) Then
|
|
TextoError = "Los datos de conexion al servidor de contabilidad son incorrectos"
|
|
End If
|
|
End If
|
|
Else
|
|
TextoError = "Los datos de conexion al servidor de contabilidad son incorrectos"
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
Alert("La empresa tiene la información para el uso de contabilidad pero no se tiene activada", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
|
|
If TextoError = "" Then
|
|
ObjEmpresas.Commit()
|
|
If ObjContPAQ IsNot Nothing Then ObjContPAQ.Commit()
|
|
Alert(TextoOK, TipoMensaje.MsgInformacion, "document.location.href=""/Sistemas/Empresa.aspx?CveEmpresa=" & TxtCveEmpresa.Text.Trim & """;")
|
|
Session("FileUpload") = ""
|
|
CargaDatos()
|
|
UpDatos.Update()
|
|
Else
|
|
ObjEmpresas.RollBack()
|
|
If ObjContPAQ IsNot Nothing Then ObjContPAQ.RollBack()
|
|
Alert(TextoError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjEmpresas.Dispose()
|
|
ObjGral.Dispose()
|
|
If ObjContPAQ IsNot Nothing Then ObjContPAQ.Dispose()
|
|
End Sub
|
|
Private Function AgregarFuncionalidad(ObjEmpresas As ClsSisEmpresas, CveFuncionalidad As Integer, ByRef Ddl As DropDownList) As String
|
|
Dim Retorno As String = ""
|
|
|
|
If Not ObjEmpresas.AddUpdateEmpresaFuncionalidades(TxtCveEmpresa.Text.Trim.ToEntero, CveFuncionalidad, Ddl.SelectedValue) Then
|
|
Retorno = "Ocurrió un error al vincular la cuenta contable"
|
|
End If
|
|
|
|
Return Retorno
|
|
End Function
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
If ObjEmpresas.RemoveEmpresa(CveEmpresa) Then
|
|
GlobalDTEmpresas = ObjEmpresas.DtResultados
|
|
Alert("La Empresa se Eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Sistemas/Empresa.aspx"";")
|
|
End If
|
|
ObjEmpresas.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaDdlPac()
|
|
Dim Objeto As New ClsSisEmpresas
|
|
If Objeto.GetPacs() Then
|
|
DdlCvePac.DataSource = Objeto.DtResultados
|
|
DdlCvePac.DataBind()
|
|
DdlCvePac.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaZonasHorarias()
|
|
Dim GPS As New ClsGPS
|
|
If GPS.GetZonasHorarias() Then
|
|
DdlZonaHoraria.DataSource = GPS.DtResultados
|
|
Else
|
|
DdlZonaHoraria.DataSource = Nothing
|
|
End If
|
|
DdlZonaHoraria.DataBind()
|
|
DdlZonaHoraria.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
GPS.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaRegimenFiscal()
|
|
Dim ObjSis As New ClsSisEmpresas
|
|
If ObjSis.GetRegimenFiscal(-1) Then
|
|
DdlRegimen.DataSource = ObjSis.DtResultados
|
|
DdlRegimen.DataBind()
|
|
DdlRegimen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
ObjSis.Dispose()
|
|
End Sub
|
|
|
|
#Region "CONFIGURACION EMPRESA"
|
|
Private Sub ConfiguracionEmpresa()
|
|
If UsuarioActual.CveRol <> 1 Then
|
|
TabSistema.Visible = False
|
|
BtnCancelar.Visible = False
|
|
BtnEliminar.Visible = False
|
|
BiInform.Visible = False
|
|
End If
|
|
If TipoContabilidad = 2 Then
|
|
TabContabilidad.Visible = True
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "TAB - INDICADORES "
|
|
Public Sub CargaGridIndicadores()
|
|
Dim Objeto As New ClsIndicadores
|
|
If Objeto.GetEmpresasIndicadores(UsuarioActual.CveEmpresa) Then
|
|
GvIndicadores.DataSource = Objeto.DtResultados
|
|
End If
|
|
GvIndicadores.DataBind()
|
|
Objeto.Dispose()
|
|
End Sub
|
|
|
|
Private Sub GvIndicadores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIndicadores.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("CveEmpresa") <> "" Then
|
|
e.Row.FCCheckBox("chkIndicador").Checked = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "P L A N T I L L A C O R R E O"
|
|
|
|
Private Sub BtnGuardarPlantilla_Click(sender As Object, e As EventArgs) Handles BtnGuardarPlantilla.Click
|
|
If UsuarioActual.Empresa.PlantillaMailVenta.Length > 0 Then
|
|
|
|
End If
|
|
Dim ObjEmpresa As New ClsSisEmpresas()
|
|
If ObjEmpresa.UpdatePlantillaMail("AsuntoPlantillaMailVenta", TxtAsunto.Text.Trim, "PlantillaMailVenta", TxtPlantillaVenta.Text.Trim, CveEmpresa) Then
|
|
|
|
If ObjEmpresa.UpdatePlantillaMail("AsuntoPlantillaMailVentaCotizacion", TxtAsuntoCotizacion.Text.Trim, "PlantillaMailVentaCotizacion", TxtPlantillaCotizacion.Text.Trim, CveEmpresa) Then
|
|
|
|
End If
|
|
Alert("La plantilla de mail de ventas se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
|
|
UsuarioActual.Empresa.PlantillaMailVenta = TxtPlantillaVenta.Text.Trim
|
|
UsuarioActual.Empresa.AsuntoPlantillaMailVenta = TxtAsunto.Text.Trim
|
|
|
|
UsuarioActual.Empresa.AsuntoPlantillaMailVentaCotizacion = TxtAsuntoCotizacion.Text.Trim
|
|
UsuarioActual.Empresa.PlantillaMailVentaCotizacion = TxtPlantillaCotizacion.Text.Trim
|
|
|
|
'TxtPlantillaVenta.Text = ""
|
|
'TxtAsunto.Text = ""
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
Alert(TxtPlantillaVenta.Text.Trim, TipoMensaje.MsgInformacion)
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub LnkOpenModalDatosFiel_Click(sender As Object, e As EventArgs)
|
|
TxtFielPass.Text = ""
|
|
TxtFielArchivoCER.Text = ""
|
|
TxtFielArchivoKey.Text = ""
|
|
RegistraScript("$('#ModalUpFiel').modal();")
|
|
End Sub
|
|
Protected Sub LnkUpDatosFiel_Click(sender As Object, e As EventArgs)
|
|
Dim Password As String = TxtFielPass.Text
|
|
Dim akey As String
|
|
Dim acer As String
|
|
Dim pemkey As String
|
|
Dim pemcer As String
|
|
Dim pfxname As String
|
|
Dim Archivopfx As String
|
|
Dim Archivokey As Archivo = Nothing
|
|
Dim Archivocer As Archivo = Nothing
|
|
|
|
Dim dirbase As String = "" ' String.Format("{0}Empresas\{1}\Certificados\Fiel\", ModExtensiones.DirectorioBaseEmpresas, ViewState("CveEmpresa"))
|
|
Dim dirbasepfx As String = "" ' String.Format("{0}Empresas\{1}\Certificados\", ModExtensiones.DirectorioBaseEmpresas, ViewState("CveEmpresa"))
|
|
If EmpresaEditar IsNot Nothing Then
|
|
dirbase = String.Format("{0}Certificados\Fiel\", EmpresaEditar.Ruta)
|
|
dirbasepfx = String.Format("{0}Certificados\", EmpresaEditar.Ruta)
|
|
Else
|
|
dirbase = String.Format("{0}Empresas\{1}\Certificados\Fiel\", ModExtensiones.DirectorioBaseEmpresas, ViewState("CveEmpresa"))
|
|
dirbasepfx = String.Format("{0}Empresas\{1}\Certificados\", ModExtensiones.DirectorioBaseEmpresas, ViewState("CveEmpresa"))
|
|
End If
|
|
|
|
If (Not Directory.Exists(dirbase)) Then
|
|
Directory.CreateDirectory(dirbase)
|
|
End If
|
|
|
|
Dim Filesgral As List(Of Archivo) = TxtFielArchivoCER.getfiles().Archivos
|
|
If Filesgral.Count > 0 Then
|
|
Archivocer = Filesgral(0)
|
|
End If
|
|
Filesgral = TxtFielArchivoKey.getfiles().Archivos
|
|
If Filesgral.Count > 0 Then
|
|
Archivokey = Filesgral(0)
|
|
End If
|
|
If Not IsNothing(Archivokey) AndAlso Not IsNothing(Archivocer) And Password.Length > 0 Then
|
|
akey = String.Format("{0}{1}", dirbase, Archivokey.filenameO)
|
|
If File.Exists(akey) Then
|
|
File.Delete(akey)
|
|
End If
|
|
File.Copy(Archivokey.FileUrl, akey)
|
|
acer = String.Format("{0}{1}", dirbase, Archivocer.filenameO)
|
|
If File.Exists(acer) Then
|
|
File.Delete(acer)
|
|
End If
|
|
File.Copy(Archivocer.FileUrl, acer)
|
|
Archivopfx = Archivokey.filenameO.Substring(0, Archivokey.filenameO.Length - 4)
|
|
pemkey = String.Format("{0}{1}.pem", dirbase, Archivopfx)
|
|
pfxname = String.Format("{0}{1}.pfx", dirbasepfx, Archivopfx)
|
|
pemcer = String.Format("{0}{1}.pem", dirbase, Archivokey.filenameO.Substring(0, Archivocer.filenameO.Length - 4))
|
|
|
|
If File.Exists(pemkey) Then
|
|
File.Delete(pemkey)
|
|
End If
|
|
|
|
If File.Exists(pfxname) Then
|
|
File.Delete(pfxname)
|
|
End If
|
|
|
|
If File.Exists(pemcer) Then
|
|
File.Delete(pemcer)
|
|
End If
|
|
|
|
Dim resultado As New StringBuilder
|
|
resultado.AppendLine("<br/>PAso 1:<br/>")
|
|
resultado.AppendLine(execCommand({"cd C:\Generar PFX\", String.Format("openssl.exe x509 -inform DER -in ""{0}"" -out ""{1}""", acer, pemcer)}))
|
|
resultado.AppendLine("<br/>PAso 2:<br/>")
|
|
resultado.AppendLine(execCommand({"cd C:\Generar PFX\", String.Format("openssl pkcs8 -inform DER -in ""{0}"" -passin pass:""{1}"" -out ""{2}""", akey, Password, pemkey)}))
|
|
resultado.AppendLine("<br/>Paso 3:<br/>")
|
|
resultado.AppendLine(execCommand({"cd C:\Generar PFX\", String.Format("openssl pkcs12 -export -out ""{0}"" -inkey ""{1}"" -in ""{2}"" -passout pass:""{3}""", pfxname, pemkey, pemcer, Password)}))
|
|
resultado.AppendLine("<br/>")
|
|
'Alert(resultado.ToString())
|
|
|
|
If File.Exists(pemkey) Then
|
|
File.Delete(pemkey)
|
|
End If
|
|
If File.Exists(pemcer) Then
|
|
File.Delete(pemcer)
|
|
End If
|
|
If File.Exists(acer) Then
|
|
File.Delete(acer)
|
|
End If
|
|
If File.Exists(akey) Then
|
|
File.Delete(akey)
|
|
End If
|
|
If File.Exists(Archivocer.FileUrl) Then
|
|
File.Delete(Archivocer.FileUrl)
|
|
End If
|
|
If File.Exists(Archivokey.FileUrl) Then
|
|
File.Delete(Archivokey.FileUrl)
|
|
End If
|
|
If Not File.Exists(pfxname) Then
|
|
Archivopfx = ""
|
|
Password = ""
|
|
End If
|
|
Dim objempresa As New ClsSisEmpresas
|
|
objempresa.UpEmpresaFiel(ViewState("CveEmpresa").ToString().ToEntero(), Password, $"{Archivopfx}.pfx")
|
|
objempresa.Dispose()
|
|
lblPassFiel.Text = Password
|
|
LblPfx.Text = $"{Archivopfx}.pfx"
|
|
Alert("La Fiel se ha actualizado")
|
|
UpmodalFiel.Update()
|
|
RegistraScript("$('#ModalUpFiel').modal('hide');")
|
|
Else
|
|
Alert("Favor de llenar todos los campos : <br/>-Contraseña<br/>-Archivo CER<br/>-Archivo KEY", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Public Function execCommand(command As String()) As String
|
|
|
|
Dim proceso As Diagnostics.Process = New Diagnostics.Process()
|
|
proceso.StartInfo.FileName = "cmd.exe"
|
|
proceso.StartInfo.CreateNoWindow = True
|
|
proceso.StartInfo.RedirectStandardInput = True
|
|
proceso.StartInfo.RedirectStandardOutput = True
|
|
proceso.StartInfo.UseShellExecute = False
|
|
proceso.Start()
|
|
For Each c As String In command
|
|
proceso.StandardInput.WriteLine(c)
|
|
|
|
Next
|
|
proceso.StandardInput.Flush()
|
|
proceso.StandardInput.Close()
|
|
proceso.WaitForExit()
|
|
Return proceso.StandardOutput.ReadToEnd()
|
|
End Function
|
|
Private Sub CargaTareasProgramadas()
|
|
Dim objTP As New ClsTareasProgramadas()
|
|
ChkDescargaMasivaSat.Checked = False
|
|
If objTP.GetTareasProgramadas(ViewState("CveEmpresa").ToString.ToEntero()) AndAlso objTP.DtResultados.Rows.Count > 0 Then
|
|
ChkDescargaMasivaSat.Checked = (objTP.DtResultados.COUNT("CveTareaProgramada", "CveTareaProgramada=1") > 0)
|
|
End If
|
|
objTP.Dispose()
|
|
End Sub
|
|
Protected Sub ChkDescargaMasivaSat_CheckedChanged(sender As Object, e As EventArgs)
|
|
Dim objTP As New ClsTareasProgramadas()
|
|
If ChkDescargaMasivaSat.Checked Then
|
|
If objTP.AddTareasProgramadas(ViewState("CveEmpresa").ToString.ToEntero(), 1, NowADS().ToString("yyyy/MM/dd"), "", 0, "", NowADS().ToString("yyyy/MM/dd"), NowADS().ToString("yyyy/MM/dd"), "", "", 0, 1) Then
|
|
Alert("La tarea programada de descarga masiva del sat a agregado satisfactoriamente")
|
|
End If
|
|
Else
|
|
If objTP.RemoveTareasProgramadas(1, ViewState("CveEmpresa").ToString().ToEntero()) Then
|
|
Alert("La tarea programada de descarga masiva del sat se ha removido satisfactoriamente")
|
|
End If
|
|
End If
|
|
|
|
objTP.Dispose()
|
|
End Sub
|
|
Protected Sub LnkRegistrarPAC3_Click(sender As Object, e As EventArgs)
|
|
If Me.CveEmpresa > 0 Then
|
|
RegistrarPAC3()
|
|
Else
|
|
Alert("Debe registrar la empresa para poder registrarla en el PAC", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub RegistrarPAC3()
|
|
Try
|
|
|
|
Dim Credenciales As String = "vSGxMFWnNRy/nDoowxqrqw==|Sia123654"
|
|
Dim ArchivoLLave As String = String.Format("{0}\Certificados\{1}", EmpresaEditar.Ruta, EmpresaEditar.ArchivoKey)
|
|
Dim ArchivoCertificado As String = String.Format("{0}\Certificados\{1}", EmpresaEditar.Ruta, EmpresaEditar.ArchivoCer)
|
|
|
|
Dim llaveByte As Byte() = System.IO.File.ReadAllBytes(ArchivoLLave)
|
|
Dim certByte As Byte() = System.IO.File.ReadAllBytes(ArchivoCertificado)
|
|
|
|
Dim RFCEmisor As String = TxtRFC.Text.Trim()
|
|
Dim contrasena As String = TxtContraseñaKey.Text.Trim()
|
|
|
|
Dim conector As New Profact.TimbraCFDI33.Conector(EmpresaEditar.FacturaProduccion)
|
|
|
|
If Not EmpresaEditar.FacturaProduccion OrElse EmpresaEditar.CveEmpresa = 1 Then
|
|
conector.EstableceCredenciales("mvpNUXmQfK8=")
|
|
Else
|
|
conector.EstableceCredenciales(Credenciales)
|
|
End If
|
|
|
|
Dim result As Profact.TimbraCFDI.ResultadoRegistro = conector.RegistraEmisor(RFCEmisor, certByte, llaveByte, contrasena)
|
|
|
|
If result.Exitoso Then
|
|
Alert("El emisor se registró correctamente.<br>" & result.Descripcion)
|
|
Else
|
|
Alert("Ocurrió un error al registrar el emisor.<br>" & result.Descripcion & ".<br> Numero Error: " & result.NumeroError, TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
OnError("Ocurrió un error al registrar el emisor", ex)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkArchivoKey_Click(sender As Object, e As EventArgs) Handles LnkArchivoKey.Click
|
|
TxtCargaImg.getfiles().Archivos = Nothing
|
|
TxtCargaImg.Text = "[]"
|
|
OpActualizaArchivosCer = EnumOpActualizaArchivosCer.KEY
|
|
LblModalCertificadosTitulo.Text = "Archivo KEY"
|
|
UpModalCertificados.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalArchvivo"))
|
|
End Sub
|
|
|
|
Protected Sub LnkArchivoCer_Click(sender As Object, e As EventArgs) Handles LnkArchivoCer.Click
|
|
TxtCargaImg.getfiles().Archivos = Nothing
|
|
TxtCargaImg.Text = "[]"
|
|
OpActualizaArchivosCer = EnumOpActualizaArchivosCer.CER
|
|
LblModalCertificadosTitulo.Text = "Archivo CER"
|
|
UpModalCertificados.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalArchvivo"))
|
|
End Sub
|
|
|
|
Protected Sub LnkArchivoPfx_Click(sender As Object, e As EventArgs) Handles LnkArchivoPfx.Click
|
|
TxtCargaImg.getfiles().Archivos = Nothing
|
|
TxtCargaImg.Text = "[]"
|
|
OpActualizaArchivosCer = EnumOpActualizaArchivosCer.PFX
|
|
LblModalCertificadosTitulo.Text = "Archivo PFX"
|
|
UpModalCertificados.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "ModalArchvivo"))
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarArchivo_Click(sender As Object, e As EventArgs)
|
|
Dim FileExtension As String = "-1"
|
|
Dim filesgral As List(Of Archivo) = TxtCargaImg.getfiles().Archivos
|
|
Dim filemove As String = ""
|
|
Dim TieneError As Boolean = False
|
|
|
|
For Each fileItem As Archivo In filesgral
|
|
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
filemove = fileItem.filename
|
|
|
|
Dim Patron As String = "(^\d{1,}-)|(\.\w{1,}$)"
|
|
Dim NombreArchivo As String = Regex.Replace(filemove, Patron, "")
|
|
|
|
Dim yaExistente As String = String.Format("{0}Empresas\{1}\Certificados\{2}.{3}", ModExtensiones.DirectorioBaseEmpresas, CveEmpresa, NombreArchivo, FileExtension)
|
|
|
|
Dim ArchivoCertificado As String = $"{NombreArchivo}.{FileExtension}"
|
|
|
|
If File.Exists(yaExistente) Then
|
|
File.Delete(yaExistente)
|
|
End If
|
|
Try
|
|
If filemove <> "" Then
|
|
Dim Ruta As String = String.Format("Empresas\{0}\Certificados\", CveEmpresa)
|
|
filemove.FilesMove(NombreArchivo, Ruta)
|
|
End If
|
|
Catch ex As Exception
|
|
TieneError = True
|
|
End Try
|
|
|
|
|
|
If CveEmpresa > 0 AndAlso Not TieneError Then
|
|
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
|
|
|
|
Dim ArchivoKey As String = "-1"
|
|
Dim ArchivoCer As String = "-1"
|
|
Dim ArchivoPfx As String = "-1"
|
|
|
|
|
|
If OpActualizaArchivosCer = EnumOpActualizaArchivosCer.KEY Then
|
|
ArchivoKey = ArchivoCertificado
|
|
TxtArchivoKey.Text = ArchivoKey
|
|
ElseIf OpActualizaArchivosCer = EnumOpActualizaArchivosCer.CER Then
|
|
ArchivoCer = ArchivoCertificado
|
|
TxtArchivoCer.Text = ArchivoCer
|
|
ElseIf OpActualizaArchivosCer = EnumOpActualizaArchivosCer.PFX Then
|
|
ArchivoPfx = ArchivoCertificado
|
|
TxtArchivoPfx.Text = ArchivoPfx
|
|
End If
|
|
|
|
If Not ObjEmpresas.UpdateEmpresasCertificados(ArchivoKey, ArchivoCer, ArchivoPfx, CveEmpresa) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
|
|
ObjEmpresas.Dispose()
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
If Not TieneError Then
|
|
Alert("Certificado cargado con exito")
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalArchvivo"))
|
|
End If
|
|
TxtCargaImg.getfiles().Archivos = Nothing
|
|
UpAddArchivo.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub LbArchivoKeyDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoKeyDescarga.Click
|
|
|
|
Dim NombreArchivo As String = TxtArchivoKey.Text
|
|
DescargarArchivo(NombreArchivo)
|
|
|
|
End Sub
|
|
|
|
Protected Sub LbArchivoCerDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoCerDescarga.Click
|
|
|
|
Dim NombreArchivo As String = TxtArchivoCer.Text
|
|
DescargarArchivo(NombreArchivo)
|
|
|
|
End Sub
|
|
|
|
Protected Sub LbArchivoPfxDescarga_Download(sender As Object, e As EventArgs) Handles LbArchivoPfxDescarga.Click
|
|
|
|
Dim NombreArchivo As String = TxtArchivoPfx.Text
|
|
DescargarArchivo(NombreArchivo)
|
|
|
|
End Sub
|
|
|
|
Private Sub DescargarArchivo(NombreArchivo As String)
|
|
|
|
Dim FilePath As String = String.Format("{0}Empresas\{1}\Certificados\{2}", ModExtensiones.DirectorioBaseEmpresas, CveEmpresa, NombreArchivo)
|
|
Dim byteArray As Byte() = File.ReadAllBytes(FilePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", NombreArchivo))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", byteArray.Length.ToString())
|
|
HttpContext.Current.Response.OutputStream.Write(byteArray, 0, byteArray.Length)
|
|
HttpContext.Current.Response.End()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkClonmarCNomModal_Click(sender As Object, e As EventArgs)
|
|
|
|
RegistraScript("$('#ModalClonarConceptosNominas').modal();")
|
|
End Sub
|
|
Protected Sub LnkClonarConceptosNomina_Click(sender As Object, e As EventArgs)
|
|
Dim CveEmpresaOrigen = DdlEmpresa.SelectedValue.ToEntero()
|
|
Dim cveEmpresaDestino = CveEmpresa ' Request("CveEmpresa").ToString().ToEntero()
|
|
If (CveEmpresaOrigen > 0 AndAlso cveEmpresaDestino > 0) Then
|
|
Using onom = New ClsNominas
|
|
If onom.ConceptosGetallnewEmpresa(CveEmpresaOrigen, CveEmpresa) Then
|
|
Alert("los conceptos se clonaron satisfactoriamente", TipoMensaje.MsgInformacion)
|
|
|
|
End If
|
|
End Using
|
|
Else
|
|
If CveEmpresaOrigen > 0 Then
|
|
Alert("ya debe estar generado la empresa destino", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Alert("Debe seleccionar una empresa Origen", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|