コード例 #1
0
        public HT_TRUY_CAP Sua(HT_TRUY_CAP obj)
        {
            HT_TRUY_CAP kq       = null;
            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 = obj;
            }
            catch (System.Exception ex)
            {
                kq = null;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
コード例 #2
0
        public bool Xoa(HT_TRUY_CAP obj)
        {
            bool     kq       = true;
            Entities entities = ContextFactory.GetInstance();

            try
            {
                entities.HT_TRUY_CAP.Attach(obj);
                entities.HT_TRUY_CAP.DeleteObject(obj);
                entities.SaveChanges();
            }
            catch (System.Exception ex)
            {
                kq = false;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
コード例 #3
0
        public HT_TRUY_CAP Them(HT_TRUY_CAP obj)
        {
            HT_TRUY_CAP kq       = null;
            Entities    entities = ContextFactory.GetInstance();

            try
            {
                entities.HT_TRUY_CAP.AddObject(obj);
                entities.SaveChanges();
                kq = obj;
            }
            catch (System.Exception ex)
            {
                kq = null;
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
                throw ex;
            }
            finally
            {
                entities = null;
            }
            return(kq);
        }
コード例 #4
0
        public void getObject(DatabaseConstant.Action action)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                if (obj == null)
                {
                    obj = new HT_NHNSD();
                }
                //obj.MA_DVI_QLY = txtMaDonVi.Text;
                obj.MA_DVI_QLY = lstSourceDonVi.ElementAt(cmbDonVi.SelectedIndex).KeywordStrings.First();
                obj.MA_DVI_TAO = ClientInformation.MaDonVi;
                obj.MA_NHNSD   = txtMaNhom.Text;
                obj.MO_TA      = txtMoTa.Text;
                if (chkHoatDong.IsChecked == true)
                {
                    obj.HAN_CHE_TRUY_CAP = BusinessConstant.CoKhong.CO.layGiaTri();
                }
                else
                {
                    obj.HAN_CHE_TRUY_CAP = BusinessConstant.CoKhong.KHONG.layGiaTri();
                }
                obj.NGAY_CNHAT = (DateTime.Today).ToString("yyyyMMdd");
                if (obj.ID == 0)
                {
                    obj.NGAY_NHAP = (DateTime.Today).ToString("yyyyMMdd");
                }
                obj.NGUOI_CNHAT = ClientInformation.TenDangNhap;
                if (obj.ID == 0)
                {
                    obj.NGUOI_NHAP = ClientInformation.TenDangNhap;
                }
                obj.TEN_NHNSD = txtTenNhom.Text;
                string strTTNV = string.Empty;
                if (obj.ID == 0)
                {
                    obj.NGUON_TAO_DL = "NSD";
                    obj.PVI_KTHAC    = "K";
                    strTTNV          = obj.TTHAI_NVU;
                }
                obj.TTHAI_NVU  = CommonFunction.LayTrangThaiBanGhi(action, BusinessConstant.layTrangThaiNghiepVu(strTTNV));
                obj.TTHAI_BGHI = BusinessConstant.TrangThaiBanGhi.SU_DUNG.layGiaTri();

                // Luôn là đã duyệt (???)
                obj.TTHAI_NVU = BusinessConstant.TrangThaiNghiepVu.DA_DUYET.layGiaTri();

                //Lấy thông tin hạn chế truy cập MAC or IP
                lstTruyCap = new List <HT_TRUY_CAP>();
                foreach (DataRow dr in dtTruyCap.Rows)
                {
                    if (!dr["STT"].ToString().IsNullOrEmptyOrSpace())
                    {
                        HT_TRUY_CAP objTruyCap = new HT_TRUY_CAP();
                        objTruyCap.ID_DTUONG   = obj.ID;
                        objTruyCap.MA_DTUONG   = obj.MA_NHNSD;
                        objTruyCap.LOAI_DTUONG = BusinessConstant.LoaiDoiTuong.NHOM_NGUOI_SDUNG.layGiaTri();

                        if (Convert.ToBoolean(dr["KICH_HOAT"]) == true)
                        {
                            objTruyCap.KICH_HOAT = BusinessConstant.CoKhong.CO.layGiaTri();
                        }
                        else
                        {
                            objTruyCap.KICH_HOAT = BusinessConstant.CoKhong.KHONG.layGiaTri();
                        }

                        objTruyCap.DIA_CHI      = dr["DIA_CHI"].ToString().ToUpper();
                        objTruyCap.LOAI_DIA_CHI = dr["LOAI_DIA_CHI"].ToString();

                        lstTruyCap.Add(objTruyCap);
                    }
                }
            }
            catch (System.Exception ex)
            {
                CommonFunction.ThongBaoLoi(ex);
                LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex);
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }