Ejemplo n.º 1
0
 public NHOMQUYEN LayNhomQuyen(NGUOIDUNG user)
 {
     try
     {
         using (var db = new QLPhongKaraokeEntities())
         {
             var x = (from s in db.NHOMQUYENs
                      where s.MaNhomQuyen == user.MaNhomQuyen
                      select s).FirstOrDefault();
             return(x);
         }
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 public bool Update(NGUOIDUNG item)
 {
     try
     {
         using (var db = new QLPhongKaraokeEntities())
         {
             var x = from s in db.NGUOIDUNGs
                     where s.ID == item.ID
                     select s;
             var sv = x.FirstOrDefault();
             if (sv != null)
             {
                 if (sv.MaDangNhap.CompareTo(item.MaDangNhap) != 0)
                 {
                     var y = from s in db.NGUOIDUNGs
                             where s.MaDangNhap == item.MaDangNhap
                             select s;
                     var svy = x.FirstOrDefault();
                     if (svy != null)
                     {
                         return(false);
                     }
                 }
                 sv.MaDangNhap  = item.MaDangNhap;
                 sv.MatKhau     = item.MatKhau;
                 sv.HoTen       = item.HoTen;
                 sv.Email       = item.Email;
                 sv.SoDT        = item.SoDT;
                 sv.MaNhomQuyen = item.MaNhomQuyen;
                 db.SaveChanges();
                 return(true);
             }
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
 public bool Insert(NGUOIDUNG item)
 {
     try
     {
         using (var db = new QLPhongKaraokeEntities())
         {
             var x = from s in db.NGUOIDUNGs
                     where s.MaDangNhap == item.MaDangNhap
                     select s;
             var sv = x.FirstOrDefault();
             if (sv == null)
             {
                 db.NGUOIDUNGs.Add(item);
                 db.SaveChanges();
                 return(true);
             }
             return(false);//trung username
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }