多种形式的申请 [英] multiple forms application

查看:113
本文介绍了多种形式的申请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用c sharp-使Windows应用程序具有4种形式.第一种形式包含两个用于输入用户名和密码的文本框,如果输入正确,它将提示您进入另一种形式.身份验证有更好的主意吗?

其次,当我运行该应用程序时,如何仅显示身份验证表单,而其他隐藏.如果身份验证成功,那么如何显示第二种形式并隐藏其他形式?

需要您的专家指导朋友.

Using c sharp - making a windows application with 4 forms. The first form contains two text box for username and password, if entered correctly it will prompt to another form. Any better idea for authentication ?

Secondly how to display only authentication form when i run the application and others are hidden. If authentication is successful then how to show the second form and make others hidden??

Need your expert guide friends.

推荐答案

您应该研究使用IIdentity和IPrincipal接口.我写了一篇文章,向您展示如何创建自己的凭据对象

WinForms-通过AspNetDb使用自定义主体 [
然后,您可以使用以下几行代码来检查用户是否输入了正确的用户名\ pwd

You should look into using the IIdentity and IPrincipal interfaces. I wrote an article that shows you how you can create your own credential objects

WinForms - Using a custom principal with AspNetDb[^]

The article shows how to create ''AspNetDb'' credentials, but you can customise the AspNetDbIdentity ctor to retrieve username and password from whatever database you like. You''d also need to change IIdentity.IsAuthenticated to tell when the user has input correct credentials

You could then use code along the following lines to check that user has input the correct username \ pwd

if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
{
    // show some form when user is authenticated
}




该链接要高级一些,但此处提供了一些有用的信息和工具.

http://msdn.microsoft.com/en-us/library/ff650605.aspx [ ^ ]




This link is a bit more advanced, but some userful information and tools are available here.

http://msdn.microsoft.com/en-us/library/ff650605.aspx[^]


嗨 我认为第二个比第一个好,因为未经授权,未经登录就无法查看下一个屏幕.

您可以执行以下操作:
假设您的登录表单名称为frmLogin,主表单为frmHome

Hi I think the second is better than first, because unauthorized would not able to see the next screen without doing logged in.

you can do as follows:
Suppose your login form name is frmLogin and main form is frmHome

btnLogin_Click(..)
{
 //code to be written here for login authentication...
 if(success)
 {
   frmHome home = new frmHome();
   home.show();
   this.close();
 } 
}



谢谢,
Imdadhusen



Thanks,
Imdadhusen


这篇关于多种形式的申请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆