Esempio n. 1
0
        public ActionResult UpdateStudent(SE_Student form, int No = 0)
        {
            bool updatecheck = _studentHelper.UpdateStudent(form, No);

            return(new JsonResult {
                Data = new { success = updatecheck }
            });
        }
Esempio n. 2
0
        public ActionResult AddStudent(SE_Student data)
        {
            data.Active    = true;
            data.StudentID = "00000";
            bool insertcheck = _studentHelper.InsertStudent(data);

            return(new JsonResult {
                Data = new { success = insertcheck }
            });
        }
Esempio n. 3
0
        public ActionResult StudentEditArea(int no = 0)
        {
            SE_Student result = new SE_Student();

            result = _studentHelper.GetAllStudent().FirstOrDefault(m => m.StudentNo == no && m.Active == true);
            if (result == null || result.StudentNo == 0)
            {
                result = new SE_Student();
            }
            return(View(result));
        }
Esempio n. 4
0
        public bool InsertStudent(SE_Student data)
        {
            try
            {
                _context.SE_Student.Add(data);
                _context.SaveChanges();
                data.StudentID = $"S" + data.StudentNo.ToString().PadLeft(4, '0');

                return(_context.SaveChanges() > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public bool DeleteStudent(int No = 0)
        {
            try
            {
                SE_Student sE_Student = _context.SE_Student.FirstOrDefault(m => m.StudentNo == No);
                if (sE_Student == null || sE_Student.StudentNo == 0)
                {
                    return(false);
                }

                sE_Student.Active = false;

                return(_context.SaveChanges() > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        public bool UpdateStudent(SE_Student data, int No = 0)
        {
            try
            {
                SE_Student sE_Student = _context.SE_Student.FirstOrDefault(m => m.StudentNo == No);
                if (sE_Student == null || sE_Student.StudentNo == 0)
                {
                    return(false);
                }
                DateTime birth = DateTime.Now;
                if (DateTime.TryParse(data.Birth.ToString(), out birth))
                {
                    sE_Student.Birth = birth;
                }
                sE_Student.Name  = string.IsNullOrEmpty(data.Name) ? "" : data.Name;
                sE_Student.Email = string.IsNullOrEmpty(data.Email) ? "" : data.Email;

                return(_context.SaveChanges() > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }