示例#1
0
文件: Form1.cs 项目: calafia/CFDi_VB
        //9.-Funcion para llenar los datos utilizando las label posteriormente llamo a la funcion timbrar()
        private void llenarDatosEmisorReceptor()
        {
            try
            {
                //establecemos el numero de serie de la licencia del SDK para poder hacer uso de ella.
                //En caso de no asignara, el SDK funcionará con las restricciones de version DEMO,
                //las cuales permite hacer unicamente CFDI con el RFC Genérico XAXX010101000
                LicenciasBuildCFDI lic1 = new LicenciasBuildCFDI();
                DateTime FechTimbre=DateTime.Now;
                lic1.Licencia(liccenciaBuildCFDI);
                
                
                if (cbFechTimb.Checked == true && cbFechTimb.Visible == true)
                {   
                    //Timbro con la fecha actual no con la que se genero la carta porte
                    FechTimbre = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy H:mm:ss"));
                    
                }else 
                {
                    //Timbrar con la fecha en la que se genera la carta porte el dato es tomado desde la base de datos
                    FechTimbre = Convert.ToDateTime(label[33]);                    
                }
                
                CFDI.Comprobante c = new CFDI.Comprobante(FechTimbre, Convert.ToString(label[44])/*lblMetodoPago.Text*/, CFDI.Comprobante.opTipoDeComprobante.ingreso, Convert.ToDouble(label[37]/*lblSubtotal.Text*/), Convert.ToDouble(label[28]/*lblTotal.Text*/), Convert.ToString(label[45])/*lblMetodoPago.Text*/, Convert.ToString(label[42])/*lblDireccion.Text*/ + "  Tels.:" + Convert.ToString(label[47])/*lblTelefono1.Text*/ + ", " + Convert.ToString(label[48])/*lblTelefono2.Text*/, Convert.ToString(label[1])/*lblNumero.Text*/, Convert.ToString(label[0])/*lblSerie.Text*/, "", default(DateTime),-1 /*lblTotal.Text*/, "PESOS MEXICANOS", "1", Convert.ToString(label[46])/*lblTerminacion.Text*/, Convert.ToString(label[44])/*lblLeyenda.Text*/, -1, "");    
                      
                //Establecemos datos del Emisor
                //esta variable con esta funcion nos dejará indicar el regimen fiscal de la empresa emisora
                CFDI.Emisor.RegimenFiscal reg = new CFDI.Emisor.RegimenFiscal();
                reg.AgregarRegimen(leyenda);

                //esta funcion nos permite indicar la información obligatoria para el emisor
                CFDI.Emisor em = new CFDI.Emisor(rfcE, reg, razonSocial);

                //con esta variable establecemos los datos del emisor
                CFDI.Emisor.DomicilioFiscal df = new CFDI.Emisor.DomicilioFiscal(direccion,municipioE , estadoE, paisE, cpE, numeroExterior, "N/A", coloniaE);

                //con esta funcion agregamos los datos fiscales del emisor
                em.EstablecerDomicilioFiscal(df);                

                //Establecemos datos del Receptor
                //esta funcion nos permite indicar la información obligatoria para el emisor
                CFDI.Receptor r = new CFDI.Receptor(rfc, nombre);

                //con esta variable establecemos los datos del receptor
                CFDI.Receptor.Domicilio d = new CFDI.Receptor.Domicilio(pais, direcc,numExt ,numInt, colonia, ciudad, "", null, estado, cp);
                r.EstablecerDomicilio(d);
                                
                //Establecemos Conceptos
                //Podemos crear un ciclo for ó cualquier otro tipo de ciclo para agregar la cantidad de conceptos necesarios.
                //Aquí solo aclaramos un poco la idea de como hay que hacerlo.
                CFDI.Conceptos co = new CFDI.Conceptos();         
                                               
                for (int fila = 0; fila <gridConceptos.RowCount-1; fila++)
                {
                    if (gridConceptos[1, fila].Value.ToString() != "0.00")
                        {                          
                            co.AgregarConcepto(1, "N/A", gridConceptos[0, fila].Value.ToString(), Convert.ToDouble(gridConceptos[1, fila].Value.ToString()), Convert.ToDouble(gridConceptos[1, fila].Value.ToString()));
                        }                   
                }               
                
                //Establecemos Impuestos
                //aquí declaramos un impuesto IVA trasladado con tasa de 16%
                CFDI.Impuestos im = new CFDI.Impuestos();
                
                if (Convert.ToDouble(label[39])/*lblRetIva.Text*/ >0)
                {
                    im.AgregarImpuestosTrasladados(CFDI.Impuestos.opTraslado.IVA, Convert.ToDouble(label[38]/*lblIvaActual.Text*/), Convert.ToDouble(label[39]/*lblIva.Text*/));
                }
                if (Convert.ToDouble(label[41])/*lblRetIva.Text*/>0)
                {
                    im.AgregarImpuestosRetenidos(CFDI.Impuestos.opRetencion.IVA, Convert.ToDouble(label[41]/*lblRetIva.Text*/));
                }
                /*******************************TOMAR LA RUTA DE .CER Y .KEY DE LA BASE DE DATOS**********************************/

                //ubicacion para guardar el XML en la aplicacion de masteredi y posteriormente timbrarla 
                SqlDataReader ResConsul;
                string consulta = "select * from Certifcado where Id_cer=(SELECT MAX(Id_cer) from Certifcado);";
                metodos BD = new metodos();
                ResConsul = BD.Buscar(consulta, this.conn);

                if (ResConsul.Read())
                {   
                    //Tomando la Ruta de los archivo .cer y .key y la clave privada desde la base de datos  
                    if (File.Exists(CerFileLocal))
                    {
                        CertFile = CerFileLocal;
                    }
                    else
                    {
                        CertFile = @ResConsul.GetString(1).ToString();
                    }

                    if (File.Exists(KeyPassLocal))
                    {
                        keyFile = KeyPassLocal;
                    }
                    else
                    {
                        keyFile = @ResConsul.GetString(2).ToString();
                    }

                    keyPass = ResConsul.GetString(3).ToString();
                }

                //Creamos el XML con todos los datos llenados especificando certificado, llave privada, contraseña y ruta de destino
                CFDI sellar = new CFDI();
                                     
                //Tambien lo guardo en un archivo TXT de manera local en la carperta temporal para despues timbrarlo. 
                sellar.CrearXML(CertFile, keyFile, keyPass, c, em, r, co, im, @temp + nomenclatura + c.serie + c.folio + ".txt");
                sellar.CrearXML(CertFile, keyFile, keyPass, c, em, r, co, im, @temp + nomenclatura + c.serie + c.folio + ".xml");

                //OBTENER CADENA ORIGINAL DEL CFD
                /*XslCompiledTransform transformador = new XslCompiledTransform();
                transformador.Load(@"C:\Users\Admin\Desktop\Factura CFDI Visual 2010\XSLT\cadenaoriginal_3_2.xslt");
                transformador.Transform(temp + label[0] + label[1] + ".xml", temp + label[0] + label[1] + "CO.txt");
                */
                   
                //Enviamos un mensaje al usuario para informar que se ha creado el xml
                //MessageBox.Show("¡Se ha creado el XML con éxito!");
                Timbrar();
                        
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error para sellar el xml\n" + ex);
            }


        }
示例#2
0
文件: Form1.cs 项目: calafia/CFDi_VB
        //?.- Valido si ya esta registrada la carta porte en la tabla CFDi, si esta solo genero CB.png
        private void validarRegistro()
        {       
           
                SqlDataReader ResConsu;
                string consulta2 = "select idCFDi,codigoBD from CFDi where idCFDi=" + datosDelphi;

                metodos BD = new metodos();
                ResConsu = BD.Buscar(consulta2, this.conn);
               
                if (ResConsu.Read())
                {
                    try
                    {
                       
                            //MessageBox.Show(ResConsu.GetValue(ResConsu.GetOrdinal("codigoBD")).ToString());
                        

                        /*if (File.Exists(@directorioGuardarCP + label[0] + "\\" + label[49] + "\\" + label[50] + "\\" + nomenclatura + label[0] + label[1] + ".xml"))
                        {*/
                            //LicenciasBuildCFDI lic1 = new LicenciasBuildCFDI();
                            //lic1.Licencia(liccenciaBuildCFDI);                           
                            //QRCode.GeneratePng(@temp + label[0] + label[1] + "Qc.jpg","asdfs",5,0, ErrorCorrectionLevel.StandardQuality);
                        pictureBox1.Image = QRCode.GetBitmap(ResConsu.GetValue(ResConsu.GetOrdinal("codigoBD")).ToString(),0,5, ErrorCorrectionLevel.HighQuality);
                        pictureBox1.Image.Save(@temp + label[0] + label[1] + ".jpg", ImageFormat.Jpeg);    
                        
                        
                        //QRCode.GenerateBitmap(@"\STC R2\Qc.jpeg","asdfs",5,0, ErrorCorrectionLevel.HighQuality);
                            //MessageBox.Show(temp);
                        //Crear y leer el codigo qr                            
                        //    u.CrearQR(@directorioGuardarCP + label[0] + "\\" + label[49] + "\\" + label[50] + "\\" + nomenclatura + label[0] + label[1] + ".xml", temp + label[0] + label[1] + ".jpg");
                            
                            

                        if (Directory.Exists("C:\\WINDOWS\\Temp\\"))
                            {
                                try
                                {
                                    pictureBox1.Image.Save("C:\\WINDOWS\\Temp\\" + label[0] + label[1] + ".jpg", ImageFormat.Jpeg);
                                    //QRCode.GeneratePng("C:\\WINDOWS\\Temp\\" + label[0] + label[1] + ".jpg", ResConsu.GetValue(ResConsu.GetOrdinal("codigoBD")).ToString(),ErrorCorrectionLevel.StandardQuality);
                                    //u.CrearQR(@directorioGuardarCP + label[0] + "\\" + label[49] + "\\" + label[50] + "\\" + nomenclatura + label[0] + label[1] + ".xml", "C:\\WINDOWS\\Temp\\" + label[0] + label[1] + ".jpg");
                                }
                                catch (Exception jpg)
                                {

                                    MessageBox.Show("No se puede guardar el jpg en C:\\WINDOWS\\Temp\\ ruta escrita manualmente\n" + jpg);
                                }

                            }
                            
                        /*}
                        else
                        {
                            MessageBox.Show("El xml no existe en la rutaaa\n" + @directorioGuardarCP + label[0] + "\\" + label[49] + "\\" + label[50] + "\\" + nomenclatura + label[0] + label[1] + ".xml");
                        }*/
                    }
                    finally
                    {
                        Application.Exit();
                    }

                }              
               
        }
示例#3
0
文件: Form1.cs 项目: calafia/CFDi_VB
 public void llamarTimbrado() {
         string[] remplazando = directorioGuardarCP.Split('\\');
     
         string rutaFTP = "";
         for (int contador = 0; contador <= remplazando.Length-1;contador++ )
         {
             if (remplazando[contador] != "")
             {
               rutaFTP +="/"+remplazando[contador];
             }
         
         }
         rutaFTP = "ftp:/" + rutaFTP + "/" + label[0] + "/" + label[49] + "/" + label[50]+"/";
         
        if (System.IO.File.Exists(@directorioGuardarCP + label[0] + "\\" + label[49] + "\\" + label[50] + "\\" + nomenclatura + label[0] + label[1] + ".xml"))
        {
            if (!rutaFTP.Contains("Prueba"))
            {
                MessageBox.Show("Esta carta porte " + label[0] + "-" + label[1] + " ya tiene un timbre \n" + "Descargarla en: \n" +  rutaFTP + label[0] + "/" + label[49] + "/" + label[50] + "/", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }else
            {
                MessageBox.Show("No se abre el pdf porque la ruta es:\n" + rutaFTP);
                this.Close();                       
            }       
            
        }else            
        {
           if (txtFolio.Text == "4890") { MessageBox.Show("Esta carta " + label[0] + txtFolio.Text + " no debe ser timbrada", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);  }
           else
           {                                     
                    /***********SQL PARA VALIDAR QUE NO EXISTE EL TIMBRE EN LA BASE DE DATOS**************/
               SqlDataReader ResConsul;
               string consulta = " select serie,folio,uuid from CFDi where idCFDi=" + Convert.ToInt32(label[43]);
            
               metodos BD = new metodos();
               ResConsul = BD.Buscar(consulta, this.conn);
             
               if (ResConsul.Read())
               {                   
                   MessageBox.Show("Esta carta porte " + ResConsul.GetString(0).ToString() + "-" + ResConsul.GetInt32(1).ToString() + " ya tiene un timbre" + "\nUUID=" + ResConsul.GetString(2).ToString()+"\nY el XML no existe", "TIMBRAR XML", MessageBoxButtons.OK, MessageBoxIcon.Stop);
               }else
               {                        
                   if (chbXml.Checked == true || chbPdf.Checked == true)
                   {
                       if (!BD.validarEmail(txtCorreo.Text))
                       {
                           MessageBox.Show("NO ES UN CORREO VALIDO \n " + txtCorreo.Text, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                           if (txtCorreo.Text == "ESCRIBE AQUI EL CORREO")
                           {
                               txtCorreo.Text = "";
                           }
                           txtCorreo.Focus();
                       }else
                       {
                           btnTimbrar.Visible = false;
                           limpiarVariablesTimbrado();
                           llenarDatosEmisorReceptor();
                       }
                   }else
                   {
                       if (Convert.ToString(label[28])/*lblTotal.Text*/== "0.00")
                       {
                           MessageBox.Show("El total y los conceptos deben ser mayor a 0\n" + strError, "Proceso de timbrado", MessageBoxButtons.OK, MessageBoxIcon.Error);
                           this.Close();
                       }else
                       {
                           btnTimbrar.Visible = false;
                           limpiarVariablesTimbrado();
                           llenarDatosEmisorReceptor();
                       }
                   }                        
               }  
                
           }//cerrar la validacion de datos delphi
         }//cerrar la validacion del fichero       
 
 }
示例#4
0
文件: Form1.cs 项目: calafia/CFDi_VB
 //Generar addenda;
 private void GenerarAddenda() {
                           
     SqlDataReader ResConsul;
     string consulta = "select Estru_ade from Addenda where Id_ade=" + gridCartPort.Rows[gridCartPort.CurrentRow.Index].Cells["Id_ade_cp"].Value.ToString();
     
     metodos BD = new metodos();
     ResConsul = BD.Buscar(consulta,this.conn);
     
     if(ResConsul.Read()){
         addenda= ResConsul.GetString(0).ToString();
         
     }else
     {
         MessageBox.Show("Revisar permisos en la tabla Addenda");
     }
                        
                            
     for (int i = 0; i < gridCartPort.Columns.Count;i++)
     {             
         addenda = addenda.Replace(gridCartPort.Columns[i].Name.ToString(), gridCartPort.Rows[gridCartPort.CurrentRow.Index].Cells[gridCartPort.Columns[i].Name].Value.ToString());
     }                   
             
           
 }
示例#5
0
文件: Form1.cs 项目: calafia/CFDi_VB
        private void licenciasRutasUsuarios()
        {
            
            //string[] discos = Directory.GetLogicalDrives();
            //MessageBox.Show(Directory.GetDirectoryRoot(Directory.GetCurrentDirectory()));            
            //Environment.Exit(0);
            //MessageBox.Show(conn.ConnectionString);
            

           

            SqlDataReader ResConsul;
            string consulta1 = "select * from licenciasRutasUsuariosCFDi";
            
            metodos BD = new metodos();
            ResConsul = BD.Buscar(consulta1, this.conn);         
                              
            if (ResConsul.Read())
            {
                //Ping pingPc=new Ping();
                System.Version myVer;
                
                string Ver=Application.ProductVersion;                
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    myVer = ApplicationDeployment.CurrentDeployment.CurrentVersion;
                    Ver = string.Concat(myVer);                    
                }
                
                
                System.OperatingSystem osInfo = System.Environment.OSVersion;
                //MessageBox.Show(osInfo.Version.Major.ToString());
                if(osInfo.Version.Major<6)
                {
                    dirDropBox = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Mis Documentos\Dropbox\";  
                }else if(osInfo.Version.Major>=6)
                {
                    dirDropBox = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Dropbox\";
                    
                }
                //dirDropBox = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Dropbox\";
                //MessageBox.Show(dirDropBox);
                rutaEjecu_lbl.Text = Application.ExecutablePath;
                label1.Text = "Version:" + Ver +" /  Servidor conec...";
                
                //dirDropBox = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Dropbox\";
                CerFileLocal = @directorioRaiz + @"STC R2\CSD\00001000000202528447.cer";
                KeyPassLocal = @directorioRaiz + @"STC R2\CSD\tca890904p18_1212061131s.key";

                //Lleno las variables
                liccenciaBuildCFDI = ResConsul.GetString(0).ToString();
                liccenciaViewXMLCFDI = ResConsul.GetString(1).ToString();
                strUser = ResConsul.GetString(2).ToString();
                strPass = ResConsul.GetString(3).ToString();
                directorioGuardarCP = ResConsul.GetString(5).ToString();
               
                string[] remplazando = directorioGuardarCP.Split('\\');
                string ipDeRed =remplazando[2];

                string[] ipConexionA = ipConexion.Split(',');
                /*ipConexion = remplazandoo[0];*/
                
                
                //pingPc.Send(ipDeRed, 10).Status == IPStatus.Success
                if (ipDeRed==ipConexionA[0] && !Directory.Exists(dirDropBox))
                {
                    vpn_lbl.Text = "[Conectado y funcionando IP: "+ipDeRed+"\nRed Interna de Transportes Calafia 'VPN']";
                    yourToolTip.ToolTipTitle = "Información";
                    yourToolTip.AutoPopDelay = 1500000;
                    yourToolTip.SetToolTip(vpn_lbl, "Los XML y PDF se guardan en la 'Red Interna de Transportes Calafia automaticamente.'\nImportante estar autentificado por IP y por nombre del servidor [SERVIDORTQP]\nel cual debe estar registrado en el archivo hosts");
                          
                }
                else if (ipDeRed != ipConexionA[0] && Directory.Exists(dirDropBox))
                {
                    Process[] localAll = Process.GetProcesses();
                    Boolean dropBoxIniciado = false;

                    foreach (Process s in localAll)
                    {
                        if (s.ProcessName.Trim() == "Dropbox")
                        {
                            //MessageBox.Show(s.ProcessName);
                            dropBoxIniciado = true;
                        }

                    }
                    dirDropBox_chb.Checked = true;
                    yourToolTip.ToolTipTitle = "Información";
                    yourToolTip.AutoPopDelay = 10000;
                    yourToolTip.SetToolTip(dirDropBox_chb, "Exito el directorio existe");                      
                    
                    if (Directory.Exists(dirDropBox) && File.Exists(CerFileLocal) && File.Exists(KeyPassLocal) && dropBoxIniciado==true)
                    {
                        directorioGuardarCP = @dirDropBox;                       
                        vpn_lbl.Text = "[Conectado por la IP  " + ipConexion + "]\n'DEBE ESTAR CONECADO POR LA IP 200.76.182.56'";                        
                        yourToolTip.SetToolTip(vpn_lbl, "Los XML y PDF se guardan en DropBox automaticamente.");

                    }else if (!File.Exists(CerFileLocal) || !File.Exists(KeyPassLocal))
                    {
                        vpn_lbl.Text = "Conectado sin VPN y sin funcionar.\n\nCertificado o Llave digital local, no existe:\n"+CerFileLocal+"\n"+KeyPassLocal;                        
                        yourToolTip.SetToolTip(vpn_lbl, "Sin estos archivos, no puede ser generado el XML.");                        
                        btnTimbrar.Text = "CERRAR SIN TIMBRAR";
                    }else if(dropBoxIniciado==false)
                    {
                        MessageBox.Show("DropBox no esta iniciado. Por favor inicia sesion", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.Exit();
                    }

                }
                else if (ipDeRed != ipConexionA[0] && !Directory.Exists(dirDropBox))
                {
                    yourToolTip.ToolTipTitle = "Información";
                    btnTimbrar.Text = "CERRAR SIN TIMBRAR";
                    yourToolTip.SetToolTip(dirDropBox_chb, "Si existe el directorio, aparcera palomiado automaticamente");
                    vpn_lbl.Text = "Conectado sin VPN y sin funcionar,\nfalta el directorio predeterminado de Dropbox";
                    yourToolTip.SetToolTip(vpn_lbl, "Los XML y PDF, no pueden ser guardados, sin este directorio.");
                }
                else if (ipDeRed == ipConexionA[0] && Directory.Exists(dirDropBox))
                {
                    MessageBox.Show("Debes desinstalar DropBox o Renombrar el directorio " + dirDropBox, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
 
                }

                if (!File.Exists(@directorioRaiz + @"STC R2\Ruta_CFDi.txt"))
                {                     
                    File.WriteAllText(@directorioRaiz + @"STC R2\Ruta_CFDi.txt",@rutaEjecu_lbl.Text); 
                }
                else
                {                  
                   StreamReader sr = new StreamReader(@directorioRaiz + @"STC R2\Ruta_CFDi.txt");                                  
                   string line = sr.ReadLine();
                   sr.Close();                                                       
                    
                   if(line!=@rutaEjecu_lbl.Text) 
                    {
                        StreamWriter escribirRuta = new StreamWriter(@directorioRaiz + @"STC R2\Ruta_CFDi.txt");
                        escribirRuta.WriteLine(@rutaEjecu_lbl.Text);
                        escribirRuta.Close();
                    }           
                }
                                             
                smtp = ResConsul.GetString(6).ToString();
                puertoCorreo = ResConsul.GetInt32(7);
                usuarioCorreo = ResConsul.GetString(8).ToString();
                contrasenaCorreo = ResConsul.GetString(9).ToString();
                de = ResConsul.GetString(10).ToString();
                asuntoCorreo = ResConsul.GetString(11).ToString();
                cuerpoMensajeCorreo = ResConsul.GetString(12).ToString();
                directorioMasteredi = ResConsul.GetString(13).ToString();
                timbres = ResConsul.GetInt32(14);
                limiteTimbres = ResConsul.GetInt32(15);
                alertaTimbresCorreo = ResConsul.GetString(16).ToString();
                leyenda = ResConsul.GetString(17).ToString();
                alertaTimbresCorreoCpp = ResConsul.GetString(18).ToString();
                nomenclatura = ResConsul.GetString(19).ToString();
                razonSocial = ResConsul.GetString(20).ToString();
                direccion = ResConsul.GetString(21).ToString();
                numeroExterior = ResConsul.GetString(22).ToString();
                coloniaE = ResConsul.GetString(23).ToString();
                municipioE = ResConsul.GetString(24).ToString();
                ciudadE = ResConsul.GetString(25).ToString();
                estadoE = ResConsul.GetString(26).ToString();
                paisE = ResConsul.GetString(27).ToString();
                cpE = ResConsul.GetString(28).ToString();
                tel1  = ResConsul.GetString(29).ToString();
                tel2  = ResConsul.GetString(30).ToString();
                rfcE = ResConsul.GetString(31).ToString();
                ultiFechAlert = ResConsul.GetDateTime(32).ToString("dd/MM/yyyy");
                //MessageBox.Show(ultiFechAlert);   
             

                
               
           }
            else
            {
                MessageBox.Show("La tabla licenciasRutasUsuariosCFDi no tiene datos");
            }

            
            

        }
示例#6
0
文件: Form1.cs 项目: calafia/CFDi_VB
        private void guardarCFDi()
        {
            metodos registrarCFDi = new metodos();
            int res = -1;

            /***********SQL PARA ACUTUALIZAR LOS TIMBRES**************/
            string registrar = "exec Registrar_CFDi " + Convert.ToInt32(label[43]) + ",'" + Convert.ToString(label[0]) + "'," + Convert.ToInt32(label[1]) + ",'" + fechaTim + "','" + uuid + "','" + noCerti +"','"+ textoQr+"','" + Convert.ToString(label[51]+"','" + selloSAT+"','" + selloCFD +"','"+ lblCCS.Text+"','"+leyenda+"'");
            
            res = registrarCFDi.ABM(registrar, this.conn);
            if (res == 1)
            {
                crearPDF();               

            }
                   
        }
示例#7
0
文件: Form1.cs 项目: calafia/CFDi_VB
        //Enviar la alerta de limites al correo predertemido
        private void enviarAlertaTimbres() 
        {
            try
            {
                //Configuración del Mensaje
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient(smtp);
                
                //Especificamos el correo desde el que se enviará el Email y el nombre de la persona que lo envía
                mail.From = new MailAddress(usuarioCorreo, de, Encoding.UTF8);

                //Aquí ponemos el asunto del correo
                mail.Subject = "Cantidad de timbres disponibles "+ timbres;

                //Aquí ponemos el mensaje que incluirá el correo
                mail.Body = "Adquirir lo antes posible mas timbres con MASTEREDI TEL: (0155) 26 15 55 55  \r \nEste es un aviso desde la aplicacion CFDi en C#";

                //Especificamos a quien enviaremos el Email, no es necesario que sea Gmail, puede ser cualquier otro proveedor
                mail.To.Add(alertaTimbresCorreo);
                mail.CC.Add(alertaTimbresCorreoCpp);

                //Configuracion del SMTP
                SmtpServer.Port = puertoCorreo; //Puerto que utiliza Gmail para sus servicios

                //Especificamos las credenciales con las que enviaremos el mail
                SmtpServer.Credentials = new System.Net.NetworkCredential(usuarioCorreo, contrasenaCorreo);
                //SmtpServer.UseDefaultCredentials = true;

                SmtpServer.EnableSsl = false;
                SmtpServer.Send(mail);
               
                metodos update = new metodos();
                int res = -1;

                /***********SQL PARA ACUTUALIZAR LA ULTIMA FECHA QUE SE ENVIO LA ALERTA**************/
               
                string actualizar = "update licenciasRutasUsuariosCFDi set ultiFechAler=GETDATE();";
                res = update.ABM(actualizar, this.conn);
                if (res == 1)
                {
                    //MessageBox.Show("Se ha modificado un registro correctamente.", "Bajas", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                else
                {
                    MessageBox.Show("Problemas para actualizar la cantidad de timbres", "Cantidad de timbres", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }

            }catch (Exception ex)
            {
                MessageBox.Show("No se pudo enviar el correo \n" + ex);
            }


        }
示例#8
0
文件: Form1.cs 项目: calafia/CFDi_VB
        //Actualizar timbres en la base de datos
        private void actualizarTimbres() 
        {
            metodos update = new metodos();
            int res = -1;

            /***********SQL PARA ACUTUALIZAR LOS TIMBRES**************/
                    
            string actualizar = "exec Registrar_TimbresDisponibles_sp " + estatusUsuario[1].ToString();
            res = update.ABM(actualizar, this.conn);
            if (res == 1)
            {
                //MessageBox.Show("Se ha modificado un registro correctamente.", "Bajas", MessageBoxButtons.OK, MessageBoxIcon.Information);
             
            }
            else
            {
                MessageBox.Show("Problemas para actualizar la cantidad de timbres", "Cantidad de timbres", MessageBoxButtons.OK, MessageBoxIcon.Error);
                
            }
        
        }