Пример #1
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            yonghugongnengWindow1 yonghugongnengWindow = new yonghugongnengWindow1();

            yonghugongnengWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            yonghugongnengWindow.Left = this.Left;
            yonghugongnengWindow.Top  = this.Top;
            yonghugongnengWindow.Show();
            this.Close();
        }
        private void ReturnMain_click(object sender, RoutedEventArgs e)
        {
            yonghugongnengWindow1 yonghugongnengWindow = new yonghugongnengWindow1();

            //loginWindow.Show();
            yonghugongnengWindow.WindowStartupLocation = WindowStartupLocation.Manual;
            yonghugongnengWindow.Left = this.Left;
            yonghugongnengWindow.Top  = this.Top;
            yonghugongnengWindow.Show();
            this.Close();
        }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            //接收用户输入数据
            string name     = this.txtUserName.Text.Trim();
            string password = this.txtPassword.Password.Trim();

            if (name == "" || password == "")
            {
                // 用户名密码为空
                MessageBox.Show("用户名或密码不能为空!");
                return;
            }

            User user = null;

            BookStore.BLL.UserBLL bll = new UserBLL();

            bool flag = false;

            flag = bll.Login(name, password, out user);

            if (flag)
            {
                //不把密码保存在内存中
                user.Password = null;
                //登录成功记录登录者的信息
                Common.LoginUser = user;
                //登录成功
                //MessageBox.Show("登录成功!");
                yonghugongnengWindow1 yonghugongnengWindow = new yonghugongnengWindow1();
                //loginWindow.Show();
                yonghugongnengWindow.WindowStartupLocation = WindowStartupLocation.Manual;
                yonghugongnengWindow.Left = this.Left;
                yonghugongnengWindow.Top  = this.Top;
                yonghugongnengWindow.Show();
                this.Close();
            }
            else
            {
                //登录失败
                MessageBox.Show("用户名或密码错误!");
            }

/*            yonghugongnengWindow1 yonghugongnengWindow = new yonghugongnengWindow1();
 *          //loginWindow.Show();
 *          yonghugongnengWindow.WindowStartupLocation = WindowStartupLocation.Manual;
 *          yonghugongnengWindow.Left = this.Left;
 *          yonghugongnengWindow.Top = this.Top;
 *          yonghugongnengWindow.Show();
 *          this.Close();*/
        }