sábado, 5 de septiembre de 2020

Messagebox mostrar siempre

 

MessageBox.Show("FIN", "clientes SII", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification, False)


fuente

lunes, 3 de agosto de 2020

Trigger no eliminar fila específica

use casa
 GO
 CREATE TRIGGER no_delete_admin
         ON [dbo].[usuarios]
    INSTEAD OF DELETE 
    AS
    IF EXISTS(SELECT * FROM deleted d WHERE d.id = 4)
   BEGIN
    --ROLLBACK;
    RAISERROR('No se puede eliminar',16,1);
   END
   ELSE
   BEGIN
   DELETE usuarios WHERE id IN (SELECT id FROM deleted)
   END
   
   SELECT * FROM usuarios where id IN (1)
   SELECT * FROM deleted d WHERE d.id <> 1




version2

GO
 CREATE TRIGGER [dbo].[no_delete_admin]
         ON [dbo].[usuarios]
    INSTEAD OF DELETE 
    AS
    IF EXISTS(SELECT * FROM deleted d WHERE d.id = 4)
   BEGIN
    
    SET ANSI_WARNINGS OFF;
    SET ANSI_WARNINGS ON;
    --ROLLBACK;
    --RAISERROR('No se puede eliminar',16,1);
   END
   ELSE
   BEGIN
   DELETE usuarios WHERE id IN (SELECT id FROM deleted)
   END





lunes, 20 de julio de 2020

constraint tabla usuarios

tabla usuarios

ALTER TABLE usuarios
ADD CONSTRAINT not_empty_usuario CHECK (LEN(usuario) > 0 )

ALTER TABLE usuarios
ADD CONSTRAINT not_empty_clave CHECK (LEN(clave) > 0 )

fuente
fuente2
fuente3

miércoles, 15 de julio de 2020

Certificación boleta electrónica 2020

instructivo certificación

set de pruebas

solicitud de revisión set boletas

ejemplo certificación



  1. Boleta de Ventas y Servicios Electrónica
  2. Boleta electrónica de mercado
  3. Inscríbase aquí
  4. Procedimiento de postulación, certificación y autorización
  5. Paso 3 
  6. Realizar Declaración de Cumplimiento

sábado, 11 de julio de 2020

ToolTip CheckBox Mensaje

  Dim tool_tip1 As ToolTip = New ToolTip
        'tool_tip1.AutoPopDelay = 5000
        'tool_tip1.InitialDelay = 1000
        'tool_tip1.ReshowDelay = 500
        tool_tip1.ShowAlways = True
        tool_tip1.SetToolTip(Me.cb_selec_todo, "Seleccionar todo ✓")

fuente

domingo, 21 de junio de 2020

jueves, 18 de junio de 2020

domingo, 7 de junio de 2020

sábado, 9 de mayo de 2020

Carpeta de instalacion windows service

 Try
            ' Agregar Referencia System.Management.dll
            Dim RutaService As String = ""
            Using wmiService As ManagementObject = New ManagementObject("Win32_Service.Name='" + NombreServicio + "'")
                wmiService.Get()
                RutaService = System.IO.Directory.GetParent(wmiService("PathName").ToString.Replace("""", "")).ToString
            End Using
            Process.Start(RutaService)
        Catch ex As Exception
            MessageBox.Show("La carpeta no existe", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

fuente

viernes, 8 de mayo de 2020

martes, 5 de mayo de 2020

datagridview combobox cambiar el valor de una celda al seleccionar un dato

 Private Sub dgv_variables_CurrentCellDirtyStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgv_var_simple.CurrentCellDirtyStateChanged
        If dgv_var_simple.IsCurrentCellDirty Then
            dgv_var_simple.CommitEdit(DataGridViewDataErrorContexts.Commit)
            dgv_var_simple.EndEdit()
        End If
    End Sub

fuente

query blob

Las variables se declaran con el nombre del campo antecedido por una @

Actualizar combobox

DataGridView.EndEdit()

miércoles, 29 de abril de 2020

else if sql


IF(@Var1 Condition1)
     BEGIN
      /*Your Code Goes here*/
     END

ELSE IF(@Var1 Condition2)
      BEGIN
        /*Your Code Goes here*/ 
      END 

    ELSE      --<--- Default Task if none of the above is true
     BEGIN
       /*Your Code Goes here*/
     END


fuente

martes, 28 de abril de 2020

warning sql

Warning: Null value is eliminated by an aggregate or other SET operation


Solución

SUM(CASE WHEN t1.tipo_DTE IS NULL THEN 0 ELSE 1 END)

fuente

Separador de miles sql

SELECT CAST(CONVERT(VARCHAR, CAST(123456 AS MONEY), 1) AS VARCHAR)
SELECT REPLACE(CONVERT(VARCHAR, CONVERT(MONEY, 123456), 1), '.00', '')


DECLARE @BigNumber BIGINT
SET @BigNumber = 1234567891234

SELECT REPLACE(CONVERT(VARCHAR,CONVERT(MONEY,@BigNumber),1), '.00','')



fuente
fuente2

boleta nodo sucursal

tabla patron_SII

INSERT INTO patron_SII(
id_patronSII,valores_posibles,mascara_out,descripcion,obligatorio_FA,obligatorio_FE,obligatorio_NC,obligatorio_ND,obligatorio_FC,obligatorio_GD,
nodoxml,valor_min_num,valor_max_num,largo_max_cad,obligatorio_FX,obligatorio_DX,obligatorio_CX,obligatorio_BA,obligatorio_BE)
VALUES ('sucursal','*','c','nombre sucursal','0','0','0','0','0','0','DTE/Documento/Encabezado/Emisor/Sucursal','0','0','20','0','0','0','0','0')


string(descendant::*[local-name()='Sucursal'])
<Sucursal>mall alameda</Sucursal>
máximo 20 caracteres

formato dte, página 16,17 elemento n°41

lunes, 27 de abril de 2020

Estado de una celda

 Private Sub dgv_tareas_CurrentCellDirtyStateChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgv_tareas.CurrentCellDirtyStateChanged
        If DataGridView1.IsCurrentCellDirty Then
            DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
        End If
    End Sub


fuente

miércoles, 22 de abril de 2020

Fecha Incrementar

Private avanza As Integer = 1

    Private Sub btn_fechas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_fechas.Click

        ' Fecha inicial y fecha actual
        ' Fecha inicial y fecha final



        Dim dt1 As String = "01-04-2020"
        Dim dt2 As String = "19-04-2020"


        Dim FechaInicial As DateTime = Convert.ToDateTime(dt1)
        Dim FechaFinal As DateTime = Convert.ToDateTime(dt2)

        Dim FechaInicialTemp As DateTime = FechaInicial
        Dim FechaFinalTemp As DateTime = FechaFinal

        While True
            If FechaInicial = FechaFinal Then
                avanza = -1
            End If

            Select Case avanza
                Case 0
                    FechaInicialTemp = FechaInicialTemp.AddDays(-1)
                    If FechaInicialTemp <= FechaInicial Then
                        'FechaInicialTemp = FechaInicialTemp.AddDays(1)
                        avanza = 1
                    End If
                    'MessageBox.Show(FechaInicialTemp)
                    WriteDate(FechaInicialTemp)
                Case 1
                    FechaInicialTemp = FechaInicialTemp.AddDays(1)
                    If FechaInicialTemp >= FechaFinal Then
                        avanza = 0
                    End If
                    WriteDate(FechaInicialTemp)
                    'MessageBox.Show(FechaInicialTemp)
                Case Else
                    'MessageBox.Show(FechaInicial)
                    Continue While
            End Select
        End While
    End Sub

viernes, 3 de abril de 2020

Eliminar botón cerrar

Protected Overrides ReadOnly Property CreateParams As CreateParams

        Get
            Const CS_NOCLOSE As Integer = 512
            Dim cp As CreateParams = MyBase.CreateParams
            cp.ClassStyle = (cp.ClassStyle Or CS_NOCLOSE)
            Return cp
        End Get
    End Property

fuente

llamar a CellMouseClick

 Dim b As MouseEventArgs = New MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, MousePosition.X, MousePosition.Y, 0)
        Dim args As System.Windows.Forms.DataGridViewCellMouseEventArgs = New System.Windows.Forms.DataGridViewCellMouseEventArgs(0, principal.dgv_procesos.CurrentRow.Index, MousePosition.X, MousePosition.Y, b)

principal.dgv_procesos_CellMouseClick(sender, args)

lunes, 23 de marzo de 2020

Valor máximo de una columna datagridview

IdTarea = dgv_tareas.Rows.Cast(Of DataGridViewRow).Max(Function(row) row.Cells("Column1").Value)

fuente

miércoles, 18 de marzo de 2020

Insertar campo blob

Insert TestBlob(tbName, tbDesc, tbBin) Select
'81.pdf','PDF file', BulkColumn from Openrowset( Bulk
'C:\fact2\pdf\DTE46-F1.PDF', Single_Blob) as tb

fuente

martes, 17 de marzo de 2020

Función sumar

Dim sum As Func(Of Integer, Integer, Integer) = Function(x, y) x + y

MessaBox(sum(4,4) = 8


Dim OpAnd As Func(Of Boolean, Boolean, Boolean) = Function(x, y) x AndAlso y

Operación And

Dim OpOr As Func(Of Boolean, Boolean, Boolean) = Function(x, y) x OrElse y

jueves, 12 de marzo de 2020

jueves, 5 de marzo de 2020

miércoles, 19 de febrero de 2020

Eliminar todos los tabpage

TabControl1.TabPages.Clear()

ruta carpeta

 Private Sub btn_examinar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_examinar.Click
        If FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
            tb_carpeta.Text = FolderBrowserDialog1.SelectedPath
        End If
    End Sub

lunes, 17 de febrero de 2020

Error al abrir proyecto windows service




Solución: abrir el archivo *.vdproj y borrar las siguientes líneas

"SccProjectName" = "8:"
"SccLocalPath" = "8:"
"SccAuxPath" = "8:"
"SccProvider" = "8:"

Si no funciona, abrir nuevamente el proyecto...


fuente

martes, 11 de febrero de 2020

Desinstalar servicio


Agregar a las referencias: System.ServiceProcess


Imports System.ServiceProcess
Import  System.Configuration.Install


  Try
            Dim ObjServiceInstaller As New ServiceInstaller
            Dim context As InstallContext = New InstallContext("log.txt", Nothing)
            ObjServiceInstaller.Context = context
            ObjServiceInstaller.ServiceName = "Service1"
            ObjServiceInstaller.Uninstall(Nothing)
        Catch ex As Exception
        End Try



fuente

viernes, 31 de enero de 2020

error al leer nodo xml

Unexpected end of file has occurred. The following elements are not closed: nodo, Config. Line 1, position 25.

No utilizar Pipe "|" en el contenido del nodo

jueves, 30 de enero de 2020

Eliminar espacios/formato entre nodos xml

ejemplo: <TED version="1.0">" & vbCrLf & "  <DD>" & vbCrLf & "    <RE>123-4</RE>


Public Function str_ted_trim(ByVal str As String) As String
            Dim doc As XDocument = XDocument.Parse(str, LoadOptions.None)
            str = doc.ToString(SaveOptions.DisableFormatting)
            Return str
        End Function


<TED version="1.0"><DD> <RE>123-4</RE>


fuente

miércoles, 29 de enero de 2020

dataset itemarray to array

String.Join(separador, dr.ItemArray.Select(Function(x) x.ToString()).ToArray)


remover elemento de un array por su indice


Dim index_remove As Integer = 3

array = array.Where(Function(x, index) index <> index_remove).ToArray

fuente

viernes, 24 de enero de 2020

viernes, 10 de enero de 2020

jueves, 9 de enero de 2020

Advertencia: valor NULL eliminado por el agregado u otra operación SET

Advertencia: valor NULL eliminado por el agregado u otra operación SET

Warning: Null value is eliminated by an aggregate or other SET operation


select max(cast(null as int))
go


solución:
sum(case when t2.id_DTE is null then 0 else 1 end) as aceptado

fuente

order by vista



SELECT     TOP (100) PERCENT

CREATE VIEW ejemploVista AS SELECT TOP 100 PERCENT * FROM procesos ORDER BY id DESC GO


fuente

lenguages sql

select langid, alias from sys.syslanguages


agregar día de la semana consulta sql

FORMAT(CAST(t1.fecha_creacion_registro AS DATETIME2),'dddd') AS [día],
FORMAT(CAST(t1.fecha_creacion_registro AS DATETIME2),'dddd','en-US') AS [día],
FORMAT(CAST(t1.fecha_creacion_registro AS DATETIME2),'dddd','es-es') AS [día],

DATENAME(DW,CAST(t1.fecha_creacion_registro AS DATE)) sql 2008



fuente
fuente2

miércoles, 8 de enero de 2020

alinear texto cabecera datagridview


 Public Sub alinear_texto_cabecera()
        For Each col As DataGridViewColumn In DataGridView1.Columns
            col.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
        Next
    End Sub


fuente