Exemple #1
0
        public static Feature getFeature(DataRow row)
        {
            Feature feature = new Feature();

            feature.id = HelpNumber.ParseInt64(row["ID"]);
            feature.featureName = row["NAME"].ToString().Trim();
            feature.isRead = (row["isread_bit"].ToString().Equals("Y") ? true : false);
            feature.isInsert = (row["isinsert_bit"].ToString().Equals("Y") ? true : false);
            feature.isUpdate = (row["isupdate_bit"].ToString().Equals("Y") ? true : false);
            feature.isDelete = (row["isdelete_bit"].ToString().Equals("Y") ? true : false);
            feature.isPrint = (row["isprint_bit"].ToString().Equals("Y") ? true : false);
            feature.isExport = (row["isexport_bit"].ToString().Equals("Y") ? true : false);
            return feature;
        }
        public static void CustomizePermit()
        {
            try
            {
                if (User.isAdmin()) return;

                    DevExpress.XtraBars.Ribbon.RibbonControl ribbon = ((frmRibbonMain)FrameworkParams.MainForm).Ribbon;
                    FeatureQLTV = Permission.loadFeature(OChuongTrinh.id, OChuongTrinh.featureName, FrameworkParams.currentUser.username);
                    if (FeatureQLTV.isInsert == false)
                    {
                        ribbon.Items[typeof(FrmChuongTrinh).FullName].Enabled = false;
                        ribbon.Items[typeof(frmPostMaster).FullName].Enabled = false;
                        ribbon.Items[typeof(frmBienMuc).FullName].Enabled = false;

                    }
                    var featureMT = Permission.loadFeature(OMuonTra.id, OMuonTra.featureName, FrameworkParams.currentUser.username);
                    if (featureMT.isInsert == false)
                    {
                        ribbon.Items[typeof(frmMuonTra).FullName].Enabled = false;
                    }

                    var featureHD = Permission.loadFeature(OHardDisk.id, OHardDisk.featureName, FrameworkParams.currentUser.username);
                    if (featureHD.isRead == false)
                    {
                        ribbon.Items[typeof(DMHardDisks).FullName].Enabled = false;
                        ribbon.Items[typeof(DMThuMucHardDisk).FullName].Enabled = false;
                    }
                    var featureTTPS = Permission.loadFeature(OLichPhatSong.id, OLichPhatSong.featureName, FrameworkParams.currentUser.username);
                    if (featureTTPS.isInsert == false)
                    {
                        ribbon.Items[typeof(FrmLichPhatSonNew).FullName].Enabled = false;
                    }
                    #region Danh mục

                    var featureDMNuocSanXuat = Permission.loadFeature(DMNuocSanXuat.id, DMNuocSanXuat.featureName, FrameworkParams.currentUser.username);
                    if (featureDMNuocSanXuat.isRead == false)
                    {
                        ribbon.Items[typeof(DMNuocSanXuat).FullName].Enabled = false;
                    }

                    var featureDMDonViCungCap = Permission.loadFeature(DMDonViCungCap.id, DMDonViCungCap.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDonViCungCap.isRead == false)
                    {
                        ribbon.Items[typeof(DMDonViCungCap).FullName].Enabled = false;
                    }

                    var featureDMDonViSoHuu = Permission.loadFeature(DMDonViSoHuu.id, DMDonViSoHuu.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDonViSoHuu.isRead == false)
                    {
                        ribbon.Items[typeof(DMDonViSoHuu).FullName].Enabled = false;
                    }
                    var featureDMHangSanXuat = Permission.loadFeature(DMHangSanXuat.id, DMHangSanXuat.featureName, FrameworkParams.currentUser.username);
                    if (featureDMHangSanXuat.isRead == false)
                    {
                        ribbon.Items[typeof(DMHangSanXuat).FullName].Enabled = false;
                    }
                    var featureDMTietMuc = Permission.loadFeature(DMTietMuc.id, DMTietMuc.featureName, FrameworkParams.currentUser.username);
                    if (featureDMTietMuc.isRead == false)
                    {
                        ribbon.Items[typeof(DMTietMuc).FullName].Enabled = false;
                    }

                    var featureDMLoaiBang = Permission.loadFeature(DMLoaiBang.id, DMLoaiBang.featureName, FrameworkParams.currentUser.username);
                    if (featureDMLoaiBang.isRead == false)
                    {
                        ribbon.Items[typeof(DMLoaiBang).FullName].Enabled = false;
                    }

                    var featureDMDMThongSoLoaiBang = Permission.loadFeature(DMThongSoLoaiBang.id, DMThongSoLoaiBang.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDMThongSoLoaiBang.isRead == false)
                    {
                        ribbon.Items[typeof(DMThongSoLoaiBang).FullName].Enabled = false;
                    }

                    var featureDMDoiTuongKG = Permission.loadFeature(DMDoiTuongKG.id, DMDoiTuongKG.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDoiTuongKG.isRead == false)
                    {
                        ribbon.Items[typeof(DMDoiTuongKG).FullName].Enabled = false;
                    }

                    var featureDMDaiTruyenHinh = Permission.loadFeature(DMDaiTruyenHinh.id, DMDaiTruyenHinh.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDaiTruyenHinh.isRead == false)
                    {
                        ribbon.Items[typeof(DMDaiTruyenHinh).FullName].Enabled = false;
                    }
                    var featureDMTuKhoa = Permission.loadFeature(DMTuKhoa.id, DMTuKhoa.featureName, FrameworkParams.currentUser.username);
                    if (featureDMTuKhoa.isRead == false)
                    {
                        ribbon.Items[typeof(DMTuKhoa).FullName].Enabled = false;
                    }

                    var featureDMDaoDien = Permission.loadFeature(DMDaoDien.id, DMDaoDien.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDaoDien.isRead == false)
                    {
                        ribbon.Items[typeof(DMDaoDien).FullName].Enabled = false;
                    }

                    var featureDMDienVien = Permission.loadFeature(DMDienVien.id, DMDienVien.featureName, FrameworkParams.currentUser.username);
                    if (featureDMDienVien.isRead == false)
                    {
                        ribbon.Items[typeof(DMDienVien).FullName].Enabled = false;
                    }

                    var featureDMTinhTrangBang = Permission.loadFeature(DMTinhTrangBang.id, DMTinhTrangBang.featureName, FrameworkParams.currentUser.username);
                    if (featureDMTinhTrangBang.isRead == false)
                    {
                        ribbon.Items[typeof(DMTinhTrangBang).FullName].Enabled = false;
                    }

                    var featureDMPostMaster = Permission.loadFeature(DMPostMaster.id, DMPostMaster.featureName, FrameworkParams.currentUser.username);
                    if (featureDMPostMaster.isRead == false)
                    {
                        ribbon.Items[typeof(DMPostMaster).FullName].Enabled = false;
                    }

                    var featureDMLoaiFile = Permission.loadFeature(DMLoaiFile.id, DMLoaiFile.featureName, FrameworkParams.currentUser.username);
                    if (featureDMLoaiFile.isRead == false)
                    {
                        ribbon.Items[typeof(DMLoaiFile).FullName].Enabled = false;
                    }

                    var featureDMRanking = Permission.loadFeature(DMRanking.id, DMRanking.featureName, FrameworkParams.currentUser.username);
                    if (featureDMRanking.isRead == false)
                    {
                        ribbon.Items[typeof(DMRanking).FullName].Enabled = false;
                    }

                    var featureDMBanQuyenThuoc = Permission.loadFeature(DMBanQuyenThuoc.id, DMBanQuyenThuoc.featureName, FrameworkParams.currentUser.username);
                    if (featureDMBanQuyenThuoc.isRead == false)
                    {
                        ribbon.Items[typeof(DMBanQuyenThuoc).FullName].Enabled = false;

                    }
                    var featureLoaiGhiChu = Permission.loadFeature(DMLoaiGhiChu.id, DMLoaiGhiChu.featureName, FrameworkParams.currentUser.username);
                    if (featureLoaiGhiChu.isRead == false)
                    {
                        ribbon.Items[typeof(DMLoaiGhiChu).FullName].Enabled = false;
                    }
                    var itemDanhMuc = (BarSubItem)ribbon.Items[AppMenu.ItemDanhMuc];
                    var all = itemDanhMuc.ItemLinks.Count;
                    var c = itemDanhMuc.ItemLinks.Cast<BarItemLink>().Count(link => link.Item.Enabled == false);
                    if (all == c) itemDanhMuc.Enabled = false;

                    c = 0;
                    var featureDMCongTy = Permission.loadFeature(DMCongTy.id, DMCongTy.featureName, FrameworkParams.currentUser.username);
                    if (featureDMCongTy.isRead == false)
                    {
                        ribbon.Items[typeof(DMCongTy).FullName].Enabled = false;
                        c++;
                    }
                    var featureDMFWPhongBan = Permission.loadFeature(DMFWPhongBan.id, DMFWPhongBan.featureName, FrameworkParams.currentUser.username);
                    if (featureDMFWPhongBan.isRead == false)
                    {
                        ribbon.Items[typeof(DMFWPhongBan).FullName].Enabled = false;
                        c++;
                    }
                    var featureDMFWNhanVien = Permission.loadFeature(DMFWNhanVien.id, DMFWNhanVien.featureName, FrameworkParams.currentUser.username);
                    if (featureDMFWNhanVien.isRead == false)
                    {
                        ribbon.Items[typeof(DMFWNhanVien).FullName].Enabled = false;
                        c++;
                    }
                    if (c == 3)
                    {
                        ribbon.Items[AppMenu.ItemToChuc].Enabled = false;
                    }
                    #endregion

                    #region Phân quyền dữ liệu
                    var featurePQDLChuongTrinh = Permission.loadFeature(FPhanQuyenDLChuongTrinh.id, FPhanQuyenDLChuongTrinh.featureName, FrameworkParams.currentUser.username);
                    // Feature featureQQDLHardDisk = Permission.loadFeature(FPhanQuyenDlHardDisk.id, FPhanQuyenDlHardDisk.featureName, FrameworkParams.currentUser.username);
                    var featureQPDLMuonTra = Permission.loadFeature(FPhanQuyenDLMuonTra.id, FPhanQuyenDLMuonTra.featureName, FrameworkParams.currentUser.username);
                    var featureQQDLKHPhatSong = Permission.loadFeature(FPhanQuyenDLKHPS.id, FPhanQuyenDLKHPS.featureName, FrameworkParams.currentUser.username);
                    var featureQQDLKHBudget = Permission.loadFeature(FPhanQuyenDLKHBudget.id, FPhanQuyenDLKHBudget.featureName, FrameworkParams.currentUser.username);
                    if (featurePQDLChuongTrinh.isRead == false && featureQPDLMuonTra.isRead == false &&
                       featureQQDLKHPhatSong.isRead == false && featureQQDLKHBudget.isRead == false)
                    {
                        ribbon.Items[typeof(frmPermissionDataQL).FullName].Enabled = false;
                    }
                    else
                    {
                        ribbon.Items[typeof(frmPermissionDataQL).FullName].Enabled = true;
                    }
                    #endregion

                    FeatureChuyenTrangThaiKHBG12 = Permission.loadFeature(FChuyenTrangThaiKHBG12.id, FChuyenTrangThaiKHBG12.featureName, FrameworkParams.currentUser.username);
                    FeatureChuyenTrangThaiKHBG23 = Permission.loadFeature(FChuyenTrangThaiKHBG23.id, FChuyenTrangThaiKHBG23.featureName, FrameworkParams.currentUser.username);
                    FeatureBangGiaBudget = Permission.loadFeature(OBangGiaBudget.id, OBangGiaBudget.featureName, FrameworkParams.currentUser.username);

                    var featureTNSFile = Permission.loadFeature(OQLFileNguonTNS.id, OQLFileNguonTNS.featureName, FrameworkParams.currentUser.username);
                    if (featureTNSFile.isInsert == false)
                    {
                        ribbon.Items[typeof(FrmTNSProgramGridSCR).FullName].Enabled = false;
                    }
                    var featureTNSDSSale = Permission.loadFeature(FDanhMucSale.id, FDanhMucSale.featureName, FrameworkParams.currentUser.username);
                    if (featureTNSDSSale.isRead == false)
                    {
                        ribbon.Items[AppMenu.ItemDanhSachTNSSale].Enabled=false;
                    }

            }
            catch
            {
            }
        }
        private void barButtonItemSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            List<Feature> features = new List<Feature>();
            List<BaoBieu> reports = new List<BaoBieu>();
            if (this.xtraTabControlLeft.SelectedTabPage.Name.Equals("xtraTabPageGroup"))
            {
                foreach (int j in gridViewGroup.GetSelectedRows())
                {
                    DataRow row1 = this.gridViewGroup.GetDataRow(j);
                    long groudId = HelpNumber.ParseInt64(row1["groupid"].ToString());

                    //for (int i = 0; i < gridViewFeature.RowCount; i++)
                    //{
                    //    Feature feature = new Feature();
                    //    feature = this.getFeature(this.gridViewFeature.GetDataRow(i));
                    //    features.Add(feature);
                    //}
                    //HUNG//treelist
                    DataTable dt = treeListFeature.DataSource as DataTable;
                    foreach (DataRow row in dt.Rows)
                    {
                        //Chi luu child row, khong luu parent row
                        if (row["PARENTID"] != DBNull.Value)
                        {
                            Feature feature = new Feature();
                            feature = this.getFeature(row);
                            features.Add(feature);
                        }
                    }
                    ///---------------

                    for (int i = 0; i < gridViewReport.RowCount; i++)
                    {
                        BaoBieu report = new BaoBieu();
                        report = this.getReport(this.gridViewReport.GetDataRow(i));
                        reports.Add(report);
                    }
                    Feature.updateGroup(groudId, features);
                    BaoBieu.updateGroup(groudId, reports);
                }
            }
            else
            {
                foreach (int j in gridViewUser.GetSelectedRows())
                {
                    DataRow row1 = this.gridViewUser.GetDataRow(j);
                    long userID = HelpNumber.ParseInt64(row1["userid"].ToString());

                    //for (int i = 0; i < gridViewFeature.RowCount; i++)
                    //{
                    //    Feature feature = new Feature();
                    //    feature = this.getFeature(this.gridViewFeature.GetDataRow(i));
                    //    features.Add(feature);
                    //}

                    //HUNG//treelist
                    DataTable dt = treeListFeature.DataSource as DataTable;
                    foreach (DataRow row in dt.Rows)
                    {
                        //Chi luu child row, khong luu parent row
                        if (row["PARENTID"] != DBNull.Value)
                        {
                            Feature feature = new Feature();
                            feature = this.getFeature(row);
                            features.Add(feature);
                        }
                    }
                    ///---------------
                    for (int i = 0; i < gridViewReport.RowCount; i++)
                    {
                        BaoBieu report = new BaoBieu();
                        report = this.getReport(this.gridViewReport.GetDataRow(i));
                        reports.Add(report);
                    }
                    Feature.updateUser(userID, features);
                    BaoBieu.updateUser(userID, reports);
                }
            }

            if (xtraTabControlLeft.SelectedTabPage.Name.Equals("xtraTabPageGroup"))
                loadGridViewGroupSelectionChanged();
            else
                loadGridViewUserSelectionChanged();
        }
Exemple #4
0
        public Feature load(long featureID, string featureName, string username)
        {
            DatabaseFB db = DABase.getDatabase();
            DbCommand dbSelect = db.GetStoredProcCommand("FW_GET_FEATURE");
            db.AddInParameter(dbSelect, "@USERNAME", DbType.String, username);
            db.AddInParameter(dbSelect, "@FEATURENAME", DbType.String, featureName);
            IDataReader reader = db.ExecuteReader(dbSelect);
            Feature feature = new Feature();
            feature.featureName = featureName;
            feature.id = featureID;
            while (reader.Read())
            {
                feature.id = HelpNumber.ParseInt64(reader["ID"].ToString());
                if (reader["ISREAD_BIT"].ToString().Equals("Y"))
                    feature.isRead = true;
                if (reader["ISINSERT_BIT"].ToString().Equals("Y"))
                    feature.isInsert = true;
                if (reader["ISDELETE_BIT"].ToString().Equals("Y"))
                    feature.isDelete = true;
                if (reader["ISUPDATE_BIT"].ToString().Equals("Y"))
                    feature.isUpdate = true;
                if (reader["ISPRINT_BIT"].ToString().Equals("Y"))
                    feature.isPrint = true;
                if (reader["ISEXPORT_BIT"].ToString().Equals("Y"))
                    feature.isExport = true;

            }
            reader.Close();

            return feature;
        }
Exemple #5
0
 //PHUOC OK
 public List<Feature> getAllFeature()
 {
     List<Feature> listFeature = new List<Feature>();
     DatabaseFB db = DABase.getDatabase();
     DbCommand dbSelect = db.GetSQLStringCommand("SELECT * FROM FEATURE_CAT ORDER BY lower(NAME) ASC WHERE VISIBLE_BIT='Y'");
     IDataReader reader = db.ExecuteReader(dbSelect);
     while (reader.Read())
     {
         Feature feature = new Feature();
         feature.id = HelpNumber.ParseInt64(reader["ID"].ToString());
         feature.featureName = reader["NAME"].ToString();
         listFeature.Add(feature);
     }
     reader.Close();
     return listFeature;
 }