Sunteți pe pagina 1din 19

Private Sub impresion() On Error GoTo errores Dim formato As String = procedures.

consulta_descripcion(1, "formato", "t ipos_cobro", " where index_tipcob = " & Index_tipcobTextBox.Text & "", "", "") If formato = "" Then MsgBox("No se ha asignado ningun formato a este tip o de movimiento.", vbCritical) : Exit Sub formula_reporte = "{cuentasxcobrar.folio_cxc} = '" & Trim(Me.Folio_cxcTe xtBox.Text) & "' " If los_reportes = "" Then MsgBox("La ubicacin de los reportes no ha sido configurada.", MsgBoxStyle.Critical) : Exit Sub ubicacion_reporte = los_reportes & "\" & formato & ".rpt" crystal.ShowDialog() 'zzAx'CrystalReport1.WindowTitle = "Emisin de documentos" 'zzAx'CrystalReport1.GroupSelectionFormula = Formula 'zzAx'CrystalReport1.SelectionFormula = Formula 'zzAx'CrystalReport1.Connect = Variables_globales.conecta_crystal 'zzAx'CrystalReport1.WindowState = Crystal.WindowStateConstants.crptMaxi mized : 'zzAx'CrystalReport1.Action = 1 Exit Sub errores: MsgBox(Err.Description, vbCritical) End Sub Private Sub Index_tipcobTextBox_TextChanged(ByVal sender As System.Object, B yVal e As System.EventArgs) Handles Index_tipcobTextBox.TextChanged 'sql = "select isnull(Folio_automatico,0) as descripcion from tipos_cobr o where index_tipcob = " & Index_tipcobTextBox.Text & "" 'If procedures.consulta_descripcion_sql(sql) = 1 Then ' folio_consecutivo = 1 ' Me.Folio_cxcTextBox.Text = "" ' Me.Folio_cxcTextBox.Enabled = False ' Me.Folio_cxcTextBox.BackColor = Color.Gray 'Else ' folio_consecutivo = 0 'End If End Sub Private Sub CUENTASXCOBRARBindingNavigatorSaveItem_Click(ByVal sender As Sys tem.Object, ByVal e As System.EventArgs) Handles CUENTASXCOBRARBindingNavigatorS aveItem.Click On Error GoTo errores If Folio_cxcTextBox.Enabled = True Then sql = "SELECT COUNT(FOLIO_CXC) AS DESCRIPCION FROM CUENTASXCOBRAR W HERE Folio_cxc = '" & Me.Folio_cxcTextBox.Text & "'" If procedures.consulta_descripcion_sql(sql) <> 0 Then MsgBox("El fol io ya existe, teclee un folio vlido", MsgBoxStyle.Critical) : Me.Folio_cxcTextBox .Text = "" : Me.Folio_cxcTextBox.Focus() : Exit Sub End If If MsgBox("Estan correcto sus datos?", vbQuestion + vbYesNo, "Cargos y Ab onos") = vbNo Then Exit Sub If Me.Razonsocial_cliLabel1.Text = "" Then MsgBox("Seleccione un cliente vlido.", MsgBoxStyle.Critical) : Exit S ub End If If Me.Descripcion_tipcobLabel1.Text = "" Then MsgBox("Seleccione un movimiento vlido.", MsgBoxStyle.Critical) : Exi

t Sub End If If Me.Descripcion_monLabel1.Text = "" Then MsgBox("Seleccione una moneda vlida.", MsgBoxStyle.Critical) : Exit S ub End If If Me.MontoTextBox.Text = "" Then MsgBox("Teclee un monto vlido.", MsgBoxStyle.Critical) : Exit Sub End If If Me.MontoTextBox.Text * 1 = 0 Then MsgBox("Teclee un monto vlido.", MsgBoxStyle.Critical) : Exit Sub End If Me.ErrorProvider1.Clear() If folio_consecutivo <> 1 Then If Me.Folio_cxcTextBox.Text = "" Then MsgBox("Teclee un folio vlido.", MsgBoxStyle.Critical) : Exit Sub End If Else confirma_tipo_documento() End If If folio_consecutivo = 1 Then If Me.ObservacionTextBox.Text = "" Then MsgBox("Teclee un concepto vl ido", MsgBoxStyle.Critical) : ObservacionTextBox.Focus() : Exit Sub End If 'ES CARGO O ES ABONO sql = "select tipo as descripcion from tipos_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" Dim tipo_pago_signo As Long = procedures.consulta_descripcion_sql(sql) procedures.analiza_cuenta_rubro() If tipo_pago_signo = -1 Then If iva <> 0 Then Dim iva_1 As String iva_1 = iva / 100 iva_1 = iva_1 + 1 ivamonto = MontoTextBox.Text / iva_1 ivamonto = MontoTextBox.Text - ivamonto End If If pedido.Text = "" Then mipedido = 0 Else mipedido = Me.pedido.Text End If If folio_consecutivo = 0 Then index_cxc = Format(Now, "yyyyMMddhhmmss") & "-" & Mid(UserName, 1, 20) & "-" & "CXC" & "-" & noaprobacion_c & "-" & var_cuenta & "" If Me.Folio_fiscalTextBox.Text <> "" Then sql = "declare @maxfolio as real;select @maxfolio = max(isnu ll(CONSECUTIVO,0)) + 1 from cuentasxcobrar where isnull(serie,'" & noaprobacion _c & "') = '" & noaprobacion_c & "';Insert into cuentasxcobrar (pedido,folio_cxc ,monto,saldo,folio_fiscal,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,index_moneda,iv a,index_suc,SERIE,CONSECUTIVO,index_cxc,iva_monto) values " _

& "('" & mipedido & "','" & noaprobacion_c & "' + cast(@maxf olio as varchar(5))," & Me.MontoTextBox.Text * (-1) & "," & Me.MontoTextBox.Text * (-1) & "" _ & "," & Me.Folio_fiscalTextBox.Text & ",'" & Me.ObservacionT extBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "', '" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "'+ plazo_cli,'" & Me.Inde x_cliTextBox.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.Index_monedaTe xtBox.Text & "," & iva & "," & var_cuenta & ",'" & noaprobacion_c & "',@maxfolio ,'" & index_cxc & "'," & ivamonto & ")" Else sql = "declare @maxfolio as real;select @maxfolio = max(isnu ll(CONSECUTIVO,0)) + 1 from cuentasxcobrar where isnull(serie,'" & noaprobacion _c & "') = '" & noaprobacion_c & "';Insert into cuentasxcobrar (pedido,folio_cxc ,monto,saldo,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,ind ex_moneda,iva,index_suc,SERIE,CONSECUTIVO,index_cxc,iva_monto) values " _ & "('" & mipedido & "','" & noaprobacion_c & "' + cast(@maxfolio as varchar(5))," & Me.MontoTextBox.Text * (-1) & "," & Me.Mont oTextBox.Text * (-1) & "" _ & ",'" & Me.ObservacionTextBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/ yyyy") & "','" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Ind ex_cliTextBox.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.In dex_monedaTextBox.Text & "," & iva & "," & var_cuenta & ",'" & noaprobacion_c & "',@maxfolio,'" & index_cxc & "'," & ivamonto & ")" End If Else If Me.Folio_fiscalTextBox.Text <> "" Then sql = "Insert into cuentasxcobrar (pedido,folio_cxc,monto,sa ldo,folio_fiscal,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,index_moneda,iv a,index_suc,iva_monto) values " _ & "('" & mipedido & "','" & Me.Folio_cxcTextBox.Text & "'," & Me.MontoTextBox.Text * (-1) & "," & Me.MontoTextBox.Text * (-1) & "" _ & "," & Me.Folio_fiscalTextBox.Text & ",'" & Me.ObservacionT extBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "', '" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Index_cliTextBo x.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.Index_monedaTe xtBox.Text & "," & iva & "," & var_cuenta & "," & ivamonto & ")" Else If Impuesto.Text = "" Then Impuesto.Text = "0" ivamonto = Impuesto.Text sql = "Insert into cuentasxcobrar (pedido,folio_cxc,monto,sa ldo,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,ind ex_moneda,iva,index_suc,iva_monto) values " _ & "('" & mipedido & "','" & Me.Folio_cxcTextBox. Text & "'," & Me.MontoTextBox.Text * (-1) & "," & Me.MontoTextBox.Text * (-1) & "" _ & ",'" & Me.ObservacionTextBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/ yyyy") & "','" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Ind ex_cliTextBox.Text & "', " _

& "" & Me.Index_tipcobTextBox.Text & "," & Me.In dex_monedaTextBox.Text & "," & iva & "," & var_cuenta & "," & ivamonto & ")" End If End If Else If iva <> 0 Then Dim iva_1 As String iva_1 = iva / 100 iva_1 = iva_1 + 1 ivamonto = MontoTextBox.Text / iva_1 ivamonto = MontoTextBox.Text - ivamonto End If If folio_consecutivo = 1 Then index_cxc = Format(Now, "yyyyMMddhhmmss") & "-" & Mid(UserName, 1, 20) & "-" & "CXC" & "-" & noaprobacion_c & "-" & var_cuenta & "" If Me.Folio_fiscalTextBox.Text <> "" Then sql = "declare @maxfolio as real;select @maxfolio = max(isnu ll(CONSECUTIVO,0)) + 1 from cuentasxcobrar where isnull(serie,'" & noaprobacion _c & "') = '" & noaprobacion_c & "';Insert into cuentasxcobrar (folio_cxc,monto, saldo,folio_fiscal,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,index_moneda,iv a,index_suc,SERIE,CONSECUTIVO,index_cxc,iva_monto) values " _ & "('" & noaprobacion_c & "' + cast(@maxfolio as varchar(5)) ," & Me.MontoTextBox.Text & "," & Me.MontoTextBox.Text & "" _ & "," & Me.Folio_fiscalTextBox.Text & ",'" & Me.ObservacionT extBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "', '" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Index_cliTextBo x.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.Index_monedaTe xtBox.Text & "," & iva & "," & var_cuenta & ",'" & noaprobacion_c & "',@maxfolio ,'" & index_cxc & "'," & ivamonto & ")" Else sql = "declare @maxfolio as real;select @maxfolio = max(isnu ll(CONSECUTIVO,0)) + 1 from cuentasxcobrar where isnull(serie,'" & noaprobacion _c & "') = '" & noaprobacion_c & "';Insert into cuentasxcobrar (folio_cxc,monto, saldo,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,ind ex_moneda,iva,index_suc,SERIE,CONSECUTIVO,index_cxc,iva_monto) values " _ & "('" & noaprobacion_c & "' + cast(@maxfolio a s varchar(5))," & Me.MontoTextBox.Text & "," & Me.MontoTextBox.Text & "" _ & ",'" & Me.ObservacionTextBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/ yyyy") & "','" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Ind ex_cliTextBox.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.In dex_monedaTextBox.Text & "," & iva & "," & var_cuenta & ",'" & noaprobacion_c & "',@maxfolio,'" & index_cxc & "'," & ivamonto & ")" End If Else If Me.Folio_fiscalTextBox.Text <> "" Then sql = "Insert into cuentasxcobrar (pedido,folio_cxc,monto,sa ldo,folio_fiscal,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,index_moneda,iv a,index_suc,iva_monto) values " _ & "('" & mipedido & "','" & Me.Folio_cxcTextBox.Text & "'," & Me.MontoTextBox.Text & "," & Me.MontoTextBox.Text & "" _

& "," & Me.Folio_fiscalTextBox.Text & ",'" & Me.ObservacionT extBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "', '" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Index_cliTextBo x.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.Index_monedaTe xtBox.Text & "," & iva & "," & var_cuenta & "," & ivamonto & ")" Else If Impuesto.Text = "" Then Impuesto.Text = "0" ivamonto = Impuesto.Text sql = "Insert into cuentasxcobrar (pedido,folio_cxc,monto,sa ldo,observacion " _ & ",fecha,fecha_vence,index_cli,index_tipcob,ind ex_moneda,iva,index_suc,iva_monto) values " _ & "('" & mipedido & "','" & Me.Folio_cxcTextBox. Text & "'," & Me.MontoTextBox.Text & "," & Me.MontoTextBox.Text & "" _ & ",'" & Me.ObservacionTextBox.Text & "', " _ & "'" & Format(Me.DateTimePicker1.Value, "dd/MM/ yyyy") & "','" & Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") & "','" & Me.Ind ex_cliTextBox.Text & "', " _ & "" & Me.Index_tipcobTextBox.Text & "," & Me.In dex_monedaTextBox.Text & "," & iva & "," & var_cuenta & "," & ivamonto & ")" End If End If End If If procedures.guardar_query(sql) = 0 Then '**************************** guarda en facturas bloquea() If folio_consecutivo = 1 Then Dim folio As Integer sql = "select CONSECUTIVO as descripcion from cuentasxcobrar whe re index_cxc = '" & index_cxc & "'" folio = procedures.consulta_descripcion_sql(sql) sql = "select isnull(tipo_notacredito,0) as descripcion from tip os_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" Dim cargo_abono_tipo_mov As Long cargo_abono_tipo_mov = procedures.consulta_descripcion_sql(sql) If cargo_abono_tipo_mov = -1 Then sql = "EXEC [spNota_credito_generacion] " & folio & ",'" & Entrar.TextBox2.Text & "','" & Index_cliTextBox.Text & "'" procedures.guardar_query_factura_electronica(sql) MsgBox("Nota de crdito generada", MsgBoxStyle.Exclamation) tipo_archivo = "Nota de crdito" Else sql = "EXEC [spNota_cargo_generacion] " & folio & " ,'" & E ntrar.TextBox2.Text & "','" & Index_cliTextBox.Text & "'" procedures.guardar_query_factura_electronica(sql) MsgBox("Nota de cargo generada", MsgBoxStyle.Exclamation) tipo_archivo = "Nota de cargo" End If

sql = "select folio_cxc as descripcion from cuentasxcobrar w here index_cxc = '" & index_cxc & "'" Me.Folio_cxcTextBox.Text = procedures.consulta_descripcion_s ql(sql) sql = "select isnull(vinculacion_comprobante_digital,0) as d escripcion from tipos_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" If procedures.consulta_descripcion_sql(sql) <> 0 Then sql = "select formato as descripcion from tipos_cobro wh ere index_tipcob = " & Index_tipcobTextBox.Text & "" formato = procedures.consulta_descripcion_sql(sql) If MsgBox("Desea imprimir la " & tipo_archivo & " ?", vbQ uestion + vbYesNo + vbDefaultButton1) = vbNo Then If MsgBox("Desea enviar el archivo de la " & tipo_arc hivo & " via e-mail?", vbQuestion + vbYesNo + vbDefaultButton1) = vbNo Then no_imprime = 0 genera_archivos() Me.ToolStripButton2.Visible = True MsgBox("Presione el boton para generar el archiv o pdf", MsgBoxStyle.Information) 'Me.ToolStripButton2.PerformClick() 'Me.ToolStripButton2.Visible = False 'Exit Sub Else no_imprime = 1 genera_archivos() Me.ToolStripButton2.Visible = True MsgBox("Presione el boton para generar el archiv o pdf", MsgBoxStyle.Information) 'Me.ToolStripButton2.PerformClick() 'Me.ToolStripButton2.Visible = False 'Me.ToolStripButton3.Visible = True End If Else imprime_notacc() If ENTRAREPORTE = 1 Then MsgBox("No se encontro la ruta del reporte ", Ms gBoxStyle.Critical) Me.ToolStripButton2.Visible = True bloquea() Exit Sub End If If MsgBox("Desea enviar el archivo de la " & tipo_arc hivo & " via e-mail", vbQuestion + vbYesNo + vbDefaultButton1) = vbNo Then no_imprime = 0 genera_archivos() Me.ToolStripButton2.Visible = True MsgBox("Presione el boton para generar el archiv o pdf", MsgBoxStyle.Information) 'Me.ToolStripButton2.PerformClick() 'Me.ToolStripButton2.Visible = False 'Me.ToolStripButton3.Visible = True 'Exit Sub Else no_imprime = 1

genera_archivos() Me.ToolStripButton2.Visible = True MsgBox("Presione el boton para generar el archiv o pdf", MsgBoxStyle.Information) 'Me.ToolStripButton2.PerformClick() 'Me.ToolStripButton2.Visible = False 'Me.ToolStripButton3.Visible = True End If End If End If End If no_entro = 1 If folio_consecutivo <> 1 Then Me.Dispose() End If folio_consecutivo = 0 Exit Sub Else folio_consecutivo = 0 Exit Sub End If no_entro = 1 Me.Dispose() Index_sucTextBox.Text = SucursalToolStripTextBox.Text FechaTextBox.Text = Format(Me.DateTimePicker1.Value, "dd/MM/yyyy") Me.Fecha_venceTextBox.Text = Format(Me.DateTimePicker1.Value, "dd/MM /yyyy") Me.Validate() Me.CUENTASXCOBRARBindingSource.EndEdit() Me.CUENTASXCOBRARTableAdapter.Update(Me.Cargos_abonos_data.CUENTASXC OBRAR) Panel1.Enabled = False MsgBox("Registro guardado.", MsgBoxStyle.Exclamation) CUENTASXCOBRARBindingNavigatorSaveItem.Visible = False bloquea() Exit Sub errores: MsgBox(Err.Description, MsgBoxStyle.Critical) End Sub Private Sub bloquea() Index_cliTextBox.Enabled = False Index_cliTextBox.BackColor = Color.White Index_tipcobTextBox.Enabled = False Index_tipcobTextBox.BackColor = Color.White Index_monedaTextBox.Enabled = False Index_monedaTextBox.BackColor = Color.White ObservacionTextBox.Enabled = False ObservacionTextBox.BackColor = Color.White IvaTextBox.Enabled = False IvaTextBox.BackColor = Color.White MontoTextBox.Enabled = False MontoTextBox.BackColor = Color.White Folio_cxcTextBox.Enabled = False Folio_cxcTextBox.BackColor = Color.White Me.CUENTASXCOBRARBindingNavigatorSaveItem.Visible = False End Sub

Private Sub genera_archivos() genera_pdf() End Sub Private Sub confirma_tipo_documento() sql = "select isnull(tipo_notacredito,0) as descripcion from tipos_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" Dim cargo_abono_tipo_mov As Long cargo_abono_tipo_mov = procedures.consulta_descripcion_sql(sql) If cargo_abono_tipo_mov <> 0 Then If cargo_abono_tipo_mov = 1 Then sql = "select isnull(noaprobacion_notascargos,0) as descripcion from usuarios_permisos where elusuario = '" & Entrar.TextBox2.Text & "'" Else sql = "select isnull(noaprobacion_notascredito,0) as descripcion from usuarios_permisos where elusuario = '" & Entrar.TextBox2.Text & "'" End If noaprobacion_c = procedures.consulta_descripcion_sql(sql) If noaprobacion_c = "" Then MsgBox("Este usuario no est configurado p ara manejar notas de crdito", MsgBoxStyle.Critical) : Exit Sub sql = "select max(CONSECUTIVO) + 1 as descripcion from cuentasxcobra r where serie = '" & noaprobacion_c & "'" If procedures.consulta_descripcion_sql(sql) = "" Then folio_fac = 1 Else folio_fac = procedures.consulta_descripcion_sql(sql) End If sql = "select folio_final as descripcion from Aprovacion_factura_ele ctronica where serie = '" & noaprobacion_c & "' " Dim folio_final As Long = procedures.consulta_descripcion_sql(sql) If folio_fac > folio_final Then MsgBox("Se han agotado el nmero de fo lios en notas de crdito", MsgBoxStyle.Critical) : Exit Sub tipo_nota = 1 complemento_ruta = "Notas_credito" CONFIRAMA_RUTA_PDF() End If sql = "select isnull(nota_cargo_otra,0) as descripcion from tipos_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" If procedures.consulta_descripcion_sql(sql) <> 0 Then sql = "select isnull(noaprobacion_notascargos,0) as descripcion from usuarios_permisos where elusuario = '" & Entrar.TextBox2.Text & "'" noaprobacion_c = procedures.consulta_descripcion_sql(sql) If noaprobacion_c = "" Then MsgBox("Este usuario no esta configurado para manejar notas de cargo", MsgBoxStyle.Critical) : Exit Sub sql = "select max(CONSECUTIVO) + 1 as descripcion from cuentasxcobra r where serie = '" & noaprobacion_c & "'" If procedures.consulta_descripcion_sql(sql) = "" Then folio_fac = 1 Else folio_fac = procedures.consulta_descripcion_sql(sql) End If sql = "select folio_final as descripcion from Aprovacion_factura_ele ctronica where serie = '" & noaprobacion_c & "' " Dim folio_final As Long = procedures.consulta_descripcion_sql(sql) If folio_fac > folio_final Then MsgBox("Se han agotado el nmero de fo lios en notas de cargo", MsgBoxStyle.Critical) : Exit Sub

'Me.Folio_cxcTextBox.Text = noaprobacion_c & folio_fac tipo_nota = 2 complemento_ruta = "Notas_cargo" CONFIRAMA_RUTA_PDF() End If End Sub Private Sub imprime_notacc() Try If Folio_cxcTextBox.Text = "" Then MsgBox("Seleccione un folio vlido" , MsgBoxStyle.Critical) : Exit Sub If Index_tipcobTextBox.Text = "" Then MsgBox("Seleccione un concepto de cobro vlido", MsgBoxStyle.Critical) : Exit Sub If formato = "" Then Exit Sub 'formato = "Notas_Cargo_Bertran" formula_reporte = "{VNotaCreditoyCargo_electronica_emision.folio_cxc } = '" & Folio_cxcTextBox.Text & "'" If los_reportes = "" Then MsgBox("La ubicacin de los reportes no ha s ido configurada.", MsgBoxStyle.Critical) : Exit Sub If formato = "" Then MsgBox("El tipo de cobro no tiene configurado u n formato comrpobante fiscal digital.", MsgBoxStyle.Critical) : Exit Sub If Len(los_reportes) = 3 Then ubicacion_reporte = los_reportes & RTrim(LTrim(formato)) & ".rpt " Else ubicacion_reporte = los_reportes & "\" & RTrim(LTrim(formato)) & ".rpt" End If tipo_reporte_crystal = formato crystal.ShowDialog() Exit Sub Catch ex As Exception MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Sub genera_pdf() On Error GoTo errores Mi_reporte = New ReportDocument() 'If no_aprobacion = "" Then MsgBox("Seleccione un folio vlido", MsgBoxSty le.Critical) : Exit Sub If Index_tipcobTextBox.Text = "" Then MsgBox("Seleccione un concepto de cobro vlido", MsgBoxStyle.Critical) : Exit Sub If formato = "" Then Exit Sub formula_reporte = "{VNotaCreditoyCargo_electronica_emision.folio_cxc} = '" & Folio_cxcTextBox.Text & "'" If los_reportes = "" Then MsgBox("La ubicacin de los reportes no ha sido configurada.", MsgBoxStyle.Critical) : Exit Sub 'Else 'sql = "select isnull(formato_factura_nofiscal,'') as descripcion from m gcli where index_cli = '" & cliente & "'" 'formato_factura = procedures.consulta_descripcion_sql(sql) 'End If If formato = "" Then MsgBox("El tipo de cobro no tiene configurado un fo rmato comprobante fiscal digital.", MsgBoxStyle.Critical) : Exit Sub If Len(los_reportes) = 3 Then

ubicacion_reporte = los_reportes & formato & ".rpt" Else ubicacion_reporte = los_reportes & "\" & formato & ".rpt" End If Dim reportPath As String = Variables_globales.ubicacion_reporte Mi_reporte.Load(reportPath) CrystalReportViewer1.ReportSource = Mi_reporte Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() CrystalReportViewer1.SelectionFormula = Variables_globales.formula_repor te myConnectionInfo.DatabaseName = Entrar.TextBox4.Text myConnectionInfo.ServerName = Entrar.TextBox4.Text myConnectionInfo.UserID = "keynetfactory" myConnectionInfo.Password = "keynetfactory123456" SetDBLogonForReport(myConnectionInfo, Mi_reporte) Me.ToolStripButton3.Visible = False 'CrystalReportViewer1.(0) = "observacion1= 'PRUEBA'" Exit Sub errores: MsgBox(Err.Description, MsgBoxStyle.Critical) End Sub Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, By Val myReportDocument As ReportDocument) Dim myTables As Tables = myReportDocument.Database.Tables For Each myTable As Table In myTables Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo myTableLogonInfo.ConnectionInfo = myConnectionInfo myTable.ApplyLogOnInfo(myTableLogonInfo) Next End Sub Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Cargos_abonos_Load(ByVal sender As System.Object, ByVal e As Sys tem.EventArgs) Handles MyBase.Load sql = "select max(isnull(,0)) + 1 as descripcion from " On Error GoTo ERRORES BindingNavigatorMoveFirstItem.ToolTipText = "Mover primero" BindingNavigatorMovePreviousItem.ToolTipText = "Mover previo" BindingNavigatorCountItem.ToolTipText = "de {0}" BindingNavigatorMoveNextItem.ToolTipText = "Mover siguiente" BindingNavigatorMoveLastItem.ToolTipText = "Mover ltimo" BindingNavigatorAddNewItem.ToolTipText = "Agregar registro(s)" BindingNavigatorDeleteItem.ToolTipText = "Eliminar registro(s) o cancela r operaciones" CUENTASXCOBRARBindingNavigatorSaveItem.ToolTipText = "Actualizar registr o(s)" centrar(sender) Me.DateTimePicker1.Value = Now

Exit Sub ERRORES: MsgBox(Err.Description, MsgBoxStyle.Critical) End Sub Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Wi ndows.Forms.PaintEventArgs) Handles Panel1.Paint End Sub Private Sub MontoTextBox_KeyDown(ByVal sender As Object, ByVal e As System.W indows.Forms.KeyEventArgs) Handles MontoTextBox.KeyDown If e.KeyCode = Keys.Enter Then CUENTASXCOBRARBindingNavigatorSaveItem.PerformClick() End If End Sub

Private Sub Index_cliTextBox_KeyDown(ByVal sender As Object, ByVal e As Syst em.Windows.Forms.KeyEventArgs) Handles Index_cliTextBox.KeyDown If e.KeyCode = Keys.Enter Then If Me.Razonsocial_cliLabel1.Text = "" And Me.Index_cliTextBox.Text < > "" Then Me.Razonsocial_cliLabel1.Text = procedures.consulta_descripcion( 1, "razonsocial_cli", "mgcli", " where index_cli = '" & Me.Index_cliTextBox.Text & "'", "", "") End If SendKeys.Send("{tab}") End If If e.KeyCode = Keys.F4 Then procedures.modulo_auxiliar(1, "Index_cliTextBox", 1, "", "Mgcli", "I ndex_cli", "Razonsocial_cli", "Cliente", " and index_cli like '%" & Index_cliTex tBox.Text & "%' or Razonsocial_cli like '%" & Index_cliTextBox.Text & "%'", "ord er by razonsocial_cli", "", "", Me.Name, "Id", "Razn Social") Me.Index_cliTextBox.Text = auxiliar.index Me.Razonsocial_cliLabel1.Text = auxiliar.descripcion End If End Sub Private Sub Index_cliTextBox_TextChanged(ByVal sender As System.Object, ByVa l e As System.EventArgs) Handles Index_cliTextBox.TextChanged Me.Razonsocial_cliLabel1.Text = "" End Sub Private Sub Index_tipcobTextBox_KeyDown(ByVal sender As Object, ByVal e As S ystem.Windows.Forms.KeyEventArgs) Handles Index_tipcobTextBox.KeyDown If e.KeyCode = Keys.Enter Then If Me.Index_tipcobTextBox.Text <> "" And Me.Descripcion_tipcobLabel1 .Text = "" Then If IsNumeric(Me.Index_tipcobTextBox.Text) Then Me.Descripcion_tipcobLabel1.Text = procedures.consulta_descr ipcion(0, "descripcion_tipcob", "Tipos_cobro", " where index_tipcob = " & Me.Ind ex_tipcobTextBox.Text & "", "", "")

End If End If SendKeys.Send("{tab}") End If If e.KeyCode = Keys.F4 Then procedures.modulo_auxiliar(0, "Index_tipcobTextBox", 0, Index_tipcob TextBox.Text, "tipos_cobro", "index_tipcob", "descripcion_tipcob", "Concepto", " and aplicacion_manual <> 0 and index_tipcob <> 0 or index_tipcob = 0", "", "", " order by descripcion_tipcob", Me.Name, "Id", "Descripcin") Index_tipcobTextBox.Text = auxiliar.index Descripcion_tipcobLabel1.Text = auxiliar.descripcion End If End Sub

'Private Sub Index_tipcobTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Index_tipcobTextBox.TextChanged 'If Index_tipcobTextBox.Text = "" Then Me.Descripcion_tipcobLabel1.Text = "" : Exit Sub 'If Me.Descripcion_tipcobLabel1.Text <> "" Then ' Exit Sub 'End If 'End Sub 'para cancelar (boton escondido) Private Sub ToolStripButton15_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton15.Click On Error GoTo errores If MsgBox("Desea cancelar este Documento?", vbCritical + vbYesNo + vbDefa ultButton2, "Eliminando Registro") = vbNo Then Exit Sub sql = "Insert into Notas_credito_canceladas (index_tipcob,folio_cxc,fech a,index_cli,folio_fiscal) select index_tipcob,folio_cxc,fecha,index_cli,folio_fi scal from cuentasxcobrar where folio_cxc = '" & Folio_cxcTextBox.Text & "'" procedures.guardar_query(sql) If aplica_guardar = 0 Then MsgBox("Movimiento cancelado.", vbCritical) End If Exit Sub errores: MsgBox(Err.Description, vbCritical) End Sub 'boton escondido de impresin Private Sub imprime_ca_Click(ByVal sender As System.Object, ByVal e As Syste m.EventArgs) Handles imprime_ca.Click On Error GoTo errores If Folio_cxcTextBox.Text = "" Then MsgBox("Seleccione una nota vlida.", v bCritical) : Exit Sub sql = "SELECT FOLIO_FISCAL FROM CUENTASXCOBRAR WHERE FOLIO_CXC = '" & Fo lio_cxcTextBox.Text & "' " Dim MI_FOLIO_FISCAL As String = procedures.consulta_descripcion(1, "FOLI O_FISCAL", "CUENTASXCOBRAR", " WHERE FOLIO_CXC = '" & Folio_cxcTextBox.Text & " ' ", "", "") If MI_FOLIO_FISCAL <> "" Then impresion() Exit Sub Else Dim Valor_maximo As String = procedures.Valor_maximo_proc2("vcuentas

xcobrar_folio_fiscal", "folio_fiscal") sql = "SELECT FOLIO_FISCAL FROM CUENTASXCOBRAR WHERE FOLIO_CXC = '" & Folio_cxcTextBox.Text & "' " MI_FOLIO_FISCAL = procedures.consulta_descripcion(1, "FOLIO_FISCAL", "cuentasxcobrar", " WHERE FOLIO_CXC = '" & Folio_cxcTextBox.Text & "' ", "", " ") End If serie.Text = procedures.consulta_descripcion(1, "serie_nota_credito", "u suarios_sucursales", "where upper(elusuario) = upper(current_user)", "", "") Dim bloqueo As Long = procedures.consulta_descripcion(0, "isnull(bloqueo _notas_credito,0)", "CONFIGURACION_SiS", "", "", "") If bloqueo = 1 Then folio.Enabled = True Else folio.Enabled = False End If 'CUENTASXCOBRARBindingNavigator.Enabled = False 'FillToolStrip.Enabled = False 'Me.Panel1.Enabled = False GroupBox1.Visible = True Exit Sub errores: MsgBox(Err.Description, vbCritical) End Sub Private Sub ToolStripButton17_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton17.Click folios_asignados.ShowDialog() End Sub Private Sub Index_monedaTextBox_KeyDown(ByVal sender As Object, ByVal e As S ystem.Windows.Forms.KeyEventArgs) Handles Index_monedaTextBox.KeyDown If e.KeyCode = Keys.F4 Then procedures.modulo_auxiliar(1, "Index_monedaTextBox", 1, Index_moneda TextBox.Text, "monedas", "index_moneda", "descripcion_mon", "Monedas", "", "", " ", "Order by descripcion_mon", Me.Name, "Id", "Moneda") Me.Index_monedaTextBox.Text = auxiliar.index Me.Descripcion_monLabel1.Text = auxiliar.descripcion End If If e.KeyCode = Keys.Enter Then If Me.Descripcion_monLabel1.Text = "" And Me.Index_monedaTextBox.Tex t <> "" Then If IsNumeric(Me.Index_monedaTextBox.Text) Then Me.Descripcion_monLabel1.Text = procedures.consulta_descripc ion(0, "descripcion_mon", "monedas", " where index_moneda = " & Me.Index_monedaT extBox.Text & "", "", "") End If End If Me.ObservacionTextBox.Focus() End If End Sub

Private Sub Index_monedaTextBox_TextChanged(ByVal sender As System.Object, B yVal e As System.EventArgs) Handles Index_monedaTextBox.TextChanged

Me.Descripcion_monLabel1.Text = "" End Sub Private Sub ToolStripButton21_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton21.Click Me.Dispose() End Sub Private Sub ToolStripButton20_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton20.Click calculadora() End Sub Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click Me.Panel1.Enabled = True End Sub Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click Me.Panel1.Enabled = False End Sub Private Sub FolioToolStripTextBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FolioToolStripTextBox.Click End Sub Private Sub FolioToolStripTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles FolioToolStripTextBox.KeyDown If e.KeyCode = Keys.Enter Then ToolStripButton16.PerformClick() End If End Sub Private Sub FechaTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FechaTextBox.TextChanged Me.DateTimePicker1.Text = Me.FechaTextBox.Text End Sub Private Sub ToolStripButton18_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton18.Click 'If Me.Folio_cxcTextBox.Text = "" Or Me.Panel1.Enabled = True Then MsgBo x("Seleccione un folio vlido.", MsgBoxStyle.Critical) : Exit Sub Dim mifolio As String = procedures.consulta_descripcion(1, "folio_cxc", "cuentasxcobrar", " where folio_cxc = '" & Folio_cxcTextBox.Text & "'", "", "") If mifolio = "" Then MsgBox("Folio invlido.", MsgBoxStyle.Critical) : Exi t Sub Clasifica_cobranza.ShowDialog() End Sub Private Sub Folio_cxcTextBox_KeyDown(ByVal sender As Object, ByVal e As Syst em.Windows.Forms.KeyEventArgs) Handles Folio_cxcTextBox.KeyDown If e.KeyCode = Keys.Enter Then Me.DateTimePicker1.Focus() End If End Sub

Private Sub Folio_cxcTextBox_TextChanged(ByVal sender As System.Object, ByVa l e As System.EventArgs) Handles Folio_cxcTextBox.TextChanged End Sub Private Sub DateTimePicker1_KeyDown(ByVal sender As Object, ByVal e As Syste m.Windows.Forms.KeyEventArgs) Handles DateTimePicker1.KeyDown If e.KeyCode = Keys.Enter Then Index_cliTextBox.Focus() End If End Sub Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVa l e As System.EventArgs) Handles DateTimePicker1.ValueChanged End Sub Private Sub ObservacionTextBox_KeyDown(ByVal sender As Object, ByVal e As Sy stem.Windows.Forms.KeyEventArgs) Handles ObservacionTextBox.KeyDown If e.KeyCode = Keys.Enter Then Me.MontoTextBox.Focus() End If End Sub Private Sub ObservacionTextBox_TextChanged(ByVal sender As System.Object, By Val e As System.EventArgs) Handles ObservacionTextBox.TextChanged End Sub Private Sub IvaTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Win dows.Forms.KeyEventArgs) Handles IvaTextBox.KeyDown If e.KeyCode = Keys.Enter Then Me.MontoTextBox.Focus() End If End Sub

Private Sub IvaTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Wi ndows.Forms.KeyPressEventArgs) Handles IvaTextBox.KeyPress End Sub Private Sub IvaTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IvaTextBox.TextChanged End Sub Private Sub ToolStripButton13_Click(ByVal sender As System.Object, ByVal e A s System.EventArgs) Handles ToolStripButton13.Click CUENTASXCOBRARBindingNavigator.Enabled = True FillToolStrip.Enabled = True Me.Panel1.Enabled = True GroupBox1.Visible = False End Sub Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click On Error GoTo errores

If folio.Text = "" Then MsgBox("Teclee un flio vlido.", vbCritical) : Exit Sub sql = "Update cuentasxcobrar set folio_fiscal = " & Me.folio.Text & ",se rie_nota_credito = '" & Me.serie.Text & "' where folio_cxc = '" & Me.Folio_cxcTe xtBox.Text & "' " procedures.guardar_query(sql) If aplica_guardar = 0 Then Me.Folio_fiscalTextBox.Text = serie.Text & folio.Text impresion() ToolStripButton13.PerformClick() End If Exit Sub errores: MsgBox(Err.Description, vbCritical) End Sub Private Sub FillToolStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles FillToolStrip.It emClicked End Sub Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click 'If no_aprobacion = "" Then MsgBox("Ingrese un folio vlido", MsgBoxStyle. Critical) : Exit Sub pdf() If no_imprime = 1 Then MsgBox("Presione el boton enviar e-mail", MsgBoxStyle.Information) Me.ToolStripButton3.Visible = True Else MsgBox("Archivo generado", MsgBoxStyle.Information) End If Me.ToolStripButton2.Visible = False End Sub Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click 'If Me.ToolStripButton24.Visible = True Then MsgBox("Antes de enviar una nota, debe generarla", MsgBoxStyle.Critical) : Exit Sub If Index_cliTextBox.Text = "" Then MsgBox("Seleccione uncliente vlido", M sgBoxStyle.Critical) If Folio_cxcTextBox.Text = "" Then MsgBox("Seleccione un folio vlido", Ms gBoxStyle.Critical) : Exit Sub 'If folio.Text = "" Then MsgBox("Seleccione un folio a facturar vlido", M sgBoxStyle.Critical) : Exit Sub sql = "select isnull(email,'') as descripcion from mgcli where index_cli = '" & Index_cliTextBox.Text & "'" Dim mail As String = procedures.consulta_descripcion_sql(sql) If mail = "" Then MsgBox("Este cliente no cuenta con correo electrnico, actualice sus d atos", MsgBoxStyle.Critical) : Exit Sub Else ' pdf() End If Dim myemail As New System.Web.Mail.MailMessage

Try SmtpMail.SmtpServer = "mail.bertran.com.mx" SmtpMail.Send(myemail) MsgBox(tipo_archivo & " enviada como archivo adjunto con xito", MsgB oxStyle.Exclamation) 'Me.Index_cliTextBox.Text = "" ' Me.ToolStripButton23.Visible = False Catch ex As Exception MsgBox(ex.Source & Chr(13) & ex.Message) End Try End Sub Private Sub pdf() Dim x As String On Error GoTo fallo x = GetAttr("" & ruta & "\Nota_C_CR-" & Folio_cxcTextBox.Text & ".pdf") MsgBox("El archivo de la factura electrnica ya existe, se encuentra en la ruta: " & ruta & "\Nota_C_CR-" & Folio_cxcTextBox.Text & ".pdf", MsgBoxStyle.Ex clamation) Exit Sub fallo: Dim CrExportOptions As ExportOptions Dim CrDiskFileDestinationOptions As New _ DiskFileDestinationOptions() Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions() CrDiskFileDestinationOptions.DiskFileName = _ "" & ruta & "\Nota_C_CR-" & Folio_cxcTextBox .Text & ".pdf" CrExportOptions = Mi_reporte.ExportOptions With CrExportOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat .DestinationOptions = CrDiskFileDestinationOptions .FormatOptions = CrFormatTypeOptions End With Mi_reporte.Export() End Sub Private Sub CONFIRAMA_RUTA_PDF() On Error Resume Next Dim FILE_NAME As String Dim line As String Dim sr As StreamReader 'lectura de la ubicacion de reportes facturas = "factura_electronica" FILE_NAME = "c:\ebasic" & "\" & Variables_globales.facturas & "_reportes .cfg" If Not File.Exists(FILE_NAME) Then Dim file As System.IO.FileStream file = System.IO.File.Create("c:\ebasic" & "\" & Variables_globales. facturas & "_reportes.cfg") file.Close() MsgBox("Configure la ruta de la ubicacin de los reportes.", MsgBoxSty le.Critical) 'ToolStripButton8.PerformClick() Else

sr = New StreamReader(FILE_NAME) Do line = sr.ReadLine() If Not line Is Nothing Then If Len(line) <> 0 Then ruta = Mid(line, 1, Len(line)) End If Loop Until line Is Nothing sr.Close() sql = "select isnull(nombre_factura,'') as descripcion from empresa" Dim nom_empresa As String = procedures.consulta_descripcion_sql(sql) If nom_empresa = "" Then Exit Sub ruta = ruta & "\" & nom_empresa & "\" & complemento_ruta End If End Sub

Private Sub Descripcion_tipcobLabel1_Click(ByVal sender As System.Object, By Val e As System.EventArgs) Handles Descripcion_tipcobLabel1.Click End Sub Private Sub Descripcion_tipcobLabel1_TextChanged(ByVal sender As Object, ByV al e As System.EventArgs) Handles Descripcion_tipcobLabel1.TextChanged If Descripcion_tipcobLabel1.Text <> "" Then sql = "select isnull(Folio_automatico,0) as descripcion from tipos_c obro where index_tipcob = " & Index_tipcobTextBox.Text & "" If procedures.consulta_descripcion_sql(sql) = 1 Then Label2.Text = "Concepto:" Else Label2.Text = "Observacin:" End If sql = "select isnull(iva,0) as descripcion from tipos_cobro where in dex_tipcob = " & Index_tipcobTextBox.Text & "" iva = procedures.consulta_descripcion_sql(sql) If Index_tipcobTextBox.Text = "0" Then Panel2.Visible = True Else Panel2.Visible = False End If If Descripcion_tipcobLabel1.Text <> "" Then sql = "select isnull(Folio_automatico,0) as descripcion from tip os_cobro where index_tipcob = " & Index_tipcobTextBox.Text & "" If procedures.consulta_descripcion_sql(sql) = 1 Then folio_consecutivo = 1 Me.Folio_cxcTextBox.Text = "" Me.Folio_cxcTextBox.Enabled = False Me.Folio_cxcTextBox.BackColor = Color.Gray Else folio_consecutivo = 0 End If End If End If End Sub 'inutil... pero lo requiere. investigar despues de urgencia

Private Sub MontoLabel_Click(ByVal sender As System.Object, ByVal e As Syste m.EventArgs) End Sub

S-ar putea să vă placă și