Beispiel #1
0
        public static BHXH.Data.ListKTKL New(string MaKTKL, string TenKTKL, string LoaiKTKL)

        {
            if (MaKTKL == "" || TenKTKL == "" || LoaiKTKL == "")
            {
                return(null);
            }
            if (IsExisted(MaKTKL, TenKTKL, LoaiKTKL) != null)
            {
                return(IsExisted(MaKTKL, TenKTKL, LoaiKTKL));
            }
            BHXH.Data.BHXHEntities ctx = new Data.BHXHEntities();
            BHXH.Data.ListKTKL     n   = new Data.ListKTKL();
            n.MaKTKL   = MaKTKL;
            n.TenKTKL  = TenKTKL;
            n.LoaiKTKL = LoaiKTKL;
            ctx.ListKTKL.Add(n);

            try
            {
                ctx.SaveChanges();
                return(n);
            }
            catch (Exception)
            {
                return(null);
            }

            finally
            { }
        }
Beispiel #2
0
        public static void Delete(string MaKTKL)
        {
            BHXH.Data.BHXHEntities ctx = new Data.BHXHEntities();

            var obj = new Data.ListKTKL {
                MaKTKL = MaKTKL
            };

            ctx.ListKTKL.Attach(obj);
            ctx.ListKTKL.Remove(obj);

            ctx.SaveChanges();
        }