Exemple #1
0
        protected void ibValidar_Click(object sender, ImageClickEventArgs e)
        {
            if (txtRut.Text != "" & txtDV.Text != "")
            {
                string resultado = digitoVerificador(Convert.ToInt32(txtRut.Text));

                if (resultado == txtDV.Text.ToUpper())
                {
                    LoginSistema sis = cReg.verificarRUT(Convert.ToInt32(txtRut.Text));

                    if (sis.Nombre != "")
                    {
                        //lblNombre.Text = sis.Nombre;
                        txtCargo.Text       = sis.cargo;
                        txtCentroCosto.Text = sis.CentroCosto;

                        pnlRespuesta.Visible = true;
                        pnlRut.Visible       = false;
                        TextBox2.Text        = sis.Nombre;
                        txtRutCompleto.Text  = txtRut.Text + "-" + txtDV.Text;
                    }
                    else
                    {
                        string popupScript = "<script language='JavaScript'> alert('No existe en la bdd'); </script>";
                        Page.RegisterStartupScript("PopupScript", popupScript);
                        txtRut.Text = "";
                        txtDV.Text  = "";
                        txtRut.Focus();
                    }
                }
                else
                {
                    string popupScript = "<script language='JavaScript'> alert(' Rut incorrecto.'); </script>";
                    Page.RegisterStartupScript("PopupScript", popupScript);
                    txtRut.Text = "";
                    txtDV.Text  = "";
                    txtRut.Focus();
                }
            }
            else
            {
                string popupScript = "<script language='JavaScript'> alert(' El Campo Rut es Obligatorio.'); </script>";
                Page.RegisterStartupScript("PopupScript", popupScript);
            }
        }
Exemple #2
0
        public bool generarCorreo()
        {
            //txtusername

            string nombre = "";
            string correo = "";

            LoginSistema sis = cReg.ActivarUsuariosCorreo(txtCentroCosto.Text);

            try
            {
                nombre = sis.Nombre;
                correo = sis.Correo;
            }
            catch
            {
                nombre = "";
                correo = "";
            }
            LoginSistema lgSis = cLogin.buscarPorID(txtUsername.Text);
            int          idUs  = Convert.ToInt32(lgSis.IDLogin);


            /*-------------------------MENSAJE DE CORREO----------------------*/

            //Creamos un nuevo Objeto de mensaje
            System.Net.Mail.MailMessage mmsg = new System.Net.Mail.MailMessage();

            //Direccion de correo electronico a la que queremos enviar el mensaje
            mmsg.To.Add(correo);
            //Nota: La propiedad To es una colección que permite enviar el mensaje a más de un destinatario

            //Asunto
            mmsg.Subject         = mmsg.Subject = "Solicitud Usuario - " + TextBox2.Text;
            mmsg.SubjectEncoding = System.Text.Encoding.UTF8;

            //Direccion de correo electronico que queremos que reciba una copia del mensaje
            //mmsg.Bcc.Add("*****@*****.**"); //Opcional

            string nomb = TextBox2.Text;

            string[] str = nomb.Split(' ');
            string   n   = str[0] + "_" + str[2] + "_" + str[3];

            //Cuerpo del Mensaje
            //mmsg.Body = "asdasd redireccion: algo.aspx?c="+Codigo2+"&i=" + idUsu.ToString() + "&co=" + Codigo;
            mmsg.Body = "<table style='width:100%;'>" +
                        "<tr>" +
                        "<td>" +
                        "<img src='http://intranet.qgchile.cl/images/Logo color lateral.jpg' width='267px'  height='67px' />" +
                        //"<img src='http://www.qg.com/la/es/images/QG_Tagline_sp.jpg' />" +
                        "</td>" +
                        "</tr>" +
                        "<tr>" +
                        "<td>" +
                        "&nbsp;</td>" +
                        "</tr>" +
                        "<tr>" +
                        "<td>" +
                        "Estimado(a) " + nombre + ":" +
                        "<br />" +
                        "<br />" +
                        "<br />" +
                        "El Usuario " + TextBox2.Text + " ha iniciado el proceso de activación de su cuenta," +
                        " haz clic en el siguiente enlace para realizar la activacion: <br />" +
                        "<br />" +
                        "Nota: Para Activar la cuenta de usuario, debe estar previamente autentificado en el sistema." +
                        "<br />" +
                        "http://Intranet.qgchile.cl/ModuloJefatura/View/asignarModulos.aspx?i=" + idUs.ToString() + "&n=" + n + "&e=" + 0 + "" +
                        "<br />" +
                        "<br />" +
                        "Si eso no funciona, copia la URL y pégala en una ventana nueva del navegador." +
                        "<br />" +
                        "<br />" +
                        "Si has recibido este mensaje y el usuario " + TextBox2.Text + " no esta encargado a tu área " +
                        ", haz clic en el " +
                        "siguiente enlace para eliminar la solicitud de Activación de Cuenta:" +

                        "<br />" +
                        "<br />" +
                        "http://Intranet.qgchile.cl/ModuloJefatura/View/asignarModulos.aspx?i=" + idUs.ToString() + "&n=" + n + "&e=" + 1 + "" + "<br />" +
                        "<br />" +
                        "<br />" +
                        "Atentamente," +
                        "<br />" +
                        "Equipo de desarrollo A Impresores S.A" +
                        "</td>" +
                        "</tr>" +
                        "</table>";

            mmsg.BodyEncoding = System.Text.Encoding.UTF8;
            mmsg.IsBodyHtml   = true; //Si no queremos que se envíe como HTML

            //Correo electronico desde la que enviamos el mensaje
            mmsg.From = new System.Net.Mail.MailAddress("*****@*****.**");


            /*-------------------------CLIENTE DE CORREO----------------------*/

            //Creamos un objeto de cliente de correo
            System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();

            //Hay que crear las credenciales del correo emisor
            cliente.Credentials =
                new System.Net.NetworkCredential("*****@*****.**", "SI2013.");

            cliente.Host = "mail.aimpresores.cl";


            /*-------------------------ENVIO DE CORREO----------------------*/

            try
            {
                //Enviamos el mensaje
                cliente.Send(mmsg);
                return(true);
                //lblaglo.Text = "enviado correctamente";
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                return(false);
                //Aquí gestionamos los errores al intentar enviar el correo
                //lblaglo.Text = "error al enviar el correo";
            }
        }