当用户通过登录界面登录,登录后登录界面关闭,进入主系统界面,主系统怎么识别登录的用户?请各位高手帮帮忙!

解决方案 »

  1.   

    参数传递,通过XML等实现保存
    web中session
      

  2.   


    登录界面是主系统界面让它show出来的吧?登录界面总要通知主系统界面登录结果吧?(登录了还是取消了)这就是事件通知。简单从逻辑上来说,主系统程序往往是类似这样的static string 谁登录了=null;void main()
    {
        LoginForm loginForm = new LoginFormV2();
        loginForm.登录事件 += (s,e)=> { 谁登录了= e.登录人; this.显示登录后的界面(); }
        loginForm.取消登录事件 += (s,e) =>{ 谁登录了= null; this.显示登录前的界面(); };
        loginForm.Show();
    }
    既主系统中的一个static变量保存进程登录信息,而main只是让登录界面显示出来而已,程序就结束了。我在demo 中用一个LoginForm界面的子类实例来做Demo,因为登录界面我们可能有多款,根据用户的喜好,反正它们都是继承自LoginForm类,在这个类中定义了两个事件用于通知登录窗体操作结果。
    对于asp.net,情况复杂一点点。因为每一个页面都是独立的分离的,于是这个“谁登录了”往往使用cookie,而这里的事件导航则往往用页面重定向来实现。
      

  3.   

    WINFORM中
    新建一个类 里面添字段  public static int LoginId = 0;
    然后让点击登录的时候loginId=登录的号码
    if(loginId!=0){
    consloe.write("登陆了");
    }else{
    console.write("没登陆");
    }
      

  4.   

    public class Common 

    private static string userId; 
    private static string userName; 
    public static string UserId 
            { 
                get { return userId; } 
                set { userId = value; } 
            } 
    public static string UserName 
            { 
                get { return userName; } 
                set { userName = value; } 
            } 

    赋值 
    string userid="userid"; 
    string username="username"; 
    Common.UserId = userid; 
    Common.UserName = username; 
    任何窗体都可以调用 
    string userid=Common.UserId; 
    string username=Common.UserName; 
      

  5.   

    用session吧  登录的时候把你的用户对象放到session中:  session["user"]= user(user是一个对象)  在跳转页后置代码中取出user = (user)session["user"],在做 user的判断既可