3465 lines
164 KiB
VB.net
3465 lines
164 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Imports System.IO
|
|
|
|
|
|
Partial Class Sistemas_WizardRegistro
|
|
Inherits Page
|
|
|
|
#Region " PROPIEDADES "
|
|
Private Property CveEmpresaTemp As Integer
|
|
Get
|
|
CveEmpresaTemp = ViewState("CveEmpresaTemp").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveEmpresaTemp") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveEmpresa As Integer
|
|
Get
|
|
CveEmpresa = ViewState("CveEmpresa").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveEmpresa") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveRol As Integer
|
|
Get
|
|
CveRol = ViewState("CveRol").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveRol") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtRoles As DataTable
|
|
Get
|
|
Return CType(ViewState("DtRoles"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtRoles") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtProyectos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtProyectos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtProyectos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtUsuarios As DataTable
|
|
Get
|
|
Return CType(ViewState("DtUsuarios"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtUsuarios") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtClasificaciones As DataTable
|
|
Get
|
|
Return CType(ViewState("DtClasificaciones"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtClasificaciones") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtModulos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtModulos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtModulos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPS As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPS"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPS") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTEstatusUsuarios As DataTable
|
|
Get
|
|
Return CType(ViewState("DTEstatusUsuarios"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTEstatusUsuarios") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtUM As DataTable
|
|
Get
|
|
Return CType(ViewState("DtUM"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtUM") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtProcesos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtProcesos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtProcesos") = value
|
|
End Set
|
|
End Property
|
|
Private Property FIEL As String
|
|
Get
|
|
FIEL = ViewState("FIEL").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FIEL") = value
|
|
End Set
|
|
End Property
|
|
Private Property CSD As String
|
|
Get
|
|
CSD = ViewState("CSD").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("CSD") = value
|
|
End Set
|
|
End Property
|
|
Private Property NombreEmpresaPropiedad As String
|
|
Get
|
|
NombreEmpresaPropiedad = ViewState("NombreEmpresaPropiedad").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("NombreEmpresaPropiedad") = value
|
|
End Set
|
|
End Property
|
|
Private Property RFCPropiedad As String
|
|
Get
|
|
RFCPropiedad = ViewState("RFCPropiedad").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("RFCPropiedad") = value
|
|
End Set
|
|
End Property
|
|
Private Property Correo As String
|
|
Get
|
|
Correo = ViewState("Correo").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Correo") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property MetodoPAgo As Integer
|
|
Get
|
|
MetodoPAgo = ViewState("MetodoPAgo").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("MetodoPAgo") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " PROPIEDADES PARA MODAL DE CATALOGOS "
|
|
Private Property ModalidadModal As String
|
|
Get
|
|
ModalidadModal = ViewState("ModalidadModal").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ModalidadModal") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveModal As Integer
|
|
Get
|
|
CveModal = ViewState("CveModal").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveModal") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
RegistraScript("$('#mBody').addClass('page-sidebar-closed');$('#divMenu').css('display','none');QuitarBarras();")
|
|
If Request("P") IsNot Nothing AndAlso Decripta((Request("P").ToString)) <> "" Then
|
|
Dim UrlParametros As Hashtable = Parametros(Decripta((Request("P").ToString)))
|
|
CveRol = 0
|
|
If UrlParametros("CVEEMPRESA") IsNot Nothing AndAlso UrlParametros("CVEEMPRESA").ToString.ToEntero > 0 Then
|
|
CveEmpresa = UrlParametros("CVEEMPRESA").ToString.ToEntero
|
|
CargaDatos()
|
|
Else
|
|
DivEsconder.Style.Add("display", "none")
|
|
Alert("No se seleccionó ninguna empresa", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
Else
|
|
DivEsconder.Style.Add("display", "none")
|
|
Alert("No se seleccionó ninguna empresa", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " FUNCIONES - POSIBLE LLEVARSE PARA TODO EL SITIO "
|
|
Private Function Parametros(Cadena As String) As Hashtable
|
|
Dim P1() As String = Cadena.Split("&"c)
|
|
Dim Tmp As String
|
|
Dim P2() As String
|
|
|
|
Dim URLParametros As New Hashtable
|
|
|
|
For Each Tmp In P1
|
|
P2 = Tmp.Replace("%26%", "&").Split("="c)
|
|
URLParametros.Add(P2(0).ToString.ToUpper, P2(1))
|
|
Next
|
|
Return URLParametros
|
|
End Function
|
|
Private Function EsDuplicado(Dt As DataTable, Filtro As String) As Boolean
|
|
Dim Tabla As New DataTable()
|
|
Tabla = Dt.FiltraParametros(Filtro)
|
|
If Tabla.Rows.Count > 0 Then
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
Public Function FormatearNombreArchivo(nombreArchivoOriginal As String) As String
|
|
Dim nombreArchivoFormateado As String
|
|
nombreArchivoFormateado = nombreArchivoOriginal.Replace(" ", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("'", "")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace(Chr(34), "")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("$", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("#", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("%", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("!", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("&", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("?", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("¿", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("¡", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("*", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("~", "_")
|
|
nombreArchivoFormateado = nombreArchivoFormateado.Replace("^", "_")
|
|
Return nombreArchivoFormateado
|
|
End Function
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
Protected Sub CargaDatos()
|
|
Dim ObjEmpresa As New ClsSisEmpresas
|
|
If ObjEmpresa.GetEmpresas(CveEmpresa, "-1", "-1", "-1", "-1") AndAlso ObjEmpresa.DtResultados.Rows.Count > 0 Then
|
|
|
|
Dim DrEmpresa = ObjEmpresa.DtResultados.Rows(0)
|
|
'PROPIEDADES
|
|
NombreEmpresaPropiedad = DrEmpresa("Empresa").ToString
|
|
RFCPropiedad = DrEmpresa("RFC").ToString
|
|
'TITULO
|
|
ltlEmpresa.Text = $"Registro de {NombreEmpresaPropiedad} ({RFCPropiedad})"
|
|
|
|
'CARGA PASO 1.1 - DATOS FISCALES
|
|
TxtNomEmpresa.Text = DrEmpresa("Empresa").ToString
|
|
TxtRFC.Text = DrEmpresa("RFC").ToString
|
|
TxtEmail.Text = DrEmpresa("Mail").ToString
|
|
DdlRegimen.SelectedValueExist(DrEmpresa("Regimen").ToString)
|
|
TxtContacto.Text = DrEmpresa("Contacto").ToString
|
|
TxtTelefono.Text = DrEmpresa("Telefono").ToString
|
|
TxtExtension.Text = DrEmpresa("Extension").ToString
|
|
TxtDireccion.Text = DrEmpresa("Direccion").ToString
|
|
TxtNoExt.Text = DrEmpresa("NoExt").ToString
|
|
TxtNoInt.Text = DrEmpresa("NoInt").ToString
|
|
TxtColonia.Text = DrEmpresa("Colonia").ToString
|
|
TxtCiudad.Text = DrEmpresa("Ciudad").ToString
|
|
TxtLocalidad.Text = DrEmpresa("Localidad").ToString
|
|
TxtEstado.Text = DrEmpresa("Estado").ToString
|
|
TxtCP.Text = DrEmpresa("CP").ToString
|
|
|
|
'CARGA PASO 1.3 - DATOS FISCALES
|
|
TxtContraKey.Text = DrEmpresa("ContraseñaKey").ToString
|
|
TxtCIEC.Text = DrEmpresa("CIEC").ToString
|
|
|
|
DtClasificaciones.FiltraParametros("", "", {"CveProyecto", "Proyecto"})
|
|
|
|
Correo = DrEmpresa("Mail").ToString
|
|
MetodoPAgo = DrEmpresa("CveMetodoPago").ToString.ToEntero
|
|
|
|
'CARGA PASO 3.2 - CORREOS
|
|
txtEnvioCorreo.Text = DrEmpresa("SendMail").ToString
|
|
TxtEnvioContraseña.Text = DrEmpresa("SendMailPassword").ToString
|
|
TxtEnvioServidor.Text = DrEmpresa("SendMailServer").ToString
|
|
TxtEnvioPuerto.Text = DrEmpresa("SendMailPuerto").ToString
|
|
ChkEnvioSSL.Checked = CBool(DrEmpresa("SendMailSSL").ToString)
|
|
txtRecepCorreo.Text = DrEmpresa("Buzon_Mail").ToString
|
|
TxtRecepContraseña.Text = DrEmpresa("Buzon_PWD").ToString
|
|
TxtRecepServidor.Text = DrEmpresa("Buzon_Server").ToString
|
|
TxtRecepPuerto.Text = DrEmpresa("Buzon_Puerto").ToString
|
|
DdlRecepProtocolo.SelectedValueExist(DrEmpresa("Buzon_Tipo").ToString)
|
|
ChkRecepSSL.Checked = CBool(DrEmpresa("Buzon_SSL").ToString)
|
|
|
|
|
|
DdlTipoCentroCostos.SelectedValueExist(DrEmpresa("Tipo_CentroCosto"))
|
|
CargaSubProyectos()
|
|
CargaGvFolio()
|
|
|
|
Dim ObjRoles As New ClsSisRoles
|
|
Dim objUsuarios As New ClsSisUsuarios
|
|
Dim objunidadesMedida As New ClsUnidadesMedida
|
|
Dim objClasi As New ClsClasificaciones
|
|
Dim objPS As New ClsProductosServicios
|
|
Dim objInv As New ClsInventarios
|
|
|
|
DivRegistroInicial.Style.Add("display", "")
|
|
RFVNombre.ValidationGroup = "GrpGuardar"
|
|
REVRFC.ValidationGroup = "GrpGuardar"
|
|
RFVRFC.ValidationGroup = "GrpGuardar"
|
|
REVContactoEmail.ValidationGroup = "GrpGuardar"
|
|
RequiredFieldValidator1.ValidationGroup = "GrpGuardar"
|
|
'cvEmail.ValidationGroup = "GrpGuardar"
|
|
|
|
|
|
If objUsuarios.GetUsuarios(-1) Then
|
|
GvUsuarios.DataSource = objUsuarios.DtResultados.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
|
|
'
|
|
GvUsuarios.DataBind()
|
|
End If
|
|
If objClasi.GetClasificaciones(CveEmpresa) AndAlso objClasi.DtResultados.Rows.Count > 0 Then
|
|
DtClasificaciones = objClasi.DtResultados
|
|
CargaDdlClasificaciones()
|
|
End If
|
|
CargaGVClasificacion()
|
|
|
|
If objunidadesMedida.GetUnidadesMedida(CveEmpresa) Then
|
|
DtUM = objunidadesMedida.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", CveEmpresa))
|
|
GvUM.DataSource = DtUM
|
|
GvUM.DataBind()
|
|
CargaDdlUM()
|
|
End If
|
|
|
|
If objPS.GetPS(-1, -1, CveEmpresa) Then
|
|
GVPS.DataSource = objPS.DtResultados
|
|
GVPS.DataBind()
|
|
Else
|
|
GVPS.DataSource = Nothing
|
|
End If
|
|
|
|
If objPS.GetMetodosInv() Then
|
|
DdlMetodos.DataSource = objPS.DtResultados.FiltraParametros("CveMetodoInventario <> 0")
|
|
DdlMetodos.DataBind()
|
|
Else
|
|
DdlMetodos.DataSource = Nothing
|
|
End If
|
|
|
|
If objInv.GetTiposAlmacenes Then
|
|
DdlTipoAlmacen.DataSource = objInv.DtResultados
|
|
DdlTipoAlmacen.DataBind()
|
|
Else
|
|
DdlTipoAlmacen.DataSource = Nothing
|
|
End If
|
|
|
|
CargaGvInventario()
|
|
CargaSubProyectosInventario()
|
|
|
|
CargaGVProveedor()
|
|
|
|
|
|
ObjRoles.Dispose()
|
|
ObjEmpresa.Dispose()
|
|
objClasi.Dispose()
|
|
objUsuarios.Dispose()
|
|
objunidadesMedida.Dispose()
|
|
objPS.Dispose()
|
|
objInv.Dispose()
|
|
|
|
Dim DirFactura = ModExtensiones.DirectorioBaseEmpresas + String.Format("Empresas\{0}\Formatos\Factura.mrt", CveEmpresa)
|
|
Dim Factura As New FileInfo(DirFactura)
|
|
RblFormatoFactura.Items.Item(1).Enabled = Factura.Exists
|
|
RblFormatoFactura.Items.Item(1).Selected = Factura.Exists
|
|
|
|
|
|
CargaGVRoles()
|
|
CargaGVUsuarios()
|
|
CargaGVCC()
|
|
CargaGvCliente()
|
|
CargaDdlUsuario()
|
|
CargaDdlRegimen()
|
|
CreaGrid()
|
|
'CargaGridEstatusUsuarios()
|
|
|
|
|
|
Else
|
|
Alert("No se encontraron datos con la empresa seleccionada.", TipoMensaje.MsgAdvertencia)
|
|
DivEsconder.Style.Add("display", "none")
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " GUARDAR PASO "
|
|
Protected Sub BtnGuardarPaso_Click(sender As Object, e As EventArgs)
|
|
Dim paso = HdnPaso.Value.ToEntero
|
|
Dim subpaso = HdnSubPaso.Value.ToEntero
|
|
Pasos(paso, subpaso)
|
|
End Sub
|
|
Protected Sub Pasos(Paso As Integer, subpaso As Integer)
|
|
Dim ObjEmpresa As New ClsSisEmpresas
|
|
|
|
|
|
Dim HuboError = False
|
|
|
|
'PASO 1.1: DATOS FISCALES
|
|
Dim NombreEmpresa, RFC, CorreoElectronico, Regimen, Contacto, Telefono, Extension, Calle, NoExt, NoInt, Colonia, Ciudad, Localidad, Estado, CP As String
|
|
NombreEmpresa = TxtNomEmpresa.Text.Trim
|
|
RFC = TxtRFC.Text.Trim
|
|
CorreoElectronico = TxtEmail.Text.Trim
|
|
Regimen = DdlRegimen.SelectedValue
|
|
Contacto = TxtContacto.Text.Trim
|
|
Telefono = TxtTelefono.Text.Trim.Replace("("c, "").Replace(")"c, "").Replace("-"c, "").Replace(" ", "")
|
|
Extension = TxtExtension.Text.Trim
|
|
Calle = TxtDireccion.Text.Trim
|
|
NoExt = TxtNoExt.Text.Trim
|
|
NoInt = TxtNoInt.Text.Trim
|
|
Colonia = TxtColonia.Text.Trim
|
|
Ciudad = TxtCiudad.Text.Trim
|
|
Localidad = TxtLocalidad.Text.Trim
|
|
Estado = TxtEstado.Text.Trim
|
|
CP = TxtCP.Text.Trim
|
|
|
|
'PASO 1.3: CERTIFICADOS
|
|
Dim CSD, CIEC As String
|
|
CSD = TxtContraKey.Text.Trim
|
|
CIEC = TxtCIEC.Text.Trim
|
|
|
|
'PASO 3.2: CORREOS
|
|
Dim EnvioCorreo, EnvioContraseña, EnvioServidor, RecepCorreo, RecepContraseña, RecepServidor, RecepProtocolo As String
|
|
Dim EnvioSSL, RecepSSL As Boolean
|
|
Dim EnvioPuerto, RecepPuerto As Integer
|
|
EnvioCorreo = txtEnvioCorreo.Text.Trim
|
|
EnvioContraseña = TxtEnvioContraseña.Text.Trim
|
|
EnvioServidor = TxtEnvioServidor.Text.Trim
|
|
EnvioPuerto = TxtEnvioPuerto.Text.Trim.ToEntero
|
|
EnvioSSL = ChkEnvioSSL.Checked
|
|
RecepCorreo = txtRecepCorreo.Text.Trim
|
|
RecepContraseña = TxtRecepContraseña.Text.Trim
|
|
RecepServidor = TxtRecepServidor.Text.Trim
|
|
RecepPuerto = TxtRecepPuerto.Text.Trim.ToEntero
|
|
RecepProtocolo = DdlRecepProtocolo.SelectedValue
|
|
RecepSSL = ChkRecepSSL.Checked
|
|
|
|
Select Case Paso
|
|
Case 1
|
|
Select Case subpaso
|
|
Case 1
|
|
'DATOS FISCALES
|
|
If ObjEmpresa.RegistroEmpresasDatosFiscales(NombreEmpresa, RFC, CorreoElectronico, Regimen, Contacto, Telefono, Extension, Calle, NoExt, NoInt, Colonia, Ciudad, Localidad, Estado, CP, CveEmpresa) Then
|
|
NombreEmpresaPropiedad = NombreEmpresa
|
|
RFCPropiedad = RFC
|
|
ltlEmpresa.Text = $"Registro de {NombreEmpresaPropiedad} ({RFCPropiedad})"
|
|
Else
|
|
RegistraScript("$('a.antfiscal').click()")
|
|
End If
|
|
|
|
'ESTATUS DE REQUISICIONES PREDEFINIDAS
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetEstatus() Then
|
|
If Not ObjOC.DtResultados.FiltraParametros($"CveEmpresa={CveEmpresa}").Rows.Count > 0 Then
|
|
ObjOC.AddEstatusRequisicionesPredefinidas(CveEmpresa)
|
|
ObjOC.Dispose()
|
|
End If
|
|
End If
|
|
|
|
|
|
Case 2
|
|
'ESTA ESCONDIDO
|
|
Case 3
|
|
'CERTIFICADOS
|
|
If Not ObjEmpresa.RegistroEmpresasCertificados(CSD, CIEC, CveEmpresa) Then
|
|
RegistraScript("$('#globalprevious').click()")
|
|
End If
|
|
End Select
|
|
Case 3
|
|
Select Case subpaso
|
|
Case 1
|
|
'LOGO
|
|
GuardaLogo()
|
|
Case 2
|
|
'CORREO
|
|
If Not ObjEmpresa.RegistroEmpresasCorreos(EnvioCorreo, EnvioContraseña, EnvioServidor, EnvioPuerto, EnvioSSL, RecepCorreo, RecepContraseña, RecepServidor, RecepPuerto, RecepProtocolo, RecepSSL, CveEmpresa) Then
|
|
RegistraScript("$('a.antfiscal').click()")
|
|
End If
|
|
Case 3
|
|
If TxtPlantillaVenta.Text <> String.Empty Then
|
|
If Not ObjEmpresa.UpdatePlantillaMail("AsuntoPlantillaMailVenta", TxtAsunto.Text.Trim, "PlantillaMailVenta", TxtPlantillaVenta.Text.Trim, CveEmpresa) Then
|
|
Alert("La plantilla de mail de ventas se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
HuboError = True
|
|
End If
|
|
End If
|
|
Case 4
|
|
If TxtFormatoFactura.getfiles().Archivos().Count > 0 Then
|
|
Dim FormatoFactura As Archivo = TxtFormatoFactura.getfiles().Archivos(0)
|
|
Dim PathFormato = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Formatos\"
|
|
Dim dirFormato As String = String.Format("{0}\Factura.{1}", PathFormato, FormatoFactura.Extension)
|
|
If File.Exists(dirFormato) Then
|
|
My.Computer.FileSystem.DeleteFile(dirFormato)
|
|
End If
|
|
My.Computer.FileSystem.MoveFile(FormatoFactura.FileUrl, dirFormato)
|
|
ObjEmpresa.UpdateFormatoImpresion(CveEmpresa, 2)
|
|
Else
|
|
ObjEmpresa.UpdateFormatoImpresion(CveEmpresa, 1)
|
|
End If
|
|
End Select
|
|
Case 5
|
|
If Not True Then
|
|
RegistraScript("$('#globalprevious').click()")
|
|
End If
|
|
End Select
|
|
|
|
ObjEmpresa.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 1: DATOS FISCALES"
|
|
|
|
#Region " 1.1 DATOS FISCALES "
|
|
Private Sub CargaDdlRegimen()
|
|
Dim ObjEmpresa As New ClsSisEmpresas
|
|
If ObjEmpresa.GetRegimenFiscal(-1) Then
|
|
DdlRegimen.DataSource = ObjEmpresa.DtResultados()
|
|
Else
|
|
DdlRegimen.DataSource = Nothing
|
|
End If
|
|
ObjEmpresa.Dispose()
|
|
DdlRegimen.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " 1.2: CERTIFICADOS "
|
|
Protected Sub BtnModalFiel_Click(sender As Object, e As EventArgs)
|
|
If Not TxtModalFielArchivo.getfiles().Archivos.Count > 0 Then
|
|
Alert("No se ha cargado ningun archivo. Por favor seleccione uno o espere se termine de cargar el archivo y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ArchivoFiel As Archivo = TxtModalFielArchivo.getfiles().Archivos(0)
|
|
|
|
If ArchivoFiel.filenameO.Length > 114 Then
|
|
Alert("El nombre del archivo excede los 115 caracteres permitidos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
ObjEmpresas.IniciaTransacSQL()
|
|
Try
|
|
Dim Path As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Certificados"
|
|
DirectoryExistsCreate(Path)
|
|
Dim ArchivoDestino As String = String.Format("{0}\{1}", Path, ArchivoFiel.filename)
|
|
If File.Exists(ArchivoDestino) Then
|
|
My.Computer.FileSystem.DeleteFile(ArchivoDestino)
|
|
End If
|
|
If ObjEmpresas.RegistroEmpresasCertificadosFIEL($"{ArchivoFiel.filenameO}", CveEmpresa) Then
|
|
My.Computer.FileSystem.MoveFile(ArchivoFiel.FileUrl, ArchivoDestino)
|
|
TxtFiel.Text = ArchivoFiel.filenameO
|
|
ObjEmpresas.Commit()
|
|
|
|
Else
|
|
ObjEmpresas.RollBack()
|
|
End If
|
|
Catch ex As Exception
|
|
ObjEmpresas.RollBack()
|
|
Alert("Ocurrió un error al guardar el archivo FIEL. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
Finally
|
|
ObjEmpresas.Dispose()
|
|
End Try
|
|
UPSat.Update()
|
|
RegistraScript("$('#ModalFiel').modal('hide');")
|
|
End Sub
|
|
|
|
Protected Sub BtnCSD_Click(sender As Object, e As EventArgs)
|
|
If Not TxtModalCSDArchivo.getfiles().Archivos.Count > 0 Then
|
|
Alert("No hay seleccionado ningun archivo. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ArchivoCSD As Archivo = TxtModalCSDArchivo.getfiles().Archivos(0)
|
|
|
|
If ArchivoCSD.filenameO.Length > 114 Then
|
|
Alert("El nombre del archivo excede los 115 caracteres permitidos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
ObjEmpresas.IniciaTransacSQL()
|
|
Try
|
|
Dim Path As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Certificados"
|
|
DirectoryExistsCreate(Path)
|
|
Dim ArchivoDestino As String = String.Format("{0}\{1}", Path, ArchivoCSD.filenameO)
|
|
If File.Exists(ArchivoDestino) Then
|
|
My.Computer.FileSystem.DeleteFile(ArchivoDestino)
|
|
End If
|
|
If ObjEmpresas.RegistroEmpresasCertificadosCSD($"{ArchivoCSD.filenameO}", CveEmpresa) Then
|
|
My.Computer.FileSystem.MoveFile(ArchivoCSD.FileUrl, ArchivoDestino)
|
|
TxtCSD.Text = ArchivoCSD.filenameO
|
|
ObjEmpresas.Commit()
|
|
Else
|
|
ObjEmpresas.RollBack()
|
|
End If
|
|
Catch ex As Exception
|
|
ObjEmpresas.RollBack()
|
|
Alert("Ocurrió un error al guardar el archivo CSD. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
Finally
|
|
ObjEmpresas.Dispose()
|
|
End Try
|
|
UPSat.Update()
|
|
RegistraScript("$('#ModalCSD').modal('hide');")
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 2: USUARIOS "
|
|
|
|
#Region " 2.1: ROLES - PERFILES "
|
|
Protected Sub LBAgregarPerfil_Click(sender As Object, e As EventArgs)
|
|
TxtPerfil.Text = ""
|
|
BtnPerfil.Text = "Agregar Perfil"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpPerfil.Update()
|
|
RegistraScript(" $('#ModalPerfil').modal('show');")
|
|
End Sub
|
|
Private Sub CargaGVRoles()
|
|
|
|
Dim ObjRoles As New ClsSisRoles
|
|
If ObjRoles.GetRoles(-1, CveEmpresa) Then
|
|
DtRoles = ObjRoles.DtResultados
|
|
End If
|
|
ObjRoles.Dispose()
|
|
|
|
GVRoles.DataSource = ObjRoles.DtResultados
|
|
GVRoles.DataBind()
|
|
|
|
CargaDdlRoles()
|
|
|
|
UPRoles.Update()
|
|
End Sub
|
|
|
|
Protected Sub LBAgregarPerfilesSugeridos_Click(sender As Object, e As EventArgs) Handles LBAgregarPerfilesSugeridos.Click
|
|
Dim ObjRoles As New ClsSisRoles
|
|
If ObjRoles.AddRolesPredefinidos(CveEmpresa) Then
|
|
Alert("Los perfiles predefinidos se agregaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjRoles.Dispose()
|
|
CargaGVRoles()
|
|
End Sub
|
|
|
|
Protected Sub BtnAddUpdatePerfil_Click(sender As Object, e As EventArgs) Handles BtnPerfil.Click
|
|
|
|
'INSERTAR DE NUEVO PERFIL
|
|
If ModalidadModal = "Insertar" Then
|
|
Dim ObjRoles As New ClsSisRoles
|
|
If ObjRoles.AddRol(1, TxtPerfil.Text, 100, CveEmpresa) Then
|
|
Alert("El nuevo perfil se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjRoles.Dispose()
|
|
End If
|
|
|
|
'ACTUALIZACION DE PERFIL
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim ObjRoles As New ClsSisRoles
|
|
Dim CveRol = CveModal
|
|
If ObjRoles.UpdateRol(1, TxtPerfil.Text, 100, CveRol) Then
|
|
Alert("El perfil se actualizó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjRoles.Dispose()
|
|
End If
|
|
End If
|
|
|
|
CargaGVRoles()
|
|
RegistraScript(" $('#ModalPerfil').modal('hide');")
|
|
End Sub
|
|
Protected Sub GVRoles_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GVRoles.RowCommand
|
|
If e.CommandName = "Permisos" Then
|
|
Dim Array = e.CommandArgument.ToString.Split("|"c)
|
|
If Array.Length = 2 Then
|
|
Dim ObjPermisos As New ClsSisRoles()
|
|
ViewState("CveRol") = Array(0).ToEntero
|
|
If ObjPermisos.GetRolesModulos(Array(0).ToEntero, -1, CvePlataforma:=1, CveEmpresa:=CveEmpresa) Then
|
|
GvPermisos.DataSource = ObjPermisos.DtResultados.FiltraParametros("AGRUPACION ='N'")
|
|
Else
|
|
GvPermisos.DataSource = Nothing
|
|
End If
|
|
ObjPermisos.Dispose()
|
|
GvPermisos.DataBind()
|
|
LbPermisos.Text = String.Format("Asignación de Permisos: {0}", Array(1).ToString)
|
|
|
|
UPPAltaRep.Update()
|
|
UPAlta.Update()
|
|
RegistraScript("$('#DivPermisos').modal();")
|
|
End If
|
|
End If
|
|
If e.CommandName = "Procesos" Then
|
|
Dim Array = e.CommandArgument.ToString.Split("|"c)
|
|
If Array.Length = 2 Then
|
|
Dim ObjPermisos As New ClsSisRoles()
|
|
ViewState("CveProceso") = Array(0).ToEntero
|
|
If ObjPermisos.GetRolesProcesos(Array(0).ToEntero, -1) Then
|
|
GvProcesos.DataSource = ObjPermisos.DtResultados
|
|
Else
|
|
GvProcesos.DataSource = Nothing
|
|
End If
|
|
ObjPermisos.Dispose()
|
|
GvProcesos.DataBind()
|
|
LbProcesos.Text = String.Format("Asignación de Procesos: {0}", Array(1).ToString)
|
|
|
|
UPPAltaProcesos.Update()
|
|
UpAltaP.Update()
|
|
RegistraScript("$('#DivProcesos').modal();")
|
|
End If
|
|
End If
|
|
If e.CommandName = "Editar" Then
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
|
|
TxtPerfil.Text = GvRow.DataKey("Rol")
|
|
BtnPerfil.Text = "Actualizar Perfil"
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveRol").ToEntero
|
|
UpPerfil.Update()
|
|
RegistraScript(" $('#ModalPerfil').modal('show');")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GVRoles_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GVRoles.RowDeleting
|
|
Dim ObjRoles As New ClsSisRoles
|
|
If ObjRoles.RemoveRol(GVRoles.Rows(e.RowIndex).DataKey("CveRol").ToEntero) Then
|
|
Alert("El perfil se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjRoles.Dispose()
|
|
|
|
CargaGVRoles()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " 2.2: USUARIOS "
|
|
|
|
Private Sub RecargaGlobal()
|
|
Dim ObjUsuarios As New ClsSisUsuarios
|
|
If ObjUsuarios.GetUsuariosEmpresas(-1) Then
|
|
Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados
|
|
' GlobalDTUsuarios() = ObjUsuario.DtResultados
|
|
|
|
End If
|
|
ObjUsuarios.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaGVUsuarios()
|
|
Dim ObjUsuarios As New ClsSisUsuarios
|
|
If ObjUsuarios.GetUsuarios(-1) Then
|
|
GvUsuarios.DataSource = ObjUsuarios.DtResultados.FiltraParametros($"CveEmpresa={CveEmpresa}")
|
|
End If
|
|
ObjUsuarios.Dispose()
|
|
GvUsuarios.DataBind()
|
|
UpGVUsuarios.Update()
|
|
End Sub
|
|
Private Sub CargaDdlRoles()
|
|
DdlRoles.Items.Clear()
|
|
DdlRoles.DataSource = DtRoles
|
|
DdlRoles.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlRoles.DataBind()
|
|
End Sub
|
|
Protected Sub LBAgregarUsuario_Click(sender As Object, e As EventArgs)
|
|
TxtNombre.Text = ""
|
|
TxtCorreo.Text = ""
|
|
DdlRoles.SelectedValueExist("-1")
|
|
BtnUsuario.Text = "Agregar Usuario"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpUsuario.Update()
|
|
RegistraScript(" $('#ModalUsuario').modal('show');")
|
|
End Sub
|
|
Protected Sub BtnAddUpdateUsuario_Click(sender As Object, e As EventArgs) Handles BtnUsuario.Click
|
|
Dim Usuario As New ClsSisUsuarios
|
|
Dim Rol As String = ""
|
|
Dim CveUsuario As Integer = 0
|
|
If DdlRoles.SelectedItem.ToString = "Compras" Then Rol = DdlRoles.SelectedItem.ToString
|
|
If DdlRoles.SelectedItem.ToString = "Director General" Then Rol = DdlRoles.SelectedItem.ToString
|
|
If DdlRoles.SelectedItem.ToString = "Ventas" Then Rol = DdlRoles.SelectedItem.ToString
|
|
If DdlRoles.SelectedItem.ToString = "Almacen" Then Rol = DdlRoles.SelectedItem.ToString
|
|
If DdlRoles.SelectedItem.ToString = "Bancos" Then Rol = DdlRoles.SelectedItem.ToString
|
|
'INGRESA UN NUEVO USUARIO
|
|
If ModalidadModal = "Insertar" Then
|
|
CveUsuario = Usuario.AddUsuario(TxtCorreo.Text, ClsPaginas.ContraseñaPredeterminadaEncriptada, TxtNombre.Text, DdlRoles.SelectedValue.ToEntero, TxtCorreo.Text, -1, -1, True, 100, CveEmpresa, -1, DdlRoles.SelectedValue)
|
|
If CveUsuario > 0 Then
|
|
Alert("El nuevo Usuario se guardó correctamente con la contraseña temporal <b>-acceso-</b>.", TipoMensaje.MsgInformacion)
|
|
If Rol <> "" Then
|
|
Usuario.AddUsuariosModulosPyMe(CveUsuario, Rol)
|
|
End If
|
|
Usuario.AddUsuariosEmpresas(CveUsuario, CveEmpresa)
|
|
End If
|
|
End If
|
|
|
|
'ACTUALIZA USUARIO
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveUsuarioUpdate = CveModal
|
|
If Usuario.UpdateUsuario(TxtCorreo.Text, TxtNombre.Text, DdlRoles.SelectedValue.ToEntero, TxtCorreo.Text, -1, -1, True, True, CveEmpresa, CveUsuarioUpdate, -1, -1) Then
|
|
Alert("El Usuario se actualizó correctamente", TipoMensaje.MsgInformacion)
|
|
If Rol <> "" Then
|
|
Usuario.UpdateUsuariosModulosPyMe(CveUsuarioUpdate, Rol)
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Usuario.Dispose()
|
|
RegistraScript(" $('#ModalUsuario').modal('hide');")
|
|
CargaGVUsuarios()
|
|
CargaDdlUsuario()
|
|
RecargaGlobal()
|
|
CargaGridEstatusUsuarios()
|
|
End Sub
|
|
Protected Sub GVUsuarios_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvUsuarios.RowCommand
|
|
If e.CommandName = "Editar" Then
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
|
|
TxtNombre.Text = GvRow.DataKey("Nombre")
|
|
TxtCorreo.Text = GvRow.DataKey("Correo")
|
|
DdlRoles.SelectedValueExist(GvRow.DataKey("CveRol"))
|
|
BtnUsuario.Text = "Actualizar Usuario"
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveUsuario").ToEntero
|
|
UpUsuario.Update()
|
|
RegistraScript(" $('#ModalUsuario').modal('show');")
|
|
End If
|
|
End Sub
|
|
Protected Sub GVUsuarios_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvUsuarios.RowDeleting
|
|
Dim Usuario As New ClsSisUsuarios
|
|
If Usuario.RemoveUsuario(GvUsuarios.Rows(e.RowIndex).DataKey("CveUsuario").ToEntero) Then
|
|
Alert("El usuario se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Usuario.Dispose()
|
|
CargaGVUsuarios()
|
|
CargaGridEstatusUsuarios()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub CmdGuardar_Click(sender As Object, e As EventArgs) Handles CmdGuardar.Click
|
|
Dim Roles As New ClsSisRoles
|
|
For Each Row As GridViewRow In GvPermisos.Rows
|
|
Roles.UpdateRolesModulos(Row.DataKey("CveRol").ToEntero, Row.DataKey("CveModulo").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), 100)
|
|
Next
|
|
Roles.Dispose()
|
|
UPPAltaRep.Update()
|
|
RegistraScript("$('#DivPermisos').modal('hide');")
|
|
End Sub
|
|
Protected Sub BtnGuardaProcesos_Click(sender As Object, e As EventArgs) Handles BtnGuardaProcesos.Click
|
|
Dim Roles As New ClsSisRoles
|
|
For Each Row As GridViewRow In GvProcesos.Rows
|
|
Roles.UpdateRolesProcesos(Row.DataKey("CveRol").ToEntero, Row.DataKey("CveProceso").ToEntero, If(Row.FCCheckBox("ChkP").Checked, 1, 0), 100)
|
|
Next
|
|
Roles.Dispose()
|
|
RegistraScript("$('#DivProcesos').modal('hide');")
|
|
UPPAltaProcesos.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvPermisos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPermisos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If CveEmpresa > 0 Then
|
|
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then e.Row.FCCheckBox("ChkP").Checked = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvProcesos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProcesos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If CveEmpresa > 0 Then
|
|
If (e.Row.DBCampo("CveModuloAcceso")) <> "" Then
|
|
e.Row.Cells(0).CssClass = "bg-yellow"
|
|
End If
|
|
If (e.Row.DBCampo("CveProcesoAcceso")) <> "" Then e.Row.FCCheckBox("ChkP").Checked = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 3: CONFIGURACION "
|
|
|
|
#Region " 3.1: LOGO "
|
|
Protected Sub GuardaLogo()
|
|
If TextLogo.getfiles().Archivos().Count = 1 Then
|
|
Dim ArchivoLogo As Archivo = TextLogo.getfiles().Archivos(0)
|
|
If ArchivoLogo.filenameO.Length <= 114 Then
|
|
Try
|
|
Dim Path As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}"
|
|
DirectoryExistsCreate(Path)
|
|
Dim ArchivoDestino As String = String.Format("{0}\Logo.{1}", Path, ArchivoLogo.Extencion)
|
|
If File.Exists(ArchivoDestino) Then
|
|
My.Computer.FileSystem.DeleteFile(ArchivoDestino)
|
|
End If
|
|
My.Computer.FileSystem.CopyFile(ArchivoLogo.FileUrl, ArchivoDestino)
|
|
Catch ex As Exception
|
|
Alert("Ocurrió un error al guardar el Logo de la empresa. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End Try
|
|
Else
|
|
Alert("El nombre del archivo excede los 115 caracteres permitidos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " 3.2: CORREOS "
|
|
|
|
#End Region
|
|
|
|
#Region " 3.3: PLANTILLA PARA ENVIO DE CORREOS"
|
|
Protected Sub LnkBtnMuestraEtiquetas_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("$('#ModalEtiquetas').modal();")
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " 3.4: FORMATO FACTURA"
|
|
|
|
Protected Sub linkActualizar_Click(sender As Object, e As EventArgs)
|
|
VerEditarFactura()
|
|
End Sub
|
|
Protected Sub RblFormatoFactura_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblFormatoFactura.SelectedIndexChanged
|
|
Dim StrParams As New StringBuilder
|
|
Dim Directorio = ModExtensiones.DirectorioBaseEmpresas + String.Format("Empresas\{0}\Formatos\Factura.mrt", CveEmpresa)
|
|
Dim Archivo As New FileInfo(Directorio)
|
|
RblFormatoFactura.Items.Item(1).Enabled = Archivo.Exists
|
|
DivSubirFactura.Visible = (RblFormatoFactura.SelectedValue = "2")
|
|
HlFormatoFactura.Visible = (RblFormatoFactura.SelectedValue.Contiene("3", "4"))
|
|
HlFormatoFactura.Text = If(RblFormatoFactura.SelectedValue = "3", "<i class='fa fa-plus'>Agregar</i>", "<i class='fa fa-pencil-square-o'>Editar</i>")
|
|
StrParams.Append("TIPO=Ing")
|
|
StrParams.Append($"&CVEEMPRESA={CveEmpresa}")
|
|
StrParams.Append($"&EMPRESA={NombreEmpresaPropiedad}")
|
|
StrParams.Append($"&RFC={RFCPropiedad}")
|
|
StrParams.Append($"&DOMICILIO={TxtDireccion.Text}")
|
|
|
|
If RblFormatoFactura.SelectedValue = "4" AndAlso Archivo.Exists Then
|
|
HlFormatoFactura.NavigateUrl = $"/Ventas/ReporteDetalle.aspx?Op={Encripta(StrParams.ToString)}&Mod=Editar"
|
|
Else
|
|
HlFormatoFactura.NavigateUrl = $"/Ventas/ReporteDetalle.aspx?Op={Encripta(StrParams.ToString)}"
|
|
End If
|
|
UpFormatoFactura.Update()
|
|
End Sub
|
|
Private Sub VerEditarFactura()
|
|
Dim Directorio = ModExtensiones.DirectorioBaseEmpresas + String.Format("Empresas\{0}\Formatos\Factura.mrt", CveEmpresa)
|
|
Dim Archivo As New FileInfo(Directorio)
|
|
RblFormatoFactura.Items.Item(1).Enabled = Archivo.Exists
|
|
If Archivo.Exists Then
|
|
Alert("Formato de factura guardado correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Hubo un error al guardar el formato de factura. Favor de llamar a soporte tecnico", TipoMensaje.MsgInformacion)
|
|
End If
|
|
UpFormatoFactura.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " 3.5: CENTRO COSTOS "
|
|
|
|
Private Sub CargaRequired()
|
|
If ChkEsSucursal.Checked = True Then
|
|
RFVSerie.Enabled = True
|
|
RFVIVA.Enabled = True
|
|
RFVCalle.Enabled = True
|
|
RFVNoExtCC.Enabled = True
|
|
RFVColoniaCC.Enabled = True
|
|
RFVLocalidadCC.Enabled = True
|
|
RFVMunicipio.Enabled = True
|
|
RFVEstadoCC.Enabled = True
|
|
RFVPais.Enabled = True
|
|
RFVCPCC.Enabled = True
|
|
|
|
RFVSerie.Visible = True
|
|
RFVIVA.Visible = True
|
|
RFVCalle.Visible = True
|
|
RFVNoExtCC.Visible = True
|
|
RFVColoniaCC.Visible = True
|
|
RFVLocalidadCC.Visible = True
|
|
RFVMunicipio.Visible = True
|
|
RFVEstadoCC.Visible = True
|
|
RFVPais.Visible = True
|
|
RFVCPCC.Visible = True
|
|
|
|
Else
|
|
|
|
RFVSerie.Enabled = False
|
|
RFVIVA.Enabled = False
|
|
RFVCalle.Enabled = False
|
|
RFVNoExtCC.Enabled = False
|
|
RFVColoniaCC.Enabled = False
|
|
RFVLocalidadCC.Enabled = False
|
|
RFVMunicipio.Enabled = False
|
|
RFVEstadoCC.Enabled = False
|
|
RFVPais.Enabled = False
|
|
RFVCPCC.Enabled = False
|
|
|
|
RFVSerie.Visible = False
|
|
RFVIVA.Visible = False
|
|
RFVCalle.Visible = False
|
|
RFVNoExtCC.Visible = False
|
|
RFVColoniaCC.Visible = False
|
|
RFVLocalidadCC.Visible = False
|
|
RFVMunicipio.Visible = False
|
|
RFVEstadoCC.Visible = False
|
|
RFVPais.Visible = False
|
|
RFVCPCC.Visible = False
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ChkEsSucursal_CheckedChanged(sender As Object, e As EventArgs) Handles ChkEsSucursal.CheckedChanged
|
|
CargaRequired()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaGVCC()
|
|
Dim ObjSubProyectos As New ClsSubProyectos
|
|
If ObjSubProyectos.GetSubProyectos() Then
|
|
GvCC.DataSource = ObjSubProyectos.DtResultados.FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
End If
|
|
ObjSubProyectos.Dispose()
|
|
GvCC.DataBind()
|
|
|
|
CargaDdlProyectos()
|
|
|
|
UpGVCC.Update()
|
|
End Sub
|
|
Private Sub CargaDdlProyectos()
|
|
DdlProyecto.Items.Clear()
|
|
Dim ObjProyectos As New ClsProyectos
|
|
If ObjProyectos.GetProyectos() Then
|
|
DdlProyecto.DataSource = ObjProyectos.DtResultados.FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
End If
|
|
ObjProyectos.Dispose()
|
|
DdlProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlProyecto.DataBind()
|
|
End Sub
|
|
Protected Sub LBAgregarCC_Click(sender As Object, e As EventArgs)
|
|
|
|
TxtCentroCosto.Text = ""
|
|
DdlProyecto.SelectedValueExist("-1")
|
|
|
|
TxtSerie.Text = ""
|
|
TxtIVA.Text = ""
|
|
TxtCalle.Text = ""
|
|
TxtNoExtCC.Text = ""
|
|
TxtNoIntCC.Text = ""
|
|
TxtColoniaCC.Text = ""
|
|
TxtLocalidadCC.Text = ""
|
|
TxtMunicipio.Text = ""
|
|
TxtEstadoCC.Text = ""
|
|
TxtPais.Text = ""
|
|
TxtCPCC.Text = ""
|
|
If DdlProyecto.SelectedValue.ToEntero.Contiene(1, 2) Then
|
|
DivProyecto.Style.Add("display", "none")
|
|
Else
|
|
DivProyecto.Style.Add("display", "")
|
|
End If
|
|
ChkEsMatriz.Checked = False
|
|
ChkEsSucursal.Checked = False
|
|
|
|
BtnCC.Text = "Agregar Centro Costo"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpCC.Update()
|
|
RegistraScript(" $('#ModalCC').modal('show');")
|
|
End Sub
|
|
Protected Sub BtnCC_Click(sender As Object, e As EventArgs) Handles BtnCC.Click
|
|
If DdlProyecto.SelectedValue = "-1" And ModalidadModal = "Actualizar" Then
|
|
Alert("Tiene que seleccionar un proyecto", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Dim TieneError As Boolean = False
|
|
Dim ObjSubproyectos As New ClsSubProyectos
|
|
Dim ObjProyecto As New ClsProyectos(ObjSubproyectos.IniciaTransacSQL())
|
|
Dim TipoSucursal As Integer
|
|
Dim EsSucursal As Integer
|
|
Dim CveProyecto As Integer
|
|
If ChkEsMatriz.Checked = True Then TipoSucursal = 1 Else TipoSucursal = 0
|
|
If ChkEsSucursal.Checked = True Then EsSucursal = 1 Else EsSucursal = 0
|
|
|
|
'INGRESA UN NUEVO CC
|
|
If ModalidadModal = "Insertar" Then
|
|
If DdlProyecto.SelectedValue = "-1" Then
|
|
If Not ObjProyecto.AddProyecto(TxtCentroCosto.Text, 100, CveEmpresa) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
If TieneError = False Then
|
|
If DdlProyecto.SelectedValue = "-1" Then CveProyecto = ObjProyecto.CveProyecto Else CveProyecto = DdlProyecto.SelectedValue.ToEntero
|
|
If ObjSubproyectos.AddCentroCosto(TxtCentroCosto.Text.Trim, 0, 100, CveEmpresa, CveProyecto, Serie:=TxtSerie.Text.Trim, IVA:=TxtIVA.Text.ToDecimal, Calle:=TxtCalle.Text.Trim, NoExt:=TxtNoExtCC.Text.Trim,
|
|
NoInt:=TxtNoIntCC.Text.Trim, Colonia:=TxtColoniaCC.Text.Trim, Localidad:=TxtLocalidadCC.Text.Trim, Municipio:=TxtMunicipio.Text.Trim, Estado:=TxtEstadoCC.Text.Trim, Pais:=TxtPais.Text.Trim, CP:=TxtCPCC.Text.Trim, TipoSucursal:=TipoSucursal, EsSucursal:=EsSucursal) Then
|
|
Alert("El nuevo Centro Costo se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
'ACTUALIZA CC
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveCentroCosto = CveModal
|
|
If ObjSubproyectos.UpdateCentroCosto(CveCentroCosto, TxtCentroCosto.Text.Trim, 0, 1, 100, CveEmpresa, DdlProyecto.SelectedValue.ToEntero, Serie:=TxtSerie.Text.Trim, IVA:=TxtIVA.Text.ToDecimal, Calle:=TxtCalle.Text.Trim, NoExt:=TxtNoExtCC.Text.Trim,
|
|
NoInt:=TxtNoIntCC.Text.Trim, Colonia:=TxtColoniaCC.Text.Trim, Localidad:=TxtLocalidadCC.Text.Trim, Municipio:=TxtMunicipio.Text.Trim, Estado:=TxtEstadoCC.Text.Trim, Pais:=TxtPais.Text.Trim, CP:=TxtCPCC.Text.Trim, TipoSucursal:=TipoSucursal, EsSucursal:=EsSucursal) Then
|
|
Alert("El Centro Costo se actualizó correctamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
If TieneError = True Then
|
|
ObjProyecto.RollBack()
|
|
Else
|
|
ObjProyecto.Commit()
|
|
End If
|
|
ObjProyecto.Dispose()
|
|
ObjSubproyectos.Dispose()
|
|
|
|
RegistraScript(" $('#ModalCC').modal('hide');")
|
|
CargaGVCC()
|
|
CargaSubProyectos()
|
|
UpRequisiciones.Update()
|
|
End If
|
|
End Sub
|
|
Protected Sub GVCC_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvCC.RowCommand
|
|
If e.CommandName = "Editar" Then
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
|
|
TxtCentroCosto.Text = GvRow.DataKey("SubProyecto")
|
|
DdlProyecto.SelectedValueExist(GvRow.DataKey("CveProyecto"))
|
|
|
|
TxtSerie.Text = GvRow.DataKey("Serie")
|
|
TxtIVA.Text = GvRow.DataKey("IVA")
|
|
TxtCalle.Text = GvRow.DataKey("Calle")
|
|
TxtNoExtCC.Text = GvRow.DataKey("NoExt")
|
|
TxtNoIntCC.Text = GvRow.DataKey("NoInt")
|
|
TxtColoniaCC.Text = GvRow.DataKey("Colonia")
|
|
TxtLocalidadCC.Text = GvRow.DataKey("Localidad")
|
|
TxtMunicipio.Text = GvRow.DataKey("Municipio")
|
|
TxtEstadoCC.Text = GvRow.DataKey("Estado")
|
|
TxtPais.Text = GvRow.DataKey("Pais")
|
|
TxtCPCC.Text = GvRow.DataKey("CP")
|
|
ChkEsMatriz.Checked = If(GvRow.DataKey("Estatus") = "Activo", True, False)
|
|
ChkEsMatriz.Checked = If(GvRow.DataKey("TipoSucursal").ToString.ToEntero = 1, True, False)
|
|
ChkEsSucursal.Checked = If(GvRow.DataKey("EsSucursal").ToString.ToEntero = 1, True, False)
|
|
|
|
BtnCC.Text = "Actualizar Centro Costo"
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveSubProyecto").ToEntero
|
|
CargaRequired()
|
|
UpCC.Update()
|
|
RegistraScript(" $('#ModalCC').modal('show');")
|
|
End If
|
|
End Sub
|
|
Protected Sub GVCC_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvCC.RowDeleting
|
|
Dim ObjSubproyectos As New ClsSubProyectos
|
|
If ObjSubproyectos.RemoveSubProyecto(GvCC.Rows(e.RowIndex).DataKey("CveSubProyecto").ToEntero) Then
|
|
Alert("El Centro Costo se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjSubproyectos.Dispose()
|
|
|
|
CargaGVCC()
|
|
End Sub
|
|
|
|
Private Sub DdlTipoCentroCostos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoCentroCostos.SelectedIndexChanged
|
|
If DdlTipoCentroCostos.SelectedValue <> "-1" Then
|
|
Dim ObjEmpresas As New ClsSisEmpresas
|
|
ObjEmpresas.UpdateTipoCentroCosto(DdlTipoCentroCostos.SelectedValue.ToEntero, CveEmpresa)
|
|
ObjEmpresas.Dispose()
|
|
End If
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " 3.6: FOLIOS"
|
|
Private Sub CargaSubProyectos()
|
|
DdlSubProyecto.Items.Clear()
|
|
DdlSubProyectoClientes.Items.Clear()
|
|
DdlEstatusSubProyecto.Items.Clear()
|
|
DdlSubProyectoInventario.Items.Clear()
|
|
Dim ObjSubProyectos As New ClsSubProyectos
|
|
If ObjSubProyectos.GetSubProyectos() Then
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubProyecto.DataSource = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyectoClientes.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlSubProyectoClientes.DataSource = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlSubProyectoClientes.DataBind()
|
|
DdlEstatusSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlEstatusSubProyecto.DataSource = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlEstatusSubProyecto.DataBind()
|
|
DdlSubProyectoInventario.DataSource = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlSubProyectoInventario.DataBind()
|
|
End If
|
|
ObjSubProyectos.Dispose()
|
|
UpRequisiciones.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaGvFolio()
|
|
Dim ObjFolio As New ClsGralFolios
|
|
If ObjFolio.GetFolios(CveEmpresa:=CveEmpresa) Then
|
|
GvFolios.DataSource = ObjFolio.DtResultados
|
|
GvFolios.DataBind()
|
|
End If
|
|
UpFolio.Update()
|
|
ObjFolio.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregarFolio_Click(sender As Object, e As EventArgs) Handles LnkAgregarFolio.Click
|
|
|
|
DdlSubProyecto.SelectedValueExist("-1")
|
|
DdlTipoDocto.SelectedValueExist("-1")
|
|
TxtFolioInicial.Text = ""
|
|
TxtFolioFinal.Text = ""
|
|
TxtFolioActual.Text = ""
|
|
BtnGuardarFolio.Text = "Agregar Folio"
|
|
ModalidadModal = "Insertar"
|
|
ChkEstatus.Checked = True
|
|
CveModal = -1
|
|
UpAddFolio.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAgregarFolio"))
|
|
End Sub
|
|
|
|
|
|
Protected Sub GVFolios_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvFolios.RowCommand
|
|
If e.CommandName = "Editar" Then
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
|
|
TxtFolioActual.Text = GvRow.DataKey("FActual")
|
|
TxtFolioFinal.Text = GvRow.DataKey("FFinal")
|
|
TxtFolioInicial.Text = GvRow.DataKey("FInicial")
|
|
DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
|
|
DdlTipoDocto.SelectedValueExist(GvRow.DataKey("TipoDocto"))
|
|
ChkEstatus.Checked = If(GvRow.DataKey("Estado").ToString = "Activo", True, False)
|
|
DivFactual.Visible = True
|
|
BtnGuardarFolio.Text = "Actualizar Folio"
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveFolio").ToEntero
|
|
UpAddFolio.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAgregarFolio"))
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvFolios_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvFolios.RowDeleting
|
|
Dim ObjFolio As New ClsGralFolios
|
|
If ObjFolio.RemoveFolios(GvFolios.Rows(e.RowIndex).DataKey("CveFolio").ToEntero) Then
|
|
Alert("El Folio se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjFolio.Dispose()
|
|
|
|
CargaGvFolio()
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarFolio_Click(sender As Object, e As EventArgs) Handles BtnGuardarFolio.Click
|
|
If DdlSubProyecto.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un centro de costos.", TipoMensaje.MsgAdvertencia)
|
|
ElseIf DdlTipoDocto.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un tipo docto.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Dim ObjFolio As New ClsGralFolios
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjFolio.AddFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, "", TxtFolioInicial.Text.ToEntero, TxtFolioInicial.Text.ToEntero, TxtFolioFinal.Text.ToEntero, "", 100, CveEmpresa) Then
|
|
Alert("El Folio se agrego correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolio"))
|
|
End If
|
|
End If
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveFolio = CveModal
|
|
If ObjFolio.UpdateFolios(DdlSubProyecto.SelectedValue.ToEntero, DdlTipoDocto.SelectedValue, "", TxtFolioInicial.Text.ToEntero, TxtFolioActual.Text.ToEntero, TxtFolioFinal.Text.ToEntero, "", If(ChkEstatus.Checked, True, False), 100, CveFolio) Then
|
|
Alert("El Folio se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarFolio"))
|
|
End If
|
|
End If
|
|
End If
|
|
ObjFolio.Dispose()
|
|
CargaGvFolio()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " 3.7: ALMACEN"
|
|
|
|
Private Sub CargaSubProyectosInventario()
|
|
Dim ObjSubProyectos As New ClsSubProyectos
|
|
If ObjSubProyectos.GetSubProyectos() Then
|
|
DdlSubProyectoInventario.DataSource = ObjSubProyectos.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlSubProyectoInventario.DataBind()
|
|
|
|
End If
|
|
ObjSubProyectos.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaGvInventario()
|
|
Dim ObjInventario As New ClsInventarios
|
|
If ObjInventario.GetAlmacenes(-1, -1, CveEmpresa, -1) Then
|
|
GvInventario.DataSource = ObjInventario.DtResultados
|
|
GvInventario.DataBind()
|
|
End If
|
|
UpInventario.Update()
|
|
ObjInventario.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregarInventario_Click(sender As Object, e As EventArgs) Handles LnkAgregarInventario.Click
|
|
|
|
DdlSubProyectoInventario.SelectedValueExist("-1")
|
|
TxtAlmacen.Text = ""
|
|
DdlTipoAlmacen.SelectedValueExist("-1")
|
|
DdlModalidad.SelectedValueExist("0")
|
|
DdlInventariable.SelectedValueExist("1")
|
|
BtnAgregarAlmacen.Text = "Agregar Almacen"
|
|
ModalidadModal = "Insertar"
|
|
ChkEstatusInventario.Checked = True
|
|
CveModal = -1
|
|
UpAddAlmacen.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAlmacen"))
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvInventario_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvInventario.RowCommand
|
|
If e.CommandName = "Editar" Then
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).NamingContainer, GridViewRow)
|
|
TxtAlmacen.Text = GvRow.DataKey("Almacen")
|
|
DdlSubProyectoInventario.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
|
|
DdlTipoAlmacen.SelectedValueExist(GvRow.DataKey("CveTipoAlmacen"))
|
|
DdlModalidad.SelectedValueExist(GvRow.DataKey("CveModalidad"))
|
|
DdlInventariable.SelectedValueExist(GvRow.DataKey("Inventariable"))
|
|
ChkEstatusInventario.Checked = If(GvRow.DataKey("Estatus").ToString = "Activo", True, False)
|
|
BtnAgregarAlmacen.Text = "Actualizar Almacen"
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveAlmacen").ToEntero
|
|
UpAddAlmacen.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAlmacen"))
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvInventario_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvInventario.RowDeleting
|
|
Dim ObjInventario As New ClsInventarios
|
|
If ObjInventario.RemoveAlmacen(GvInventario.Rows(e.RowIndex).DataKey("CveAlmacen").ToEntero) Then
|
|
Alert("El Almacen se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjInventario.Dispose()
|
|
|
|
CargaGvInventario()
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarAlmacen_Click(sender As Object, e As EventArgs) Handles BtnAgregarAlmacen.Click
|
|
If DdlSubProyectoInventario.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un centro de costos.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Dim ObjInventario As New ClsInventarios
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjInventario.AddAlmacen(TxtAlmacen.Text, DdlTipoAlmacen.SelectedValue.ToEntero, Nothing, DdlModalidad.SelectedValue.ToEntero, 100, CveEmpresa, CByte(DdlInventariable.SelectedValue), DdlSubProyectoInventario.SelectedValue.ToEntero) Then
|
|
Alert("El Almacen se agrego correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAlmacen"))
|
|
End If
|
|
End If
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveAlmacen = CveModal
|
|
If ObjInventario.UpdateAlmacen(TxtAlmacen.Text, DdlTipoAlmacen.SelectedValue.ToEntero, Nothing, DdlModalidad.SelectedValue.ToEntero, If(ChkEstatusInventario.Checked, True, False), CveAlmacen, CByte(DdlInventariable.SelectedValue), DdlSubProyectoInventario.SelectedValue.ToEntero) Then
|
|
Alert("El Almacen se actualizo correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAlmacen"))
|
|
End If
|
|
End If
|
|
End If
|
|
ObjInventario.Dispose()
|
|
CargaGvInventario()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GvInventario_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvInventario.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.FCLiteral("LtlInventariable").Text = "True" Then
|
|
e.Row.FCLiteral("LtlInventariable").Text = "Si"
|
|
Else
|
|
e.Row.FCLiteral("LtlInventariable").Text = "No"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " 3.8: REQUISICIONES"
|
|
|
|
|
|
Private Sub DdlEstatusSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEstatusSubProyecto.SelectedIndexChanged
|
|
If DdlEstatusSubProyecto.SelectedValue = "-1" Then
|
|
GvEstatusUsuariosREQ.Enabled = False
|
|
GvEstatusUsuariosREQ.Visible = False
|
|
btnGuardarEstatusUsuariosREQ.Visible = False
|
|
Else
|
|
GvEstatusUsuariosREQ.Enabled = True
|
|
GvEstatusUsuariosREQ.Visible = True
|
|
btnGuardarEstatusUsuariosREQ.Visible = True
|
|
End If
|
|
|
|
CargaGridEstatusUsuarios()
|
|
|
|
End Sub
|
|
|
|
Private Sub CreaGrid()
|
|
Dim i As Integer = 1
|
|
Dim ObjOC As New ClsOC
|
|
If ObjOC.GetEstatus() Then
|
|
For Each Row As DataRow In ObjOC.DtResultados.FiltraParametros(String.Format(" CveEmpresa = '{0}' And Tipo = '{1}' ", CveEmpresa, "Req"), "Orden").Rows
|
|
GvEstatusUsuariosREQ.Columns(i).HeaderText = Row("Estatus").ToString.ToUpper
|
|
GvEstatusUsuariosREQ.Columns(i).FooterText = Row("CveEstatus").ToString
|
|
i += 1
|
|
Next
|
|
End If
|
|
ObjOC.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub btnGuardarEstatusUsuariosREQ_Click(sender As Object, e As EventArgs) Handles btnGuardarEstatusUsuariosREQ.Click
|
|
If DdlEstatusSubProyecto.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un centro de costo", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
Dim objEstatusOC As New ClsOC
|
|
objEstatusOC.IniciaTransacSQL()
|
|
Dim HuboErrores As Boolean = False
|
|
|
|
For Each Row As GridViewRow In GvEstatusUsuariosREQ.Rows
|
|
|
|
Dim r As Integer = 1
|
|
For i = 0 To Row.Cells.Count - 1
|
|
|
|
Dim CveEstatus As Integer = If(IsNumeric(GvEstatusUsuariosREQ.Columns(i).FooterText), GvEstatusUsuariosREQ.Columns(i).FooterText.ToEntero, 0)
|
|
If CveEstatus > 0 Then
|
|
|
|
If Row.FCCheckBox("chkEstatus" + r.ToString).Checked = False And Row.FCHiddenField("hdnCveEstatusUsuarios" + r.ToString).Value.ToEntero > 0 Then
|
|
'Eliminar el registro existente
|
|
If Not objEstatusOC.RemoveEstatusUsuarios(Row.FCHiddenField("hdnCveEstatusUsuarios" + r.ToString).Value.ToEntero, -1) Then
|
|
HuboErrores = True
|
|
Exit For
|
|
End If
|
|
ElseIf Row.FCCheckBox("chkEstatus" + r.ToString).Checked = True And Row.FCHiddenField("hdnCveEstatusUsuarios" + r.ToString).Value.ToEntero = -1 Then
|
|
If Not objEstatusOC.AddEstatusUsuarios(CveEstatus, DdlEstatusSubProyecto.SelectedValue.ToEntero, Row.DataKey("CveUsuario").ToString.ToEntero, True) Then
|
|
HuboErrores = True
|
|
Exit For
|
|
End If
|
|
If HuboErrores Then
|
|
Exit For
|
|
End If
|
|
End If
|
|
r += 1
|
|
End If
|
|
Next
|
|
|
|
'Si tubo algun error terminamos el proceso (FOR)
|
|
If HuboErrores Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not HuboErrores Then
|
|
objEstatusOC.Commit()
|
|
Alert("Se guardaron los Cambios exitosamente", TipoMensaje.MsgInformacion)
|
|
Else
|
|
objEstatusOC.RollBack()
|
|
Alert("Ocurrió un error al guardar los cambios. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
objEstatusOC.Dispose()
|
|
CargaGridEstatusUsuarios()
|
|
End Sub
|
|
|
|
Protected Sub CargaGridEstatusUsuarios()
|
|
|
|
'If Tipo = "OC" Then TmpDTOC.Rows.Clear() Else TmpDTReq.Rows.Clear()
|
|
If DdlEstatusSubProyecto.SelectedValue = "-1" Then
|
|
GvEstatusUsuariosREQ.DataSource = Nothing
|
|
GvEstatusUsuariosREQ.DataBind()
|
|
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim objEstatusOC As New ClsOC
|
|
|
|
If objEstatusOC.GetEstatusUsuariosPyME(-1, -1, DdlEstatusSubProyecto.SelectedValue.ToEntero, -1, CveEmpresa) Then
|
|
DTEstatusUsuarios = objEstatusOC.DtResultados
|
|
GvEstatusUsuariosREQ.DataSource = DTEstatusUsuarios.FiltraParametros("", "Nombre", {"CveUsuario", "Nombre"})
|
|
GvEstatusUsuariosREQ.DataBind()
|
|
End If
|
|
objEstatusOC.Dispose()
|
|
UpRequisiciones.Update()
|
|
End Sub
|
|
|
|
Private Sub CreaGrid(Tipo As String)
|
|
Dim i As Integer = 1
|
|
Dim ObjOC As ClsOC = New ClsOC
|
|
|
|
If ObjOC.GetEstatus() Then
|
|
For Each Row As DataRow In ObjOC.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0} AND Tipo = '{1}' ", CveEmpresa, Tipo), "Orden").Rows
|
|
GvEstatusUsuariosREQ.Columns(i).HeaderText = Row("Estatus").ToString.ToUpper
|
|
GvEstatusUsuariosREQ.Columns(i).FooterText = Row("CveEstatus").ToString
|
|
i += 1
|
|
Next
|
|
End If
|
|
|
|
ObjOC.Dispose()
|
|
|
|
While i <= 10
|
|
GvEstatusUsuariosREQ.Columns(i).Visible = False
|
|
i += 1
|
|
End While
|
|
End Sub
|
|
|
|
Protected Sub GvEstatusUsuariosREQ_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEstatusUsuariosREQ.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
Dim tmpT As DataTable = DTEstatusUsuarios.FiltraParametros(String.Format("CveUsuario = {0}", e.Row.DBCampo("CveUsuario").ToString))
|
|
|
|
For i As Integer = 1 To 3
|
|
Dim CveEstatus As Integer = GvEstatusUsuariosREQ.Columns(i).FooterText.ToEntero
|
|
|
|
If CveEstatus > 0 Then
|
|
Dim chkEstatus As CheckBox = e.Row.FCCheckBox(String.Format("chkEstatus{0}", i))
|
|
'Dim ibOpciones As ImageButton = e.Row.FCImageButton(String.Format("ibOpciones{0}", i))
|
|
Dim hdnCveEstatusUsuarios As HiddenField = e.Row.FCHiddenField(String.Format("hdnCveEstatusUsuarios{0}", i))
|
|
'Dim lblSuperior As Label = e.Row.FCLabel(String.Format("lblSuperior{0}", i))
|
|
'Dim lblLimites As Label = e.Row.FCLabel(String.Format("lblLimites{0}", i))
|
|
|
|
|
|
|
|
'ibOpciones.CommandArgument = GlobalDTOCEstatus(CveEmpresa).FiltraParametros(String.Format("CveEstatus = {0}", CveEstatus)).Rows(0)("CveEstatusSiguiente").ToString
|
|
|
|
Dim RowEU As DataRowCollection = tmpT.FiltraParametros(String.Format("CveEstatus = {0}", CveEstatus)).Rows
|
|
Dim CveEstatusUsuarios As Integer = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("CveEstatusUsuarios")), RowEU(0)("CveEstatusUsuarios").ToString.ToEntero, -1)
|
|
'Dim LimiteInferior As Decimal = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("LimiteInferior")), RowEU(0)("LimiteInferior").ToString.ToDecimal, -1)
|
|
'Dim LimiteSuperior As Decimal = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("LimiteSuperior")), RowEU(0)("LimiteSuperior").ToString.ToDecimal, -1)
|
|
Dim CveSuperior As Integer = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("CveSuperior")), RowEU(0)("CveSuperior").ToString.ToEntero, -1)
|
|
Dim CveUsuario As Integer = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("CveUsuario")), RowEU(0)("CveUsuario").ToString.ToEntero, -1)
|
|
Dim TipoTermino As Integer = If(RowEU.Count > 0 AndAlso Not IsDBNull(RowEU(0)("TipoTermino")), RowEU(0)("TipoTermino").ToString.ToEntero, -1) ' 0. supervisada, 1. autorizada, 2. rechazada
|
|
|
|
If RowEU.Count > 0 Then
|
|
chkEstatus.Checked = True
|
|
'chkEstatus.Attributes.Add("onclick", String.Format("javascript:chk1Change(this, '{0}');", ibOpciones.ClientID))
|
|
hdnCveEstatusUsuarios.Value = RowEU(0)("CveEstatusUsuarios").ToString
|
|
|
|
'ibOpciones.Style.Add("display", "inline")
|
|
|
|
Dim script As New StringBuilder
|
|
script.AppendFormat("javascript:hdnCveEstatusUsuarios.value='{0}'; ", CveEstatusUsuarios)
|
|
script.AppendFormat("IDhdnCveEstatusUsuarios.value='{0}'; ", hdnCveEstatusUsuarios.ClientID)
|
|
script.Append("hdnCveEstatus.value = '-1';")
|
|
script.Append("hdnCveUsuario.value = '-1';")
|
|
script.AppendFormat("hdnCveSuperior.value = '{0}'; ", CveSuperior)
|
|
'script.AppendFormat("chkMostrarLimites.checked = {0};chkMostrarLimitesCambio();", If(LimiteInferior > 0 Or LimiteSuperior > 0 Or TipoTermino.Contiene(0, 1, 2), "true", "false"))
|
|
'script.AppendFormat("$get('DivLimites').style.display = '{0}';", If(LimiteInferior > 0 Or LimiteSuperior > 0, "inline", "none"))
|
|
'script.AppendFormat("txtLimiteInferior.value = '{0}'; ", If(LimiteInferior > 0, LimiteInferior.FormatoNumero, ""))
|
|
'script.AppendFormat("txtLimiteSuperior.value = '{0}'; ", If(LimiteSuperior > 0, LimiteSuperior.FormatoNumero, ""))
|
|
'ibOpciones.Attributes.Add("onclick", script.ToString)
|
|
|
|
'lblSuperior.Text = RowEU(0)("Superior").ToString
|
|
|
|
'If LimiteSuperior = -1 And LimiteInferior = -1 Then
|
|
' 'Sin Limite
|
|
'ElseIf LimiteSuperior > 0 And LimiteInferior = -1 Then
|
|
' 'Solo Limite Superior
|
|
' lblLimites.Text = String.Format("Hasta {0}", LimiteSuperior.ToString("N"))
|
|
'ElseIf LimiteInferior > 0 And LimiteSuperior = -1 Then
|
|
' 'Solo limite Inferior
|
|
' lblLimites.Text = String.Format("Desde {0}", LimiteInferior.ToString("N"))
|
|
'Else
|
|
' 'Con Limites
|
|
' lblLimites.Text = String.Format("{0} - {1}", LimiteInferior.ToString("N"), LimiteSuperior.ToString("N"))
|
|
'End If
|
|
|
|
e.Row.Cells(i).BackColor = Drawing.Color.Yellow
|
|
|
|
If DTEstatusUsuarios.FiltraParametros(String.Format("CveEstatusSiguiente = {0} AND CveSuperior = {1}", CveEstatus, CveUsuario)).Rows.Count > 0 Then
|
|
chkEstatus.Attributes.Add("onclick", "javascript:var retorno = true; if (this.checked == false) retorno = confirm('Estas seguro????'); return retorno;")
|
|
End If
|
|
Else
|
|
chkEstatus.Checked = False
|
|
hdnCveEstatusUsuarios.Value = "-1"
|
|
'ibOpciones.Style.Add("display", "none")
|
|
Dim script As New StringBuilder
|
|
script.AppendFormat("javascript:hdnCveEstatusUsuarios.value='{0}'; ", CveEstatusUsuarios)
|
|
script.AppendFormat("IDhdnCveEstatusUsuarios.value='{0}'; ", hdnCveEstatusUsuarios.ClientID)
|
|
script.AppendFormat("hdnCveEstatus.value = '{0}';", CveEstatus)
|
|
script.AppendFormat("hdnCveUsuario.value = '{0}';", e.Row.DBCampo("CveUsuario").ToString)
|
|
script.AppendFormat("hdnCveSuperior.value = '-1'; ")
|
|
'script.AppendFormat("chkMostrarLimites.checked = {0};chkMostrarLimitesCambio();", If(LimiteInferior > 0 Or LimiteSuperior > 0, "true", "false"))
|
|
'script.AppendFormat("txtLimiteInferior.value = '0.00'; ")
|
|
'script.AppendFormat("txtLimiteSuperior.value = '0.00'; ")
|
|
'ibOpciones.Attributes.Add("onclick", script.ToString)
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 4: CATALOGOS "
|
|
|
|
#Region " 4.1: CLASIFICACIONES "
|
|
Private Sub CargaDdlClasificaciones()
|
|
DdlClasificacion.Items.Clear()
|
|
Dim ObjClasi As New ClsClasificaciones
|
|
If ObjClasi.GetClasificaciones(CveEmpresa) Then
|
|
DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlClasificacion.DataSource = ObjClasi.DtResultados
|
|
DdlClasificacion.DataBind()
|
|
End If
|
|
UpEditPS.Update()
|
|
UpAddPS.Update()
|
|
End Sub
|
|
Protected Sub BtnClasificacion_Click(sender As Object, e As EventArgs) Handles btnClasificacion.Click
|
|
If TxtAddClasificacion.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtAddClasificacion.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
|
|
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarExcelClasificaciones(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
'If TxtAddClasificacion.getfiles().Archivos.Count > 0 Then
|
|
'Dim file As Archivo = TxtAddClasificacion.getfiles().Archivos(0)
|
|
'Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch & file.filename
|
|
'CargarExcelClasificaciones(Directorio)
|
|
' Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
' ' CargarArchivoClasificaciones(ModExtensiones.DirectorioBaseEmpresas & file.patch, file.filename, Tipo)
|
|
'Else
|
|
' Alert("No existe el archivo.Favor de subir un archivo de excel a la plataforma", TipoMensaje.MsgError)
|
|
'End If
|
|
End Sub
|
|
Private Sub CargarExcelClasificaciones(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dtClasificacion As New DataTable
|
|
Dim ErrorExcel = False
|
|
|
|
'Verificamos que el archivo tenga el formato correcto
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection(), objDbAdapter = objDbFactory.CreateDataAdapter(), Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dtClasificacion)
|
|
Conexion.Close()
|
|
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el archivo Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
|
|
End Using
|
|
|
|
|
|
If Not ErrorExcel Then
|
|
Dim NumRows As Integer = 0
|
|
If Not dtClasificacion.Columns(0).ColumnName = "Clasificacion" Then
|
|
Alert("El nombre de la primera columna debe ser 'Clasificacion'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
|
|
For Each Row As DataRow In dtClasificacion.Rows
|
|
Dim Clasificacion As String = Row("Clasificacion").ToString
|
|
If ObjClasificaciones.AddClasificaciones(Clasificacion, "", 0, "", 0, "", 0, "", 0, 100, CveEmpresa, UsoClasificacion:=0) Then
|
|
NumRows = NumRows + 1
|
|
End If
|
|
Next
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Clasificaciones correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
If ObjClasificaciones.GetClasificaciones(CveEmpresa) Then
|
|
GvClasificaciones.DataSource = ObjClasificaciones.DtResultados
|
|
GvClasificaciones.DataBind()
|
|
End If
|
|
ObjClasificaciones.Dispose()
|
|
UpClasificaciones.Update()
|
|
RegistraScript("$('#DivAddClasificaciones').modal('hide');")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GVClasificaciones_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvClasificaciones.RowDeleting
|
|
If CveEmpresa = 0 Then
|
|
DtClasificaciones.Rows.RemoveAt(e.RowIndex)
|
|
DtClasificaciones.AcceptChanges()
|
|
GvClasificaciones.DataSource = DtClasificaciones
|
|
GvClasificaciones.DataBind()
|
|
'UPGVClasi.Update()
|
|
ElseIf CveEmpresa > 0 Then
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
If ObjClasificaciones.RemoveClasificacion(GvClasificaciones.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvClasificaciones.EditIndex = -1
|
|
GvClasificaciones.DataSource = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
GvClasificaciones.DataBind()
|
|
Alert("La clasificación se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrió un error al eliminar la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjClasificaciones.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub LnkAgregarClasificacion_Click(sender As Object, e As EventArgs) Handles LnkAgregarClasificacion.Click
|
|
TxtClasificacion.Text = ""
|
|
BtnAgregarClasificacion.Text = "Agregar Clasificacion"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpAddClasificacion.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddClasificacion"))
|
|
End Sub
|
|
|
|
Private Sub BtnAgregarClasificacion_Click(sender As Object, e As EventArgs) Handles BtnAgregarClasificacion.Click
|
|
Dim ObjClasificacion As New ClsClasificaciones
|
|
|
|
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjClasificacion.AddClasificaciones(TxtClasificacion.Text, "", 0, "", 0, "", 0, "", 0, 100, CveEmpresa, UsoClasificacion:=0) Then
|
|
Alert("La clasificacion se agrego correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveClasificacion = CveModal
|
|
If ObjClasificacion.UpdateClasificacion(TxtClasificacion.Text, "", 0, "", 0, "", 0, "", True, False, 0, 100, CveClasificacion) Then
|
|
Alert("La clasificacion se actualizo correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
ObjClasificacion.Dispose()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddClasificacion"))
|
|
CargaGVClasificacion()
|
|
End Sub
|
|
|
|
Private Sub CargaGVClasificacion()
|
|
Dim ObjClasificacion As New ClsClasificaciones
|
|
If ObjClasificacion.GetClasificaciones(CveEmpresa) Then
|
|
GvClasificaciones.DataSource = ObjClasificacion.DtResultados
|
|
GvClasificaciones.DataBind()
|
|
End If
|
|
ObjClasificacion.Dispose()
|
|
UpClasificaciones.Update()
|
|
End Sub
|
|
|
|
Public Sub EditClasificacion_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveClasificacion").ToEntero
|
|
TxtClasificacion.Text = GvRow.DataKey("Clasificacion")
|
|
BtnAgregarClasificacion.Text = "Actualizar Clasificacion"
|
|
UpAddClasificacion.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddClasificacion"))
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " 4.2: UNIDADES DE MEDIDA "
|
|
Private Sub CargaDdlUM()
|
|
DdlUM.Items.Clear()
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
If ObjUM.GetUnidadesMedida(CveEmpresa) Then
|
|
DdlUM.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlUM.DataSource = ObjUM.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
DdlUM.DataBind()
|
|
End If
|
|
UpEditPS.Update()
|
|
UpAddPS.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargarExcelUnidadesMedida(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dtUM As New DataTable
|
|
Dim ErrorExcel = False
|
|
|
|
'Verificamos que el archivo tenga el formato correcto
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection(), objDbAdapter = objDbFactory.CreateDataAdapter(), Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dtUM)
|
|
Conexion.Close()
|
|
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el archivo Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
|
|
End Using
|
|
|
|
If Not ErrorExcel AndAlso dtUM.Rows.Count > 0 Then
|
|
Dim NumRows As Integer = 0
|
|
|
|
' Verificamos que el archivo tenga la estructura de la plantilla
|
|
If Not dtUM.Columns(0).ColumnName = "UnidadMedida" Then
|
|
Alert("El nombre de la primera columna debe ser 'UnidadMedida'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtUM.Columns(1).ColumnName = "Abreviatura" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Abreviatura'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjUnidadesMedida As New ClsUnidadesMedida
|
|
|
|
For Each Row As DataRow In dtUM.Rows
|
|
Dim UnidadMedida As String = Row("UnidadMedida").ToString
|
|
Dim Abreviatura As String = Row("Abreviatura").ToString
|
|
If ObjUnidadesMedida.AddUnidadMedida(UnidadMedida, Abreviatura, "", "", "", 100, CveEmpresa, -1) > -1 Then
|
|
NumRows = NumRows + 1
|
|
End If
|
|
Next
|
|
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Unidades de Medida correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
|
|
If ObjUnidadesMedida.GetUnidadesMedida(CveEmpresa) Then
|
|
GvUM.DataSource = ObjUnidadesMedida.DtResultados.FiltraParametros($"CveEmpresa = {CveEmpresa}")
|
|
GvUM.DataBind()
|
|
End If
|
|
ObjUnidadesMedida.Dispose()
|
|
End If
|
|
UpGVUM.Update()
|
|
RegistraScript("$('#DivAddUnidadesMedida').modal('hide');")
|
|
End Sub
|
|
Protected Sub GvUM_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvUM.RowDeleting
|
|
If CveEmpresa = 0 Then
|
|
DtUM.Rows.RemoveAt(e.RowIndex)
|
|
DtUM.AcceptChanges()
|
|
GvUM.DataSource = DtUM
|
|
GvUM.DataBind()
|
|
UpGVUM.Update()
|
|
Else
|
|
Dim ObjUnidadesMedida As New ClsUnidadesMedida
|
|
If ObjUnidadesMedida.RemoveUnidadMedida(GvUM.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvUM.EditIndex = -1
|
|
GvUM.DataSource = ObjUnidadesMedida.DtResultados.FiltraParametros("CveEmpresa = " & CveEmpresa)
|
|
GvUM.DataBind()
|
|
Alert("La Unidad de Medida se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjUnidadesMedida.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub EditUM_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveUnidadMedida").ToEntero
|
|
TxtUM.Text = GvRow.DataKey("UnidadMedida")
|
|
TxtAbreviatura.Text = GvRow.DataKey("Abreviatura")
|
|
BtnAddUM.Text = "Actualizar Unidad de Medida"
|
|
UpAddUM.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddUM"))
|
|
End Sub
|
|
|
|
Private Sub CargaGVUM()
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
If ObjUM.GetUnidadesMedida(CveEmpresa) Then
|
|
GvUM.DataSource = ObjUM.DtResultados.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
|
|
GvUM.DataBind()
|
|
End If
|
|
ObjUM.Dispose()
|
|
UpGVUM.Update()
|
|
End Sub
|
|
|
|
Private Sub LnkAddUM_Click(sender As Object, e As EventArgs) Handles LnkAddUM.Click
|
|
TxtUM.Text = ""
|
|
TxtAbreviatura.Text = ""
|
|
BtnAddUM.Text = "Agregar Unidad de Medida"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpAddUM.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddUM"))
|
|
End Sub
|
|
|
|
Private Sub BtnAddUM_Click(sender As Object, e As EventArgs) Handles BtnAddUM.Click
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
|
|
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjUM.AddUnidadMedida(TxtUM.Text, TxtAbreviatura.Text, "", "", "", 100, CveEmpresa, -1) <> -1 Then
|
|
Alert("La clasificacion se agrego correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
|
|
If ModalidadModal = "Actualizar" Then
|
|
If CveModal > 0 Then
|
|
Dim CveUM = CveModal
|
|
If ObjUM.UpdateUnidadMedida(TxtUM.Text, TxtAbreviatura.Text, "", "", "", True, 100, CveUM, -1) Then
|
|
Alert("La clasificacion se actualizo correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
ObjUM.Dispose()
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddUM"))
|
|
CargaGVUM()
|
|
End Sub
|
|
|
|
Protected Sub BtnDivAddUnidadesMedida_Click(sender As Object, e As EventArgs) Handles BtnDivAddUnidadesMedida.Click
|
|
If TxtAddUnidadesMedida.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtAddUnidadesMedida.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarExcelUnidadesMedida(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " 4.3: PRODUCTOS / SERVICIOS "
|
|
|
|
Private Sub GVPS_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVPS.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.Cells(3).Text = "$" + FormatNumber(e.Row.DBCampo("Precio").ToString, 2, , , TriState.True)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargarExcelPS(rutaExcel As String, Tipo As String)
|
|
Dim DtExcel As New DataTable
|
|
Dim ErrorExcel = False
|
|
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + rutaExcel + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection,
|
|
objDbAdapter = objDbFactory.CreateDataAdapter(),
|
|
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + rutaExcel + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(DtExcel)
|
|
Conexion.Close()
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
|
|
End Using
|
|
|
|
If Not ErrorExcel Then
|
|
'Verificamos que la estructura del archivo coincida con la plantilla
|
|
|
|
If Not DtExcel.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(1).ColumnName = "Descripcion" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Descripcion'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(2).ColumnName = "Tipo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Tipo'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(3).ColumnName = "Código Barras" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Código Barras'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(4).ColumnName = "Unidad Medida" Then
|
|
Alert("El nombre de la primera columna debe ser 'Unidad Medida'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(5).ColumnName = "Clasificacion" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Clasificacion'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(6).ColumnName = "Marca" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Marca'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(7).ColumnName = "AplicaSerie" Then
|
|
Alert("El nombre de la primera columna debe ser 'AplicaSerie'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(8).ColumnName = "Precio" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Precio'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not DtExcel.Columns(9).ColumnName = "IEPS" Then
|
|
Alert("El nombre de la segunda columna debe ser 'IEPS'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
Dim NumRows As Integer = DtExcel.Rows.Count
|
|
|
|
Dim ErrorPS As Boolean = False
|
|
Dim ExistePS As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
|
|
'Obtengo Productos
|
|
Dim ObjPS As New ClsProductosServicios
|
|
Dim DTPS As New DataTable
|
|
ObjPS.IniciaTransacSQL()
|
|
If ObjPS.GetPS(-1, -1, CveEmpresa) Then
|
|
DTPS = ObjPS.DtResultados
|
|
End If
|
|
'Obtengo Clasificaciones
|
|
Dim ObjClasificaciones As New ClsClasificaciones
|
|
Dim DTClasificaciones As New DataTable
|
|
If ObjClasificaciones.GetClasificaciones(CveEmpresa) Then
|
|
DTClasificaciones = ObjClasificaciones.DtResultados
|
|
End If
|
|
ObjClasificaciones.Dispose()
|
|
|
|
'Obtengo Unidades de medida
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
Dim DTUM As New DataTable
|
|
If ObjUM.GetUnidadesMedida(CveEmpresa) Then
|
|
DTUM = ObjUM.DtResultados.FiltraParametros(String.Format("CveEmpresa={0}", CveEmpresa))
|
|
End If
|
|
ObjUM.Dispose()
|
|
|
|
For Each Row As DataRow In DtExcel.Rows
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim Descripcion As String = Row("Descripcion").ToString
|
|
Dim TipoPS As String = Row("Tipo").ToString.Trim
|
|
Dim CodigoBarras As String = Row("Código Barras").ToString
|
|
Dim UnidadMedida As String = Row("Unidad Medida").ToString
|
|
Dim Clasificacion As String = Row("Clasificacion").ToString
|
|
Dim Marca As Decimal = Row("Marca").ToString.ToDecimal
|
|
Dim AplicaSerie As String = Row("AplicaSerie").ToString
|
|
Dim Precio As String = Row("Precio").ToString
|
|
Dim IEPS As String = Row("IEPS").ToString
|
|
|
|
Dim CvePS As Integer
|
|
If DTPS.FiltraParametros($"Codigo = '{Codigo}'").Rows.Count > 0 Then
|
|
CvePS = DTPS.FiltraParametros($"Codigo = '{Codigo}'").Rows(0)("CvePS").ToString.ToEntero
|
|
Else
|
|
CvePS = 0
|
|
End If
|
|
|
|
Dim CveUnidadMedida As Integer
|
|
If DTUM.FiltraParametros($"UnidadMedida = '{UnidadMedida}'").Rows.Count > 0 Then
|
|
CveUnidadMedida = DTUM.FiltraParametros($"UnidadMedida = '{UnidadMedida}'").Rows(0)("CveUnidadMedida").ToString.ToEntero
|
|
Else
|
|
CveUnidadMedida = 0
|
|
End If
|
|
|
|
Dim CveClasificacion As Integer
|
|
If DTClasificaciones.FiltraParametros($"Clasificacion = '{Clasificacion}'").Rows.Count > 0 Then
|
|
CveClasificacion = DTClasificaciones.FiltraParametros($"Clasificacion = '{Clasificacion}'").Rows(0)("CveClasificacion").ToString.ToEntero
|
|
Else
|
|
CveClasificacion = 0
|
|
End If
|
|
|
|
If Not CveClasificacion > 0 Then Alert("No se encontró la Clasificación: " + Clasificacion, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
If Not CveUnidadMedida > 0 Then Alert("No se encontró la Unidad de Medida: " + UnidadMedida, TipoMensaje.MsgAdvertencia) : ErrorPS = True : Exit For
|
|
|
|
If CveClasificacion < 0 Then CveClasificacion = 1
|
|
|
|
If CvePS > 0 Then
|
|
ExistePS = True
|
|
Contador = Contador + 1
|
|
If Not ObjPS.UpdatePS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", CodigoBarras, Descripcion, Precio.ToDouble, 1, 1, False, 0, True, True, True, 100, CvePS, -1, -1, -1) Then
|
|
ErrorPS = True
|
|
Codigo.GuardaLog
|
|
Exit For
|
|
End If
|
|
Else
|
|
If Not ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, Codigo, "", "", Descripcion, Precio.ToDouble, 0, 0, False, 0, False, True, 100, CveEmpresa, 1, 1) <> -1 Then
|
|
ErrorPS = True
|
|
Codigo.GuardaLog
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorPS Then
|
|
ObjPS.Commit()
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Productos/Servicios correctamente. <br>Se Actualizaron: <b>{1}</b> Productos/Servicios ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Productos/Servicios correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtAddPS.Text = ""
|
|
Else
|
|
ObjPS.RollBack()
|
|
End If
|
|
End If
|
|
|
|
RegistraScript("$('#DivAddPS').modal('hide');")
|
|
|
|
CargaGVPS()
|
|
UPGvPS.Update()
|
|
End Sub
|
|
Protected Sub GvPS_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVPS.RowDeleting
|
|
Dim objPS As New ClsProductosServicios()
|
|
If objPS.RemovePS(GVPS.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
If objPS.GetPS(-1, -1, CveEmpresa) Then
|
|
GVPS.DataSource = objPS.DtResultados
|
|
GVPS.DataBind()
|
|
Else
|
|
GVPS.DataSource = Nothing
|
|
End If
|
|
Else
|
|
Alert("Ocurrió un Error al elimiar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
UPGvPS.Update()
|
|
objPS.Dispose()
|
|
End Sub
|
|
|
|
Public Sub EditPS_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CargaDdlClasificaciones()
|
|
CargaDdlUM()
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CvePS").ToEntero
|
|
TxtPS.Text = GvRow.DataKey("PS")
|
|
TxtCodigo.Text = GvRow.DataKey("Codigo")
|
|
TxtCodigoBarras.Text = GvRow.DataKey("CodigoBarras")
|
|
TxtPrecio.Text = GvRow.DataKey("Precio")
|
|
DdlUM.SelectedValueExist(GvRow.DataKey("CveUnidadMedida"))
|
|
DdlTipoPS.SelectedValueExist(GvRow.DataKey("CveTipoPS"))
|
|
DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion"))
|
|
BtnDivUpdatePS.Text = "Actualizar Producto/Servicio"
|
|
ChkAplicaParaVenta.Checked = CBool(GvRow.DataKey("AplicaParaVenta"))
|
|
UpEditPS.Update()
|
|
RegistraScript("$('#DivUpdatePS').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub CargaGVPS()
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPS(-1, -1, CveEmpresa) Then
|
|
GVPS.DataSource = ObjPS.DtResultados
|
|
GVPS.DataBind()
|
|
End If
|
|
ObjPS.Dispose()
|
|
UPGvPS.Update()
|
|
End Sub
|
|
|
|
Private Sub LnkAgregarPS_Click(sender As Object, e As EventArgs) Handles LnkAgregarPS.Click
|
|
CargaDdlClasificaciones()
|
|
CargaDdlUM()
|
|
ModalidadModal = "Insertar"
|
|
TxtPS.Text = ""
|
|
TxtCodigo.Text = ""
|
|
TxtCodigoBarras.Text = ""
|
|
TxtPrecio.Text = ""
|
|
DdlUM.SelectedValue = "-1"
|
|
DdlTipoPS.SelectedValue = "-1"
|
|
DdlClasificacion.SelectedValue = "-1"
|
|
ChkAplicaParaVenta.Checked = False
|
|
BtnDivUpdatePS.Text = "Agregar Producto/Servicio"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpEditPS.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "DivUpdatePS"))
|
|
End Sub
|
|
|
|
Protected Sub BtnDivUpdatePS_Click(sender As Object, e As EventArgs) Handles BtnDivUpdatePS.Click
|
|
If DdlClasificacion.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar una clasificacion", TipoMensaje.MsgAdvertencia)
|
|
ElseIf DdlUM.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar una unidad de medida", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjPS.AddPS(DdlClasificacion.SelectedValue.ToEntero, 1, DdlUM.SelectedValue.ToEntero, TxtCodigo.Text, "", TxtCodigoBarras.Text, TxtPS.Text, TxtPrecio.Text.ToDouble, 0, 0, False, 0, False, True, 100, CveEmpresa, 1, 1) <> -1 Then
|
|
Alert("El prodtco/servicio se agrego correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
If ModalidadModal = "Actualizar" Then
|
|
Dim CvePS As Integer
|
|
CvePS = CveModal.ToEntero
|
|
If ObjPS.UpdatePS(DdlClasificacion.SelectedValue.ToEntero, 1, DdlUM.SelectedValue.ToEntero, TxtCodigo.Text, "", TxtCodigoBarras.Text, TxtPS.Text, TxtPrecio.Text.ToDouble, 0, 0, False, 0, False, True, True, 100, CvePS, 1, 1, -1) Then
|
|
Alert("El prodtco/servicio se actualizo correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
|
|
ObjPS.Dispose()
|
|
UPGvPS.Update()
|
|
UpEditPS.Update()
|
|
CargaGVPS()
|
|
RegistraScript("$('#DivUpdatePS').modal('hide');")
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnDivAddPS_Click(sender As Object, e As EventArgs) Handles BtnDivAddPS.Click
|
|
If TxtAddPS.getfiles().Archivos.Count > 0 Then
|
|
Dim ArchivoExcel As Archivo = TxtAddPS.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & ArchivoExcel.patch & ArchivoExcel.filename
|
|
Dim Tipo As String = If(ArchivoExcel.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "OTRO")
|
|
CargarExcelPS(Directorio, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo de excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 5: CARGA INICIAL"
|
|
|
|
#Region " 5.1: PROVEEDORES"
|
|
Private Sub GvProvedoores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProvedoores.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
e.Row.Cells(7).Text = "$" + FormatNumber(e.Row.DBCampo("LimiteCredito").ToString, 2, , , TriState.True)
|
|
e.Row.Cells(8).Text = FormatNumber(e.Row.DBCampo("PlazoPago").ToString, 0, , , TriState.True)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargarArchivoProveedor(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dtProveedor As New DataTable
|
|
Dim ErrorExcel = False
|
|
|
|
'Verificamos que el archivo tenga el formato correcto
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection(), objDbAdapter = objDbFactory.CreateDataAdapter(), Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dtProveedor)
|
|
Conexion.Close()
|
|
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el archivo Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
|
|
End Using
|
|
|
|
If Not ErrorExcel Then
|
|
|
|
If Not dtProveedor.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(1).ColumnName = "RazonSocial" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Fecha'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(2).ColumnName = "RFC" Then
|
|
Alert("El nombre de la tercera columna debe ser 'RFC'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(3).ColumnName = "Calle" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Calle'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(4).ColumnName = "Número exterior" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Número exterior'.Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(5).ColumnName = "Colonia" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Colonia'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(6).ColumnName = "Código postal" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Código postal'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(7).ColumnName = "Población" Then
|
|
Alert("El nombre de la octava columna debe ser 'Población'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(8).ColumnName = "Estado" Then
|
|
Alert("El nombre de la novena columna debe ser 'Estado'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(9).ColumnName = "Teléfono" Then
|
|
Alert("El nombre de la décima columna debe ser 'Teléfono'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(10).ColumnName = "Contacto" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Contacto'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(11).ColumnName = "Celular Contacto" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Celular Contacto'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(12).ColumnName = "Limite Credito" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Limite Credito'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtProveedor.Columns(13).ColumnName = "Plazo Cobranza" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Plazo Cobranza'. Favor de verificar el archivo.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim NumRows As Integer = dtProveedor.Rows.Count
|
|
Dim ObjProv As New ClsCompProveedores
|
|
Dim ErrorProv As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim ExisteProveedor As Boolean = False
|
|
|
|
ObjProv.IniciaTransacSQL()
|
|
|
|
For Each Row As DataRow In dtProveedor.Rows
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim RazonSocial As String = Row("RazonSocial").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Calle As String = Row("Calle").ToString
|
|
Dim NumExt As Decimal = Row("Número exterior").ToString.ToDecimal
|
|
Dim Colonia As String = Row("Colonia").ToString
|
|
Dim CodigoPostal As Decimal = Row("Código Postal").ToString.ToDecimal
|
|
Dim Poblacion As String = Row("Población").ToString
|
|
Dim Estado As String = Row("Estado").ToString
|
|
Dim Telefono As String = Row("Teléfono").ToString
|
|
Dim Contacto As String = Row("Contacto").ToString
|
|
Dim CelularContacto As String = Row("Celular Contacto").ToString
|
|
Dim LimiteCredito As Integer = Row("Limite Credito").ToString.ToEntero
|
|
Dim PlazoCobranza As Integer = Row("Plazo Cobranza").ToString.ToEntero
|
|
Dim CveProveedor As Integer = 0
|
|
Dim CveProveedor2 As Integer = 0
|
|
|
|
Dim ObjProveedor As New ClsCompProveedores
|
|
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
CveProveedor = ObjProveedor.DtResultados.FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
|
CveProveedor2 = ObjProveedor.DtResultados.FiltroPrimeroValor("CveProveedor", $"RazonSocial = '{RazonSocial}'").ToString.ToEntero
|
|
End If
|
|
'ObjProveedor.Dispose()
|
|
|
|
If CveProveedor > 0 Or CveProveedor2 > 0 Then
|
|
'ExisteProveedor = True
|
|
Contador = Contador + 1
|
|
If Not ObjProv.UpdateProveedor(Codigo, RazonSocial, RazonSocial, "", RFC, Calle, Telefono,
|
|
Contacto, "", Telefono, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
|
|
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", 1, "", -1, -1, True, "", "", False, CveProveedor) Then
|
|
ErrorProv = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
If Not ObjProv.AddProveedor(Codigo, RazonSocial, RazonSocial, "", RFC, Calle, Telefono,
|
|
Contacto, "", Telefono, LimiteCredito, PlazoCobranza, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
|
|
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", 1, "", -1, -1, "", "", False, 100, CveEmpresa) Then
|
|
ErrorProv = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If Not ErrorProv Then
|
|
ObjProv.Commit()
|
|
If ObjProv.GetProveedores(ClsCompProveedores.TipoConsulta.ParaGlobalDT, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", 1, -1) Then Application("GlobalDTCompProveedores") = ObjProv.DtResultados
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Proveedores correctamente. <br>Se Omitieron: <b>{1}</b> Clientes ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Proveedores correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtAddProveedor.Text = ""
|
|
CargaGVProveedor()
|
|
RegistraScript("$('#DivExcelProveedor').modal('hide');")
|
|
Else
|
|
ObjProv.RollBack()
|
|
End If
|
|
ObjProv.Dispose()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnCargaExcelProveedor_Click(sender As Object, e As EventArgs) Handles BtnCargaExcelProveedor.Click
|
|
If TxtAddProveedor.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtAddProveedor.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarArchivoProveedor(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub EditProveedor_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveProveedor").ToEntero
|
|
TxtCodigoProveedor.Text = GvRow.DataKey("Codigo")
|
|
TxtRazonSocial.Text = GvRow.DataKey("RazonSocial")
|
|
TxtNombreCorto.Text = GvRow.DataKey("NombreCorto")
|
|
TxtRFCProv.Text = GvRow.DataKey("RFC")
|
|
TxtCalleProveedor.Text = GvRow.DataKey("Direccion")
|
|
TxtLimiteCredito.Text = GvRow.DataKey("LimiteCredito")
|
|
TxtTelefonoProveedor.Text = GvRow.DataKey("Telefono")
|
|
TxtPlazoCobranza.Text = GvRow.DataKey("PlazoPago")
|
|
TxtContactoNombre.Text = GvRow.DataKey("ContactoNombre")
|
|
BtnAddProveedor.Text = "Actualizar Proveedor"
|
|
UpAddProveedor.Update()
|
|
RegistraScript("$('#DivAddProveedor').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub LnkAddProveedor_Click(sender As Object, e As EventArgs) Handles LnkAddProveedor.Click
|
|
ModalidadModal = "Insertar"
|
|
TxtCodigoProveedor.Text = ""
|
|
TxtRazonSocial.Text = ""
|
|
TxtNombreCorto.Text = ""
|
|
TxtRFCProv.Text = ""
|
|
TxtCalleProveedor.Text = ""
|
|
TxtLimiteCredito.Text = ""
|
|
TxtTelefonoProveedor.Text = ""
|
|
TxtPlazoCobranza.Text = ""
|
|
TxtContactoNombre.Text = ""
|
|
BtnAddProveedor.Text = "Agregar Proveedor"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpAddProveedor.Update()
|
|
RegistraScript("$('#DivAddProveedor').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub CargaGVProveedor()
|
|
Dim ObjProveedor As New ClsCompProveedores
|
|
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
GvProvedoores.DataSource = ObjProveedor.DtResultados
|
|
GvProvedoores.DataBind()
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
UpGvProveedor.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnAddProveedor_Click(sender As Object, e As EventArgs) Handles BtnAddProveedor.Click
|
|
Dim ObjProveedor As New ClsCompProveedores
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjProveedor.AddProveedor(TxtCodigoProveedor.Text, TxtRazonSocial.Text, TxtRazonSocial.Text, TxtNombreCorto.Text, TxtRFCProv.Text, TxtCalleProveedor.Text, TxtTelefonoProveedor.Text,
|
|
TxtContactoNombre.Text, "", TxtTelefonoProveedor.Text, TxtLimiteCredito.Text.ToDouble, TxtPlazoCobranza.Text.ToEntero, "", 0, 0, 0, -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "",
|
|
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", 1, "", -1, -1, "", "", False, 100, CveEmpresa) Then
|
|
Alert("El proveedor se agrego correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
If ModalidadModal = "Actualizar" Then
|
|
Dim CveProveedor As Integer
|
|
CveProveedor = CveModal.ToEntero
|
|
If ObjProveedor.UpdateProveedor(TxtCodigoProveedor.Text, TxtRazonSocial.Text, TxtRazonSocial.Text, TxtNombreCorto.Text, TxtRFCProv.Text, TxtCalleProveedor.Text, TxtTelefonoProveedor.Text,
|
|
TxtContactoNombre.Text, "", TxtTelefonoProveedor.Text, TxtLimiteCredito.Text.ToDouble, TxtPlazoCobranza.Text.ToEntero, "", 0, 0, 0, -1, "", -1, "", -1, "",
|
|
-1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, "", -1, -1, True, "", "",
|
|
False, CveProveedor) Then
|
|
|
|
Alert("El proveedor se actualizo correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
|
|
ObjProveedor.Dispose()
|
|
CargaGVProveedor()
|
|
RegistraScript("$('#DivAddProveedor').modal('hide');")
|
|
End Sub
|
|
|
|
Protected Sub GvProvedoores_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvProvedoores.RowDeleting
|
|
Dim ObjProveedor As New ClsCompProveedores
|
|
If ObjProveedor.RemoveProveedor(GvProvedoores.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
Alert("El Proveedor se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
CargaGVProveedor()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " 5.2: CLIENTES"
|
|
|
|
Protected Sub GvCliente_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvCliente.RowDeleting
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.RemoveCliente(GvCliente.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
Alert("El Cliente se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjCliente.Dispose()
|
|
CargaGvCliente()
|
|
End Sub
|
|
|
|
Protected Sub BtnAddCliente_Click(sender As Object, e As EventArgs) Handles BtnAddCliente.Click
|
|
If DdlSubProyectoClientes.SelectedValue <> "-1" Then
|
|
|
|
Dim ObjCliente As New ClsClientes
|
|
If ModalidadModal = "Insertar" Then
|
|
If ObjCliente.AddCliente(TxtRazonSocialCliente.Text, TxtRazonSocialCliente.Text, TxtDireccionCliente.Text, "", "", TxtColoniaCliente.Text, "", "", TxtEstadoCliente.Text, "", TxtRFCCliente.Text, TxtCPCliente.Text, "", TxtContactoCliente.Text, "", "", "", "", "", -1, False, 1, -1, False, 100, CveEmpresa, "", -1, -1, -1,
|
|
"-1", "-1", -1, "-1", -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", "", "", "", 0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False, DdlSubProyectoClientes.SelectedValue.ToEntero, -1) Then
|
|
Alert("El cliente se agrego correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
If ModalidadModal = "Actualizar" Then
|
|
Dim CveCliente As Integer
|
|
CveCliente = CveModal.ToEntero
|
|
If ObjCliente.UpdateCliente(TxtRazonSocialCliente.Text, TxtRazonSocialCliente.Text, TxtDireccionCliente.Text, "", "", TxtColoniaCliente.Text, "", "", TxtEstadoCliente.Text, "", TxtRFCCliente.Text, TxtCPCliente.Text, "", TxtContactoCliente.Text, "", "", "", "", "", -1, False, 0.0, 0.0, False, True, "", -1, -1, -1,
|
|
"-1", "-1", -1, "-1", -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", -1, "", -1, "", "", "", "", 0.0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", 100, CveCliente, 100, CveEmpresa, "", "", False, DdlSubProyectoClientes.SelectedValue.ToEntero, -1) Then
|
|
Alert("El cliente se actualizo correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
End If
|
|
|
|
|
|
ObjCliente.Dispose()
|
|
CargaGvCliente()
|
|
RegistraScript("$('#DivAddCliente').modal('hide');")
|
|
Else
|
|
Alert("Tiene que seleccionar un a sucursal", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub EditCliente_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
CargaSubProyectos()
|
|
ModalidadModal = "Actualizar"
|
|
CveModal = GvRow.DataKey("CveCliente").ToEntero
|
|
TxtRazonSocialCliente.Text = GvRow.DataKey("Nombre")
|
|
DdlSubProyectoClientes.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
|
|
TxtRFCCliente.Text = GvRow.DataKey("RFC")
|
|
TxtDireccionCliente.Text = GvRow.DataKey("Direccion")
|
|
TxtColoniaCliente.Text = GvRow.DataKey("Colonia")
|
|
TxtEstadoCliente.Text = GvRow.DataKey("Estado")
|
|
TxtCPCliente.Text = GvRow.DataKey("CP")
|
|
TxtContactoCliente.Text = GvRow.DataKey("Contacto")
|
|
BtnAddCliente.Text = "Actualizar Cliente"
|
|
UpAddCliente.Update()
|
|
RegistraScript("$('#DivAddCliente').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub LnkAddCliente_Click(sender As Object, e As EventArgs) Handles LnkAddCliente.Click
|
|
CargaSubProyectos()
|
|
ModalidadModal = "Insertar"
|
|
TxtRazonSocialCliente.Text = ""
|
|
DdlSubProyectoClientes.SelectedValue = "-1"
|
|
TxtRFCCliente.Text = ""
|
|
TxtDireccionCliente.Text = ""
|
|
TxtColoniaCliente.Text = ""
|
|
TxtEstadoCliente.Text = ""
|
|
TxtCPCliente.Text = ""
|
|
TxtContactoCliente.Text = ""
|
|
BtnAddCliente.Text = "Agregar Cliente"
|
|
ModalidadModal = "Insertar"
|
|
CveModal = -1
|
|
UpAddCliente.Update()
|
|
RegistraScript("$('#DivAddCliente').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub CargaGvCliente()
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
GvCliente.DataSource = ObjCliente.DtResultados
|
|
GvCliente.DataBind()
|
|
End If
|
|
ObjCliente.Dispose()
|
|
UpGvCliente.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaExcelCliente_Click(sender As Object, e As EventArgs) Handles BtnCargaExcelCliente.Click
|
|
If TxtAddClientes.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtAddClientes.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarArchivoCliente(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargarArchivoCliente(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dtCliente As New DataTable
|
|
Dim ErrorExcel = False
|
|
|
|
|
|
'Verificamos que el archivo tenga el formato correcto
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection(), objDbAdapter = objDbFactory.CreateDataAdapter(), Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dtCliente)
|
|
Conexion.Close()
|
|
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el archivo Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
|
|
End Using
|
|
|
|
If Not ErrorExcel Then
|
|
|
|
If Not dtCliente.Columns(0).ColumnName = "Codigo" Then
|
|
Alert("El nombre de la primera columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(1).ColumnName = "RazonSocial" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Fecha'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(2).ColumnName = "RFC" Then
|
|
Alert("El nombre de la tercera columna debe ser 'RFC'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(3).ColumnName = "Calle" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Calle'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(4).ColumnName = "Número exterior" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Número exterior' .Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(5).ColumnName = "Colonia" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Colonia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(6).ColumnName = "Código postal" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Código postal'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(7).ColumnName = "Población" Then
|
|
Alert("El nombre de la octava columna debe ser 'Población'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(8).ColumnName = "Estado" Then
|
|
Alert("El nombre de la novena columna debe ser 'Estado'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(9).ColumnName = "Teléfono" Then
|
|
Alert("El nombre de la décima columna debe ser 'Teléfono'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(10).ColumnName = "Contacto" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(11).ColumnName = "Celular Contacto" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Celular Contacto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(12).ColumnName = "Limite Credito" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Limite Credito'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtCliente.Columns(13).ColumnName = "Plazo Cobranza" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Plazo Cobranza'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim NumRows As Integer = dtCliente.Rows.Count
|
|
Dim ObjClientes As New ClsClientes
|
|
Dim ErrorClientes As Boolean = False
|
|
Dim ExisteCliente As Boolean = False
|
|
Dim Contador As Integer = 0
|
|
Dim NumRow As Integer = 0
|
|
|
|
Try
|
|
ObjClientes.IniciaTransacSQL()
|
|
For Each Row As DataRow In dtCliente.FiltraParametros("RFC <> ''").Rows
|
|
NumRow = NumRow + 1
|
|
Dim Codigo As String = Row("Codigo").ToString
|
|
Dim RazonSocial As String = Row("RazonSocial").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Calle As String = Row("Calle").ToString
|
|
Dim NumExt As Decimal = Row("Número exterior").ToString.ToDecimal
|
|
Dim Colonia As String = Row("Colonia").ToString
|
|
Dim CodigoPostal As String = Row("Código Postal").ToString
|
|
Dim Poblacion As String = Row("Población").ToString
|
|
Dim Estado As String = Row("Estado").ToString
|
|
Dim Pais As String = Row("Pais").ToString
|
|
Dim Telefono As String = Row("Teléfono").ToString
|
|
Dim Contacto As String = Row("Contacto").ToString
|
|
Dim CelularContacto As String = Row("Celular Contacto").ToString
|
|
Dim CveCliente As Integer = 0
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
CveCliente = ObjCliente.DtResultados.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
|
End If
|
|
ObjCliente.Dispose()
|
|
|
|
If CveCliente > 0 Then
|
|
ExisteCliente = True
|
|
Contador = Contador + 1
|
|
If Not ObjClientes.UpdateCliente(RazonSocial, RazonSocial, Calle, "", "", Colonia, "", "", Estado, Pais, RFC, CodigoPostal, "", Contacto, "", "", "", "", "", -1, False, 0.0, 0.0, False, True, "", -1, -1, -1,
|
|
"-1", "-1", -1, "-1", -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", -1, "", -1, "", "", "", "", 0.0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", 100, CveCliente, 100, CveEmpresa, "", "", False, -1, -1) Then
|
|
ErrorClientes = True
|
|
RFC.GuardaLog
|
|
Exit For
|
|
End If
|
|
Else
|
|
If Not ObjClientes.AddCliente(RazonSocial, RazonSocial, Calle, "", "", Colonia, "", "", Estado, Pais, RFC, CodigoPostal, "", Contacto, "", "", "", "", "", -1, False, 1, -1, False, 100, CveEmpresa, "", -1, -1, -1,
|
|
"-1", "-1", -1, "-1", -1, "0", -1, "0", 0, "", 0, "", 0, "", 0, "", "", "", "", 0, "", 1, False, "", "", "", False, "", "", "", "", "", False, "", "", "", False, -1, -1) Then
|
|
ErrorClientes = True
|
|
RFC.GuardaLog
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
|
|
|
|
Catch ex As Exception
|
|
GuardaLog($"Ocurrio un error al agregar el Cliente: {ex}, {NumRow}")
|
|
ObjClientes.RollBack()
|
|
|
|
Finally
|
|
'ObjClientes.Dispose()
|
|
End Try
|
|
|
|
If Not ErrorClientes Then
|
|
ObjClientes.Commit()
|
|
'If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1) Then Application("GlobalDTCliente") = ObjClientes.DtResultados
|
|
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Clientes correctamente. <br>Se Omitieron: <b>{1}</b> Clientes ya que ya se encontraban registrados.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Clientes correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
TxtAddClientes.Text = ""
|
|
CargaGvCliente()
|
|
Else
|
|
ObjClientes.RollBack()
|
|
End If
|
|
ObjClientes.Dispose()
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " 5.3: FACTURAS"
|
|
Private Sub BtnCargaExcelFacturas_Click(sender As Object, e As EventArgs) Handles BtnCargaExcelFacturas.Click
|
|
If TxtAddFactura.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtAddFactura.getfiles().Archivos(0)
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarArchivoFactura(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnDescargarFacturas_Click(sender As Object, e As EventArgs) Handles BtnDescargarFacturas.Click
|
|
DescargarExcel("Fact")
|
|
End Sub
|
|
|
|
Private Sub CargarArchivoFactura(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dtFactura As New DataTable
|
|
Dim ErrorExcel = False
|
|
If Tipo <> "EXCEL" Then
|
|
Alert("El archivo no tiene el formato correcto.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim strConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + Ruta + FileName + ";Extended Properties=Excel 8.0;"
|
|
Dim objDbFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory("System.Data.OleDb")
|
|
|
|
Using objDbConnection = objDbFactory.CreateConnection(), objDbAdapter = objDbFactory.CreateDataAdapter(), Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
|
|
objDbConnection.ConnectionString = strConnString
|
|
objDbConnection.Open()
|
|
Dim objSheetNames As DataTable = objDbConnection.GetSchema("Tables")
|
|
Dim HojaExcel As String = objSheetNames.FiltroPrimeroValor("TABLE_NAME")
|
|
Try
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = $"SELECT * FROM [{HojaExcel}]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dtFactura)
|
|
Conexion.Close()
|
|
|
|
Catch ex As Exception
|
|
ErrorExcel = True
|
|
OnError("Ocurrio un error al leer el archivo Excel <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
|
|
End Using
|
|
|
|
If Not ErrorExcel Then
|
|
|
|
If Not dtFactura.Columns(0).ColumnName = "Sucursal" Then
|
|
Alert("El nombre de la primera columna debe ser 'Sucursal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(1).ColumnName = "RFC" Then
|
|
Alert("El nombre de la segunda columna debe ser 'RFC'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(2).ColumnName = "Serie" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Serie'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(3).ColumnName = "Folio" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Folio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(4).ColumnName = "Fecha" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Fecha'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(5).ColumnName = "SubTotal" Then
|
|
Alert("El nombre de la sexta columna debe ser 'SubTotal'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(6).ColumnName = "IVA" Then
|
|
Alert("El nombre de la séptima columna debe ser 'IVA'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(7).ColumnName = "Total" Then
|
|
Alert("El nombre de la octava columna debe ser 'Total'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(8).ColumnName = "Saldo" Then
|
|
Alert("El nombre de la novena columna debe ser 'Saldo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(9).ColumnName = "Tipo Documento" Then
|
|
Alert("El nombre de la décima columna debe ser 'Tipo Documento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(10).ColumnName = "Ret IVA" Then
|
|
Alert("El nombre de la onceava columna debe ser 'Ret IVA'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(11).ColumnName = "Ret ISR" Then
|
|
Alert("El nombre de la doceava columna debe ser 'Ret ISR'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(12).ColumnName = "Moneda" Then
|
|
Alert("El nombre de la treceava columna debe ser 'Moneda'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
If Not dtFactura.Columns(13).ColumnName = "Tipo Cambio" Then
|
|
Alert("El nombre de la catorceava columna debe ser 'Tipo Cambio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dtFactura.Columns(14).ColumnName = "Fecha Vencimiento" Then
|
|
Alert("El nombre de la quinceava columna debe ser 'Fecha Vencimiento'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If RblFormato.SelectedValue = "1" Then
|
|
Dim NumRows As Integer = dtFactura.Rows.Count
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ErrorCompras As Boolean = False
|
|
Dim ObjConta As New ClsContabilidad(ObjCompras.IniciaTransacSQL())
|
|
Dim CveCompra As Integer
|
|
Dim Contador As Integer = 0
|
|
Dim ExisteCompra As Boolean = False
|
|
Dim DtProveedores = New DataTable
|
|
Dim ObjProve As New ClsCompProveedores
|
|
|
|
If ObjProve.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, -1, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
DtProveedores = ObjProve.DtResultados
|
|
End If
|
|
ObjProve.Dispose()
|
|
|
|
For Each Row As DataRow In dtFactura.FiltraParametros("RFC <> '' AND Folio <> '' ").Rows
|
|
Dim Sucursal As String = Row("Sucursal").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Serie As String = Row("Serie").ToString
|
|
Dim Folio As String = Row("Folio").ToString
|
|
Dim Fecha As Date = Row("Fecha").ToString.ToDate
|
|
Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal
|
|
Dim IVA As Decimal = Row("IVA").ToString.ToDecimal
|
|
Dim Total As Decimal = Row("Total").ToString.ToDecimal
|
|
Dim Saldo As Decimal = Row("Saldo").ToString.ToDecimal
|
|
Dim TipoDocto As String = Row("Tipo Documento").ToString
|
|
Dim CveProveedor As Integer = DtProveedores.FiltroPrimeroValor("CveProveedor", $"RFC = '{RFC}'").ToString.ToEntero
|
|
Dim CvePS As Integer = 0
|
|
Dim CveUnidadMedida As Integer = 0
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPS(-1, -1, CveEmpresa) Then
|
|
CvePS = ObjPS.DtResultados.FiltroPrimeroValor("CvePS").ToString.ToEntero
|
|
End If
|
|
ObjPS.Dispose()
|
|
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
If ObjUM.GetUnidadesMedida(CveEmpresa) Then
|
|
CveUnidadMedida = ObjUM.DtResultados.FiltraParametros($"CveEmpresa={CveEmpresa}").FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero
|
|
End If
|
|
ObjUM.Dispose()
|
|
|
|
Dim RetIVA As Double = Row("Ret IVA").ToString.ToDouble
|
|
Dim RetISR As Double = Row("Ret ISR").ToString.ToDouble
|
|
Dim Moneda As String = Row("Moneda").ToString
|
|
Dim TipoCambio As String = Row("Tipo Cambio").ToString
|
|
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate
|
|
Dim CveMoneda As Integer = 1
|
|
|
|
If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorCompras = True
|
|
If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorCompras = True
|
|
If Not CveProveedor > 0 Then Alert(String.Format("No se encontró el Proveedor con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorCompras = True : Exit For
|
|
TipoDocto = IIf(TipoDocto = "Ingresos", "Fac", "NC").ToString
|
|
|
|
'Moneda
|
|
If Moneda = "Pesos" Then
|
|
CveMoneda = 1
|
|
ElseIf Moneda = "Dólares" Then
|
|
CveMoneda = 2
|
|
End If
|
|
|
|
'Si no se especifica TC, se manda como pesos.
|
|
If TipoCambio = "" Then TipoCambio = "1"
|
|
|
|
'PrePóliza
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Compras/SaldoInicial", 1, Total, Total, CveMoneda, Fecha, "", 100, CveEmpresa)
|
|
If Not CvePrePoliza > 0 Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
|
|
'Compra
|
|
If Not ObjCompras.AddCompra(TipoDocto, "", Serie, Folio, "", CveProveedor.ToEntero, SubTotal, 0, 0, IVA, RetIVA, RetISR, 0, 0, 0, Total, Fecha, CveMoneda, TipoCambio.ToDouble, FechaVencimiento,
|
|
True, "", 1, CvePrePoliza, 100, CveEmpresa) Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
CveCompra = ObjCompras.CveCompra
|
|
|
|
'Compra Detalle
|
|
If Not ObjCompras.AddCompraDetalle(CveCompra, CveUnidadMedida, CvePS, -1, -1, 0, 1, SubTotal, 0.16, SubTotal, 0, "Carga Inicial", -1) Then
|
|
ErrorCompras = True
|
|
Exit For
|
|
End If
|
|
|
|
'PrePólizaDetalle
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio, IIf(TipoDocto = "Fac", 5, 18).ToString.ToEntero, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, SubTotal, Folio, 6, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, IVA, Folio, 14, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
|
|
|
'Saldo
|
|
If Saldo < Total Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Folio, 17, Folio, Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio, 95, Folio, Fecha, -1, -1, CveCompra:=CveCompra, CveProveedor:=CveProveedor) Then ErrorCompras = True : Exit For
|
|
End If
|
|
|
|
|
|
Next
|
|
If Not ErrorCompras Then
|
|
If Contador > 0 Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente.<br>Se Omitieron: <b>{1}</b> Compras ya que ya se encuentran registradas.", NumRows - Contador, Contador), TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
End If
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Compras correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
ObjCompras.Commit()
|
|
TxtAddFactura.Text = ""
|
|
UpCarga.Update()
|
|
Else
|
|
ObjCompras.RollBack()
|
|
End If
|
|
ObjCompras.Dispose()
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
|
|
Dim ErrorVentas As Boolean = False
|
|
Dim CveVenta As Integer
|
|
Dim NumRows As Integer = 0
|
|
Dim DtClientes = New DataTable
|
|
Dim CvePS As Integer = 0
|
|
Dim CveUnidadMedida As Integer = 0
|
|
' Dim ExisteVenta As Boolean = False
|
|
'Dim Contador As Integer = 0
|
|
Dim ObjCliente As New ClsClientes
|
|
If ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, CveEmpresa) Then
|
|
DtClientes = ObjCliente.DtResultados
|
|
End If
|
|
ObjCliente.Dispose()
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
If ObjPS.GetPS(-1, -1, CveEmpresa) Then
|
|
CvePS = ObjPS.DtResultados.FiltroPrimeroValor("CvePS").ToString.ToEntero
|
|
End If
|
|
ObjPS.Dispose()
|
|
|
|
Dim ObjUM As New ClsUnidadesMedida
|
|
If ObjUM.GetUnidadesMedida(CveEmpresa) Then
|
|
CveUnidadMedida = ObjUM.DtResultados.FiltraParametros($"CveEmpresa={CveEmpresa}").FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero
|
|
End If
|
|
ObjUM.Dispose()
|
|
|
|
|
|
If Not CvePS > 0 Then Alert(String.Format("No se encontró el Producto Servicio"), TipoMensaje.MsgError) : ErrorVentas = True
|
|
' If Not CveSucursal > 0 Then Alert("No se encontró la sucursal.", TipoMensaje.MsgError) : ErrorVentas = True
|
|
If Not CveUnidadMedida > 0 Then Alert(String.Format("No se encontró la Unidad de Medida."), TipoMensaje.MsgError) : ErrorVentas = True
|
|
|
|
For Each Row As DataRow In dtFactura.Rows
|
|
Dim Sucursal As String = Row("Sucursal").ToString
|
|
Dim TipoDocto As String = Row("Tipo Documento").ToString
|
|
Dim RFC As String = Row("RFC").ToString.Trim
|
|
Dim Serie As String = Row("Serie").ToString
|
|
Dim Folio As Integer = Row("Folio").ToString.ToEntero
|
|
Dim Fecha As Date = Row("Fecha").ToString.ToDate
|
|
Dim FechaVencimiento As Date = Row("Fecha Vencimiento").ToString.ToDate
|
|
Dim SubTotal As Decimal = Row("SubTotal").ToString.ToDecimal
|
|
Dim IVA As Decimal = Row("IVA").ToString.ToDecimal
|
|
Dim Total As Decimal = Row("Total").ToString.ToDecimal
|
|
Dim Saldo As Decimal = Row("Saldo").ToString.ToDecimal
|
|
Dim CveCliente As Integer = DtClientes.FiltroPrimeroValor("CveCliente", $"RFC = '{RFC}'").ToString.ToEntero
|
|
Dim RetIVA As Double = Row("Ret IVA").ToString.ToDouble
|
|
Dim RetISR As Double = Row("Ret ISR").ToString.ToDouble
|
|
Dim Moneda As String = Row("Moneda").ToString
|
|
Dim TipoCambio As String = Row("Tipo Cambio").ToString
|
|
Dim CveMoneda As Integer = 1
|
|
|
|
If Not CveCliente > 0 Then Alert(String.Format("No se encontró el cliente con el RFC: {0}", {RFC}), TipoMensaje.MsgError) : ErrorVentas = True : RFC.GuardaLog : Exit For
|
|
TipoDocto = IIf(TipoDocto = "Ingresos", "Ing", IIf(TipoDocto = "Egresos", "Egs", "Rem")).ToString
|
|
'PrePóliza
|
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Venta/SaldoIncial", 1, Total, Total, 1, Fecha, "", 100, CveEmpresa)
|
|
|
|
'Moneda
|
|
If Moneda = "Pesos" Then
|
|
CveMoneda = 1
|
|
ElseIf Moneda = "Dólares" Then
|
|
CveMoneda = 2
|
|
End If
|
|
|
|
'Si no se especifica TC, se manda como pesos.
|
|
If TipoCambio = "" Then TipoCambio = "1"
|
|
|
|
|
|
'Venta
|
|
If Not ObjVentas.AddVenta(TipoDocto, Folio, CveCliente.ToEntero, -1, SubTotal, 0, 0, IVA, RetIVA, RetISR, Total, CveMoneda, TipoCambio.ToDouble,
|
|
0, 0, 0, FechaVencimiento, Fecha, "", "", Fecha, 0, "", "", "", 0, 0, 0, "-1".ToDate, "-1".ToDate, "-1".ToDate, -1, -1, 0, CvePrePoliza,
|
|
100, CveEmpresa, Serie:=Serie, CveSubProyecto:=Sucursal.ToEntero, CveSubProyectoEjecucion:=Sucursal.ToEntero, CveSubProyectoCobranza:=Sucursal.ToEntero) Then
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
CveVenta = ObjVentas.CveVenta
|
|
|
|
If Not ObjVentas.AddVentaDetalle(CveVenta, CvePS, 1, CveUnidadMedida, SubTotal, 0.16, SubTotal, "Saldo Inicial", 0, 0, -1, 0) Then
|
|
ErrorVentas = True
|
|
Exit For
|
|
End If
|
|
|
|
|
|
'PrePólizaDetalle
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, SubTotal, Folio.ToString, 4, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente, CveClasificacion:=1) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total, Folio.ToString, 1, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, Folio.ToString, 13, String.Format("{0}-{1}", Serie, Folio), Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
|
|
'Saldo
|
|
If Saldo < Total Then
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, Total - Saldo, Folio.ToString, 2, Folio.ToString, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, Total - Saldo, Folio.ToString, 95, Folio.ToString, Fecha, -1, -1, CveVenta:=CveVenta, CveCliente:=CveCliente) Then ErrorVentas = True : Exit For
|
|
End If
|
|
|
|
Next
|
|
If Not ErrorVentas Then
|
|
Alert(String.Format("Se agregaron: <b>{0}</b> Ventas correctamente.", NumRows), TipoMensaje.MsgInformacion)
|
|
ObjVentas.Commit()
|
|
TxtAddFactura.Text = ""
|
|
UpCarga.Update()
|
|
Else
|
|
ObjVentas.RollBack()
|
|
End If
|
|
ObjVentas.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " PASO 6: FINALIZAR"
|
|
|
|
Private Sub CargaDdlUsuario()
|
|
DdlUsuario.Items.Clear()
|
|
Dim ObjUsuario As New ClsSisUsuarios
|
|
If ObjUsuario.GetUsuarios(-1) Then
|
|
DdlUsuario.DataSource = ObjUsuario.DtResultados.FiltraParametros($"CveEmpresa={CveEmpresa}")
|
|
DdlUsuario.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
DdlUsuario.DataBind()
|
|
End If
|
|
ObjUsuario.Dispose()
|
|
UpFinalizar.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnIniciarSesion_Click(sender As Object, e As EventArgs) Handles BtnIniciarSesion.Click
|
|
If DdlUsuario.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un usuario.", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Dim Liga As String = "/LogIn.aspx"
|
|
Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & DdlUsuario.SelectedValue.ToEntero & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & CveEmpresa)
|
|
Response.Redirect(LigaActivar, True)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " DESCARGA FORMATOS EXCEL "
|
|
Private Sub DescargarExcel(Tipo As String)
|
|
Dim Directorio As String = ""
|
|
Select Case Tipo
|
|
Case "Clasi"
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\FormatoClasificaciones.xlsx"
|
|
Case "UM"
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\FormatoUnidadesMedida.xlsx"
|
|
Case "PS"
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoPS.xlsx"
|
|
Case "Prove"
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoProveedores.xlsx"
|
|
Case "Cli"
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoClientes.xlsx"
|
|
Case "Fact"
|
|
If RblFormato.SelectedValue = "1" Then
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoProveedores-Facturas.xlsx"
|
|
End If
|
|
If RblFormato.SelectedValue = "2" Then
|
|
Directorio = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\SaldosIniciales\FormatoClientes-Facturas.xlsx"
|
|
End If
|
|
|
|
|
|
End Select
|
|
Dim Archivo As New IO.FileInfo(Directorio)
|
|
If Archivo.Exists Then
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
|
|
Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
Response.ContentType = "text/plain"
|
|
Response.Flush()
|
|
Response.TransmitFile(Archivo.FullName)
|
|
Response.End()
|
|
End If
|
|
End Sub
|
|
Protected Sub LnkDescargarExcelClasi_Click(sender As Object, e As EventArgs) Handles LnkDescargarExcelClasi.Click
|
|
DescargarExcel("Clasi")
|
|
End Sub
|
|
Protected Sub LnkDescargarExcelUM_Click(sender As Object, e As EventArgs) Handles LnkDescargarExcelUM.Click
|
|
DescargarExcel("UM")
|
|
End Sub
|
|
Protected Sub LnkDescargarExcelPS_Click(sender As Object, e As EventArgs) Handles LnkDescargarExcelPS.Click
|
|
DescargarExcel("PS")
|
|
End Sub
|
|
Protected Sub LnkDescargaProveedor(sender As Object, e As EventArgs) Handles LnkDescargaExcelProveedor.Click
|
|
DescargarExcel("Prove")
|
|
End Sub
|
|
|
|
Protected Sub LnkDescargarExcelCliente(sender As Object, e As EventArgs) Handles LnkDescargarExcelClientes.Click
|
|
DescargarExcel("Cli")
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " GUARDAR - NO SE DEBERIA USAR UN GUARDAR GENERAL, PORQUE SE GUARDA PESTAÑA POR PESTAÑA "
|
|
'Protected Sub LBGuardar_Click(sender As Object, e As EventArgs) Handles LBGuardar.Click
|
|
' Alert("Metodo guardar raro", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
|
|
' Dim ObjEmpresa As New ClsSisEmpresas
|
|
' Dim ObjRoles As New ClsSisRoles(ObjEmpresa.IniciaTransacSQL)
|
|
' Dim ObjUsuarios As New ClsSisUsuarios(ObjEmpresa.IniciaTransacSQL)
|
|
' Dim objClasi As New ClsClasificaciones(ObjEmpresa.IniciaTransacSQL)
|
|
' Dim objGenerales As New ClsGenerales(ObjEmpresa.IniciaTransacSQL)
|
|
' Dim Mensaje As New StringBuilder
|
|
|
|
' 'DatosFiscales
|
|
' Dim Direccion, NoExt, NoInt, Colonia, Ciudad, Estado, CP, Regimen, Contacto, Telefono, Ciec, Localidad, Extension As String
|
|
|
|
' 'Envio de correos
|
|
' Dim MailEnvio, ContraseñaEnvio, ServidorEnvio, PuertoEnvio, Protocolo As String
|
|
' Dim UsaSSLEnvio As Boolean
|
|
|
|
' 'RecepcionDeCorreos
|
|
' Dim MailRecep, ServidorRecep, PuertoRecep, UsuarioRecep, ContraseñaRecep As String
|
|
' Dim UsaSSLRecep As Boolean
|
|
|
|
' Dim CorrectoEmpresa = False
|
|
' Dim HuboError = False
|
|
|
|
' Direccion = TxtDireccion.Text.Trim
|
|
' NoExt = TxtNoExt.Text.Trim
|
|
' NoInt = TxtNoInt.Text.Trim
|
|
' Colonia = TxtColonia.Text.Trim
|
|
' Ciudad = TxtCiudad.Text.Trim
|
|
' Estado = TxtEstado.Text.Trim
|
|
' CP = TxtCP.Text.Trim
|
|
' Localidad = TxtLocalidad.Text
|
|
' Extension = TxtExtension.Text
|
|
|
|
' Regimen = DdlRegimen.SelectedValue
|
|
' Contacto = TxtContacto.Text.Trim
|
|
' Telefono = TxtTelefono.Text.Trim
|
|
' Ciec = TxtCIEC.Text.Trim
|
|
' MailEnvio = txtEnvioMail.Text.Trim
|
|
' ContraseñaEnvio = TxtContraseñaSend.Text.Trim
|
|
' ServidorEnvio = TxtServidor.Text.Trim
|
|
' PuertoEnvio = TxtSendMailPort.Text.Trim
|
|
' Protocolo = DDLProtocolo.SelectedValue.Trim
|
|
' UsaSSLEnvio = chkSSL.Checked
|
|
' MailRecep = txtRecepMail.Text.Trim
|
|
' ServidorRecep = TxtServidorRecep.Text.Trim
|
|
' PuertoRecep = TxtRecepMailPort.Text.Trim
|
|
' UsuarioRecep = TxtUsuarioRecep.Text.Trim
|
|
' ContraseñaRecep = TxtUsuarioRecep.Text.Trim
|
|
' UsaSSLRecep = chkSSLRecep.Checked
|
|
|
|
|
|
' If CveEmpresa = 0 Then
|
|
' If ObjEmpresa.AddEmpresa(-1, Empresa, Direccion, NoExt, NoInt, Colonia, Ciudad, Estado, RFC, CP.ToEntero, Telefono, Contacto, Correo, "CFDi", "", "", TxtContraKey.Text, TxtFiel.Text, TxtCSD.Text, "", "", 100, False, False, False, Regimen, False, MailEnvio, ContraseñaEnvio, ServidorEnvio, PuertoEnvio.ToEntero, UsaSSLEnvio, False, False, False, False, False, False, False, False, False,
|
|
' "", "", "", "", MailRecep, ServidorRecep, PuertoRecep.ToEntero, UsaSSLRecep, UsuarioRecep, ContraseñaRecep, Protocolo, "", "", 0, False, "", "", "", 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, "", "", -1, 0.0D, "", 0, False, 0.0D, "", "", 0, False, 0, 0, False, 0, 0, False, 0, CveMetodoPago:=MetodoPAgo, CvePAC:=1) Then
|
|
' CveEmpresa = ObjEmpresa.CveEmpresa
|
|
' If CveEmpresa > 0 Then
|
|
' CorrectoEmpresa = True
|
|
' Mensaje.Append("Agregar Empresa: Correcto ")
|
|
' Else
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Empresa: Incorrecto")
|
|
' End If
|
|
' End If
|
|
' If CorrectoEmpresa Then
|
|
' For Each row As DataRow In DtRoles.Rows
|
|
' Try
|
|
' If Not ObjRoles.AddRol(1, row("Rol").ToString, 100, CveEmpresa) Then
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Roles: Incorrecto")
|
|
' End If
|
|
' If Not HuboError Then
|
|
' For Each ModRow As DataRow In DtModulos.FiltraParametros(String.Format("CveRol = {0} ", row("CveRol").ToString)).Rows
|
|
' If Not ObjRoles.UpdateRolesModulos(ObjRoles.CveRol, ModRow("CveModulo").ToString.ToEntero, ModRow("Valor").ToString.ToEntero, 100) Then
|
|
' HuboError = True
|
|
' End If
|
|
' Next
|
|
' End If
|
|
' If Not HuboError Then
|
|
' For Each ProcRow As DataRow In DtProcesos.FiltraParametros(String.Format("CveRol = {0} ", row("CveRol").ToString)).Rows
|
|
' If Not ObjRoles.UpdateRolesProcesos(ObjRoles.CveRol, ProcRow("CveProceso").ToString.ToEntero, ProcRow("Valor").ToString.ToEntero, 100) Then
|
|
' HuboError = True
|
|
' End If
|
|
' Next
|
|
' End If
|
|
' Catch ex As Exception
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Roles: Incorrecto")
|
|
' OnError(ex.Message, ex)
|
|
' End Try
|
|
' Next
|
|
' End If
|
|
' If CorrectoEmpresa AndAlso TxtPlantillaVenta.Text <> String.Empty Then
|
|
' If Not ObjEmpresa.UpdatePlantillaMail("AsuntoPlantillaMailVenta", TxtAsunto.Text.Trim, "PlantillaMailVenta", TxtPlantillaVenta.Text.Trim, CveEmpresa) Then
|
|
' Alert("La plantilla de mail de ventas se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
' HuboError = True
|
|
' End If
|
|
' End If
|
|
' If CorrectoEmpresa AndAlso Not HuboError Then
|
|
' Mensaje.Append("Agregar Roles: Correcto")
|
|
' For Each row As DataRow In DtUsuarios.Rows
|
|
' Try
|
|
' If ObjUsuarios.AddUsuario(row("Usuario").ToString, ContraseñaPredeterminadaEncriptada, row("Nombre").ToString, -2, row("Correo").ToString, 0, 0, 0, True, 100, CveEmpresa, -1, row("rol").ToString) = -1 Then
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Usuarios: Incorrecto")
|
|
' End If
|
|
' Catch ex As Exception
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Usuarios: Incorrecto")
|
|
' OnError(ex.Message, ex)
|
|
' End Try
|
|
' Next
|
|
' End If
|
|
' If CorrectoEmpresa AndAlso Not HuboError Then
|
|
' Mensaje.Append("Agregar Usuarios: Correcto")
|
|
' If DtClasificaciones.Rows.Count > 0 Then
|
|
' objGenerales.AddCategorias("Categoria General", 100, CveEmpresa)
|
|
' For Each row As DataRow In DtClasificaciones.Rows
|
|
' If Not objClasi.AddClasificaciones(row("Clasificacion").ToString, "", 0, "", 0, "", 0, "", 0, 100, CveEmpresa) Then
|
|
' HuboError = True
|
|
' Mensaje.Append("Agregar Clasificaciones: Incorrecto")
|
|
' End If
|
|
' Next
|
|
' End If
|
|
' End If
|
|
' If CorrectoEmpresa AndAlso Not HuboError Then
|
|
' Try
|
|
' If TxtModalFielArchivo.getfiles().Archivos.Count > 0 Then
|
|
' Dim ArchivoFiel As Archivo = TxtModalFielArchivo.getfiles().Archivos(0)
|
|
' Dim Path As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Certificados"
|
|
' If Not Directory.Exists(Path) Then
|
|
' Directory.CreateDirectory(Path)
|
|
' End If
|
|
' Dim directorioNew As String = String.Format("{0}\{1}.{2}", Path, FIEL, ArchivoFiel.Extencion)
|
|
' If File.Exists(directorioNew) Then
|
|
' My.Computer.FileSystem.DeleteFile(directorioNew)
|
|
' End If
|
|
' My.Computer.FileSystem.MoveFile(ArchivoFiel.FileUrl, directorioNew)
|
|
' End If
|
|
|
|
' If TxtCSD.getfiles().Archivos.Count > 0 Then
|
|
' Dim ArchivoCSD As Archivo = TxtCSD.getfiles().Archivos(0)
|
|
' Dim PathCSD As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Certificados"
|
|
' Dim dirCSD As String = String.Format("{0}\{1}.{2}", PathCSD, CSD, ArchivoCSD.Extencion)
|
|
' If File.Exists(dirCSD) Then
|
|
' My.Computer.FileSystem.DeleteFile(dirCSD)
|
|
' End If
|
|
' My.Computer.FileSystem.MoveFile(ArchivoCSD.FileUrl, dirCSD)
|
|
' End If
|
|
|
|
' If TextLogo.getfiles().Archivos().Count > 0 Then
|
|
' Dim Logo As Archivo = TextLogo.getfiles().Archivos(0)
|
|
' Dim PathLogo As String = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\"
|
|
' Dim dirLogo As String = String.Format("{0}\logo.{1}", PathLogo, Logo.Extencion)
|
|
' If File.Exists(dirLogo) Then
|
|
' My.Computer.FileSystem.DeleteFile(dirLogo)
|
|
' End If
|
|
' My.Computer.FileSystem.MoveFile(Logo.FileUrl, dirLogo)
|
|
' End If
|
|
|
|
' If TxtFormatoFactura.getfiles().Archivos().Count > 0 Then
|
|
' Dim FormatoFactura As Archivo = TxtFormatoFactura.getfiles().Archivos(0)
|
|
' Dim PathFormato = $"{ModExtensiones.DirectorioBaseEmpresas}Empresas\{CveEmpresa}\Formatos\"
|
|
' Dim dirFormato As String = String.Format("{0}\Factura.{1}", PathFormato, FormatoFactura.Extencion)
|
|
' If File.Exists(dirFormato) Then
|
|
' My.Computer.FileSystem.DeleteFile(dirFormato)
|
|
' End If
|
|
' My.Computer.FileSystem.MoveFile(FormatoFactura.FileUrl, dirFormato)
|
|
' End If
|
|
' Catch ex As Exception
|
|
' HuboError = True
|
|
' OnError(ex.Message, ex)
|
|
' End Try
|
|
' End If
|
|
|
|
' If Not HuboError AndAlso CorrectoEmpresa Then
|
|
' ObjEmpresa.Commit()
|
|
' Alert("La información de la nueva empresa de guardó correctamente", TipoMensaje.MsgInformacion)
|
|
' Else
|
|
' ObjEmpresa.RollBack()
|
|
' Alert("Ocurrió un error al guardar los datos de la empresa", TipoMensaje.MsgError)
|
|
' End If
|
|
' ObjEmpresa.Dispose()
|
|
' ElseIf CveEmpresa > 0 Then
|
|
' If ObjEmpresa.UpdateEmpresaXWizard(TxtNomEmpresa.Text, Direccion, NoExt, NoInt, Colonia, Ciudad, Estado, TxtRFC.Text, CP.ToEntero, Telefono, Contacto, TxtEmail.Text, Regimen, MailEnvio, ContraseñaEnvio, ServidorEnvio, PuertoEnvio.ToEntero, UsaSSLEnvio, MailRecep, ServidorRecep, PuertoRecep.ToEntero,
|
|
' UsaSSLRecep, UsuarioRecep, ContraseñaRecep, CveEmpresa, Protocolo, Localidad, Extension, Ciec, TxtFiel.Text, TxtCSD.Text, TxtContraKey.Text) Then
|
|
' CorrectoEmpresa = True
|
|
' End If
|
|
' If CorrectoEmpresa Then
|
|
' If Not ObjEmpresa.UpdatePlantillaMail("AsuntoPlantillaMailVenta", TxtAsunto.Text.Trim, "PlantillaMailVenta", TxtPlantillaVenta.Text.Trim, CveEmpresa) Then
|
|
' CorrectoEmpresa = False
|
|
' End If
|
|
' End If
|
|
|
|
' If DtModulos IsNot Nothing Then
|
|
' For Each ModRow As DataRow In DtModulos.Rows
|
|
' If Not ObjRoles.UpdateRolesModulos(ModRow("CveRol").ToString.ToEntero, ModRow("CveModulo").ToString.ToEntero, ModRow("Valor").ToString.ToEntero, 100) Then
|
|
' CorrectoEmpresa = False
|
|
' End If
|
|
' Next
|
|
' End If
|
|
|
|
' If DtProcesos IsNot Nothing Then
|
|
' For Each ProcRow As DataRow In DtProcesos.Rows
|
|
' If Not ObjRoles.UpdateRolesProcesos(ProcRow("CveRol").ToString.ToEntero, ProcRow("CveProceso").ToString.ToEntero, ProcRow("Valor").ToString.ToEntero, 100) Then
|
|
' HuboError = True
|
|
' End If
|
|
' Next
|
|
' End If
|
|
|
|
' If CorrectoEmpresa Then
|
|
' ObjEmpresa.Commit()
|
|
' Alert("Se actualizaron los datos de la empresa", TipoMensaje.MsgInformacion)
|
|
' Else
|
|
' ObjEmpresa.RollBack()
|
|
' Alert("Ocurrió un error al acualizar los datos de la empresa", TipoMensaje.MsgError)
|
|
' End If
|
|
' ObjEmpresa.Dispose()
|
|
' End If
|
|
'End Sub
|
|
#End Region
|
|
|
|
End Class
|