Esempio n. 1
0
        private void btnEnter_Click(object sender, RoutedEventArgs e)
        {
            string lUser     = "";
            string lPassword = "";

            lUser     = txtUser.Text;
            lPassword = txtPassword.Password;

            var lLoginDal = new LoginDal();

            DataTable lDt = lLoginDal.GetUser(lUser, lPassword);

            //DESENCRYPTA LA CONTRASEÑA
            byte[]        data = Encoding.UTF8.GetBytes(lPassword);
            HashAlgorithm hash = new SHA1Managed();

            byte[] hashBytes = hash.ComputeHash(data);
            String hashValue = BitConverter.ToString(hashBytes).Replace("-", "");


            if (lDt.Rows.Count >= 1)
            {
                if ((string)lDt.Rows[0]["Usuario"] == lUser && lDt.Rows[0]["Password"].ToString().ToUpper() == hashValue)
                {
                    ControlDePacientes.Entities.GlobalUser.Idusuario = (int)lDt.Rows[0]["IdUsuario"];


                    // MessageBox.Show("Usuario existe en la base de Datos", "Mensaje");
                    DockGeneral lDockGeneral = new DockGeneral();
                    this.Close();
                    lDockGeneral.mIdTipoUsuario = (int)lDt.Rows[0]["CodTipoUsuario"];
                    lDockGeneral.mUserName      = (string)lDt.Rows[0]["Usuario"];
                    lDockGeneral.ShowDialog();
                }
                else

                {
                    ControlOperation.alertWarning("Usuario no existe ");
                    txtUser.Text         = "";
                    txtPassword.Password = "";
                    txtUser.Focus();
                }
            }
            else
            {
                ControlOperation.alertWarning("Usuario no existe ");
                txtUser.Text         = "";
                txtPassword.Password = "";
                txtUser.Focus();
            }
        }