/// <summary> /// 用户点击登录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string name = textBox1.Text.Trim(); string pwd = password.Text; //实例化model user UserInfo userInfo = new UserInfo(); userInfo.Card_Number = name; userInfo.Card_Password = pwd; bool result = bankbll.UserLogin(userInfo); if (result == true) { MessageBox.Show("登录成功!"); //1、显示index窗体 2、传递当前用户卡号到index窗体 Index home = new Index(this.textBox1.Text); home.Owner = this; home.Show(); //隐藏当前窗体 this.Hide(); } else { MessageBox.Show("用户或密码错误请重新输入!"); this.textBox1.Text = ""; this.password.Text = ""; } }