C# winform三层构架系统,非传值方式,能否从业务逻辑层直接取得登录者信息?

解决方案 »

  1.   

    用一个公用的Class文件存取登录者信息就OK了
      

  2.   

    /*公用Class用于保存登录者信息*/
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    namespace BusinessLogic
    {
        public class Sys_User
        {
            public static string sUserID ;
        }
    }
    /*登陆操作*/
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using BusinessLogic;
    using System.Threading;namespace CMS
    {
        public  partial class frmLogin 
        {        public frmLogin()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                if(登陆成功)
                  {
                    tbSys_BL.sUserID =this.txtUserId.Text;
                   }
            }        private void button2_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
        }
    }/*使用*/
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using BusinessLogic;
    using System.Threading;
    public  partial class frmUser 
        {        public frmLogin()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                  MessageBox.Show("当前用户"+tbSys_BL.sUserID);
                   
            }        private void button2_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
        }