219 lines
8.8 KiB
VB.net
219 lines
8.8 KiB
VB.net
|
|
Imports ClosedXML.Excel
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
Partial Class AIMMGM_Pagos
|
|
Inherits ClsPaginas
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
Dim Cliente As New ClsClientes
|
|
If Cliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, 43, -1) Then
|
|
DdlCliente.DataSource = Cliente.DtResultados
|
|
End If
|
|
Cliente.Dispose()
|
|
|
|
DdlCliente.DataBind()
|
|
DdlCliente.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
CargaDatos()
|
|
End If
|
|
|
|
'Alert(GeneraContrasena)
|
|
|
|
End Sub
|
|
|
|
Sub CargaDatos()
|
|
Dim Aprobacion As Integer = -1
|
|
Dim AIM As New ClsAIMMGM
|
|
|
|
If TxtAprobacion.Text.Trim <> "" Then Aprobacion = TxtAprobacion.Text.ToEntero
|
|
If AIM.GetPagos(DdlCliente.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, Aprobacion:=Aprobacion) Then
|
|
GvPagos.DataSource = AIM.DtResultados
|
|
|
|
End If
|
|
|
|
AIM.Dispose()
|
|
GvPagos.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Protected Sub GvPagos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPagos.RowDataBound
|
|
If 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
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkValidar_Click(sender As Object, e As EventArgs)
|
|
Dim Lnk As LinkButton = CType(sender, LinkButton)
|
|
Dim gvr As GridViewRow = CType(Lnk.NamingContainer, GridViewRow)
|
|
|
|
If Lnk.CommandArgument.ToEntero > 0 Then
|
|
|
|
Dim AIM As New ClsAIMMGM
|
|
If AIM.GetPagos(-1, -1, Lnk.CommandArgument.ToEntero) Then
|
|
If AIM.DtResultados.Rows.Count > 0 Then
|
|
Dim dr As DataRow = AIM.DtResultados.Rows(0)
|
|
EnviaCorreo(dr("Mail").ToString, dr("Importe").ToString.ToDouble, dr("Fecha").ToString.ToDate)
|
|
|
|
If gvr.FCCheckBox("ChkRequiereFactura").Checked Then
|
|
AIM.UpdateEstatus(2, 1, Lnk.CommandArgument.ToEntero)
|
|
Else
|
|
AIM.UpdateEstatus(4, 1, Lnk.CommandArgument.ToEntero)
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
|
|
AIM.Dispose()
|
|
CargaDatos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub EnviaCorreo(Correo As String, Importe As Double, Fecha As Date)
|
|
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 Cliente <br> ")
|
|
strSQL.AppendFormat(" El Pago por ${0} con fecha {1} ha sido validado. ", Importe.FormatoNumero(), Fecha.ToShortDateString())
|
|
strSQL.Append(" <br><br> Muchas gracias por su Pago.")
|
|
strSQL.Append(" ")
|
|
strSQL.Append(" <br><br> ")
|
|
|
|
strSQL.Append(" </span></p></body></html> ")
|
|
|
|
|
|
|
|
'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, "ExpominSon 2014: Comprobante de Pago validado", "", "", {""}, strSQL.ToString) Then
|
|
|
|
|
|
'End If
|
|
End Sub
|
|
|
|
Protected Sub BtnSolicitarFactura_Click(sender As Object, e As EventArgs) Handles BtnSolicitarFactura.Click
|
|
'solicitar la facturas de los pagos pendientes que no se han facturado
|
|
|
|
Dim AIM As New ClsAIMMGM
|
|
Dim dt As DataTable
|
|
If AIM.GetPagos(DdlCliente.SelectedValue.ToEntero, 2) Then
|
|
dt = AIM.DtResultados.FiltraParametros("Facturado = 0 and RequiereFactura = 1")
|
|
' GvE.Caption = String.Format("<table style='width:100%; background-color:#ADD8E6;'><tr><td>{0}</td></tr></table>", Now.ToLongDateString)
|
|
GvE.CaptionAlign = TableCaptionAlign.Left
|
|
GvE.DataSource = dt
|
|
GvE.DataBind()
|
|
|
|
|
|
If GvE IsNot Nothing AndAlso GvE.Rows.Count > 0 Then
|
|
Dim NombreArchivoXLSX As String = "Listado"
|
|
Dim dtt As New DataTable(NombreArchivoXLSX)
|
|
Dim i As Integer = 0
|
|
Dim ArrColumnasVisibles As New List(Of Integer) 'solo recorro las columnas visibles
|
|
|
|
For Each cell As TableCell In GvE.HeaderRow.Cells
|
|
If GvE.Columns(i).Visible Then
|
|
dtt.Columns.Add(HttpUtility.HtmlDecode(TextoCelda(cell)))
|
|
ArrColumnasVisibles.Add(i)
|
|
End If
|
|
i += 1
|
|
Next
|
|
i = 0
|
|
|
|
For Each row As GridViewRow In GvE.Rows
|
|
dtt.Rows.Add()
|
|
i = 0
|
|
For Each j As Integer In ArrColumnasVisibles
|
|
|
|
dtt.Rows(dtt.Rows.Count - 1)(i) = TextoCelda(row.Cells(j))
|
|
i = i + 1
|
|
|
|
Next
|
|
Next
|
|
Dim Archivoxlsx As String = String.Format("{0}/Empresas/{1}/Documentos/{2}.xlsx", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, NombreArchivoXLSX)
|
|
Using wb As New XLWorkbook()
|
|
wb.Worksheets.Add(dtt)
|
|
wb.SaveAs(Archivoxlsx)
|
|
|
|
End Using
|
|
|
|
For Each dr As DataRow In AIM.DtResultados.Rows
|
|
AIM.UpdateEstatus(3, 1, dr("CvePago").ToString.ToEntero)
|
|
Next
|
|
|
|
EnviaSolicitud("contabilidad2010@aimmgm.org.mx", Archivoxlsx)
|
|
Alert("Facturas Solicitadas", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("No hay pagos que facturar", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
AIM.Dispose()
|
|
End Sub
|
|
|
|
|
|
Private Sub EnviaSolicitud(Correo As String, Adjunto As String)
|
|
Dim strSQL As New StringBuilder
|
|
strSQL.Append(" <html> ")
|
|
strSQL.Append(" <head></head> ")
|
|
strSQL.Append(" <body> ")
|
|
strSQL.Append(" <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'>Hola gracias por elaborar la facturas con los datos anexos<br /><br /> Atentamente<br /><br /> AIMMGM, AC Distrito Sonora")
|
|
strSQL.Append(" </span></p> </body></html> ")
|
|
|
|
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, "Solicitud de Factura", Adjunto, "", {"admonaimmgm@gmail.com", "facturacion@aimmgm.org.mx"}, strSQL.ToString) Then
|
|
|
|
|
|
'End If
|
|
'If ObjMail.Mandacorreo(Emp, Correo, "Solicitud de Factura", Adjunto, "", {"rene.molina@gmail.com", "rene.molina@adsistemas.mx"}, strSQL.ToString) Then
|
|
|
|
|
|
'End If
|
|
End Sub
|
|
|
|
End Class
|