コード例 #1
0
ファイル: TeacherLogin.xaml.cs プロジェクト: LEFrost/Training
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            App.IsStu = false;

            _ViewModel = new LoginViewModel();
            teacherinfo teacher = new teacherinfo()
            {
                teacher_id  = UserName.Text,
                teacher_pwd = Password.Password
            };

            if (_ViewModel.Login(teacher))
            {
                App.ID = UserName.Text;
                //App.IsAdmin = IsAdmin.IsChecked.HasValue;
                TeacherWindow window = new TeacherWindow();
                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                window.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("请确保密码和账号正确", "登陆失败");
            }
        }
コード例 #2
0
        public bool Login(teacherinfo teacher)
        {
            var query = from q in DBContext.teacherinfo
                        where q.teacher_id == teacher.teacher_id && q.teacher_pwd == teacher.teacher_pwd
                        select q;

            /*DBContext.teacherinfo.FirstOrDefault(x => x.teacher_id == teacher.teacher_id&&x.teacher_pwd==teacher.teacher_pwd);*/
            if (query != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (maskedTextBox1.Text == maskedTextBox2.Text && maskedTextBox2.Text.Length < 9 && maskedTextBox2.Text.Length > 3)
            {
                var questionQuery = from o in pp.context.teacherinfo
                                    where o.teacherid == pp.teacher.teacherid
                                    select o;


                teacherinfo st = questionQuery.First <teacherinfo>();
                st.pd = maskedTextBox1.Text;
                pp.context.UpdateObject(st);
                pp.context.SaveChanges();
                MessageBox.Show("密码已修改!");
                this.Close();
            }
            else
            {
                MessageBox.Show("两次的密码输入不一样,密码大于八位或小于四位!");
            }
        }