//传入主界面参数的构造函数
 public Library(IntroForm intro)
 {
     type           = 1;//定义主界面层级为1
     this.introForm = intro;
     this.username  = intro.username;
     InitializeComponent();
 }
        //登录
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (textBoxX1.Text == "" || textBoxX2.Text == "")
                MessageBox.Show("用户名或密码不能为空!", "提示");
            else
            {
                string strdb = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" + Application.StartupPath + "\\SampleData1.accdb";
                OleDbConnection con = new OleDbConnection(strdb);
                con.Open();
                string strsql = "select * from users where username='******'and password='******'";
                OleDbCommand cmd = new OleDbCommand(strsql, con);
                OleDbDataReader rd = cmd.ExecuteReader();//???

                if (!rd.HasRows)
                {

                    MessageBox.Show("用户名或密码错误,请重新输入!", "提示");
                    return;
                }
                else
                {
                    this.Hide();
                    //判断返回参数类型
                    if (type == 1)//传入函数来自主界面
                    {
                        this.introForm = new IntroForm(textBoxX1.Text);
                        this.introForm.ShowDialog();
                    }
                    else if (type == 2)//传入函数来自Library界面
                    {
                        this.userLibrary = new Library(textBoxX1.Text);
                        this.userLibrary.ShowDialog();

                         
                    }
                    else if (type == 3)//传入函数来自ObjectDeatils界面
                    {
                        this.objectDetails.main.username = textBoxX1.Text;//传入用户名称
                        //this.objectDetails.ShowDialog();
                    }
                    else if (type == 4)//传入函数来自StudyBuilding界面
                    {
                        this.studyBuilding.main.username = textBoxX1.Text;
                    }


                }
            }
        }
Ejemplo n.º 3
0
        //返回键


        private void lblReturn_Click(object sender, EventArgs e)
        {
            if (this.username == null)//用户未登陆
            {
                this.Hide();
                IntroForm intro = new IntroForm();
                intro.ShowDialog();
            }
            else
            {
                this.Hide();
                IntroForm intro = new IntroForm(this.username);
                intro.ShowDialog();
            }
        }
 private void lbl_return_Click(object sender, EventArgs e)
 {
     //判断用户是否已登录
     if (type == 0 && this.username != null)//用户在Library界面点开Login并登录
     {
         this.Hide();
         introForm = new IntroForm(this.username);
         introForm.ShowDialog();
     }
     else if (type == 1)//Library来自主界面
     {
         this.Hide();
         introForm = new IntroForm(this.username);
         introForm.ShowDialog();
     }
     else if (type == 2)//Library来自SearchInfo界面
     {
         this.Hide();
         searchInfo = new SearchInfo(this.username, "图书馆");
         searchInfo.ShowDialog();
     }
 }
Ejemplo n.º 5
0
 public UserRegister(IntroForm form1)
 {
     InitializeComponent();
     main = form1;
 }