예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SQLFunction sQLFunction = new SQLFunction();

            if (sQLFunction.CheckUser(Login.Text, Password.Text))
            {
                Main.Show();
                Close();
            }
            else
            {
                MessageBox.Show("Користувача не знайдено");
                Login.Text    = "";
                Password.Text = "";
            }
        }
예제 #2
0
        public IActionResult LoginUser([Bind("username", "password")] User user)
        {
            if (ModelState["username"].Errors.Any() || ModelState["password"].Errors.Any())
            {
                return(View("Login"));
            }

            SQLFunction functions = HttpContext.RequestServices.GetService(typeof(SQLFunction)) as SQLFunction;

            if (functions.CheckUser(user.username, user.password))
            {
                HttpContext.Session.SetString("Username", user.username);
                return(RedirectToAction("Index", "Home"));
            }

            ViewData["Invalid"] = "Invalid Username/Password";
            return(View("Login"));
        }