You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
using RegistrationForm.Models;
|
|
|
|
namespace RegistrationForm.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
EmployerListEntities db = new EmployerListEntities();
|
|
public ActionResult Main()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult Login()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Login(Employ_Table model)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
var emnum = db.Employ_Table
|
|
.Where(e => e.EmployNum == model.EmployNum)
|
|
.FirstOrDefault();
|
|
try
|
|
{
|
|
if (emnum.Password == model.Password)
|
|
{
|
|
|
|
TempData["greeting"] = emnum.Name + "님 환영합니다.";
|
|
|
|
|
|
return RedirectToAction("UserDashBoard","Home");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
ViewBag.Message = "비밀번호가 일치하지 않습니다.";
|
|
}
|
|
|
|
//var Name = db.Database.ExecuteSqlCommand("SELECT Name FROM Registration_Table WHERE Employee_Num = {0}", model.Employee_Num);
|
|
//return RedirectToAction("UserDashBoard", "Home");
|
|
}
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult Index(Employ_Table table)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
|
|
db.Employ_Table.Add(table);
|
|
db.SaveChanges();
|
|
|
|
return View("Main", "Home"); //리턴 변경
|
|
}
|
|
return View();
|
|
}
|
|
|
|
public ActionResult UserDashBoard()
|
|
{
|
|
ViewBag.Name = TempData["greeting"];
|
|
return View();
|
|
}
|
|
}
|
|
}
|