Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,674 @@
Imports System.IO
Imports Extensiones
Imports System.Data
Partial Class Bancos_Transferencias
Inherits ClsPaginas
#Region "Propiedades"
Private Property DtCuentas As DataTable
Get
Return CType(ViewState("DtCuentas"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCuentas") = value
End Set
End Property
Private Property Opcion As Integer
Get
Return ViewState("Opcion").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("Opcion") = value
End Set
End Property
Private Property tCveMonedaOrigen As Integer
Get
Return ViewState("tCveMonedaOrigen").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("tCveMonedaOrigen") = value
End Set
End Property
Private Property tCveMonedaDestino As Integer
Get
Return ViewState("tCveMonedaDestino").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("tCveMonedaDestino") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
tCveMonedaOrigen = 0
tCveMonedaDestino = 0
If Request("OPC") IsNot Nothing AndAlso IsNumeric(Request("OPC")) Then
Opcion = Request("OPC").ToEntero
Else
Opcion = -1
End If
DtCuentas = GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
If Opcion = 1 Then
LtlTitulo.Text = "Domicializaci<EFBFBD>n de tarjeta"
RBLOpcion.Visible = True
TrCuentaOrigen.Visible = False
chkMovimientoTarjeta.Checked = True
chkMovimientoTarjeta.Enabled = False
chkMovimientoTarjeta_CheckedChanged(Nothing, Nothing)
CargaCuenta(-1, DdlCuentaDestino)
CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
Else
CargaCuenta(-1, DdlCuentaOrigen)
CargaCuenta(DdlCuentaOrigen.SelectedValue.ToEntero, DdlCuentaDestino)
CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
End If
TxtFechaDocumento.Text = Now.ToShortDateString
End If
End Sub
Private Sub CargaCuenta(CveCuenta As Integer, Ddl As DropDownList)
Ddl.Items.Clear()
If UsuarioActual.CveEmpresa = 119 Then
Ddl.DataSource = DtCuentas
Else
Ddl.DataSource = DtCuentas.FiltraParametros(String.Format("CveCuenta <> {0}", CveCuenta))
End If
Ddl.DataBind()
DdlCuentaDestino_SelectedIndexChanged(Nothing, Nothing)
If CveCuenta > 0 Then VerificaMonedas()
End Sub
Private Sub VerificaMonedas()
'si es la destino verifico si la moneda es la misma, sino pregunto por la paridad cambiaria
Dim drOrigen As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue.ToEntero))
Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaDestino.SelectedValue.ToEntero))
'Dim tCveMonedaOrigen, tCveMonedaDestino As Integer
If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing Then
tCveMonedaOrigen = drOrigen("CveMoneda").ToString.ToEntero
tCveMonedaDestino = drDestino("CveMoneda").ToString.ToEntero
End If
If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing AndAlso drOrigen("CveMoneda").ToString <> drDestino("CveMoneda").ToString Then
If tCveMonedaOrigen = 1 AndAlso tCveMonedaDestino <> 1 Then
'pesos a otra moneda se divide
TxtTipoCambio.Attributes.Add("onkeyup", "$get('HdnTC').value='2'; Calcula();")
RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='2'; Calcula();")
ElseIf tCveMonedaOrigen <> 1 AndAlso tCveMonedaDestino = 1 Then
'de otra moneda a pesos se multiplica
TxtTipoCambio.Attributes.Add("onkeyup", "$get('HdnTC').value='1'; Calcula();")
RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='1'; Calcula();")
End If
PnlTipoCambio.Visible = True
'RegistraScript("$get('TrTC').style.display='';")
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
Else
PnlTipoCambio.Visible = False
RegistraScript("$get('TrTC').style.display='none';")
TxtFechaDocumento.Attributes.Remove("onchange")
End If
If drOrigen IsNot Nothing AndAlso drDestino IsNot Nothing AndAlso tCveMonedaOrigen = 2 OrElse tCveMonedaDestino = 2 Then
PnlTipoCambio.Visible = True
RegistraScript("$get('TrTC').style.display='';")
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
End If
End Sub
Protected Sub DdlCuentaOrigen_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaOrigen.SelectedIndexChanged
CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
CargaCuenta(DdlCuentaOrigen.SelectedValue.ToEntero, DdlCuentaDestino)
If DdlCuentaOrigen.SelectedValue.ToEntero() > 0 Then
If DtCuentas.FiltroPrimeroValor("CveTipoCuenta", String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue)) = "1" Then
CargaMovimientosCajaChica()
TrCajaChica.Visible = True
Else
DdlCajaChica.DataSource = Nothing
DdlCajaChica.DataBind()
TrCajaChica.Visible = False
End If
End If
End Sub
Protected Sub DdlCuentaDestino_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaDestino.SelectedIndexChanged
VerificaMonedas()
If Opcion = 1 Then
CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
End If
If chkMovimientoTarjeta.Checked AndAlso GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveCuenta = {0} AND UsaTarjeta = 1", DdlCuentaDestino.SelectedValue.ToEntero)).Rows.Count > 0 Then
CargaGridTarjetas()
Else
GvTC.Visible = False
End If
End Sub
Private Sub CargaGridTarjetas()
Dim ObjCreditos As New ClsBancos
If ObjCreditos.GetTarjetasCreditos(DdlCuentaDestino.SelectedValue.ToEntero) Then
If ObjCreditos.DtResultados.Rows.Count > 0 Then
GvTC.DataSource = ObjCreditos.DtResultados
End If
GvTC.DataBind()
UpGvTC.Update()
GvTC.Visible = True
End If
ObjCreditos.Dispose()
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
'VALIDACIONES
Dim SumaImportesTarjeta As Decimal
If GvTC.Visible Then
For Each row As GridViewRow In GvTC.Rows
SumaImportesTarjeta += row.FCTextBox("TxtAbono").Text.ToDecimal
Next
If TxtImporte.Text.ToDouble <> SumaImportesTarjeta Then
Alert("Las Cantidades a Abonar no Coinciden con el Importe a Transferir", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
If DdlCuentaDestino.SelectedValue = "" Then
Alert("Seleccione cuenta destino", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtImporte.Text.ToDouble <= 0 Then
Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
If TxtTipoCambio.Visible AndAlso TxtTipoCambio.Text.ToDouble <= 0 Then
Alert("Debe ingresar el tipo de cambio", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim MsgError As String = ""
Dim ImporteDestino As Double = TxtImporte.Text.Trim.ToDouble
Dim ImporteMXOrigen As Double = TxtImporte.Text.Trim.ToDouble
Dim ImporteMXDestino As Double = TxtImporte.Text.Trim.ToDouble
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
'Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL)
Dim TipoCambio As Double = If(TxtTipoCambio.Visible, TxtTipoCambio.Text.ToDecimal, 0)
Dim CveMonedaOrigen, CveMonedaDestino As Integer
Dim FolioOrigen As String = TxtFolio.Text.Trim
Dim FolioDestino As String = GetFolio(DdlCuentaDestino.SelectedValue.ToEntero, If(DdlTipoMovto.SelectedValue = "2", 8, 3))
Dim CveIE As Integer
Dim CveIEDestino As Integer
Dim CuentaDestino As String = ""
Dim Observaciones As String = ""
Dim dr As DataRow
Dim AlertaGlobal As New StringBuilder
'COMPROBANTE
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
Dim filemove As String = ""
Dim Comprobante As String = ""
For Each fileItem As Archivo In filesgral
Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
filemove = fileItem.filename
Next
dr = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaDestino.SelectedValue))
If dr IsNot Nothing Then CveMonedaDestino = dr("CveMoneda").ToString.ToEntero
If Opcion = -1 Then
dr = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaOrigen.SelectedValue))
If dr IsNot Nothing Then CveMonedaOrigen = dr("CveMoneda").ToString.ToEntero
Else
CveMonedaOrigen = CveMonedaDestino
End If
If CveMonedaOrigen = 1 AndAlso CveMonedaDestino <> 1 Then
'pesos a otra moneda se divide
ImporteMXDestino = Math.Round(TxtImporte.Text.Trim.ToDouble / TxtTipoCambio.Text.ToDouble, 2)
ElseIf CveMonedaOrigen <> 1 AndAlso CveMonedaDestino = 1 Then
'de otra moneda a pesos se multiplica
ImporteDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2)
ImporteMXDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2)
ImporteMXOrigen = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2)
ElseIf CveMonedaOrigen <> 1 AndAlso CveMonedaDestino <> 1 Then
ImporteMXDestino = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2)
ImporteMXOrigen = Math.Round(TxtImporte.Text.Trim.ToDouble * TxtTipoCambio.Text.ToDouble, 2)
End If
If CveMonedaOrigen = 2 AndAlso CveMonedaDestino = 2 Then
TipoCambio = TxtTipoCambio.Text.ToDouble 'GlobalTipoCambio(TxtFechaDocumento.Text.ToDate)
End If
Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/Transferencias", 13, TxtImporte.Text.Trim.ToDouble, TxtImporte.Text.Trim.ToDouble, CveMonedaOrigen, TxtFechaDocumento.Text.ToDate, $"Transferencia entre cuentas {TxtObservaciones.Text}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If UsuarioActual.CveEmpresa = 48 Then
CuentaDestino = "Alumbrado publico de Hermosillo S.A de C.V"
Observaciones = String.Format("{0} {1}", DdlCuentaDestino.SelectedItem.Text, TxtObservaciones.Text.Trim)
Else
CuentaDestino = String.Format("Transferencia Cta: {0}", DdlCuentaDestino.SelectedItem.Text)
Observaciones = TxtObservaciones.Text.Trim
End If
If Opcion = 1 Then
CveIE = ObjIE.AddBancos_IE(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, CuentaDestino, ImporteMXOrigen, CveMonedaOrigen, TipoCambio, Observaciones, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
CveIEDestino = CveIE
Else
CveIE = ObjIE.AddBancos_IE(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, CuentaDestino, TxtImporte.Text.Trim.ToDouble, CveMonedaOrigen, TipoCambio, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
CveIEDestino = ObjIE.AddBancos_IE(DdlCuentaDestino.SelectedValue.ToEntero, If(DdlTipoMovto.SelectedValue = "2", 8, 3), TxtFechaDocumento.Text.Trim.ToDate, FolioDestino, String.Format("Transferencia Cta: {0}", DdlCuentaOrigen.SelectedItem.Text), ImporteDestino, CveMonedaDestino, TipoCambio, TxtObservaciones.Text.Trim, "", False, False, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
End If
Dim CveIEDevolucion As Integer = -1
If DdlCajaChica.SelectedValue.ToEntero() > 0 AndAlso TrCajaChica.Visible Then
CveIEDevolucion = DdlCajaChica.SelectedValue.ToEntero()
End If
If (CveIE > 0 AndAlso CveIEDestino > 0) Then
If filemove <> "" Then
filemove.FilesMove(CveIE.ToString, String.Format("Empresas\{0}\IE", UsuarioActual.CveEmpresa, UsuarioActual.Empresa.Ruta))
End If
'inserto los movimientos de la conta para abonar al saldo
If MsgError = "" Then
If CvePrePoliza > 0 Then
Dim alertaContabilizacion As String = "Se envi<76> correctamente la siguiente p<>liza:<br><br>"
Dim CuentasContablesInvalidas As New StringBuilder
Dim IdCtaContableOrigen As Integer = 0
Dim IDCtaContableComplementariaOrigen As Integer = 0
Dim IDCtaContableComplementariaDestino As Integer = 0
Dim IdCtaContableDestino As Integer = 0
Dim CuentasContablesInvalidasSIG As New StringBuilder
Dim CveCuentaOrigen As Integer = 0
Dim CveCuentaDestino As Integer = 0
Dim RowCuentaOrigen As DataRow = Nothing
RowCuentaOrigen = DtCuentas.FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaOrigen.SelectedValue.ToEntero))
Dim RowCuentaDestino As DataRow = DtCuentas.FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentaDestino.SelectedValue.ToEntero))
If RowCuentaOrigen IsNot Nothing Then
IdCtaContableOrigen = RowCuentaOrigen("IdCtaContable").ToString.ToEntero
IDCtaContableComplementariaOrigen = RowCuentaOrigen("IDCtaContableComplementaria").ToString.ToEntero
CveCuentaOrigen = RowCuentaOrigen("IdCtaContableSIG").ToString.ToEntero
End If
If RowCuentaDestino IsNot Nothing Then
IdCtaContableDestino = RowCuentaDestino("IdCtaContable").ToString.ToEntero
IDCtaContableComplementariaDestino = RowCuentaDestino("IDCtaContableComplementaria").ToString.ToEntero
CveCuentaDestino = RowCuentaDestino("IdCtaContableSIG").ToString.ToEntero
End If
'Conta ContPAQ
If IdCtaContableOrigen < 1 Then
CuentasContablesInvalidas.Append("<br> Cuenta Contable Origen")
End If
If IdCtaContableDestino < 1 Then
CuentasContablesInvalidas.Append("<br> Cuenta Contable Destino")
End If
'Conta SIG
If CveCuentaOrigen < 1 Then
CuentasContablesInvalidasSIG.Append("<br> Cuenta Contable Origen")
End If
If CveCuentaDestino < 1 Then
CuentasContablesInvalidasSIG.Append("<br> Cuenta Contable Destino")
End If
If Opcion = 1 Then ' CUANDO ES DOMICILIZACION
IdCtaContableOrigen = IdCtaContableDestino
CveCuentaOrigen = CveCuentaDestino
End If
Dim TipoMovtoDetalle As Boolean = True
If RBLOpcion.SelectedValue = "2" Then TipoMovtoDetalle = False ' cuando sea un reembolso/devoluci<63>n, es ingreso a bancos
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoDetalle, TxtImporte.Text.ToDouble, $"Transferencia entre cuentas {TxtObservaciones.Text}", 30, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IdCtaContableOrigen, -1, CveIE, ImporteMX:=If(UsuarioActual.CveEmpresa = 119, TxtImporte.Text.ToDouble, ImporteMXOrigen), ImporteME:=If(CveMonedaOrigen > 1, TxtImporte.Text.ToDouble * TC, 0), CveCuenta:=CveCuentaOrigen, CveIEDevolucion:=CveIEDevolucion) Then
If CveMonedaOrigen > 1 AndAlso UsuarioActual.CveEmpresa = 119 Then
'Agregamos complementaria
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovtoDetalle, 0, $"Transferencia entre cuentas {TxtObservaciones.Text}", 204, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IDCtaContableComplementariaOrigen, -1, CveIE:=CveIE, ImporteMX:=(TxtImporte.Text.ToDouble * TC - TxtImporte.Text.ToDouble).RoundSQL, ImporteME:=TxtImporte.Text.ToDouble, TipoCambio:=TC) Then
MsgError = "Ocurri<EFBFBD> un error al registrar el asiento del ingreso."
End If
End If
'Agregamos los Movimientos de Acreedor cuando es tarjeta
If GvTC.Visible Then
For Each row As GridViewRow In GvTC.Rows
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, row.FCTextBox("TxtAbono").Text.ToDouble, $"Transferencia entre cuentas {TxtObservaciones.Text}", 41, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, If(row.DataKey("IdCtaContableTarjeta").ToEntero > 0, row.DataKey("IdCtaContableTarjeta").ToEntero, row.DataKey("IdCtaContable").ToEntero), -1, CveIEDestino, ImporteMX:=row.FCTextBox("TxtAbono").Text.ToDouble, CveCuenta:=If(UsuarioActual.Empresa.UsaContabilidad AndAlso UsuarioActual.Empresa.UsaContabilidadSIG, ObtenerCuentaDobleConta(If(row.DataKey("IdCtaContableTarjeta").ToEntero > 0, row.DataKey("IdCtaContableTarjeta").ToEntero, row.DataKey("IdCtaContable").ToEntero), UsuarioActual.CveEmpresa), -1)) Then
MsgError = "Ocurrio un error al ingresar la prepoliza"
End If
Next
'Agregamos la contraria a bancos cuando es cuenta
Else
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, ImporteDestino, $"Transferencia entre cuentas {TxtObservaciones.Text}", 30, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IdCtaContableDestino, -1, CveIEDestino, ImporteMX:=If(UsuarioActual.CveEmpresa = 119, ImporteDestino, ImporteMXDestino), ImporteME:=If(CveMonedaDestino > 1, TxtImporte.Text.ToDouble * TC, 0), CveCuenta:=CveCuentaDestino) Then
MsgError = "Ocurrio un error al ingresar la prepoliza"
End If
If CveMonedaDestino > 1 AndAlso UsuarioActual.CveEmpresa = 119 Then
'Agregamos complementaria
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovtoDetalle, 0, $"Transferencia entre cuentas {TxtObservaciones.Text}", 204, $"Transferencia entre cuentas {TxtObservaciones.Text}", Now, IDCtaContableComplementariaDestino, -1, CveIE:=CveIEDestino, ImporteMX:=(TxtImporte.Text.ToDouble * TC - TxtImporte.Text.ToDouble).RoundSQL, ImporteME:=TxtImporte.Text.ToDouble, TipoCambio:=TC) Then
MsgError = "Ocurri<EFBFBD> un error al registrar el asiento del ingreso."
End If
End If
End If
If MsgError = "" Then
'Conta SIG
If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidadSIG Then
If (CveCuentaOrigen > 0 AndAlso CveCuentaDestino > 0) OrElse (CveCuentaDestino > 0 AndAlso Opcion = 1) Then
If ObjMov.ContabilizarPrePolizaSIG(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, Fecha:=TxtFechaDocumento.Text) Then
If ObjMov.ContaIdPoliza > 0 Then
AlertaGlobal.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver P<>liza</a>", ObjMov.ContaIdPoliza)
End If
Else
MsgError = "Ocurrio un error al contabilizar en SIG, pongase en contacto con Soporte T<>cnico"
End If
Else
MsgError = String.Format("No se puede contabilizar la Prepoliza en SIG debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidasSIG)
End If
End If
'Conta ContPAQ
If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" AndAlso UsuarioActual.Empresa.UsaContabilidad Then
If (IdCtaContableOrigen > 0 AndAlso IdCtaContableDestino > 0) OrElse (IdCtaContableDestino > 0 AndAlso Opcion = 1) Then
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, Fecha:=TxtFechaDocumento.Text) Then
If ObjMov.ContaIdPoliza > 0 Then
AlertaGlobal.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver P<>liza</a>", ObjMov.ContaIdPoliza)
End If
Else
MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte T<>cnico"
End If
Else
MsgError = String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas)
End If
End If
If CveIE > 0 Then
AlertaGlobal.AppendFormat("<br/><br/>Movimiento: <a class=""Texto"" target='_blank' href=""/Bancos/IE.aspx?CveIE={0}"">{1}</a>", CveIE, FolioOrigen)
End If
If CveIEDestino > 0 AndAlso CveIE <> CveIEDestino Then
AlertaGlobal.AppendFormat("<br/><br/>Recepci<63>n: <a class=""Texto"" target='_blank' href=""/Bancos/IE.aspx?CveIE={0}"">{1}</a>", CveIEDestino, FolioDestino)
End If
Else
MsgError = "no se pudo insertar el detalle de la p<>liza2"
End If
Else
MsgError = "no se pudo insertar el detalle de la p<>liza"
End If
Else
MsgError = "No se pudo insertar la p<>liza"
End If
Else
MsgError = "No se insert<72> el encabezado"
End If
Else
MsgError = "Error al guardar"
End If
If MsgError = "" Then
ObjIE.Commit()
Alert(String.Format("El Movimiento se realizo correctamente.<br>{0}", AlertaGlobal), TipoMensaje.MsgInformacion)
Anexo.Text = ""
'Enviar Correo a los usuarios que tienen acceso a las dos cuentas
If UsuarioActual.CveEmpresa = 13 Then EnviaCorreo(Comprobante)
'LIMPIA
CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
TxtImporte.Text = ""
TxtObservaciones.Text = ""
GeneraChequePDF(CveIEDestino, UsuarioActual.Empresa)
Else
ObjIE.RollBack()
Alert(MsgError)
End If
ObjIE.Dispose()
ObjMov.Dispose()
'If ObjComp IsNot Nothing Then ObjComp.Dispose()
End Sub
Private Sub EnviaCorreo(Comprobante As String)
Dim dtcorreo As DataTable = GlobalDTBancosCuentas(-1, DdlCuentaOrigen.SelectedValue.ToEntero)
dtcorreo.Merge(GlobalDTBancosCuentas(-1, DdlCuentaDestino.SelectedValue.ToEntero))
' Dim CorreosCCP As New List(Of String)
Dim StrCorreos As New StringBuilder
For Each Row As DataRow In dtcorreo.Rows
' CorreosCCP.Add(GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString)
StrCorreos.AppendFormat("{0};", GlobalDTUsuarios(Row("CveUsuario").ToString.ToEntero)(0)("correo").ToString)
Next
Dim strBody As New StringBuilder
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
strBody.Append("<head> ")
strBody.Append(" <style type=""text/css""> ")
strBody.Append(" body ")
strBody.Append(" { ")
strBody.Append(" margin:0px; ")
strBody.Append(" padding:0px 0px 0px 0px; ")
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
strBody.Append(" font-size: 10px; ")
strBody.Append(" background-color:#F0F0F0; ")
strBody.Append(" } ")
strBody.Append(" a.Texto ")
strBody.Append(" { ")
strBody.Append(" font-size:11px; ")
strBody.Append(" background-color:#F7F6F3; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" } ")
strBody.Append(" .Texto ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .TextoAlterno ")
strBody.Append(" { ")
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
strBody.Append(" vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .BarraIdentidad ")
strBody.Append(" { ")
strBody.Append(" color:#FFFFFF; ")
strBody.Append(" background:#F0F0F0; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" font-size:19px; ")
strBody.Append(" font-style:oblique; ")
strBody.Append(" } ")
strBody.Append(" .Titulos ")
strBody.Append(" { ")
strBody.Append(" background-color: Gray;")
strBody.Append(" color:White; ")
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" } ")
strBody.Append(" .Verde {color: #00CC00;} ")
strBody.Append(" .Negro {color: #000000;} ")
strBody.Append(" .Rojo {color: #FF0000;} ")
strBody.Append(" </style> ")
strBody.Append("</head> ")
strBody.Append("<body> ")
strBody.Append(" <div id=""C_divOC"" style=""width: 550px""> <fieldset> <legend><b>Transferencia Bancaria</b></legend> ")
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td style=""width: 90px""> Cuenta Origen:</td><td colspan=""3""><b>{0}</b></td></td> ", DdlCuentaOrigen.SelectedItem.Text)
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td style=""width: 90px""> Cuenta Destino:</td><td colspan=""3""><b>{0}</b></td> ", DdlCuentaDestino.SelectedItem.Text)
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 20px""> ")
strBody.AppendFormat(" <td>Folio:</td><td colspan='3'><b>{0}</b></td> ", TxtFolio.Text.Trim)
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 20px""> ")
strBody.AppendFormat(" <td>Importe:</td><td colspan='3'>$ <b>{0}</b></td> ", TxtImporte.Text.FormatoNumero)
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 20px""> ")
strBody.AppendFormat(" <td>Fecha:</td><td colspan='3'> <b>{0}</b></td> ", TxtFechaDocumento.Text)
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 20px""> ")
strBody.AppendFormat(" <td>Observaciones</td><td colspan=""3""><textarea name=""ctlTJ"" rows=""5"" cols=""20"" readonly=""readonly""id=""ctlTJ"" style=""width: 300px;"">{0}</textarea></td> ", TxtObservaciones.Text)
strBody.Append(" </tr> ")
strBody.Append(" </table> ")
strBody.Append(" </fieldset> ")
strBody.Append(" </div> ")
strBody.Append("</body></html>")
Try
ViewState("Para") = StrCorreos.ToString 'String.Join(";", CorreosCCP.Distinct().ToArray)
'ViewState("ArrayCC") =
ViewState("Asunto") = "SIG -Transferencia Realizada"
ViewState("Body") = strBody.ToString
ViewState("Adjunto") = Comprobante
Dim Hilo As New System.Threading.Thread(AddressOf MandaCorreo)
Hilo.Start()
' If NotificarAlert = True Then Alert("Se enviara correo por cambio de Estatus")
Catch ex As Exception
OnError("Ocurri<EFBFBD> error al mandar MAIL", ex)
End Try
End Sub
Private Sub MandaCorreo()
'Dim ArrayAttachment As New List(Of String)
Dim ListaArchivos As New List(Of ClsSisMail.ArchivoMail)
If ViewState("Adjunto") IsNot Nothing AndAlso ViewState("Adjunto") <> "" Then
' ArrayAttachment.Add(ViewState("Adjunto").ToString)
ListaArchivos.Add(New ClsSisMail.ArchivoMail With {.Ruta = ViewState("Adjunto").ToString})
End If
Dim Mail As New ClsSisMail()
'Mail.MandaCorreo(EmpresaNotificaciones, ViewState("Para").ToString, ViewState("Asunto").ToString, ViewState("Body").ToString, ArrayAttachment:=ArrayAttachment)
Mail.SendMail(EmpresaNotificaciones, ViewState("Para").ToString, ViewState("Asunto").ToString, ViewState("Body").ToString, Archivos:=ListaArchivos)
End Sub
Private Sub CargaFolio(CveCuenta As Integer, CveTipoTransaccion As Integer)
TxtFolio.Text = GetFolio(CveCuenta, CveTipoTransaccion)
End Sub
Private Function GetFolio(CveCuenta As Integer, CveTipoTransaccion As Integer) As String
Dim Folio As String
Dim Banco As New ClsBancos
Folio = Banco.GetNextFolio(CveCuenta, CveTipoTransaccion).ToString
Banco.Dispose()
Return Folio
End Function
Private Sub chkMovimientoTarjeta_CheckedChanged(sender As Object, e As EventArgs) Handles chkMovimientoTarjeta.CheckedChanged
If chkMovimientoTarjeta.Checked Then
If GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros(String.Format("CveCuenta = {0} AND UsaTarjeta = 1", DdlCuentaDestino.SelectedValue.ToEntero)).Rows.Count > 0 Then
CargaGridTarjetas()
End If
Else
GvTC.Visible = False
UpGvTC.Update()
End If
End Sub
Private Sub DdlTipoMovto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoMovto.SelectedIndexChanged
If Opcion = 1 Then
CargaFolio(DdlCuentaDestino.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
Else
CargaFolio(DdlCuentaOrigen.SelectedValue.ToEntero, DdlTipoMovto.SelectedValue.ToEntero)
End If
End Sub
Protected Sub RBLOpcion_SelectedIndexChanged(sender As Object, e As EventArgs)
If RBLOpcion.SelectedValue = "2" Then ' reembolso
DdlTipoMovto.Items.Clear()
DdlTipoMovto.Items.Add(New ListItem("Dep<EFBFBD>sito", "4"))
Else
DdlTipoMovto.Items.Clear()
DdlTipoMovto.Items.Add(New ListItem("Cheque Emitido", "1"))
DdlTipoMovto.Items.Add(New ListItem("Transferencia Bancaria", "2"))
End If
End Sub
Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
CambiaTipoMoneda()
End Sub
Private Sub CambiaTipoMoneda()
If TxtTipoCambio.Visible = True Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
End If
If tCveMonedaOrigen = 1 AndAlso tCveMonedaDestino <> 1 Then
'pesos a otra moneda se divide
RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='2'; Calcula();")
ElseIf tCveMonedaOrigen <> 1 AndAlso tCveMonedaDestino = 1 Then
'de otra moneda a pesos se multiplica
RegistraScript("$get('TrTC').style.display=''; $get('HdnTC').value='1'; Calcula();")
End If
UPPDatos.Update()
End Sub
Private Sub CargaMovimientosCajaChica()
Dim CveCajaChica As Integer = DdlCuentaOrigen.SelectedValue.ToEntero()
Dim ObjMovtos As New ClsMovimientos
If ObjMovtos.GetCajaChicaDetalle(CveCajaChica, UsuarioActual.CveEmpresa) Then
DdlCajaChica.DataSource = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha")
End If
ObjMovtos.Dispose()
DdlCajaChica.DataBind()
DdlCajaChica.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
End Class