public static bool Delete(int _nhanvienId)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    //xoa nhan vien + xoa phan quyen tai khoan + Xoa tai khoan
                    var temp        = SelectSingle(_nhanvienId);
                    int _TaiKhoanId = temp.TaiKhoanId ?? 0;
                    Database.NHANVIENs.DeleteOnSubmit(temp);
                    //Database.SubmitChanges();

                    List <PHANQUYENTAIKHOAN> _lstpqtk = PhanQuyenTaiKhoanLogic.SelectTheoTaiKhoan(_TaiKhoanId);
                    if (_lstpqtk != null && _lstpqtk.Count > 0)
                    {
                        Database.PHANQUYENTAIKHOANs.DeleteAllOnSubmit(_lstpqtk);
                        //Database.SubmitChanges();
                    }
                    TAIKHOAN _taikhoan = TaiKhoanLogic.SelectSingle(_TaiKhoanId);
                    Database.TAIKHOANs.DeleteOnSubmit(_taikhoan);

                    Database.SubmitChanges();
                    ts.Complete();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        public static BarItemVisibility KiemTraChucNang_Form(string _machucnang)
        {
            BarItemVisibility result = BarItemVisibility.Never;

            try
            {
                if (GlobalSettings.UserCode == KeyTrongPhanMem.AdminUser_key)
                {
                    result = BarItemVisibility.Always;
                }
                else
                {
                    PHANQUYENTAIKHOAN _phanquyen = PhanQuyenTaiKhoanLogic.SelectTheoMaChucNang(_machucnang);
                    if (_phanquyen != null)
                    {
                        result = BarItemVisibility.Always;
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
            return(result);
        }
Beispiel #3
0
        public static bool Delete(int _GiangVienId)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    //kiem tra neu giang vien: co GIANGDAY + XEPLICHHOC thi khong cho xoa
                    List <GIANGDAY> _lstGiangDay = GiangDayLogic.SelectTheoGiangVien(_GiangVienId);
                    if (_lstGiangDay != null && _lstGiangDay.Count > 0)
                    {
                        Database.GIANGDAYs.DeleteAllOnSubmit(_lstGiangDay);
                        Database.SubmitChanges();
                    }

                    XepLichHocFilter _filter_xlh = new XepLichHocFilter();
                    _filter_xlh.GiaoVien_ChinhId    = _GiangVienId;
                    _filter_xlh.GiaoVien_TroGiangId = _GiangVienId;
                    List <XEPLICHHOC> _lstXepLichHoc = XepLichHocLogic.SelectTheoGiangVien(_filter_xlh);
                    if (_lstXepLichHoc != null && _lstXepLichHoc.Count > 0)
                    {
                        Database.XEPLICHHOCs.DeleteAllOnSubmit(_lstXepLichHoc);
                        Database.SubmitChanges();
                    }
                    //xoa GIANGVIEN
                    var temp = SelectSigleTheoKhoaKhoa(_GiangVienId);
                    Database.GIANGVIENs.DeleteOnSubmit(temp);
                    Database.SubmitChanges();

                    //Xoa PHANQUYENTAIKHOAN
                    List <PHANQUYENTAIKHOAN> _lstpqtk = PhanQuyenTaiKhoanLogic.SelectTheoTaiKhoan(temp.TaiKhoanId ?? 0);
                    if (_lstpqtk != null && _lstpqtk.Count > 0)
                    {
                        Database.PHANQUYENTAIKHOANs.DeleteAllOnSubmit(_lstpqtk);
                        Database.SubmitChanges();
                    }
                    TAIKHOAN _taikhoan = TaiKhoanLogic.SelectSingle(temp.TaiKhoanId ?? 0);
                    if (_taikhoan != null)
                    {
                        Database.TAIKHOANs.DeleteOnSubmit(_taikhoan);
                        Database.SubmitChanges();
                    }
                    Database.SubmitChanges();
                    ts.Complete();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        public static bool Delete(int _hocvienId) //xoa hoc vien
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    //Xoa LICHSUTUVAN
                    List <LICHSUTUVAN> _lstTuVan = LichSuTuVanLogic.SelectTheoHocVien(_hocvienId);
                    if (_lstTuVan != null && _lstTuVan.Count > 0)
                    {
                        Database.LICHSUTUVANs.DeleteAllOnSubmit(_lstTuVan);
                    }
                    //Xoa PHIEUGHIDANH
                    List <PHIEUGHIDANH> _lstPhieuGD = PhieuGhiDanhLogic.SelectTheoHocVien(_hocvienId);
                    if (_lstPhieuGD != null && _lstPhieuGD.Count > 0)
                    {
                        Database.PHIEUGHIDANHs.DeleteAllOnSubmit(_lstPhieuGD);
                    }
                    //XOA HOCVIENs
                    var temp = SelectSingle(_hocvienId);
                    //int _loaihocvien = temp.LoaiHocVienId ?? 0;
                    int _TaiKhoanId = temp.TaiKhoanId ?? 0;

                    Database.HOCVIENs.DeleteOnSubmit(temp);

                    //Xoa tai khoan
                    //Xoa phan quyen tai khoan
                    List <PHANQUYENTAIKHOAN> _lstPhanQuyen = PhanQuyenTaiKhoanLogic.SelectTheoTaiKhoan(_TaiKhoanId);
                    Database.PHANQUYENTAIKHOANs.DeleteAllOnSubmit(_lstPhanQuyen);
                    var temp_TK = (from p in Database.TAIKHOANs
                                   where p.TaiKhoanId == _TaiKhoanId
                                   select p).Single();

                    Database.TAIKHOANs.DeleteOnSubmit(temp_TK);

                    Database.SubmitChanges();
                    ts.Complete();
                    return(true);
                }
            }
            catch (System.Exception ex)
            {
                return(false);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        public static void Delete(int _TaiKhoanId)
        {
            try
            {
                //Xoa phan quyen tai khoan
                List <PHANQUYENTAIKHOAN> _lstPhanQuyen = PhanQuyenTaiKhoanLogic.SelectTheoTaiKhoan(_TaiKhoanId);
                Database.PHANQUYENTAIKHOANs.DeleteAllOnSubmit(_lstPhanQuyen);
                var temp = (from p in Database.TAIKHOANs
                            where p.TaiKhoanId == _TaiKhoanId
                            select p).Single();

                Database.TAIKHOANs.DeleteOnSubmit(temp);
                Database.SubmitChanges();
            }
            catch (System.Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Beispiel #6
0
        private void LoadPhanQuyenTheoTaiKhoan(int _taikhoanId)
        {
            try
            {
                gridControlChucNang.DataSource = null;
                gridControlBaoCao.DataSource   = null;
                this.lstPQ_TK_ChucNang         = new List <PhanQuyenTaiKhoan_PlusDTO>();
                this.lstPQ_TK_BaoCao           = new List <PhanQuyenTaiKhoan_PlusDTO>();

                List <PhanQuyenTaiKhoan_PlusDTO> _lstPQ_TK_All = PhanQuyenTaiKhoanLogic.SelectKieuPhanQuyen(_taikhoanId);
                this.lstPQ_TK_ChucNang         = _lstPQ_TK_All.Where(o => o.LoaiChucNangId != 3).ToList();
                gridControlChucNang.DataSource = this.lstPQ_TK_ChucNang;

                this.lstPQ_TK_BaoCao         = _lstPQ_TK_All.Where(o => o.LoaiChucNangId == 3).ToList();
                gridControlBaoCao.DataSource = this.lstPQ_TK_BaoCao;
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }
        public static bool KiemTraChucNang_Nut(string _machucnang, ButtonEnum _button)
        {
            bool result = false;

            try
            {
                if (GlobalSettings.UserCode == KeyTrongPhanMem.AdminUser_key)
                {
                    result = true;
                }
                else
                {
                    PHANQUYENTAIKHOAN _phanquyen = PhanQuyenTaiKhoanLogic.SelectTheoMaChucNang(_machucnang);
                    if (_phanquyen != null)
                    {
                        switch (_button)
                        {
                        case ButtonEnum.Them:
                        {
                            result = _phanquyen.Them == 1 ? true : false;
                            break;
                        }

                        case ButtonEnum.Sua:
                        {
                            result = _phanquyen.Sua == 1 ? true : false;
                            break;
                        }

                        case ButtonEnum.Xoa:
                        {
                            result = _phanquyen.Xoa == 1 ? true : false;
                            break;
                        }

                        case ButtonEnum.In:
                        {
                            result = _phanquyen.InAn == 1 ? true : false;
                            break;
                        }

                        case ButtonEnum.XuatFile:
                        {
                            result = _phanquyen.XuatFile == 1 ? true : false;
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
            return(result);
        }
Beispiel #8
0
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.TaiKhoan_Select != null)
                {
                    //Update TAIKHOAN: passs
                    this.TaiKhoan_Select.MatKhau = txtMatKhau.Text;

                    //Update PHANQUYENTAIKHOAN
                    List <PHANQUYENTAIKHOAN> _lstPQ_TK_All = new List <PHANQUYENTAIKHOAN>();
                    foreach (var _item in this.lstPQ_TK_ChucNang)
                    {
                        if (_item.IsCheck)
                        {
                            PHANQUYENTAIKHOAN _phanquyen = new PHANQUYENTAIKHOAN
                            {
                                TaiKhoanId = this.TaiKhoan_Select.TaiKhoanId,
                                ChucNangId = _item.ChucNangId,
                                Them       = _item.Them == true ? 1 : 0,
                                Sua        = _item.Sua == true ? 1 : 0,
                                Xoa        = _item.Xoa == true ? 1 : 0,
                                InAn       = _item.InAn == true ? 1 : 0,
                                XuatFile   = _item.XuatFile == true ? 1 : 0,
                            };
                            _lstPQ_TK_All.Add(_phanquyen);
                        }
                    }
                    foreach (var _item in this.lstPQ_TK_BaoCao)
                    {
                        if (_item.IsCheck)
                        {
                            PHANQUYENTAIKHOAN _phanquyen = new PHANQUYENTAIKHOAN
                            {
                                TaiKhoanId = this.TaiKhoan_Select.TaiKhoanId,
                                ChucNangId = _item.ChucNangId,
                                Them       = _item.Them == true ? 1 : 0,
                                Sua        = _item.Sua == true ? 1 : 0,
                                Xoa        = _item.Xoa == true ? 1 : 0,
                                InAn       = _item.InAn == true ? 1 : 0,
                                XuatFile   = _item.XuatFile == true ? 1 : 0,
                            };
                            _lstPQ_TK_All.Add(_phanquyen);
                        }
                    }

                    if (TaiKhoanLogic.Update(this.TaiKhoan_Select) && PhanQuyenTaiKhoanLogic.DeleteAndInsert(_lstPQ_TK_All, this.TaiKhoan_Select.TaiKhoanId))
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                        frmthongbao.Show();
                    }
                    else
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                        frmthongbao.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }