WinFrom登陆的用户名都储存在什么地方了?
B/S保存到Session了。
那么应用程序保存到什么地方了?
如果还有其他要保存的东西比如说密码等,这些都要保存到哪里?怎么调用?

解决方案 »

  1.   

    来个例子。
    再说Winfrom是储存在cookie吗?
      

  2.   

    Form的定义中,两个变量就可以用来存放这些信息
    保存在全局静态类的属性里面
    model.GetInstance().userId = textBox1.Text;  
      

  3.   

    可以写一个类不必要是静态类,但属性必须是静态的,来存放登录用户的信息。我可以给你代码!
     [Serializable]
        public static class ProfileUser
        {
      
            /// <summary>
            /// 当前登录用户名
            /// </summary>
            private static string name;
            /// <summary>
            /// 当前用户的角色名
            /// </summary>
            private static string roleName;
            /// <summary>
            /// 当前用户的角色码用于标识用户级别
            /// </summary>
            private static string roleCode;        /// <summary>
            /// 当前用户的ID
            /// </summary>
            private static string userID;
            #region 属性        /// <summary>
            /// 当前用户的角色码用于标识用户级别
            /// </summary>
            public static string RoleCode
            {
                get { return ProfileUser.roleCode; }
                set { ProfileUser.roleCode = value; }
            }        /// <summary>
            /// 当前用户的角色名
            /// </summary>
            public static string RoleName
            {
                get { return ProfileUser.roleName; }
                set { ProfileUser.roleName = value; }
            }        /// <summary>
            /// 当前登录用户名
            /// </summary>
            public static string Name
            {
                get { return ProfileUser.name; }
                set { ProfileUser.name = value; }
            }        /// <summary>
            /// 当前用户的ID
            /// </summary>
            public static string UserID
            {
                get { return ProfileUser.userID; }
                set { ProfileUser.userID = value; }
            }
            #endregion    }
      

  4.   

    这个可以用界面间的传值的
    form1里定义个全局变量a;
    把要传的值给a就好了,
    form2 f2=new form(a);
    f2.show();在form2里
            public string m_A;
            public Form2(string pA)
            {
                InitializeComponent();
                m_A=pA;       //m_A就是传来的值了
            }
      

  5.   

    我这几天正在做一个WINFORM项目刚好写了一个保存用户信息的类 public static T GetServiceToken<T>() where T : class,  new()
            {
                T token = new T();
                typeof(T).InvokeMember("Authenticate", BindingFlags.SetProperty, null, token, new object[] { Program.ServiceTokenAuthenticate }, null);
                typeof(T).InvokeMember("UserCode", BindingFlags.SetProperty, null, token, new object[] { Program.CurrentUserInfo.UserCode }, null);
                typeof(T).InvokeMember("BizDate", BindingFlags.SetProperty, null, token, new object[] { Program.BizDate }, null);
                typeof(T).InvokeMember("Language", BindingFlags.SetProperty, null, token, new object[] { Program.Language }, null);
                typeof(T).InvokeMember("Password", BindingFlags.SetProperty, null, token, new object[] { Program.CurrentUserInfo.Password }, null);
                typeof(T).InvokeMember("UserID", BindingFlags.SetProperty, null, token, new object[] { Program.CurrentUserInfo.UserID }, null);            return token;
            }
      

  6.   

    Form的定义中,两个变量就可以用来存放这些信息
    保存在全局静态类的属性里面
      

  7.   

    可以保存在cookie中;前提是保存Cookie的进程不要湮灭,这主要是针对多线程要注意的。
    实例:登录淘宝。        public void Fun_SignIn(string[][] loginData)
            {
                string TargetURL = "http://login.taobao.com/member/login.jhtml";
                myrefining.Fun_HttpGET(TargetURL);//获取Cookie
                loginBytes = Fun_Arr2Bytes(loginData);//根据上面返回的页面,组织写入post
                myrefining.Fun_HttpPOST(TargetURL, loginBytes);//post,同时获取Cookie
                myrefining.Fun_SyntaxLogInfo("亲,你已经成功登录淘宝!");
            }下面重点展示post
    1、定义部分private CookieContainer _myCookies;
    public CookieContainer myCookies{ get {return _myCookies;} set {_myCookies = value;}}
            public void Fun_HttpPOST(string PostURL, byte[] PostBytes)
            {
                HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(PostURL);
                httpReq.Method = "POST";
                httpReq.KeepAlive = false;
                httpReq.ContentType = "application/x-www-form-urlencoded";
                httpReq.Timeout = timeout;
                httpReq.CookieContainer = myCookies;
                httpReq.AllowAutoRedirect = true;
                httpReq.ContentLength = PostBytes.Length;
                Stream requestStream = httpReq.GetRequestStream();
                requestStream.Write(PostBytes, 0, PostBytes.Length);
                requestStream.Close();
                HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();
                if (httpRes.Cookies["_tb_token_"] != null)
                    TBToken = httpRes.Cookies["_tb_token_"].Value;
                Stream responseStream = httpRes.GetResponseStream();
                StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("GBK"));
                string StreamString = streamReader.ReadToEnd();
                streamReader.Close();
                httpRes.Close();
            }
      

  8.   

    timeout的值为5000,可以修改的。
      

  9.   

    myrefining,是我定义的一个类,可以多线程的。
    Fun_HttpPOST放在这个类中。
      

  10.   

    XML 或者  本地见一个Access数据库,XML利用序列化反序列化,然后进行加密,Access就是数据库,在对他加个密,或者做一个自定文件格式,就行QQ那样自己弄个自定义类型的文件。都可以,或者二进制,方法太多了
      

  11.   

    XML ,文件,注册表,数据库
    看你的用处
    一般是在数据库的