Files
SIG/AIMMGM/ConsultaCliente.aspx.vb
2023-10-09 11:55:07 -07:00

916 lines
45 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports System.Drawing
Imports Extensiones
'Imports Microsoft.Office.Interop.Excel
'Imports msExcel = Microsoft.Office.Interop.Excel
'Imports VBIDE
Partial Class AIMMGM_ConsultaCliente
Inherits ClsPaginas
Private Shared missing As Object = System.Reflection.Missing.Value
'Configuración
Private Property CveCliente As Integer
Get
Return ViewState("CveCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCliente") = value
End Set
End Property
Private Property CveVentaDetalle As Integer
Get
Return ViewState("CveVentaDetalle").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveVentaDetalle") = value
End Set
End Property
Private Property DtCompras As Data.DataTable
Get
Return CType(ViewState("DtCompras"), Data.DataTable)
End Get
Set(value As Data.DataTable)
ViewState("DtCompras") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Session("FileUpload") = ""
ViewState("Orden") = ""
ViewState("ONombre") = "Nombre DESC"
TxtFecha.Text = NowADS().ToShortDateString
If Request("CveCliente") IsNot Nothing Then
CveCliente = Request("CveCliente").ToString.ToEntero()
Else
CveCliente = UsuarioActual.CveCliente
End If
CveVentaDetalle = -1
If UsuarioActual.CveUsuario = 136 Then
imgP.Visible = False
Lbl.Visible = False
End If
'cargo usuarios y verifico permisos
'Configuración de Modalidad Update
'BtnGuardar.Text = "Guardar"
LtlTitulo.Text = "Portal del Cliente"
Dim ObjClientes As New ClsClientes
If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
LtlTitulo.Text = "Portal del Cliente: " & ObjClientes.Nombre
CargaCompras(CveCliente)
CargaPagos(CveCliente)
DdlMetodoPago.DataSource = DirectCast(Application("GlobalDTMetodosPago"), Data.DataTable).FiltraParametros("CveMetodoPago IN (1,2,3,4,5)")
DdlMetodoPago.DataBind()
TxtNombre.Text = ObjClientes.Nombre
TxtNombreComercial.Text = ObjClientes.NombreComercial
TxtDireccion.Text = ObjClientes.Direccion
TxtNoExt.Text = ObjClientes.NoExt
TxtNoInt.Text = ObjClientes.NoInt
TxtColonia.Text = ObjClientes.Colonia
TxtLocalidad.Text = ObjClientes.Localidad
TxtCiudad.Text = ObjClientes.Ciudad
TxtEstado.Text = ObjClientes.Estado
TxtRFC.Text = ObjClientes.RFC
TxtCP.Text = ObjClientes.CP.ToString
TxtTelefono.Text = ObjClientes.Telefono
TxtContacto.Text = ObjClientes.Contacto
TxtEmail.Text = ObjClientes.Mail
TxtPagina.Text = ObjClientes.Pagina
TxtGiro.Text = ObjClientes.Giro
TxtProfesion.Text = ObjClientes.ConvenioCIE
TxtNumCtaPago.Text = ObjClientes.NumCtaPago
DdlMetodoPago.SelectedValue = ObjClientes.CveMetodoPago.ToString
BtnGuardar.Visible = True
HplComprar.Visible = True
HplComprar.NavigateUrl = String.Format("PopRegistro.aspx?CveCliente={0}&TB_iframe=true&height=450&width=980", CveCliente)
HplComprar.Target = "_blank"
End If
End If
ObjClientes.Dispose()
If UsuarioActual.CveRol.Contiene(1, 1022) Then
GVMisCompras.Columns(4).Visible = True
GVMisCompras.Columns(5).Visible = True
GVMisCompras.Columns(6).Visible = True
GVMisCompras.Columns(7).Visible = True
GVMisCompras.Columns(8).Visible = True
GvPagos.Columns(6).Visible = True
End If
'End If
End If
End Sub
Private Sub CargaCompras(CveCliente As Integer)
Dim DtDatosCompras As New Data.DataTable
DtDatosCompras.Columns.Add("PS", Type.GetType("System.String"))
DtDatosCompras.Columns.Add("Clasificacion", Type.GetType("System.String"))
DtDatosCompras.Columns.Add("Obs", Type.GetType("System.String"))
DtDatosCompras.Columns.Add("Fecha", Type.GetType("System.DateTime"))
DtDatosCompras.Columns.Add("Total", Type.GetType("System.Double"))
DtDatosCompras.Columns.Add("CveVentaDetalle", Type.GetType("System.Int32"))
DtDatosCompras.Columns.Add("CveVenta", Type.GetType("System.Int32"))
DtDatosCompras.Columns.Add("VentaMovs", Type.GetType("System.Int32")) 'registro el numero de movimientos detalle que tiene la venta, para saber si la elimino o solo la actualizo
Dim TieneStand As Boolean = False
Dim ObjClientes As New ClsClientes()
If ObjClientes.GetHistorialVentas(CveCliente) Then
If ObjClientes.DtResultados.Rows.Count > 0 Then
Dim dt As Data.DataTable = ObjClientes.DtResultados
Dim Venta As New ClsVentas
Dim AIM As New ClsAIMMGM
For Each dr As DataRow In dt.Rows
If AIM.GetVentas(CveCliente) Then
DtDatosCompras = AIM.DtResultados
End If
Next
Venta.Dispose()
GVMisCompras.DataSource = DtDatosCompras
DtCompras = DtDatosCompras
If DtDatosCompras.Rows.Count = 0 Then
CveVentaDetalle = DtDatosCompras.MIN("CveVentaDetalle").ToEntero
Else
CveVentaDetalle = -1
End If
Else
GVMisCompras.DataSource = Nothing
End If
Else
GVMisCompras.DataSource = Nothing
End If
ObjClientes.Dispose()
GVMisCompras.DataBind()
'If TieneStand Then
' TxtImporte.ReadOnly = False
'Else
' If DtCompras IsNot Nothing Then
' TxtImporte.Text = DtCompras.SUM("Total")
' End If
'End If
End Sub
Private Sub CargaPagos(CveCliente As Integer)
Dim Pagado As Double = 0
Dim AIM As New ClsAIMMGM
If AIM.GetPagos(CveCliente, -1) Then
GvPagos.DataSource = AIM.DtResultados
If AIM.DtResultados.Rows.Count > 0 Then
Pagado = AIM.DtResultados.SUM("Importe")
End If
End If
AIM.Dispose()
GvPagos.DataBind()
LblSaldo.Text = (DtCompras.SUM("Total") - Pagado).FormatoNumero
End Sub
'Private Sub CargaDatosCliente()
' Dim ObjClientes As New ClsClientes()
' If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, 43) Then
' If ObjClientes.DtResultados.Rows.Count > 0 Then
' 'Campos para Modificación
' TxtNombre.Text = ObjClientes.Nombre
' TxtNombreComercial.Text = ObjClientes.NombreComercial
' TxtDireccion.Text = ObjClientes.Direccion
' TxtNoExt.Text = ObjClientes.NoExt
' TxtNoInt.Text = ObjClientes.NoInt
' TxtColonia.Text = ObjClientes.Colonia
' TxtLocalidad.Text = ObjClientes.Localidad
' TxtCiudad.Text = ObjClientes.Ciudad
' TxtEstado.Text = ObjClientes.Estado
' TxtRFC.Text = ObjClientes.RFC
' TxtCP.Text = ObjClientes.CP.ToString
' TxtTelefono.Text = ObjClientes.Telefono
' TxtContacto.Text = ObjClientes.Contacto
' TxtEmail.Text = ObjClientes.Mail
' TxtPagina.Text = ObjClientes.Pagina
' TxtGiro.Text = ObjClientes.Giro
' TxtNumCtaPago.Text = ObjClientes.NumCtaPago
' DdlMetodoPago.SelectedValue = ObjClientes.CveMetodoPago.ToString
' Else
' Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
' End If
' End If
' ObjClientes.Dispose()
'End Sub
Protected Sub GVMisCompras_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GVMisCompras.RowCommand
If e.CommandName = "Eliminar" Then
Dim Retorno As Boolean = True
'PARAMETROS:
'0. CveVenta, 1. CveVentaDetalle, 2.Clasificacion, 3.MovimientosVentas, 4.Total
Dim S As String() = e.CommandArgument.ToString.Split("|"c)
Dim CveVenta, CveVentaDetalle, MovimientosVentas As Integer
Dim Clasificacion As String
Dim Total As Double = S(4).ToDouble
CveVenta = S(0).ToEntero : CveVentaDetalle = S(1).ToEntero : Clasificacion = S(2).ToString : MovimientosVentas = S(3).ToEntero
Dim Venta As New ClsVentas
Dim AIM As New ClsAIMMGM(Venta.IniciaTransacSQL)
Select Case Clasificacion
Case "Stand"
'libero el stand
Retorno = AIM.LiberaStand(CveVentaDetalle)
Case "Espacios Promocionales"
'libero publicidad
Retorno = AIM.LiberaPatrocinio(CveVentaDetalle)
End Select
If Retorno Then
'se actualiza
If Venta.RemoveVentasDetalle(CveVenta, CveVentaDetalle) Then
'NECESITO VERIFICAR SI ES STAND, O PATROCIONIO PARA LIBERAR LAS UBICACIONES
If Venta.GetVenta(CveVenta, 43) Then
Dim dr As DataRow = Venta.DtResultados.Rows(0)
Venta.UpdateVentas(dr("SubTotal").ToString.ToDouble - Total, 0, 0, dr("SubTotal").ToString.ToDouble - Total, 1, 1, dr("Fecha").ToString.ToDate, "", 43, CveVenta, "Rem")
Alert("El Registro ha sido eliminado", TipoMensaje.MsgInformacion)
If MovimientosVentas.ToEntero = 1 Then 'se cancela la venta en su totalidad
Venta.UpdateEstatusFactura(4, "", "", NowADS(), CveVenta)
End If
Venta.Commit()
CargaCompras(CveCliente)
Else
Venta.RollBack()
End If
Else
Venta.RollBack()
End If
Else
Venta.RollBack()
End If
Venta.Dispose()
AIM.Dispose()
Else
If e.CommandName = "Imprimir" Then
Dim S As String() = e.CommandArgument.ToString.Split("|"c)
Dim dt As New Data.DataTable
dt.Columns.Add("Expositor", Type.GetType("System.String"))
dt.Columns.Add("Empresa", Type.GetType("System.String"))
dt.Columns.Add("Telefono", Type.GetType("System.String"))
dt.Columns.Add("Correo", Type.GetType("System.String"))
dt.Columns.Add("Pagina", Type.GetType("System.String"))
dt.Columns.Add("CvePS", Type.GetType("System.Int32"))
Dim dr As DataRow = dt.NewRow
dr("Expositor") = S(0)
dr("Empresa") = S(1)
dr("Correo") = S(2)
dr("Telefono") = S(3)
dr("Pagina") = S(4)
dr("CvePS") = S(5)
dt.Rows.Add(dr)
GeneraPDF(dt, 10)
End If
End If
End Sub
Private Function GeneraPDF(dtMovs As Data.DataTable, Opcion As Integer) As Boolean
Dim Retorno As Boolean = False
'Dim Excel As msExcel.Application = New msExcel.Application()
'Dim VB_Module As VBComponent = Nothing
'Excel.Visible = True
'Excel.ScreenUpdating = True
'Excel.DisplayAlerts = True
'Dim pdfFileOut As String
'Dim xlsxFileOut As String
'Dim Ruta As String = String.Format("{0}\AIMMGM\Gafetes\", ModExtensiones.DirectorioBaseEmpresas)
'If IO.File.Exists(Ruta & "FormatoAIMMGM.xlsx") Then
' IO.File.Copy(Ruta & "FormatoAIMMGM.xlsx", Ruta & "FormatoAIMMGM2.xlsx", True)
'End If
'Dim ArchivoBase As New System.IO.FileInfo(Ruta & "FormatoAIMMGM2.xlsx")
'ArchivoBase.CopyTo(Ruta & "FormatoAIMMGM33.xlsx", True)
''Dim ArchivoTemp As New System.IO.FileInfo("c:\inetpub\wwwVentas\AIMMGM\Gafetes\FormatoAIMMGM3.xlsx")
''Dim ArchivoBase As New System.IO.FileInfo(String.Format("{0}Formatos\OrdenCompra.xlsm", UsuarioActual.Empresa.Ruta))
''If ArchivoBase.CopyTo(String.Format("{0}Formatos\OC-{1}.xlsm", UsuarioActual.Empresa.Ruta, pCveOrdenCompra), True) IsNot Nothing Then
''Dim ArchivoTemp As New System.IO.FileInfo(String.Format("{0}Formatos\OC-{1}.xlsm", UsuarioActual.Empresa.Ruta, pCveOrdenCompra))
'Dim Libro As msExcel.Workbook = Excel.Workbooks.Open(Ruta & "FormatoAIMMGM33.xlsx", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
'Libro.Activate()
'Dim Hoja As msExcel.Worksheet = CType(Libro.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
'Hoja.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible
'Hoja.Activate()
'Try
' ' Hoja.Range("G1:G1").Value = FechaExpedicion.ToShortDateString
' 'Hoja.Range("B3:B3").Value = PagueseA
' 'Hoja.Range("G3:G3").Value = Importe.ToString("N2")
' ''Generales
' ''Hoja.Range("G2:G2").Value = Folio
' 'Hoja.Range("B4:B4").Value = TextoImporte
' 'Hoja.Range("B6:B6").Value = Observacion
' 'Hoja.Range("C10:C10").Value = UsuarioRegistro
' 'Hoja.Range("F6:F6").Value = SubProyecto
' Dim CeldaI As Integer = 2
' Dim CeldaF As Integer = 2
' Dim Top, Left As Single
' Dim CBB As String
' Left = 0
' Dim Imagen As Bitmap
' Dim i As Integer = 0
' For Each Row As DataRow In dtMovs.Rows
' 'Cantidad
' 'If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
' Hoja.Range("A" & CeldaF - 1 & ":A" & CeldaF - 1).RowHeight = 60
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).RowHeight = 50
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Cells.VerticalAlignment = XlVAlign.xlVAlignCenter
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Cells.VerticalAlignment = XlVAlign.xlVAlignCenter
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Cells.HorizontalAlignment = XlHAlign.xlHAlignCenter
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Cells.HorizontalAlignment = XlHAlign.xlHAlignCenter
' 'Hoja.Range("C" & CeldaF & ":C" & CeldaF).VerticalAlignment = Top
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).ColumnWidth = 49
' Hoja.Range("B" & CeldaF & ":B" & CeldaF).ColumnWidth = 2
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).ColumnWidth = 49
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Font.Size = 23
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Font.Size = 23
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Font.Bold = True
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Font.Bold = True
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).WrapText = True
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).WrapText = True
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Value = Row("Expositor").ToString.ToUpper()
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Value = Row("Expositor").ToString.ToUpper()
' 'Unidad
' 'If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight = 35
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).Value = If(Row("CvePS").ToString.ToEntero = 36976, "Estudiante", Row("Empresa").ToString)
' Hoja.Range("C" & CeldaF + 1 & ":C" & CeldaF + 1).Value = If(Row("CvePS").ToString.ToEntero = 36976, "Estudiante", Row("Empresa").ToString)
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).Font.Size = 13
' Hoja.Range("C" & CeldaF + 1 & ":C" & CeldaF + 1).Font.Size = 13
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).Cells.HorizontalAlignment = XlHAlign.xlHAlignCenter
' Hoja.Range("C" & CeldaF + 1 & ":C" & CeldaF + 1).Cells.HorizontalAlignment = XlHAlign.xlHAlignCenter
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).Cells.VerticalAlignment = XlVAlign.xlVAlignCenter
' Hoja.Range("C" & CeldaF + 1 & ":C" & CeldaF + 1).Cells.VerticalAlignment = XlVAlign.xlVAlignCenter
' Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).WrapText = True
' Hoja.Range("C" & CeldaF + 1 & ":C" & CeldaF + 1).WrapText = True
' 'Concepto y Descripción
' 'Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = If(Row("Cargo").ToString.ToDouble > 0, Row("Cargo").ToString.ToDouble.FormatoNumero, "")
' 'P Unitario
' 'Morro el precio unitario si va a ir?
' 'Hoja.Range("G" & CeldaF & ":G" & CeldaF).Value = If(Row("Abono").ToString.ToDouble > 0, Row("Abono").ToString.ToDouble.FormatoNumero, "")
' Top = CSng(Hoja.Range("A" & (3 + CeldaF).ToString & ":C" & (4 + CeldaF).ToString).Top) - 18
' CBB = String.Format(Ruta & "\QR-{0}.jpg", i)
' Select Case Opcion
' Case 3
' Dim tam As Integer = 25
' If Row("Expositor").ToString.Length <= 15 Then
' tam = 30
' End If
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Font.Size = tam
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Font.Size = tam
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).RowHeight = 50 + 100
' 'Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight = Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight - 10
' CeldaF = CeldaF + 35 ' 17
' Case 4, 5
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Font.Size = 35
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Font.Size = 35
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).RowHeight = 50 + 100
' 'Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight = Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight - 10
' CeldaF = CeldaF + 35 ' 17
' Case 6
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Font.Size = 30
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Font.Size = 30
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).RowHeight = 50 + 100
' 'Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight = Hoja.Range("A" & CeldaF + 1 & ":A" & CeldaF + 1).RowHeight - 10
' CeldaF = CeldaF + 35 ' 17
' Case Else
' Imagen = GenerateQRCode(String.Format("{0}{4}|{1}|{2}|{3}", Row("Empresa"), Row("Expositor"), Row("Telefono"), Row("Correo"), If(Row("Pagina").ToString.Trim <> "", String.Format("({0})", Row("Pagina")), "")))
' Imagen.Save(CBB)
' Hoja.Shapes.AddPicture(CBB, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, Left, Top, 62, 62)
' Hoja.Shapes.AddPicture(CBB, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, Left + 278, Top, 62, 62)
' CeldaF = CeldaF + 39 ' 17
' End Select
' i += 1
' 'If dtMovs.Rows.Count > 1 AndAlso CeldaF - CeldaI < dtMovs.Rows.Count - 1 Then
' ' CeldaF = CeldaF + 1
' ' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
' ' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
' ' Libro.Save()
' ' Libro.Application.DisplayAlerts = False
' ' Libro.Application.ScreenUpdating = False
' 'End If
' Next
' Libro.Save()
' Libro.Application.DisplayAlerts = False
' Libro.Application.ScreenUpdating = False
' Dim AddedRow As Integer = CeldaF - CeldaI
' Dim EsVistaPrevia As Boolean = True
' xlsxFileOut = String.Format("Format{0}-{1}.xlsx", Opcion, NowADS().Ticks)
' 'Exportar PDF
' pdfFileOut = String.Format("Format{0}-{1}.pdf", Opcion, NowADS().Ticks)
' Dim outputFileName As Object = Ruta & xlsxFileOut
' If IO.File.Exists(Ruta & "FormatoAIMMGM33.xlsx") Then
' IO.File.Copy(Ruta & "FormatoAIMMGM33.xlsx", outputFileName.ToString, True)
' End If
' Dim fileFormat As msExcel.XlFixedFormatType = msExcel.XlFixedFormatType.xlTypePDF
' 'Libro.ExportAsFixedFormat(fileFormat, outputFileName, missing, missing, missing, missing, missing, missing, missing)
' Dim Descargas As New StringBuilder()
' Descargas.AppendFormat("<li><a class=""Texto"" target='_blank' href=""/AIMMGM/Gafetes/{0}"">Impresion</a></li>", xlsxFileOut)
' 'Descargas.AppendFormat("<li><a class=""Texto"" href=""/Contabilidad/Poliza.aspx?IdPoliza={0}"">Póliza</a></li>", pIDPoliza)
' ''Descargas.AppendFormat("<li><a class=""Texto"" href=""/Ventas/PopUpImprimir.aspx?CveVenta=" & pCveOrdenCompra & "&Ext=CadenaOriginal"">Cadena Original</a></li>", UsuarioActual.CveEmpresa, Folio)
' Alert("<br />La impresión se generó correctamente.<br /><br /><br />Descargas:<ul>" & Descargas.ToString & "</ul>", TipoMensaje.MsgInformacion)
' Retorno = True
'Catch ex As Exception
' ' LblMsg.Text = ex.Message
' Alert("<br />La impresión no se generó correctamente.<br /><br /><br />" & ex.Message, TipoMensaje.MsgInformacion)
'End Try
'System.Runtime.InteropServices.Marshal.ReleaseComObject(Hoja)
'Hoja = Nothing
'Dim saveChanges As Object = msExcel.XlSaveAction.xlDoNotSaveChanges
'CType(Libro, msExcel._Workbook).Close(saveChanges, missing, missing)
'System.Runtime.InteropServices.Marshal.ReleaseComObject(Libro)
'Libro = Nothing
'Excel.Quit()
'System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
'Excel = Nothing
'GC.Collect()
'GC.WaitForPendingFinalizers()
'ArchivoTemp.Delete()
Return Retorno
End Function
Private Function GenerateQRCode(Cadena As String) As Bitmap
'Dim Encoder As New Gma.QrCodeNet.Encoding.QrEncoder(Gma.QrCodeNet.Encoding.ErrorCorrectionLevel.L)
'Dim Code As Gma.QrCodeNet.Encoding.QrCode = Encoder.Encode(Cadena)
'Dim TempBMP As New Bitmap(Code.Matrix.Width, Code.Matrix.Height)
'For X As Integer = 0 To Code.Matrix.Width - 1
' For Y As Integer = 0 To Code.Matrix.Height - 1
' If Code.Matrix.InternalArray(X, Y) Then TempBMP.SetPixel(X, Y, Color.Black) Else TempBMP.SetPixel(X, Y, Color.White)
' Next
'Next
'Return TempBMP
Return Nothing
End Function
Protected Sub GVMisCompras_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GVMisCompras.RowEditing
GVMisCompras.EditIndex = e.NewEditIndex
GVMisCompras.DataSource = DtCompras
GVMisCompras.DataBind()
End Sub
Protected Sub GVMisCompras_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GVMisCompras.RowUpdating
Dim tCveVentaDetalle As Integer = e.Keys("CveVentaDetalle").ToString.ToEntero
Dim Obs As String = GVMisCompras.Rows(e.RowIndex).FCTextBox("TxtObs").Text
Dim AIM As New ClsAIMMGM
If AIM.UpdateVentaDetalleReferencia(Obs, tCveVentaDetalle) Then
GVMisCompras.EditIndex = -1
CargaCompras(CveCliente)
End If
AIM.Dispose()
GVMisCompras.DataSource = DtCompras
GVMisCompras.DataBind()
End Sub
Protected Sub GVMisCompras_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) Handles GVMisCompras.RowCancelingEdit
GVMisCompras.EditIndex = -1
GVMisCompras.DataSource = DtCompras
GVMisCompras.DataBind()
End Sub
Protected Sub GVMisCompras_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVMisCompras.RowDataBound
If e.Row.RowType = DataControlRowType.Footer Then
Dim Imp As Double = CType(GVMisCompras.DataSource, Data.DataTable).SUM("Total")
e.Row.FCLabel("LblTotal").Text = Imp.FormatoNumero()
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
'If e.Row.DBCampo("Clasificacion") <> "Stand" Then e.Row.FCLiteral("LtlObs").Text = ""
End If
End Sub
Protected Sub GvPagos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvPagos.RowCommand
If e.CommandName = "Eliminar" Then
Dim CvePago As Integer = e.CommandArgument.ToString.ToEntero
Dim AIM As New ClsAIMMGM()
'se actualiza
If AIM.RemovePago(CvePago) Then
Alert("El Pago se ha eliminado", TipoMensaje.MsgInformacion)
CargaPagos(CveCliente)
End If
AIM.Dispose()
End If
End Sub
Protected Sub GvPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPagos.RowDataBound
If e.Row.RowType = DataControlRowType.Footer Then
Dim Imp As Double = CType(GvPagos.DataSource, Data.DataTable).SUM("Importe")
e.Row.FCLabel("LblTotal").Text = Imp.FormatoNumero()
ElseIf e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("Archivo") <> "" Then
e.Row.FCHyperLink("ImgArchivo").NavigateUrl = String.Format("/Empresas/{0}/Documentos/{1}", UsuarioActual.CveEmpresa, e.Row.DBCampo("Archivo"))
End If
If e.Row.DBCampo("Pagado") = "True" AndAlso e.Row.DBCampo("Validado") = "False" Then
e.Row.FCLiteral("LtlEstatus").Text = "Sin Validar"
ElseIf e.Row.DBCampo("Validado") = "True" AndAlso e.Row.DBCampo("Facturado") = "False" Then
e.Row.FCLiteral("LtlEstatus").Text = "Validado"
ElseIf e.Row.DBCampo("Validado") = "True" AndAlso e.Row.DBCampo("Facturado") = "True" Then
e.Row.FCLiteral("LtlEstatus").Text = "Facturado"
Else
e.Row.FCLiteral("LtlEstatus").Text = "Registrado"
End If
If e.Row.DBCampo("Validado") = "False" Then
e.Row.FCImageButton("ImgEliminar").Visible = True
End If
If e.Row.DBCampo("xml") <> "" Then
e.Row.FCHyperLink("ImgDownXML").NavigateUrl = String.Format("/Empresas/{0}/Compras/{1}", UsuarioActual.CveEmpresa, e.Row.DBCampo("XML"))
e.Row.FCHyperLink("ImgDownXML").Visible = True
End If
If e.Row.DBCampo("pdf") <> "" Then
e.Row.FCHyperLink("ImgDownPDF").NavigateUrl = String.Format("/Empresas/{0}/Compras/{1}", UsuarioActual.CveEmpresa, e.Row.DBCampo("PDF"))
e.Row.FCHyperLink("ImgDownPDF").Visible = True
End If
End If
End Sub
Protected Sub BtnComprobante_Click(sender As Object, e As EventArgs) Handles BtnComprabante.Click
'If Not FUComprobante.HasFile Then
' Alert("Ingrese por favor el comprobante")
' Exit Sub
'End If
If TxtImporte.Text.ToDouble <= 0 Then
Alert("Ingrese un importe", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtImporte.Text.ToDouble > LblSaldo.Text.ToDouble Then
Alert("Ingrese un importe menor al saldo", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim AIM As New ClsAIMMGM
If Not IO.Directory.Exists(String.Format("{0}Documentos", UsuarioActual.Empresa.Ruta)) Then
IO.Directory.CreateDirectory(String.Format("{0}Documentos", UsuarioActual.Empresa.Ruta, UsuarioActual.CveEmpresa))
End If
Dim Cve As Integer = AIM.AddPago(CveCliente, CveVentaDetalle, TxtImporte.Text.ToDouble, 1, TxtFecha.Text.ToDate, IO.Path.GetExtension(FUComprobante.FileName), TxtObservaciones.Text.Trim, 9999, TxtAprobacion.Text.ToEntero)
If Cve > 0 Then
FUComprobante.SaveAs(String.Format("{0}Documentos/{1}{2}", UsuarioActual.Empresa.Ruta, Cve, IO.Path.GetExtension(FUComprobante.FileName)))
Alert("Pago ingresado correctamente", TipoMensaje.MsgInformacion)
End If
AIM.Dispose()
CargaPagos(CveCliente)
End Sub
Protected Sub BtnSubirLogo_Click(sender As Object, e As EventArgs) Handles BtnSubirLogo.Click
If Not FULogo.HasFile Then
Alert("Seleccione el logo de su empresa", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'obtengo la clave de la publicidad
If Not IO.Directory.Exists(String.Format("{0}Documentos", UsuarioActual.Empresa.Ruta)) Then
IO.Directory.CreateDirectory(String.Format("{0}Documentos", UsuarioActual.Empresa.Ruta))
End If
Dim Logo As String
Dim CvePublicidad As Integer
Dim AIM As New ClsAIMMGM
If AIM.GetPublicidad(CveCliente) Then
If AIM.DtResultados.Rows.Count > 0 Then
CvePublicidad = AIM.DtResultados.Rows(0)("CvePublicidad").ToString.ToEntero
Logo = String.Format("Logo{0}{1}", CvePublicidad, IO.Path.GetExtension(FULogo.FileName))
FULogo.SaveAs(String.Format("{0}Documentos/{2}", UsuarioActual.Empresa.Ruta, Logo))
AIM.UpdateLogo(CvePublicidad, Logo)
ImgLogo.ImageUrl = String.Format("{0}/Documentos/{1}", UsuarioActual.Empresa.Ruta, Logo)
End If
End If
AIM.Dispose()
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
Dim ObjClientes As New ClsClientes()
If CveCliente = -1 Then
'If ObjClientes.AddCliente(TxtNombre.Text.Trim, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtCiudad.Text.Trim, TxtLocalidad.Text.Trim, TxtEstado.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim,
' TxtTelefono.Text.Trim, TxtContacto.Text.Trim, TxtEmail.Text.Trim, False, DdlSucursal.SelectedValue.ToEntero, TxtRetIVA.Text.ToDouble,
' TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtNombreCorto.Text.Trim, TxtVendedor.Text.Trim, TxtPlazoCobranza.Text.Trim.ToEntero,
' TxtSucursalCliente.Text.Trim, TxtRecepcionPago.Text.Trim, TxtTipoPago.Text.Trim, TxtCuentaContable.Text.Trim, DdlCtaContableClientes.SelectedValue.ToEntero,
' DdlCtaContableAnticipos.SelectedValue.ToString.ToEntero, DdlCtaContableRetIVA.SelectedValue.ToString.ToEntero, DdlCtaContableRetISR.SelectedValue.ToString.ToEntero,
' TxtConvenioCIE.Text.Trim, TxtFormaFacturacion.Text.Trim, TxtCodigo.Text.Trim, TxtLimiteCredito.Text.ToDouble, TxtNumCtaPago.Text.Trim,
' DdlMetodoPago.SelectedValue.ToEntero, ChkAplicaFEMSA.Checked, TxtFEMSA_NumSociedad.Text.Trim,
' TxtFEMSA_NumProveedor.Text.Trim, TxtFEMA_Mail.Text.Trim, ChkAplicaDetallista.Checked, TxtDet_GLNComprador.Text.Trim, TxtDet_Departamento.Text.Trim,
' TxtDet_GLNVendedor.Text.Trim, TxtDet_NumProveedor.Text.Trim) Then
' Alert("El Cliente se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatClientes.aspx""")
'End If
Else
If ObjClientes.UpdateCliente(TxtNombre.Text.Trim, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtCiudad.Text.Trim, TxtLocalidad.Text.Trim, TxtEstado.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim,
TxtTelefono.Text.Trim, TxtContacto.Text.Trim, TxtEmail.Text.Trim, "-1", TxtPagina.Text.Trim, TxtGiro.Text.Trim, -1, False,
2069, 0, 0, False, True, "", -1, 0, "", "", "", "", -1, -1, -1, -1, TxtProfesion.Text.Trim, "", "", 0, TxtNumCtaPago.Text.Trim, DdlMetodoPago.SelectedValue.ToEntero, False, "", "", "", False, "", "", "", "", "", False, "", 0, CveCliente, UsuarioActual.CveEmpresa, "", False) Then
'CargaDatos()
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
End If
End If
ObjClientes.Dispose()
End Sub
Protected Sub LbPortal_Click(sender As Object, e As EventArgs) Handles LbPortal.Click
ActivaPortal(CveCliente, TxtEmail.Text.Trim)
End Sub
Private Sub ActivaPortal(CveCliente As Integer, Correo As String)
'guarda el nuevo usuario
Dim Usr As New ClsSisUsuarios
Dim CveUsr As Integer
Dim Activa As Boolean = True
If Usr.GetUsuariosPortal(-1, CveCliente, -1) Then
If Usr.DtResultados.Rows.Count = 0 Then
'lo ingreso
CveUsr = Usr.AddUsuarioPortal("Admin", "-acceso-", "Administrador", "", CveCliente, -1, True, True, True, True, True, True, True, True, True, True, 1, 0)
'lo desactivo para que me pida la nueva contrase;a en el portal
If CveUsr > 0 Then
Usr.UpdateUsuarioPortal("Admin", "Administrador", "", True, True, True, True, True, True, True, True, True, True, False, ContraseñaPredeterminada, CveCliente, 0, CveUsr)
End If
Activa = True
Else
CveUsr = Usr.DtResultados.Rows(0)("CveUsuarioPortal").ToString.ToEntero
If Usr.DtResultados.Rows(0)("Estatus").ToString = "0" Then
Activa = True 'sino esta activada la cuenta, sigue mandando la liga para activar
Else
Activa = False
End If
End If
End If
Usr.Dispose()
If CveUsr > 0 Then
Dim Liga As String = "http://aimmgm.adsistemas.mx/AIMMGM/Portal.aspx"
Dim LigaActivar As String = Liga & "?p=" & Extensiones.Encripta("CveU=" & CveUsr & "&Clave=" & CveCliente & "&Opcion=Activar&Hora=" & NowADS().Ticks)
Dim strSQL As New StringBuilder
strSQL.Append(" <html> ")
strSQL.Append(" <head></head> ")
strSQL.Append(" <body> ")
strSQL.Append(" <img src='http://expominson2014.com/CorreoEncabezado.jpg'><br /> ")
strSQL.Append(" ")
strSQL.Append(" <p class=MsoNormal style='margin-top:15.0pt;margin-right:0cm;margin-bottom: ")
strSQL.Append(" 7.5pt;margin-left:0cm;line-height:normal;mso-outline-level:3'><b><span ")
strSQL.Append(" style='font-size:14.5pt;font-family:""Century Gothic"",""sans-serif"";mso-fareast-font-family: ")
strSQL.Append(" ""Times New Roman"";mso-bidi-font-family:""Times New Roman"";color:#2A4A7E; ")
strSQL.Append(" mso-fareast-language:ES-MX'>SONORA 2014: Minería Moderna, Ejemplo de Industria ")
strSQL.Append(" Responsable</span></b><b><span style='font-size:14.5pt;font-family:""Century Gothic"",""sans-serif""; ")
strSQL.Append(" mso-fareast-font-family:""Times New Roman"";mso-bidi-font-family:""Times New Roman""; ")
strSQL.Append(" color:#89BCDC;mso-fareast-language:ES-MX'><o:p></o:p></span></b></p> ")
strSQL.Append(" <br> ")
strSQL.Append(" <br> ")
strSQL.Append(" <p class=MsoNormal style='margin-top:9.0pt;margin-right:0cm;margin-bottom:9.0pt; ")
strSQL.Append(" margin-left:0cm;text-align:justify;line-height:normal'><span style='font-size: ")
strSQL.Append(" 12.0pt;font-family:""Century Gothic"",""sans-serif"";mso-fareast-font-family:""Times New Roman""; ")
strSQL.Append(" mso-bidi-font-family:""Times New Roman"";color:#2C2C25;mso-fareast-language:ES-MX'>Estimado ")
strSQL.Append(" Socio y Amigo, Gracias por su asistencia, le brindamos la dirección al portal. ")
strSQL.Append(" ")
strSQL.Append(" ")
strSQL.Append(" <br><br> ")
If Activa Then strSQL.AppendFormat("<br>Haga click para activar su cuenta <a href='{0}' target='_blank'>Activar</a>", LigaActivar)
strSQL.Append(" <br><br> ")
strSQL.AppendFormat(" Dirección de acceso al Portal: <a href='{0}' target='_blank'>Portal AIMMGM</a> ", Liga)
strSQL.Append(" <br><br> ")
strSQL.Append(" Datos de acceso: ")
strSQL.Append(" <br><br> ")
strSQL.AppendFormat(" Clave Cliente: {0}", CveCliente)
strSQL.Append(" <br><br> ")
strSQL.Append(" Dentro del Portal usted tendrá acceso a visualizar el detalle de sus compras, subir la comprobación de sus pagos. ")
strSQL.Append(" <br><br><table id=""TrPagoss"" width=""994px"" style='font-size:14.5pt;font-family:""Century Gothic"",""sans-serif"";mso-fareast-font-family: ")
strSQL.Append(" ""Times New Roman"";mso-bidi-font-family:""Times New Roman"";color:#2A4A7E; ")
strSQL.Append(" mso-fareast-language:ES-MX'> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td colspan=""2"" style=""background-color:#5D7B9D; text-align: center; height: 20px;""> ")
strSQL.Append(" Pagos-Transferencias Nacionales ")
strSQL.Append(" <b></b> ")
strSQL.Append(" </td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td style=""width:275px;"">Banco:</td><td><b>Inbursa</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Sucursal:</td><td><b>Nápoles 021</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Cuenta:</td><td><b>50019145334</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>CLABE:</td><td><b>036180500191453345</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Nombre del Beneficiario:</td><td><b>Asociación de Ingenieros de Minas, Metalurgistas y Geólogos de México A.C.</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" ")
strSQL.Append(" </table> ")
strSQL.Append(" <br/> ")
strSQL.Append(" <table id=""TrPagoss2"" width=""994px""style='font-size:14.5pt;font-family:""Century Gothic"",""sans-serif"";mso-fareast-font-family: ")
strSQL.Append(" ""Times New Roman"";mso-bidi-font-family:""Times New Roman"";color:#2A4A7E; ")
strSQL.Append(" mso-fareast-language:ES-MX'> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td colspan=""2"" style=""background-color:#5D7B9D; text-align: center; height: 20px;""> ")
strSQL.Append(" Pagos-Transferencias Internacionales ")
strSQL.Append(" <b></b> ")
strSQL.Append(" </td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td style=""width:275px;"">Moneda:</td><td><b>Dólares Americanos</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Banco:</td><td><b>JPMorgan Chase Bank New York NY USA</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Código Swift:</td><td><b>CHASUS33</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Ruta Banco Receptor (ABA):</td><td><b>021 000 021</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Nombre del Beneficiario:</td><td><b>Asociación de Ingenieros de Minas, Metalurgistas y Geólogos de México A.C. </b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Cuenta del Beneficiario:</td><td><b>50019145334</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>CLABE:</td><td><b>036180500191453345</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Banco Beneficiario:</td><td><b>Banco Inbursa, S.A. México, D.F.</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" <tr> ")
strSQL.Append(" <td>Nuestro Código Swift:</td><td><b>INBUMXMM</b></td> ")
strSQL.Append(" </tr> ")
strSQL.Append(" ")
strSQL.Append(" </table> ")
strSQL.Append(" </span></p> ")
strSQL.Append(" </body> ")
'Dim ObjMail As New ClsSisMail()
Dim Emp As New Empresa
Dim ObjEmp As New ClsSisEmpresas
If ObjEmp.GetEmpresas(43, "-1", "-1", "-1", "-1") Then
Emp = ObjEmp.Empresa
End If
ObjEmp.Dispose()
'If ObjMail.Mandacorreo(Emp, Correo, If(Activa, "Activación de cuenta ExpominSon 2014", "Registro de Compra ExpominSon 2014"), "", "", {""}, strSQL.ToString) Then
'End If
End If
End Sub
Protected Sub ChkPagado_CheckedChanged(sender As Object, e As EventArgs)
Dim Chk As WebControls.CheckBox = DirectCast(sender, WebControls.CheckBox)
Dim gvr As GridViewRow = DirectCast(Chk.BindingContainer, GridViewRow)
Dim Aim As New ClsAIMMGM
Aim.AddUpdVentaDetallePagado(gvr.DataKey("CveVentaDetalle").ToString.ToEntero, Chk.Checked)
Aim.Dispose()
End Sub
Protected Sub ChkImpreso_CheckedChanged(sender As Object, e As EventArgs)
Dim Chk As WebControls.CheckBox = DirectCast(sender, WebControls.CheckBox)
Dim gvr As GridViewRow = DirectCast(Chk.BindingContainer, GridViewRow)
Dim Aim As New ClsAIMMGM
Aim.AddUpdVentaDetalleImpreso(gvr.DataKey("CveVentaDetalle").ToString.ToEntero, Chk.Checked)
Aim.Dispose()
End Sub
Sub DDlContratadoSelectedIndex_Changed(sender As Object, e As EventArgs)
Dim DDl As WebControls.DropDownList = DirectCast(sender, WebControls.DropDownList)
Dim gvr As GridViewRow = DirectCast(DDl.BindingContainer, GridViewRow)
Dim Aim As New ClsAIMMGM
Aim.AddUpdVentaDetalleComprobado(gvr.DataKey("CveVentaDetalle").ToString.ToEntero, DDl.SelectedValue.ToEntero)
Aim.Dispose()
End Sub
End Class