Ejemplo n.º 1
0
 public bool DeleteTHISINH(int id)
 {
     try
     {
         THISINH u = dataContext.THISINHs.Single(p => p.ID == id);
         dataContext.THISINHs.Remove(u);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 2
0
 public int AddTHISINH(THISINH THISINH)
 {
     try
     {
         dataContext.THISINHs.Add(THISINH);
         dataContext.SaveChanges();
     }
     catch (DbUpdateException e)
     {
         Debug.WriteLine(e.ToString());
         throw;
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         throw;
     }
     return(THISINH.ID);
 }
Ejemplo n.º 3
0
        public bool UpdateActive(THISINH ts)
        {
            THISINH x = dataContext.THISINHs.Where(l => l.ID == ts.ID).SingleOrDefault();

            if (x != null)
            {
                x.DaHoanThanh = true;
                dataContext.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public ActionResult Logout()
        {
            THISINH      us      = new THISINH();
            var          dao     = new ThiSinhDAO();
            ThiSinhLogin THISINH = (ThiSinhLogin)Session[Constants.THISINH_SESSION];

            us.ID = THISINH.ThiSinhID;

            if (!dao.UpdateActive(us))
            {
                ModelState.AddModelError("", "Không thể update dữ liệu");
            }
            Session[Constants.THISINH_SESSION] = null;
            return(View("Index"));
        }
Ejemplo n.º 5
0
 public bool UpdateTHISINH(THISINH THISINHDAO)
 {
     try
     {
         THISINH u = dataContext.THISINHs.Where(p => p.ID == THISINHDAO.ID).SingleOrDefault();
         u.MaDuThi     = THISINHDAO.MaDuThi;
         u.HoTen       = THISINHDAO.HoTen;
         u.Password    = THISINHDAO.Password;
         u.SDT         = THISINHDAO.SDT;
         u.NgaySinh    = THISINHDAO.NgaySinh;
         u.DiaChi      = THISINHDAO.DiaChi;
         u.GioiTinh    = THISINHDAO.GioiTinh;
         u.CMND        = THISINHDAO.CMND;
         u.Email       = THISINHDAO.Email;
         u.MaCaThi     = THISINHDAO.MaCaThi;
         u.MaDeThi     = THISINHDAO.MaDeThi;
         u.TrangThai   = THISINHDAO.TrangThai;
         u.SoMay       = THISINHDAO.SoMay;
         u.DaHoanThanh = THISINHDAO.DaHoanThanh;
         u.ThoiGian    = THISINHDAO.ThoiGian;
         dataContext.SaveChanges();
         return(true);
     }
     catch (DbEntityValidationException e)
     {
         foreach (var eve in e.EntityValidationErrors)
         {
             Debug.WriteLine("- Entity of type \"{0}\", in state \"{1}\" has the following validation errors: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
             foreach (var ve in eve.ValidationErrors)
             {
                 Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
         return(false);
     }
 }
Ejemplo n.º 6
0
        public THISINH getIDByUserName(string user)
        {
            THISINH x = dataContext.THISINHs.SingleOrDefault(p => p.MaDuThi == user);

            return(x);
        }