martes, 16 de enero de 2018

Descarga gratis Libreria Facturacion Electronica CFDI 3.3

Hola Amigos, como estan hace mucho ya no escribia, pero bueno por aca ando nuevamente, les traigo la libreria para que generen sus CFDIs y ya solo lo timbren con quien necesiten, ya trae casi todos los complementos, incluyendo pagos.

Descarga la libreria aquí

solo agregala a tu proyecto .Net y Listo

utiliza el objeto.



Si gustas invitarme un cafe, dale aquí.

saludos.

domingo, 18 de octubre de 2015

I took the solution from

Michael Crump blog .

I was recently running into a situation where every time I opened Visual Studio 2010 SP1 the following message would appear for about 60 seconds or so:

"Loading toolbox content from package Microsoft.VisualStudio.IDE.Toolbox.ControlInstaller.ToolboxInstallerPackage
'{2C98B35-07DA-45F1-96A3-BE55D91C8D7A}'"

After finally get fed up with the issue I started researching it and decided that I’d share the steps that I took to resolve it below:
•I first made a complete backup of my registry.
•I then removed the following key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Packages\{2c298b35-07da-45f1-96a3-be55d91c8d7a}]
•I went to the following directory: C:\Users\Your Name Here\AppData\Local\Microsoft\VisualStudio\10.0\ and created a folder called bk and moved the .tbd files to that folder (they are hidden so you will have to show all files). I then removed the .tbd files in the root directory.



SNAGHTMLcaac6ca
•I then launched Visual Studio 2010 SP1 again and it recreated those files and the problem was gone.

Anyways I hope this helps someone with a similar problem. I created this blog partially for myself but it is always nice to help my fellow developer.

Thanks for reading.

jueves, 7 de mayo de 2015

DEscarga MASIVA CFDI

Aqui tienen la aportacion que hemos realizado varios.
podran descargar el codigo si, asi lo desean.

http://www.lawebdelprogramador.com/foros/Visual-Basic.NET/1478397-Descarga-Masiva-XML-SAT.html#i1495133

saludos.

Delete LINQ to SQL and One-To-Many Relationships

Según el respectivo idioma les saldrá este error:

An attempt was made to remove a relationship between a ParentTable and a ChildTable. However, one of the relationship’s foreign keys (ChildTable.parent_id) cannot be set to null.

…ó el siguiente:

Se ha intentado quitar una relación entre TablaPadre y TablaHija, pero una de las claves externas de la relación (TablaHija.nIdPadre) no se puede establecer en null.

In order to be able to delete a child row independently in the database when calling SubmitChanges(), we must indicate DeleteOnNull="true" on this association. Unfortunately the only way to change this is to drop out of the designer and make the change manually in the .dbml file. Luckily, however, you can switch back to the designer and it will not remove this attribute if you continue to modify the model as long as you don't remove the entities entirely. Once we make this change we can now delete just a single Order from the grid and save normally:



The other option to fix this issue is to modify the Delete Rule to "Cascade" on the relationship in the database. In that case the designer correctly infers this attribute on the association. This may be a better solution if you want to always automatically delete the related orders when a customer is deleted in your database no matter what application is working against the data. Additionally, if you apply the Cascade delete rule on your database relationship, then you will not have to manually delete the children first every time the parent is deleted when working with the DataContext. (Note: To enable cascading deletes, just right click on the parent table in the Server Explorer, select "Open Table Definition", right-click on any column and select "Relationships", select the relation and expand the "INSERT and UPDATE Specification" then for the Delete Rule set it to CASCADE.)

jueves, 12 de febrero de 2015

GRANT TABLES, VIEW and SP's

--GRANT TO TABLES
DECLARE CURSOR_GRANT CURSOR FOR
SELECT
'GRANT SELECT ON [dbo].['+NAME+'] TO [E8F575915A2E4897A517779C0DD7CE]',
'GRANT CONTROL ON [dbo].['+NAME+'] TO [MSDSL]'
FROM SYSOBJECTS WHERE NAME LIKE 'X%' AND TYPE = 'U'

DECLARE @SELECT AS VARCHAR(100)
DECLARE @CONTROL AS VARCHAR(100)
DECLARE @CONTADOR AS INT
SET @CONTADOR = 0

OPEN CURSOR_GRANT

FETCH NEXT FROM CURSOR_GRANT INTO @SELECT, @CONTROL

WHILE @@FETCH_STATUS = 0
BEGIN
EXECUTE(@SELECT)
EXECUTE(@CONTROL)
SET @CONTADOR = @CONTADOR + 1
FETCH NEXT FROM CURSOR_GRANT INTO @SELECT, @CONTROL
END

CLOSE CURSOR_GRANT
DEALLOCATE CURSOR_GRANT
PRINT @CONTADOR
GO

--GRANT TO VIEWS
DECLARE CURSOR_GRANT CURSOR FOR
SELECT
'GRANT SELECT ON [dbo].['+NAME+'] TO [E8F575915A2E4897A517779C0DD7CE]',
'GRANT CONTROL ON [dbo].['+NAME+'] TO [MSDSL]'
FROM SYSOBJECTS WHERE NAME LIKE 'X%' AND TYPE = 'V'

DECLARE @SELECT AS VARCHAR(100)
DECLARE @CONTROL AS VARCHAR(100)
DECLARE @CONTADOR AS INT
SET @CONTADOR = 0

OPEN CURSOR_GRANT

FETCH NEXT FROM CURSOR_GRANT INTO @SELECT, @CONTROL

WHILE @@FETCH_STATUS = 0
BEGIN
EXECUTE(@SELECT)
EXECUTE(@CONTROL)
SET @CONTADOR = @CONTADOR + 1
FETCH NEXT FROM CURSOR_GRANT INTO @SELECT, @CONTROL
END

CLOSE CURSOR_GRANT
DEALLOCATE CURSOR_GRANT
PRINT @CONTADOR
GO

--GRANT TO PROCEDURES
DECLARE CURSOR_GRANT CURSOR FOR
SELECT
'GRANT EXECUTE ON [dbo].['+NAME+'] TO [E8F575915A2E4897A517779C0DD7CE]',
'GRANT CONTROL ON [dbo].['+NAME+'] TO [MSDSL]'
FROM SYSOBJECTS WHERE NAME LIKE 'X%' AND TYPE = 'P'

DECLARE @EXECUTE AS VARCHAR(100)
DECLARE @CONTROL AS VARCHAR(100)
DECLARE @CONTADOR AS INT
SET @CONTADOR = 0

OPEN CURSOR_GRANT

FETCH NEXT FROM CURSOR_GRANT INTO @EXECUTE, @CONTROL

WHILE @@FETCH_STATUS = 0
BEGIN
EXECUTE(@EXECUTE)
EXECUTE(@CONTROL)
SET @CONTADOR = @CONTADOR + 1
FETCH NEXT FROM CURSOR_GRANT INTO @EXECUTE, @CONTROL
END

CLOSE CURSOR_GRANT
DEALLOCATE CURSOR_GRANT
PRINT @CONTADOR
GO

martes, 6 de enero de 2015

UTF8 encode and decode VB.Net


Public Function XUTF8_Decode(ByVal pStr As String) As String
Dim Buffer As String
Dim i As Integer
Dim vChar() As Char = pStr.ToCharArray()
Dim vutf8data(vChar.Length) As Byte
'vutf8data = Encoding.UTF8.GetBytes(pStr)
For i = 0 To (vChar.Length - 1)
vutf8data(i) = System.Convert.ToByte(vChar(i))
Next
Buffer = Encoding.UTF8.GetString(vutf8data)
'Return .
XUTF8_Decode = Buffer
End Function

Public Function XUTF8_Encode(ByVal pStr As String) As String
Dim vutf8Encoding As New System.Text.UTF8Encoding
Dim vencodedString() As Byte
Dim vStringRes As String

vencodedString = vutf8Encoding.GetBytes(pStr)
vStringRes = vutf8Encoding.GetString(vencodedString)
'Return
XUTF8_Encode = vStringRes
End Function

Obtener los días del mes en SQL

Para obtener los días del mes en SQL lo podemos hacer de la siguiente manera, espero les sea muy útil.

DECLARE @mydate DATETIME
SELECT @mydate = GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,
'Último día del mes anterior'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value,
'Primer día del mes corriente' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),@mydate,101) AS Date_Value, 'Hoy' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,
'Último día del mes corriente'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,1,@mydate)),101) ,
'Primer día del mes siguiente'
GO


jueves, 14 de agosto de 2014

Add VB Code Inspector VS 2008

Open up Visual Studio > Tools Menu > Options > Environment > Add-In/Macro Security > Add the path "C:\Program Files(86)\CommFiles\Microsoft Shared\DynamicsSL"
Restart Visual Studio and the add-in is listed!

miércoles, 2 de julio de 2014

Call WebService and Send params VB6

' (This is Visual Basic 6 code.)
Private Sub Form_Load()
   
    ' Create the SoapClient.
    Dim SoapClient As MSSOAPLib30.SoapClient30
    Set SoapClient = New MSSOAPLib30.SoapClient30
   
    ' Use the Init method to generate a proxy 
    Dim WSDLPath As String
    WSDLPath = "http://localhost/VBCookbookWebServices/Recipe16-2.asmx?WSDL"
    Call SoapClient.MSSoapInit(WSDLPath)
   
    ' Call the GetDate web method to retrieve some information.
    MsgBox("Server returned: " & SoapClient.GetDate())
   
End Sub
'Other Function 
Public Function XVALIDATEQR(ByVal pRfce As String, ByVal pRfcr As String, ByVal pMonto As Double, ByVal pUUID As String) As Integer
    Dim vSOAPcnt As New SoapClient30
    Dim vResult As String
    Set vSOAPcnt = New SoapClient30
    
    Call vSOAPcnt.MSSoapInit("http://urlService.asmx?wsdl")
    vResult = vSOAPcnt.ExpImpresa(txtrfce.Text, txtrfcr.Text, txtmonto.Text, txtUUID.Text)
    
    MsgBox ("Server returned: " & vResult)
                     
End Function

jueves, 6 de febrero de 2014

Validar UUID del SAT

WEbReference https://consultaqr.facturaelectronica.sat.gob.mx/ConsultaCFDIService.svc

Codigo C#

ConsultaCFDI.ConsultaCFDIServiceClient oConsulta = new ConsultaCFDIServiceClient();
            ConsultaCFDI.Acuse oAcuse = new Acuse();

            oAcuse=oConsulta.Consulta("?re=BEN9501023I0&rr=SARM8209281F1&tt=440.000000&id=EC609EC1-5F63-4333-A2B8-2EDC10B68075");

            MessageBox.Show("Estatus " + oAcuse.CodigoEstatus + " Estado: " + oAcuse.Estado);

Si te interesa hacer algo mas, un desarrollo integración de CFDI o validador de facturas de proveedores -> josmisu_@hotmail.com

miércoles, 5 de febrero de 2014

Cómo leer Archivo de LCO del SAT

    Function FileToString(ByVal filePath As String) As String
        Dim f As FileStream

        f = New FileStream(filePath, FileMode.Open, FileAccess.Read)

        Dim streamLength As Integer = Convert.ToInt32(f.Length)
        Dim fileData As Byte() = New Byte(streamLength) {}

        f.Read(fileData, 0, streamLength)
        f.Close()
        Return System.Text.Encoding.Default.GetString(fileData)
    End Function

    Private Function LimpiaLCO(ByVal sPath As String, ByVal sFile As String) As String
        Dim RutaLCO As [String] = sPath
        Dim xmlLCO As String = RutaLCO & sFile
        'Dim objReader As New StreamReader(xmlLCO)

        Dim sRes As String = FileToString(xmlLCO) 'objReader.ReadToEnd()
        Dim posIni As Integer = sRes.LastIndexOf("<?xml", System.StringComparison.Ordinal)
        Dim posFin As Integer = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)

        sRes = sRes.Substring(posIni, posFin)
        posFin = sRes.LastIndexOf("</lco:LCO>", System.StringComparison.Ordinal)

        sRes = sRes.Substring(0, posFin)
        Dim SW As StreamWriter
        Dim origName = xmlLCO.Remove(xmlLCO.Length - 4)
        origName += "Clean.XML"
        SW = File.CreateText(sPath)
        SW.WriteLine(sRes)
        SW.WriteLine("</lco:LCO>")
        SW.Close()
        Return origName
    End Function

    Private Shared Sub LoadLco(ByVal sPathFileLCO_Clean As String)
        'Dim RutaLCO As [String] = sPath
        Dim xmlLCO As String = sPathFileLCO_Clean  ' RutaLCO & sfileClean


        'Cargamos XML 
        Dim xdoc As XDocument = XDocument.Load(xmlLCO)

        'Query 
        Dim LCO = From Contribuyente In xdoc.Descendants("Contribuyente") _
               Select New With {Key .RFC = Contribuyente.Attribute("RFC").Value, _
                                Key .Certificados = Contribuyente.Descendants("Certificado")}

        'Resultado 
        For Each Contribuyente As Object In LCO
            Console.WriteLine(Contribuyente.RFC)

            For Each Certificado As Object In Contribuyente.Certificados
                Dim Result = ""
                Dim xAttribute = Certificado.Attribute("noCertificado")
                If xAttribute IsNot Nothing Then
                    Result += " " & Convert.ToString(xAttribute.Value)
                End If
                Dim attribute = Certificado.Attribute("ValidezObligaciones")
                If attribute IsNot Nothing Then
                    Result += " " & Convert.ToString(attribute.Value)
                End If
                Dim xAttribute1 = Certificado.Attribute("EstatusCertificado")
                If xAttribute1 IsNot Nothing Then
                    Result += " " & Convert.ToString(xAttribute1.Value)
                End If
                Dim attribute1 = Certificado.Attribute("FechaInicio")
                If attribute1 IsNot Nothing Then
                    Result += " " & Convert.ToString(attribute1.Value)
                End If
                Dim xAttribute2 = Certificado.Attribute("FechaFinal")
                If xAttribute2 IsNot Nothing Then
                    Result += " " & Convert.ToString(xAttribute2.Value)
                End If
                MessageBox.Show(Result)
            Next
        Next


    End Sub

jueves, 30 de enero de 2014

Como obtener la Lista de usuarios del ActiveDirectory

Comando para listar el Active Directory en un Documento separado por Coma.

CSVDE -f nombredeldocumento.csv -b usuario dominio contraseña

Para listar solo por usuarios:

CSVDE -f onlyusers.csv -r "(&(objectClass=user)(objectCategory=person))"

martes, 29 de octubre de 2013

RadControls for WinForms are not loaded at design-time,

PROBLEM
After you update to a new version of the Telerik WinForms suite, you start seeing RadControls for WinForms in the component tray and you are not able to select them on the form.


SOLUTION
The design-time capabilities of RadControls for WinForms are implemented in the Telerik.WinControls.UI.Design.dll assembly. If decide to use our installer to install the WinForms suite on your machine, this assembly is automatically installed in your Global Assemly Cache. The same is the situation if you decide to upgrade your Telerik version via ourVisual Studio Extensions - the Telerik.WinControls.UI.Design assembly will be set in your GAC. However, if you decide to upgrade Telerik assembly references manually by downloading the archive file that contains assemblies only, please be aware that these two approaches do not install the Design assembly in your GAC automatically. 

So, to resolve this case, you should simply install the Telerik.WinControls.UI.Design.dll assembly manually in your GAC. If you have downloaded the archive file that contains the Telerik WinForms assemblies, you can find this assembly there. If you decide to follow the Upgrade Wizard approach, then you can find the assembly at: %APPDATA%\Telerik\Updates
If this still does not resolve the issue, please make sure that all references to Telerik assemblies point to assemblies having the latest version. As we provide two builds - one for .NET 2.0 and one for .NET 4.0 it is also 
important to make sure that the referenced assemblies end up by the same number - .20 or .40.

jueves, 17 de octubre de 2013

JSON Response C#


private static void JsonResponse(object pObject)
{
try
{
HttpResponse response = HttpContext.Current.Response;
response.ContentType = "application/json";
response.Charset = "utf-8";

var utf8 = new UTF8Encoding();
String json = JsonConvert.SerializeObject(pObject);
Byte[] encoded = utf8.GetBytes(json);
response.BinaryWrite(encoded);
response.End();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}

}

viernes, 11 de octubre de 2013

VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed

There is a simpler fix for the JavaScript debugging issue in IE10:
  1. Close IE
  2. In elevated cmd prompt run this command:
    regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll"
    
(or %ProgramFiles% on a 32-bit OS)

miércoles, 11 de septiembre de 2013

Open Radwindow o window.open Passing parameters

<telerik:RadButton ID="Imprimir" runat="server" Text="Imprimir" ButtonType="LinkButton" Image-ImageUrl ="imgs/printerOld.png" Visible="False" OnClientClicking = "openRadWindow" Height="32px" Width="32px" > </telerik:RadButton>


<script type="text/javascript">
        function openRadWindow(button, args) {
           // radopen(button.get_navigateUrl(), "Tranfer");
            window.open(button.get_navigateUrl(), "_blank", "toolbar=yes, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes");
            args.set_cancel(true);
        }
    </script>


 Protected Sub btnreg_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnreg.Click
        Imprimir.NavigateUrl = "frm_transf.aspx?BatNbr=" + Batnbr
End Sub


Send Mail .NET

Seguro más de uno nos hemos topado con una aplicación para enviar mails y validar al menos el formato de correo, aqui les dejo esta clase, espero les sea util.

class Email
    {

        static MailMessage _message;
        static SmtpClient _clienteSmtp;
        static Attachment _at;
        static int _puerto = 25;
        static string _user = "", _password = "";

        public static bool IsValidEmail(string email)
        {
            string expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";

            if (Regex.IsMatch(email, expresion))
            {
                if (Regex.Replace(email, expresion, String.Empty).Length == 0)
                { return true; }
                else
                { return false; }
            }
            else
            { return false; }
        }

        public static void ConfigEmail(string from, string usuario, string contraseña, int puertoSalida, string smtp)
        {
            _message = new MailMessage();
            _message.From = new MailAddress(from);
            _clienteSmtp = new SmtpClient(smtp);
            _user = usuario;
            _password = contraseña;
            _clienteSmtp.Port = puertoSalida;
        }

        public static bool SendEmail(string to, string cc, string asunto, string mensaje, string ruta_archivo_adjunto)
        {

            try
            {

                _at = new Attachment(ruta_archivo_adjunto);

                _message.Attachments.Add(_at);

                _message.To.Add(to);

                _message.CC.Add(cc);

                _message.Subject = asunto;

                _message.IsBodyHtml = true; //el texto del mensaje lo pueden poner en HTML y darle formato

                _message.Body = mensaje;

                //Establesco que usare seguridad (ssl = Secure Sockets Layer)
                _clienteSmtp.EnableSsl = true;

                _clienteSmtp.UseDefaultCredentials = false;

                _clienteSmtp.Credentials = new NetworkCredential(_user, _password);

                ServicePointManager.ServerCertificateValidationCallback =
                       (s, certificate, chain, sslPolicyErrors) => true;
                _clienteSmtp.Send(_message);

                return true;

            }
            catch
            {

                try
                {
                    //Establesco que no usare seguridad ssl (por si no pudo enviarlo con ssl habilitado)
                    _clienteSmtp.EnableSsl = false;
                    _clienteSmtp.Send(_message);

                    return true;
                }
                catch
                {
                    return false;
                }

            }

        }
    }

martes, 10 de septiembre de 2013

Error: El Proveedor 'Microsoft.ACE.OLEDB.12.0' no está Registrado en del el equipo local.


Hace unos años atrás, antes de que Microsoft Office 2010, la vida era un poco más fácil para los desarrolladores:  sin embargo Office es de 32 bits, y punto, no  hay mas. 

Como saben ha sido un poco más complicado ya que con Microsoft Office 2010, los usuarios también pueden instalar una versión nativa de 64 bits de Office también.

Esto significa para nosotros que nuestros desarrollados de aplicaciones de 32 bits que utilizan un proveedor OLEDB para acceder a archivos de Excel o Access pueden no funcionar más ya que el proveedor de 32 bits no puede existir en una instalación de 64 bits de Office 2010.

En estos casos, a pesar de que el usuario tiene una instalación válida de Microsoft Office 2010 instalado en su máquina, su aplicación podría obtener un error como:
 El Proveedor 'Microsoft.ACE.OLEDB.12.0' no está Registrado en del el equipo local.

Bueno, para hacer frente a estos problemas Microsoft lanzó un instalador llamado "Microsoft Access Database Engine 2010 Redistributable". Este redistribuible proporciona una de 32 bits o una versión de 64 bits del proveedor de Microsoft OLEDB ACE que se puede descargar quí:


Posterior mente nos vamos a nuestro proyecto propiedades -> compile -> Advanced compile options -> TARGET CPU:  x86

Y con  eso debe funcionar nuestra aplicación. 

jueves, 27 de septiembre de 2012

How to populate a dropdown from XML

Dim oTemp As New Temp
Dim path As String path = HttpContext.Current.Request.Url.OriginalString.Substring(0, HttpContext.Current.Request.Url.OriginalString.LastIndexOf("/"))
path = path + "/XMLInfo/ConfigCompany.xml"

Dim Ds As New System.Data.DataSet Ds.ReadXml(path) RadcbCpnyId.DataSource =
Ds.Tables(0).DefaultView
RadcbCpnyId.DataTextField = "CpnyId" RadcbCpnyId.DataValueField = "ConStr" RadcbCpnyId.DataBind()

 XML SAmple




 
    CpnyId1
    ConStr1
 
 
    CpnyId3
    ConStr3
 
 
    CpnyId4
    ConStr4