Example #1
0
        public ActionResult StudentList()
        {
            var dal  = new DAL.StudentDAL();
            var stud = dal.StudentList();

            return(View(stud));
        }
Example #2
0
 public ActionResult Login(Models.Login model)
 {
     if (ModelState.IsValid)
     {
         var daluser = new DAL.UserDAL();
         var user    = daluser.Login(model);
         if (user != null)
         {
             Session["USER"] = user;
             var sestud  = (Entity.User)Session["USER"];
             int id      = sestud.User_id;
             var dalstud = new DAL.StudentDAL();
             var stud    = dalstud.Searchstud(id);
             if (stud != null)
             {
                 Session["Stud"] = stud;
             }
             var dalteac = new DAL.TeacherDAL();
             var teacher = dalteac.Searchteac(id);
             if (teacher != null)
             {
                 Session["Teacher"] = teacher;
             }
             return(RedirectToAction("Index", "User"));
         }
         else
         {
             Response.Write("<script> alert('ไม่พบผู้ใช้')</script>");
         }
     }
     return(View(model));
 }
Example #3
0
 public ActionResult Edit(DAL.StudentDAL std)
 {
     if (ModelState.IsValid)
     {
         Student = bll.getByID(std.ID);
         DAL.StudentDAL nameAlreadyExists = new DAL.StudentDAL();
         nameAlreadyExists = bll.getAll().Where(s => s.fname == std.fname).FirstOrDefault();
         if (std != null)
         {
             if ((nameAlreadyExists != null) && (Student.ID != nameAlreadyExists.ID))
             {
                 ModelState.AddModelError("fname", "Student Name Already Exists.");
             }
             else
             {
                 bll.Edit(std);
             }
         }
         else
         {
             if (nameAlreadyExists != null)
             {
                 ModelState.AddModelError("fname", "Student Name Already Exists.");
             }
             else
             {
                 bll.Add(Student);
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(std));
 }
Example #4
0
        public ActionResult Create(Entity.ProfileStudent model)
        {
            var user = (Entity.User)Session["user"];
            var id   = user.User_id;

            if (ModelState.IsValid)
            {
                var dal = new DAL.StudentDAL();
                var chk = dal.Chkstud(model);
                if (chk != null)
                {
                    Response.Write("<script> alert('รหัสนักศึกษานี้ถูกลงทะเบียนเเล้ว')</script>");
                }
                else
                {
                    var result = dal.Create(model, id);
                    if (result)
                    {
                        Response.Write("<script> alert('ลงทะเบียนสำเร็จ')</script>");
                    }
                    return(RedirectToAction("index", "User"));
                }
                return(View());
            }
            return(View(model));
        }
Example #5
0
        public ActionResult Details(string id)
        {
            var dal  = new DAL.StudentDAL();
            var Stud = dal.Search(id);

            return(View(Stud));
        }
Example #6
0
 public ActionResult EditStud(Entity.ProfileStudent model, string id)
 {
     try
     {
         var dal  = new DAL.StudentDAL();
         var stud = dal.Search(id);
         stud.Stud_id   = model.Stud_id;
         stud.Pre_Name  = model.Pre_Name;
         stud.FristName = model.FristName;
         stud.LastName  = model.LastName;
         stud.Group_id  = model.Group_id;
         stud.Branch    = model.Branch;
         stud.Faculty   = model.Faculty;
         var result = dal.EditeStud(stud);
         if (result)
         {
             Response.Write("<script> alert('แก้ไข้ข้อมูลสำเร็จ')</script>");
         }
         return(RedirectToAction("StudentList"));
     }
     catch (Exception)
     {
         Response.Write("<scrip> aler('ไม่สำเร็จ')</scrip>");
     }
     return(View(model));
 }
Example #7
0
 static BaseBLL()
 {
     admins      = DAL.DataFileAccess.GetAdmins();
     students    = DAL.DataFileAccess.GetStudents();
     teachers    = DAL.DataFileAccess.GetTeachers();
     courses     = DAL.DataFileAccess.GetCourses();
     termCourses = DAL.DataFileAccess.GetTermCourses();
 }
Example #8
0
 public ActionResult Edit(int?ID)
 {
     if (ID != null)
     {
         int _id = (Int32)ID;
         Student = bll.getByID(_id);
     }
     return(View(Student));
 }
Example #9
0
        public ActionResult StudHistory()
        {
            var    model = (Entity.ProfileStudent)Session["Stud"];
            string id    = model.Stud_id;
            var    dal   = new DAL.StudentDAL();
            var    stud  = dal.Search(id);

            return(View(stud));
        }
Example #10
0
        public ActionResult Edit(string id)
        {
            using (var db = new Entity.Entities())
            {
                ViewBag.PreName = db.PreName.ToList();
            }
            var dal  = new DAL.StudentDAL();
            var stud = dal.Search(id);

            return(View(stud));
        }
Example #11
0
        public ActionResult Delete(string id)
        {
            var dal    = new DAL.StudentDAL();
            var stud   = dal.Search(id);
            var result = dal.Delete(stud);

            if (result)
            {
                Response.Write("<script> alert('ลบข้อมูลเรียบร้อย')</script>");
            }
            return(RedirectToAction("StudentList"));
        }
Example #12
0
 public ActionResult Delete(int ID)
 {
     Student = bll.getByID(ID);
     return(View(Student));
 }
Example #13
0
 public ActionResult Delete(DAL.StudentDAL std)
 {
     bll.Delete(std.ID);
     return(RedirectToAction("Index"));
 }