public ActionResult Login(Admain model)
        {
            var state = false;

            if (ModelState.IsValid)
            {
                var db = new OsDatabase();
                db.Database.CreateIfNotExists();

                var lst = db.Admins.AsQueryable();
                lst = lst.Where(o => o.UserName.Contains(model.UserName));
                foreach (var a in lst)
                {
                    if (a.UserName == model.UserName && a.UserMima == model.UserMima)
                    {
                        state = true;
                    }
                    else
                    {
                        state = false;
                    }
                }
            }
            if (state == true)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(Redirect("LoginView"));
            }
        }
        public ActionResult SetupNM(Admain model)
        {
            var account = new Admain();

            account.Id       = model.Id;
            account.UserName = model.UserName;
            account.UserMima = model.UserMima;
            var db = new OsDatabase();

            db.Admins.Add(account);
            db.SaveChanges();
            return(Redirect("LoginView"));
        }
Beispiel #3
0
        private void btalter_Click(object sender, EventArgs e)
        {
            string user         = txtUserName.Text.Trim();
            string oldpassword  = txtoldpassword.Text.Trim();
            string newpassword  = txtnewpassword.Text.Trim();
            string aginpassword = txtaginpassword.Text.Trim();
            Admain ad           = new Admain();



            bool re = ad.Login(user, this.txtoldpassword.Text.Trim());

            if (newpassword != aginpassword)
            {
                MessageBox.Show("你2次输入的密码不相同!");
            }
            else if (re)
            {
                alterPassWord pass = new alterPassWord();
                pass.AltarPassWord(oldpassword, newpassword);
                MessageBox.Show("修改密码成功!");
            }
        }
Beispiel #4
0
        public bool LoginAmin(string user, string pass)
        {
            Admain admin = new Admain();

            return(admin.Login(user, pass));
        }