예제 #1
0
        public bool XoaListTheoID(List <int> listID)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    foreach (int id in listID)
                    {
                        HT_TNGUYEN_LOAI obj = new HT_TNGUYEN_LOAI();
                        obj = entities.HT_TNGUYEN_LOAI.FirstOrDefault(e => e.ID == id);
                        entities.DeleteObject(obj);
                        entities.SaveChanges();
                    }
                    trans.Complete();
                }
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #2
0
        public bool Sua(HT_TNGUYEN_LOAI obj)
        {
            bool      kq       = true;
            Entities  entities = ContextFactory.GetInstance();
            EntityKey key      = null;
            object    original = null;

            try
            {
                key = entities.CreateEntityKey(ENTITY_SET_NAME, obj);
                if (entities.TryGetObjectByKey(key, out original))
                {
                    entities.ApplyCurrentValues(key.EntitySetName, obj);
                }
                entities.SaveChanges();
                kq = true;
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #3
0
        public bool HuyDuyetListTheoID(List <int> listID)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    foreach (int id in listID)
                    {
                        HT_TNGUYEN_LOAI obj = new HT_TNGUYEN_LOAI();
                        obj           = entities.HT_TNGUYEN_LOAI.FirstOrDefault(e => e.ID == id);
                        obj.TTHAI_NVU = BusinessConstant.TrangThaiNghiepVu.THOAI_DUYET.layGiaTri();
                        entities.SaveChanges();
                    }
                    trans.Complete();
                }
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #4
0
        public bool Xoa(HT_TNGUYEN_LOAI obj)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                entities.DeleteObject(obj);
                entities.SaveChanges();
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
예제 #5
0
        public HT_TNGUYEN_LOAI GetByMa(string ma)
        {
            HT_TNGUYEN_LOAI kq       = null;
            Entities        entities = ContextFactory.GetInstance();

            try
            {
                kq = entities.HT_TNGUYEN_LOAI.FirstOrDefault(e => e.MA_TNGUYEN_LOAI.Equals(ma));
                return(kq);
            }
            catch (System.Exception ex)
            {
                kq = null;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }