コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string rut  = txtrut.Text;
            string pass = txtpass.Password;
            //Verificar usuario
            vendedorFacade vendFac   = new vendedorFacade();
            string         passAdmin = vendFac.getpassbyRut(rut);

            byte[] data      = Encoding.ASCII.GetBytes(pass);
            SHA1   algorithm = SHA1.Create();

            byte[]        hash = algorithm.ComputeHash(data);
            StringBuilder sb   = new StringBuilder();

            //string base64 = Convert.ToBase64String(hash);

            /*for (int i = 0; i < hash.Length; i++)
             * {
             *  sb.AppendFormat("{x2}", hash[i]);
             * }*/
            foreach (Byte b in hash)
            {
                sb.Append(b.ToString("x2"));
            }

            if (passAdmin.Equals(sb.ToString()))
            {
                //ir a pagina reporte

                TransLoginToProductosAdmin tl = getContent();

                //method1();
                //tl.btnLogin.Visibility = Visibility.Visible;
                ProductosAdmin prodAdmin = new ProductosAdmin();
                prodAdmin.setContent(tl);
                prodAdmin.ladmin.Content = "Administrador:" + vendFac.getNombreAdminByRut(txtrut.Text);
                tl.pageTransitionControl.ShowPage(prodAdmin);

                //method1();
            }
            else
            {
                lmsg.Content = "Administrador no existe";

                /* System.Threading.Thread.Sleep(600);
                 * Microsoft.VisualBasic.Interaction.AppActivate(
                 *    System.Diagnostics.Process.GetCurrentProcess().Id);
                 * System.Windows.Forms.SendKeys.SendWait(" ");
                 * lmsg.Content = "";*/
            }
        }
コード例 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string rut = txtrut.Text;
            string pass = txtpass.Password;
            //Verificar usuario
            vendedorFacade vendFac = new vendedorFacade();
            string passAdmin = vendFac.getpassbyRut(rut);

            byte[] data = Encoding.ASCII.GetBytes(pass);
            SHA1 algorithm = SHA1.Create();
            byte[] hash = algorithm.ComputeHash(data);
            StringBuilder sb = new StringBuilder();
            //string base64 = Convert.ToBase64String(hash);
            /*for (int i = 0; i < hash.Length; i++)
            {
                sb.AppendFormat("{x2}", hash[i]);
            }*/
            foreach (Byte b in hash)
                sb.Append(b.ToString("x2"));

            if (passAdmin.Equals(sb.ToString()))
            {
                //ir a pagina reporte 

                TransLoginToProductosAdmin tl = getContent();

                //method1();
                //tl.btnLogin.Visibility = Visibility.Visible;
                ProductosAdmin prodAdmin = new ProductosAdmin();
                prodAdmin.setContent(tl);
                prodAdmin.ladmin.Content = "Administrador:" + vendFac.getNombreAdminByRut(txtrut.Text);
                tl.pageTransitionControl.ShowPage(prodAdmin);

                //method1();


            }
            else
            {
                lmsg.Content = "Administrador no existe";
                /* System.Threading.Thread.Sleep(600);
                 Microsoft.VisualBasic.Interaction.AppActivate(
                      System.Diagnostics.Process.GetCurrentProcess().Id);
                 System.Windows.Forms.SendKeys.SendWait(" ");
                 lmsg.Content = "";*/

            }

        }