// xoa nguoi dung
        public bool xoaNhomND(string manhom)
        {
            QL_NhomNguoiDung nnd = ch.QL_NhomNguoiDungs.SingleOrDefault(t => t.MaNhom == manhom);

            if (ch.QL_PhanQuyens.Count(t => t.MaNhom == nnd.MaNhom) == 0)
            {
                foreach (QL_NguoiDung item in ch.QL_NguoiDungs.Where(t => t.MaNhom == nnd.MaNhom))
                {
                    item.MaNhom = null;
                }
                ch.QL_NhomNguoiDungs.DeleteOnSubmit(nnd);
            }

            else
            {
                foreach (QL_PhanQuyen item in ch.QL_PhanQuyens.Where(t => t.MaNhom == nnd.MaNhom))
                {
                    ch.QL_PhanQuyens.DeleteOnSubmit(item);
                }

                foreach (QL_NguoiDung item in ch.QL_NguoiDungs.Where(t => t.MaNhom == nnd.MaNhom))
                {
                    item.MaNhom = null;
                }
                ch.QL_NhomNguoiDungs.DeleteOnSubmit(nnd);
                submitChange();
            }
            return(true);
        }
        public bool suaNhomND(QL_NhomNguoiDung nnd, List <QL_PhanQuyen> lstPQ)
        {
            try
            {
                QL_NhomNguoiDung nhom = ch.QL_NhomNguoiDungs.SingleOrDefault(t => t.MaNhom == nnd.MaNhom);
                nhom = nnd;
                if (lstPQ.Count == 0)
                {
                    submitChange();
                    return(true);
                }
                else
                {
                    foreach (QL_PhanQuyen item in ch.QL_PhanQuyens.Where(t => t.MaNhom == nnd.MaNhom))
                    {
                        ch.QL_PhanQuyens.DeleteOnSubmit(item);
                    }
                    foreach (QL_PhanQuyen pq in lstPQ)
                    {
                        ch.QL_PhanQuyens.InsertOnSubmit(pq);
                    }
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
示例#3
0
 public bool themNhomND(QL_NhomNguoiDung nnd , List<QL_PhanQuyen> lstPQ)
 {
     try
     {
         ch.QL_NhomNguoiDungs.InsertOnSubmit(nnd);
         foreach (QL_PhanQuyen item in lstPQ)
         {
           ch.QL_PhanQuyens.InsertOnSubmit(item);
         }
         
         return true;
     }
     catch (Exception)
     {
         return false;
         throw;
     }
 }