OSS인증 - 팀장 : 서영민 - 팀원 : 김현, 박상진, 박승영, 윤동수, 김성미
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.

80 lines
2.1 KiB

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using RegistrationForm.Models;
  7. namespace RegistrationForm.Controllers
  8. {
  9. public class HomeController : Controller
  10. {
  11. EmployerListEntities db = new EmployerListEntities();
  12. public ActionResult Main()
  13. {
  14. return View();
  15. }
  16. [HttpGet]
  17. public ActionResult Login()
  18. {
  19. return View();
  20. }
  21. [HttpPost]
  22. [ValidateAntiForgeryToken]
  23. public ActionResult Login(Employ_Table model)
  24. {
  25. if (ModelState.IsValid)
  26. {
  27. var emnum = db.Employ_Table
  28. .Where(e => e.EmployNum == model.EmployNum)
  29. .FirstOrDefault();
  30. try
  31. {
  32. if (emnum.Password == model.Password)
  33. {
  34. TempData["greeting"] = emnum.Name + "님 환영합니다.";
  35. return RedirectToAction("UserDashBoard","Home");
  36. }
  37. }
  38. catch (Exception)
  39. {
  40. ViewBag.Message = "비밀번호가 일치하지 않습니다.";
  41. }
  42. //var Name = db.Database.ExecuteSqlCommand("SELECT Name FROM Registration_Table WHERE Employee_Num = {0}", model.Employee_Num);
  43. //return RedirectToAction("UserDashBoard", "Home");
  44. }
  45. return View();
  46. }
  47. public ActionResult Index()
  48. {
  49. return View();
  50. }
  51. [HttpPost]
  52. public ActionResult Index(Employ_Table table)
  53. {
  54. if (ModelState.IsValid)
  55. {
  56. db.Employ_Table.Add(table);
  57. db.SaveChanges();
  58. return View("Main", "Home"); //리턴 변경
  59. }
  60. return View();
  61. }
  62. public ActionResult UserDashBoard()
  63. {
  64. ViewBag.Name = TempData["greeting"];
  65. return View();
  66. }
  67. }
  68. }