Exemplo n.º 1
0
        public void Capnhatnhombantin(int idnhom, string tenmoi, string motamoi, List <int> usermoi)
        {
            bantin_nhom capnhat = (from tk in data.bantin_nhoms
                                   where tk.idnhombantin == idnhom
                                   select tk).Single();

            capnhat.tennhom = tenmoi;
            capnhat.mota    = motamoi;
            data.SubmitChanges();

            List <bantin_kqnhom> dskqxoa = (from tk in data.bantin_kqnhoms
                                            where tk.idnhombantin == idnhom
                                            select tk).ToList();

            data.bantin_kqnhoms.DeleteAllOnSubmit(dskqxoa);

            foreach (int item in usermoi)
            {
                int dem2 = (from tk in data.bantin_kqnhoms
                            select tk).ToList().Last().idkqnhom;
                bantin_kqnhom themkq = new bantin_kqnhom();
                if (dem2 == 0)
                {
                    themkq.idkqnhom = 1;
                }
                else
                {
                    themkq.idkqnhom = dem2 + 1;
                }
                themkq.idnhombantin = idnhom;
                themkq.iduser       = item;
                data.bantin_kqnhoms.InsertOnSubmit(themkq);
                data.SubmitChanges();
            }
        }
Exemplo n.º 2
0
        public bantin_nhom Laynhom(int idnhom)
        {
            bantin_nhom nhombt = (from cd in data.bantin_nhoms
                                  where cd.idnhombantin == idnhom
                                  select cd).Single();

            return(nhombt);
        }
Exemplo n.º 3
0
        public void Xoanhombantin(int idnhom)
        {
            List <bantin_kqnhom> dskqxoa = (from tk in data.bantin_kqnhoms
                                            where tk.idnhombantin == idnhom
                                            select tk).ToList();

            data.bantin_kqnhoms.DeleteAllOnSubmit(dskqxoa);

            bantin_nhom xoanhombantin = (from tk in data.bantin_nhoms
                                         where tk.idnhombantin == idnhom
                                         select tk).Single();

            data.bantin_nhoms.DeleteOnSubmit(xoanhombantin);

            data.SubmitChanges();
        }
Exemplo n.º 4
0
        public void Themnhombantin(string tennhombantin, string mota, List <int> iduser)
        {
            int dem = (from tk in data.bantin_nhoms
                       select tk).ToList().Last().idnhombantin;
            bantin_nhom themnhombantin = new bantin_nhom();

            if (dem == 0)
            {
                themnhombantin.idnhombantin = 1;
            }
            else
            {
                themnhombantin.idnhombantin = dem + 1;
            }
            themnhombantin.tennhom = tennhombantin;
            themnhombantin.mota    = mota;
            data.bantin_nhoms.InsertOnSubmit(themnhombantin);
            data.SubmitChanges();

            foreach (int item in iduser)
            {
                int dem2 = (from tk in data.bantin_kqnhoms
                            select tk).ToList().Last().idkqnhom;
                bantin_kqnhom themkq = new bantin_kqnhom();
                if (dem2 == 0)
                {
                    themkq.idkqnhom = 1;
                }
                else
                {
                    themkq.idkqnhom = dem2 + 1;
                }
                themkq.idnhombantin = themnhombantin.idnhombantin;
                themkq.iduser       = item;
                data.bantin_kqnhoms.InsertOnSubmit(themkq);
                data.SubmitChanges();
            }
        }