442 lines
21 KiB
VB.net
442 lines
21 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
|
|
Partial Class AIMMGM_ePagos
|
|
Inherits Page
|
|
|
|
|
|
Private Property TmpDT As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDT"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDT") = 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
|
|
|
|
Property GlobalDTGralEstados(CvePais As Integer) As DataTable
|
|
Get
|
|
GlobalDTGralEstados = DirectCast(Application("GlobalDTGralEstados"), DataTable).FiltraParametros(String.Format("CvePais ={0}", CvePais))
|
|
End Get
|
|
Set(value As DataTable)
|
|
Application("GlobalDTGralEstados") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property ClavePago() As String
|
|
Get
|
|
ClavePago = Application("ClavePago").ToString
|
|
End Get
|
|
Set(value As String)
|
|
Application("ClavePago") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
|
|
'CType(Me.Master, BaseMasterPage).EsPopup = True
|
|
'CType(Me.Master, BaseMasterPage).PopupWidth = 1000
|
|
|
|
'Dim ObjPS As New ClsProductosServicios()
|
|
'If ObjPS.GetPS(-1, -1, 43) Then
|
|
' 'ViewState("DTPS") = ObjPS.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa & " AND Estado = 'Activo'", "PS")
|
|
' ViewState("DTPS") = ObjPS.DtResultados.FiltraParametros("CveEmpresa = 43 AND Estado = 'Activo'", "PS")
|
|
|
|
'End If
|
|
'ObjPS.Dispose()
|
|
|
|
Dim Cadena As String = Decripta(Request("p"))
|
|
If Cadena <> "" Then
|
|
ClsPaginas.CargaParametros(Cadena)
|
|
|
|
If ClsPaginas.UrlParametros("CVE") IsNot Nothing AndAlso ClsPaginas.UrlParametros("F") IsNot Nothing Then
|
|
|
|
Dim Fecha As String = ClsPaginas.UrlParametros("F").ToString
|
|
|
|
If Fecha.ToDate > NowADS().AddHours(-1) AndAlso ClsPaginas.UrlParametros("P") IsNot Nothing AndAlso ClsPaginas.UrlParametros("P").ToString = "1" Then
|
|
|
|
ClavePago = ClsPaginas.UrlParametros("CVE").ToString
|
|
CargaCompra()
|
|
Else
|
|
If ClsPaginas.UrlParametros("NP") IsNot Nothing AndAlso ClsPaginas.UrlParametros("NP").ToString = "1" Then
|
|
LblMensaje.Text = "No se pudo realizar el pago de la compra. favor de intentarlo de nuevo"
|
|
HplReIntentar.Visible = True
|
|
HplReIntentar.NavigateUrl = String.Format("Registro.aspx?CP={0}&C={1}", ClsPaginas.UrlParametros("CVE"), ClsPaginas.UrlParametros("CVECLIENTE"))
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaCompra()
|
|
|
|
Dim tmp As New DataTable
|
|
Dim Carpeta As String = String.Format("{0}AIMMGM/ePagos", UsuarioActual.Empresa.Ruta)
|
|
Dim Archivo As String = String.Format("{0}/{1}.xml", Carpeta, ClavePago)
|
|
Dim Archivo2 As String = String.Format("{0}/C{1}.xml", Carpeta, ClavePago)
|
|
|
|
If File.Exists(Archivo) Then
|
|
|
|
tmp.ReadXml(Archivo)
|
|
TmpDT = tmp
|
|
|
|
PnlPagar.Visible = True
|
|
GvCompras.DataSource = tmp
|
|
GvCompras.DataBind()
|
|
|
|
Dim CveCliente As Integer = tmp.MAX("CveCliente").ToString.ToEntero
|
|
Dim Nombre As String = ""
|
|
Dim CveMetodoPago As Integer = 0
|
|
|
|
Dim Cliente As New ClsClientes
|
|
If Cliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, 43, -1) Then
|
|
|
|
If Cliente.DtResultados.Rows.Count > 0 Then
|
|
CveMetodoPago = Cliente.CveMetodoPago
|
|
Nombre = Cliente.Nombre
|
|
End If
|
|
|
|
End If
|
|
Cliente.Dispose()
|
|
|
|
Dim Errorr As Boolean = False
|
|
Dim Venta As New ClsVentas
|
|
Dim AIM As New ClsAIMMGM(Venta.IniciaTransacSQL)
|
|
Dim tnombre As String
|
|
Dim TieneExcursion As Boolean = False
|
|
|
|
If Venta.AddVenta("Rem", 0, CveCliente, 2069, TmpDT.SUM("Total"), 0, 0, 0, 0, 0, TmpDT.SUM("Total"), 1, 0, CveMetodoPago, 0, 0, NowADS(), "", "", -1, NowADS(), -1, -1, "", "", "", 0, 0, 0, 0, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, -1, -1, 0, 1, 0, 2069, 43) Then
|
|
Dim CveVenta As Integer = Venta.CveVenta
|
|
For Each dr As DataRow In TmpDT.Rows
|
|
Dim CveUnidadMedida As Integer
|
|
|
|
Dim PS As New ClsProductosServicios
|
|
|
|
If PS.GetPS(dr("CvePS").ToString.ToEntero, -1, 43) Then
|
|
If PS.DtResultados.Rows.Count > 0 Then
|
|
CveUnidadMedida = PS.DtResultados.Rows(0)("CveUnidadMedida").ToString.ToEntero
|
|
If PS.DtResultados.Rows(0)("Clasificacion").ToString = "Excursiones" Then
|
|
TieneExcursion = True
|
|
End If
|
|
End If
|
|
End If
|
|
PS.Dispose()
|
|
|
|
If dr("CvePS").ToString.ToEntero = 36977 Then 'cuando es acompa;ante pongo el nombre del acompa;ante
|
|
tnombre = dr("Obs").ToString
|
|
Else
|
|
tnombre = Nombre
|
|
End If
|
|
|
|
If Not Venta.AddVentaDetalle(CveVenta, dr("CvePS").ToString.ToEntero, 1, CveUnidadMedida, dr("Total").ToString.ToDouble, 0, dr("Total").ToString.ToDouble, tnombre, 0, 0, -1, 0) Then
|
|
Errorr = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If Not Errorr Then
|
|
If AIM.AddPago(CveCliente, -1, TmpDT.SUM("Total"), 1, NowADS(), "", "Pago en línea", 0, 0) <= 0 Then
|
|
Errorr = True
|
|
End If
|
|
If Not Errorr Then
|
|
If Not AIM.AddUpdVentaDetallePagado(Venta.CveVentaDetalle, True) Then
|
|
Errorr = True
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
Errorr = True
|
|
End If
|
|
|
|
If Not Errorr Then
|
|
File.Move(Archivo, Archivo2)
|
|
|
|
LblMensaje.Text = "El Pago se registró con éxito"
|
|
Venta.Commit()
|
|
Else
|
|
Venta.RollBack()
|
|
End If
|
|
|
|
Venta.Dispose()
|
|
AIM.Dispose()
|
|
Else
|
|
LblMensaje.Text = "Pago ya registrado"
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvCompras_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCompras.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.Footer Then
|
|
e.Row.FCLabel("LblTotal").Text = TmpDT.SUM("Total").ToString("N2") & " MXN"
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Public Sub Alert(Mensaje As String, pOpcion As TipoMensaje, Optional JSBtnAceptar As String = "")
|
|
|
|
If System.Web.HttpContext.Current IsNot Nothing AndAlso System.Web.HttpContext.Current.Handler IsNot Nothing Then
|
|
Dim Img, Botones As String
|
|
Dim Titulo As String
|
|
Dim Plus As String = NowADS().Ticks.ToString
|
|
|
|
Mensaje = Mensaje.Replace("'"c, "\'")
|
|
JSBtnAceptar = JSBtnAceptar.Replace("'"c, "\'")
|
|
|
|
Select Case pOpcion
|
|
Case TipoMensaje.MsgInformacion
|
|
Titulo = "Información"
|
|
Img = "I"
|
|
'Img = "<img src=""/Imagenes/Mensajes/Information.jpg"" width=""50px"" style=""float:left;"" alt="""" />"
|
|
'Botones = String.Format("<input id=""_CmdAceptar"" type=""button"" value=""Aceptar"" onclick=""OcultaAlert();{1}"" />", Plus, JSBtnAceptar)
|
|
Botones = "1"
|
|
Case TipoMensaje.MsgConfirmacion
|
|
Titulo = "Confirmación"
|
|
Img = "C"
|
|
'Img = "<img src=""/Imagenes/Mensajes/Interrogation.jpg"" width=""50px"" style=""float:left;"" alt="""" />"
|
|
'Botones = String.Format("<input id=""_CmdAceptar"" type=""button"" value=""Aceptar"" onclick=""OcultaAlert();{1} return true;""><input type=""Button"" value=""Cancelar"" onclick=""OcultaAlert(\""{0}\""); return false;"">", Plus, JSBtnAceptar)
|
|
Botones = "2"
|
|
Case TipoMensaje.MsgAdvertencia
|
|
Titulo = "Advertencia"
|
|
Img = "A"
|
|
'Img = "<img src=""/Imagenes/Mensajes/Exclamation.jpg"" width=""50px"" style=""float:left;"" alt="""" />"
|
|
'Botones = String.Format("<input id=""_CmdAceptar"" type=""button"" value=""Aceptar"" onclick=""OcultaAlert();{1}"" />", Plus, JSBtnAceptar)
|
|
Botones = "1"
|
|
Case Else
|
|
Titulo = "Error"
|
|
Img = "E"
|
|
'Img = "<img src=""/Imagenes/Mensajes/Error.jpg"" width=""50px"" style=""float:left;"" alt="""" />"
|
|
'Botones = String.Format("<input id=""_CmdAceptar"" type=""button"" value=""Aceptar"" onclick=""OcultaAlert();"" />", Plus, JSBtnAceptar)
|
|
Botones = "1"
|
|
End Select
|
|
|
|
Try
|
|
|
|
|
|
Dim Pag As Page = DirectCast(System.Web.HttpContext.Current.Handler, Page)
|
|
'ScriptManager.RegisterStartupScript(Pag, Pag.GetType(), (NowADS().Ticks + 1).ToString(), "MuestraAlert('" & Alerta.ToString() & "', '" & Plus & "');", True)
|
|
ScriptManager.RegisterStartupScript(Pag, Pag.GetType(), (NowADS().Ticks + 1).ToString(), String.Format("MuestraAlerta('{0}','{1}','{2}','{3}','{4}');", Titulo, Mensaje, Img, Botones, JSBtnAceptar), True)
|
|
Pag = Nothing
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
'Alerta = Nothing
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub EnviaNotificacion(dtt As DataTable, Correo As String)
|
|
|
|
'Dim ObjMail As New ClsSisMail()
|
|
Dim Body As New StringBuilder
|
|
'Body.AppendFormat("Se ha realizado el registro de: {0} {1} {2}<br><br>El detalle de lo registrado es:", TxtAPaterno.Text, TxtAMaterno.Text, TxtNombres.Text)
|
|
Body.AppendFormat("<table width='500px'>")
|
|
For Each dr As DataRow In TmpDT.Rows
|
|
Body.AppendFormat("<tr><td style='width:400px'>{0}</td><td style='width:100px'>{1} {2}</td></tr>", dr("PS"), dr("Total"), dr("Abreviatura"))
|
|
Next
|
|
Body.AppendFormat("</table>")
|
|
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, "Notificación de compra", "", "", {""}, Body.ToString) Then
|
|
|
|
|
|
'End If
|
|
|
|
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 ContraseñaPredeterminada As String = "-acceso-"
|
|
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=" & 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
|
|
|
|
|
|
|
|
End Class
|